How to arm sensors that are alive

Hi All,

I would like to make a scene that arms the motionsensors (home alarm application).
As sensors with no battery or not within wireless range go into alarm state, I do not want to arm these.
This script does not work. What am I doing wrong?

local sens=13
local lastwu = luup.variable_get(“urn:micasaverdecom:serviceId:SecuritySensor1”,“LastWakeup”,sens)
if (os.difftime (os.time(),tonumber(lastwu)) < 3600 )
then
luup.variable_set(“urn:micasaverde-com:serviceId:SecuritySensor1”, “Armed”, 1, sens);
end

Thanks,
Luc.

There’s a typo on line 2:
[tt]urn:micasaverdecom → urn:micasaverde-com[/tt]

Oops, that’s corrected now, but it still does not work. It seems the Wakeupvalue == 0.

I tested this now:
local sens=13
local lastwu = luup.variable_get (“urn:micasaverde-com:serviceId:SecuritySensor1”,“LastWakeup”,sens)
local lastwu = tonumber(lastwu)
luup.log ("LastWekeup: " … lastwu)

In the logs, I can see this:
08 06/16/12 17:48:36.978 JobHandler_LuaUPnP::HandleActionRequest argument Code=local sens=13
local lastwu = luup.variable_get(“urn:micasaverde-com:serviceId:SecuritySensor1”,“LastWakeup”,sens)
luup.log ("LastWekeup: " … lastwu) <0x3c10>
01 06/16/12 17:48:36.981 LuaInterface::StartEngine failed run: 0 [string “local sens=13…”]:3: attempt to concatenate local ‘lastwu’ (a nil value) <0x3c10>
01 06/16/12 17:48:36.981 JobHandler_LuaUPnP::RunLua failed: local sens=13
local lastwu = luup.variable_get(“urn:micasaverde-com:serviceId:SecuritySensor1”,“LastWakeup”,sens)
luup.log ("LastWekeup: " … lastwu) <0x3c10>
08 06/16/12 17:49:26.036 JobHandler_LuaUPnP::HandleActionRequest device: 0 service: urn:micasaverde-com:serviceId:HomeAutomationGateway1 action: RunLua <0x3c10>
08 06/16/12 17:49:26.037 JobHandler_LuaUPnP::HandleActionRequest argument Code=local sens=13
local lastwu = luup.variable_get(“urn:micasaverde-com:serviceId:SecuritySensor1”,“LastWakeup”,sens)
luup.log ("LastWekeup: " … lastwu) <0x3c10>
01 06/16/12 17:49:26.038 LuaInterface::StartEngine failed run: 0 [string “local sens=13…”]:3: attempt to concatenate local ‘lastwu’ (a nil value) <0x3c10>
01 06/16/12 17:49:26.039 JobHandler_LuaUPnP::RunLua failed: local sens=13
local lastwu = luup.variable_get(“urn:micasaverde-com:serviceId:SecuritySensor1”,“LastWakeup”,sens)
luup.log ("LastWekeup: " … lastwu) <0x3c10>

Is LastWakeup an unkown value?
In the advanced tab of that device, I can read the value LastWakeup == 1339859410

Thanks,
Luc.

[quote=“lucbosmans, post:3, topic:171817”]Is LastWakeup an unkown value?
In the advanced tab of that device, I can read the value LastWakeup == 1339859410[/quote]
Given the error you’re getting the value is coming back nil, which means it doesn’t have a value for that ServiceId/Name combination, for the deviceId being passed in.

It’s possible that the ServiceId specified is incorrect, or maybe the deviceId is incorrect. I don’t have that Variable in my Vera, so you’d need to hover the mouse over the Label, for that variable, in Advanced tab of the device. When you hover the mouse over the label, the bubble-help will show the actual ServiceId.

According to this:
http://wiki.micasaverde.com/index.php/Luup_UPNP_Files#ZWaveDevice

This variable is part of this serviceId:
[tt] urn:micasaverde-com:serviceId:ZWaveDevice1[/tt]

It works.
Thanks for the info and the link.

Luc.