This is all very out of date and only an initial proof of concept. You shouldn’t be using the code on this thread, but the one from the beta test thread here: http://forum.micasaverde.com/index.php/topic,24669.msg171205.html#msg171205
Here’s a prototype of some of the major components of a next-generation dataMine, along the lines of the design criteria I outlined here: http://forum.micasaverde.com/index.php/topic,17232.msg154658.html#msg154658
When installed and configured, this demo should:
[ul][li]watch a few key variables: temperature, security, power, and battery levels[/li]
[li]store them in a Whisper database (yes, on Vera itself, but the files are very small)[/li]
[li]enable plotting of these data from this database and from a dataMine one (if present)[/li][/ul]
To install, unzip and load the files in the usual way, then run this script in the Test Luup code (Lua) window:
------
--
-- DataYours - a prototype next-generation datamine
-- version = 2014.02.08 @akbooer
--
--
-- load and start the three component daemons
require "L_DataWatcher"
require "L_DataCache"
require "L_DataGraph"
local IP = "127.0.0.1" -- this machine
local PORT = "1392" -- unassigned port
local DATAMINE = "/dataMine/" -- dataMine database root
--local SYSLOG = "xxx.xx.xx.xxx:yyy" -- set if you want to log to syslog rather than Vera's log file
local function DWconfig (x) luup.inet.wget ("http://"..IP..":3480/data_request?id=lr_DataWatcher&"..x, 1) end
local function DCconfig (x) luup.inet.wget ("http://"..IP..":3480/data_request?id=lr_DataCache&"..x, 1) end
local function DGconfig (x) luup.inet.wget ("http://"..IP..":3480/data_request?id=lr_DataGraph&"..x, 1) end
-- create a directory for the Whisper database
os.execute "mkdir /whisper/"
-- configure DataWatcher to watch all Termperature, Security, Power and Batteries and send to specific port
DWconfig ("send="..IP..":"..PORT)
if SYSLOG then DWconfig ("syslog="..SYSLOG) end
DWconfig "watch=*.urn:upnp-org:serviceId:TemperatureSensor1.CurrentTemperature"
DWconfig "watch=*.urn:micasaverde-com:serviceId:SecuritySensor1.Tripped"
DWconfig "watch=*.urn:micasaverde-com:serviceId:EnergyMetering1.Watts"
DWconfig "watch=*.urn:micasaverde-com:serviceId:HaDevice1.BatteryLevel"
-- configure DataCache to listen and store the results
DCconfig ("listen="..PORT)
if SYSLOG then DCconfig ("syslog="..SYSLOG) end
-- configure DataGraph to read Whisper and dataMine databases
if SYSLOG then DGconfig ("syslog="..SYSLOG) end
DGconfig ("datamine="..DATAMINE)
--
-- Congratulations! You should now be logging specified device data
--
-- to plot, visit, for example, the URL
-- <yourVeraIP>:3480/data_request?id=lr_render&target=Vera-12345678.321.urn:upnp-org:serviceId:TemperatureSensor1.CurrentTemperature
--
The configuration may take about 10 seconds to run. The script should be easy to understand and modify (for example, to add new variables.) Again, this is only a prototype, so in future this will all be hidden behind a GUI. Once configured, the settings are persistent, so you don’t have to run it again. In order to start the prototype after every reload, simply include the three [tt]‘require’[/tt] lines in Startup Lua.
To test, you’ll have to wait a while for some data to become available. The database is located in [tt]/whisper/[/tt] with one file per variable, so you should be able to see the total size after running the script. The individual files never get any bigger (because this is a ‘round-robin’ database). They are all limited to just one week duration, except for battery levels which are one year (one point a day). To plot, you can just browse URLs like this:
<yourVeraIP>:3480/data_request?id=lr_render&target=Vera-12345678.321.urn:upnp-org:serviceId:TemperatureSensor1.CurrentTemperature
The target names are of the form [tt]...[/tt]. The exact naming and numbering can be seen from the [tt]/whisper/[/tt] directory, EXCEPT that in the serviceId colons ‘:’ have been replaced by carets ‘^’ because of filename restrictions on some operating systems.
I’m very keen to get feedback on the operational aspects of this prototype which I have had running on my own systems for over a week. I’ll follow up with more details in posts on each one of the components.
This is all very out of date and only an initial proof of concept. You shouldn’t be using the code on this thread, but the one from the beta test thread here: http://forum.micasaverde.com/index.php/topic,24669.msg171205.html#msg171205