Using Luup to watch a variable

Hi,

I’m new to using Luup, and I’m trying to write some code to send an alert when a variable has changed. Specifically, I want to know when each of my battery-powered z-wave thermostats wakes up. Currently, I have added the following to my Startup Lua on my VeraLite (using UI5), which monitors the value of the LastWakeup variable on just one of my thermostats, which has id 141:

local function stellaNotify(lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
luup.log(“Sending a thermostat wakeup alert”)
local status, result = luup.inet.wget(“http://xxx.xxx.x.x:xxx/?stellaZWakeUp”, 5)
luup.log(status)
end
luup.variable_watch(“stellaNotify”,“urn:upnp-org:serviceId:ZWaveDevice1”,“LastWakeup”, 141)

At the moment, the code doesn’t appear to do anything - no errors appear in LuaUPnP.log - but equally, the alert never seems to get sent, nor do I see the log entries that I’ve added to the stellaNotify function, which makes me wonder if any of the code is actually being called. I can see that the value of LastWakeup changes though - here is the log corresponding to when I manually wake up the thermostat:

06 04/08/15 13:10:47.048 Device_Variable::m_szValue_set device: 141 service: urn:micasaverde-com:serviceId:ZWaveDevice1 variable: LastWakeup was: 1428494922 now: 1428495047 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x2b491680>
02 04/08/15 13:10:47.049 ZWaveNode::Wakeup did a poll for 7 0 seconds interval 10800 existing (nil) heal (nil) <0x2b491680>
02 04/08/15 13:10:47.050 ZWJob_SendData UPDATE MANUAL ROUTE 7=(nil) <0x2b491680>
01 04/08/15 13:10:47.071 got CAN <0x2bc91680>
02 04/08/15 13:10:47.072 ZWaveSerial::Send m_iFrameID 86 got a CAN – Dongle is in a bad state. Wait 1 second before continuing to let it try to recover. <0x2b891680>
02 04/08/15 13:10:48.209 ZW_Send_Data node 7 NO ROUTE (nil) <0x2b891680>
06 04/08/15 13:10:48.359 Device_Variable::m_szValue_set device: 141 service: urn:upnp-org:serviceId:TemperatureSensor1 variable: CurrentTemperature was: 23 now: 23 #hooks: 3 upnp: 0 v:0xacaad8/NONE duplicate:1 <0x2b491680>
02 04/08/15 13:10:48.360 ZW_Send_Data node 7 NO ROUTE (nil) <0x2b891680>
02 04/08/15 13:10:48.509 ZW_Send_Data node 7 NO ROUTE (nil) <0x2b891680>
02 04/08/15 13:10:48.659 ZW_Send_Data node 7 NO ROUTE (nil) <0x2b891680>
06 04/08/15 13:10:48.838 Device_Variable::m_szValue_set device: 141 service: urn:micasaverde-com:serviceId:HaDevice1 variable: BatteryDate was: 1428494681 now: 1428495048 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x2b491680>
06 04/08/15 13:10:48.839 Device_Variable::m_szValue_set device: 141 service: urn:micasaverde-com:serviceId:HaDevice1 variable: BatteryLevel was: 71 now: 71 #hooks: 0 upnp: 0 v:0xa121c0/NONE duplicate:1 <0x2b491680>
04 04/08/15 13:10:48.842 <0x2b491680>
02 04/08/15 13:10:48.908 UPDATE MANUAL ROUTE2 7=(nil) <0x2b891680>
02 04/08/15 13:10:48.909 ZW_Send_Data node 7 NO ROUTE (nil) <0x2b891680>
04 04/08/15 13:10:49.011

I’m not sure what the ‘dongle is in a bad state’ warning refers to, but I’m assuming it’s unrelated to my current problem. Any advice or ideas why this might not be working would be much appreciated! Perhaps putting it in the startup Lua is inappropriate for some reason?

REMOVE LOCAL from the function.
When Vera looks up the Function from the Function NAME it uses the GLOBAL name space.

Many thanks, that worked.