luup.variable_watch

I am trying to test out some variables to watch. i loaded the ping sensor and decided to test things out. in my code file i have the following in the init() block:

luup.variable_watch("sensorTripped", "urn:micasaverde-com:serviceId:SecuritySensor1","ArmedTripped", DEV["PING - Server"]) luup.variable_watch("sensorTripped", "urn:micasaverde-com:serviceId:SecuritySensor1","ArmedTripped", DEV["PING - Beach"])

the DEV variable holds a table of my devices by name to make things a bit readable. in that same file, i define a function for sensorTripped as follows:

function sensorTripped(dev_id,service, variable, old_val, new_val) if new_val == "1" then vLog("lost a ping sensor.") saySomething("the device ".. dev_id.. " has lost connection, please check it out now") else vLog("Ping sensor reset.") end end

The vLog fucntion just wraps some text around the data passed so I can find it easier in the logs. the saySomething function basically speaks whatever is passed over the sonsos. In the logs i see the variable change, but for some reason i am getting a nil value error. i have no idea where that is happening:

06 03/11/16 16:28:40.789 Device_Variable::m_szValue_set device: 74 service: urn:demo-ted-striker:serviceId:PingSensor1 variable: Invert was: 1 now: 0 #hooks: 0 upnp: 0 skip: 0 v:0xd0f3f8/NONE duplicate:0 <0x2f4ec680> 06 03/11/16 16:28:40.789 Device_Variable::m_szValue_set device: 74 service: urn:micasaverde-com:serviceId:SecuritySensor1 variable: ArmedTripped was: 0 now: 1 #hooks: 2 upnp: 0 skip: 0 v:0xc455b8/DL_ARMEDTRIPPED duplicate:0 <0x2f4ec680> 01 03/11/16 16:28:40.790 LuaInterface::CallFunction_Variable func: sensorTripped Device_Variable 74 urn:micasaverde-com:serviceId:SecuritySensor1:ArmedTripped failed attempt to call a nil value <0x2f4ec680> 01 03/11/16 16:28:40.791 LuaInterface::CallFunction_Variable func: sensorTripped Device_Variable 74 urn:micasaverde-com:serviceId:SecuritySensor1:ArmedTripped failed attempt to call a nil value <0x2f4ec680> 06 03/11/16 16:28:40.792 Device_Variable::m_szValue_set device: 74 service: urn:micasaverde-com:serviceId:SecuritySensor1 variable: LastTrip was: 1457701327 now: 1457731720 #hooks: 0 upnp: 0 skip: 0 v:0xe50798/NONE duplicate:0 <0x2f4ec680>

Never mind, thanks to akbooer, i figured this out…