I have three variables, HallwayPir, OutsidePir and PirDiff. I use them to see when we are leaving or coming home (small negativ / positiv number)
Code: Select all
commandArray = {}
z = tonumber(uservariables['HallwayPir'])
w = os.time()
x = w - z
if (devicechanged['Outside Veranda West Pir'] == 'On') then
commandArray['Variable:PirDiff'] = tostring(x)
commandArray['Variable:OutsidePir'] = tostring(w)
end
return commandArray
Code: Select all
Error: EventSystem: in device_outsidepir: [string "commandArray = {} ..."]:4: attempt to perform arithmetic on global 'z' (a nil value)
Any one that can point me to my mistake?