I’m making a return to Vera, and I’m just getting familiar with UI7. In my previous setup, I used UI5 and PLEG to send Prowl notifications whenever something happened that I wanted to be notified of: a door opening when I’m not there, motion detection, etc. I’ve been playing around with Reactor, and it works just fine–but to create a whole new Reactor sensor seems like overkill if I just want to run a couple lines of lua code when an event occurs.
I do this by setting up a luup.variable_watch in my startup lua which then runs a function with the couple of lines of code also in the startup lua. So yes it is possible.
function updateoL(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
local tgt = tonumber(lul_device) + 10000
local url = string.format(“http://openluupip:3480/data_request?id=variableset&DeviceNum=%s&serviceId=%s&Variable=%s&Value=%s”,tgt,lul_service,lul_variable,lul_value_new)
luup.inet.wget(url)
end
for k, v in pairs(luup.devices) do
if v.category_num == 4 and (v.subcategory_num == 1 or v.subcategory_num == 3) then
luup.variable_watch(“updateoL”, “urn:micasaverde-com:serviceId:SecuritySensor1”, “Tripped”, k)
end
if v.category_num == 7 then
luup.variable_watch(“updateoL”, “urn:micasaverde-com:serviceId:DoorLock1”, “Status”, k)
end
end
This is what I use to have the vera send immediate status updates to openLuup instead of waiting for verabridge to poll the vera on security sensors and locks.
This is sometimes the case, but two things: (1) ReactorSensors are very light on system resources; (2) Reactor 3.0 (early May release, Beta available now) lets you have multiple logic blocks and multiple activities in one ReactorSensor, so you could, for example, have one RS that’s just a catch-all for number of tiny jobs that otherwise would be too trivial or cluttery to keep in separate RS’s.
That’s interesting–the bold part is exactly what I used to do in PLEG. I had a single, hmm, Condition?–the terminology escapes me now–which had as many as 30 triggers, each one representing an event about which I wanted to receive notification.