Alright, here goes.
(Disclaimer: this is my first foray into json and Lua, so I’m sure that what I’ve done is neither pretty nor efficient, but I think it works)
Attached is my DTempLeakSensor1.json file. Note that it is configured for use in UI5, not UI4.
In order for it to work, you’ll need to add some variables to your WWA devices. (I’m using WWA-02, so I don’t know if the new json file will work for other models).
Essentially, this code adds more information to the “Control” tab. Additionally, the SceneGroup and ControlGroup keys cause this information to be posted to the dashboard (see http://wiki.micasaverde.com/index.php/Luup_plugin_tabs#Dashboard_appearance).
4 lines of information should be displayed on the dashboard for each device:
-
The first line of information is just a label for the device (since I have a few different ones). I added the variable “LabelNum” with service “urn:micasaverde-com:serviceId:SecuritySensor1.”
-
The second line displays temperature, as per the original tweak.
-
The third line displays the date and time of the last alarm. I ran into a bug here which I clumsily fixed by separating the date and time into two variables. For this, I had to alter the startup Lua to convert the unix timestamp given by the preexisting “LastTrip” variable into human readable form. For example, for a device with id = 6:
local grossdate6 = luup.variable_get( "urn:micasaverde-com:serviceId:SecuritySensor1" , "LastTrip", 6 )
luup.variable_set( "urn:micasaverde-com:serviceId:SecuritySensor1", "LastTrip_HRF_ymd", os.date('%Y-%m-%d', grossdate6), 6 )
luup.variable_set( "urn:micasaverde-com:serviceId:SecuritySensor1", "LastTrip_HRF_hms", os.date('%H:%M:%S', grossdate6), 6)
This creates or sets the variable “LastTrip_HRF_ymd” and “LastTrip_HRF_hms” to the human readable date and time of the last alarm.
- Finally, the fourth line displays the current alarm status. This uses a new variable “Tripped_display”, which is either “LEAK NOW” (if “Tripped” is 1) or “no leak” (if “Tripped” is 0). Thus, I added to my startup Lua something like:
local status6 = luup.variable_get( "urn:micasaverde-com:serviceId:SecuritySensor1" , "Tripped", 6 )
if (status6 == "1") then
luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped_display", "LEAK NOW", 6 )
else
luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1", "Tripped_display", "no leak", 6 )
end
A note on dynamic updating:
While scouring through the forum, I found that someone recommended using the “variable_watch()” function to monitor a variable and call a given function if that variable changes. I didn’t have much luck with that. Instead, I just entered the above code into the startup Lua, so that those dynamic variables are reset every time you refresh. So, in order to actively monitor the alarm status, you DO have to keep refreshing the page. Not ideal, I know, but it’s the best I could manage.
Ok, that about sums it up. This code is the result of a day or two of tinkering with things that I know nothing about, so don’t be disappointed if it doesn’t work immediately. It certainly didn’t for me
The forum is a pretty good resource, as are the documentation pages I linked to earlier. Good luck.