Luup code that works... but it doesn't

Greetings,

I have a Luup script that works… at least when I click on the “Run” button for the scene that it’s in. The code is supposed to “un-trip” the security sensors and then arm them.

The interesting thing is, only the first half of that equation works “for real” (the un-tripping the sensors part). The sensors won’'t arm. The scene is activated by me entering a specific PIN on my Schlage lock. All of the sensors un-trip no problem… but they won’t arm. How could this be?

This is the Luup script that I’ve used:


local magnetDevice = 7
local movementDevice = 10
local SS_SID = “urn:micasaverde-com:serviceId:SecuritySensor1”

luup.variable_set(SS_SID,“Tripped”,“0”,magnetDevice)

luup.variable_set(SS_SID,“Tripped”,“0”,movementDevice)

luup.variable_set(SS_SID,“Armed”,“1”,magnetDevice)

luup.variable_set(SS_SID,“Armed”,“1”,movementDevice)

@Samea,

Im still learning to deal with luup myself, but trying to approach this from a logical point of view,
Could it be the devices need a “pause” between the commands?

I can imagine the first commands are sent and the device executes them. While its in this process it receives the second command, that might be dropped because device - busy?

i recommend using the " [code ]" , " [ /code]" description to put your code in a frame like this:
when posting in the forum.

[code]
–identification
local magnetDevice = 7
local movementDevice = 10
local SS_SID = “urn:micasaverde-com:serviceId:SecuritySensor1”

–untrip the device
luup.variable_set(SS_SID,“Tripped”,“0”,magnetDevice)
luup.variable_set(SS_SID,“Tripped”,“0”,movementDevice)

–suggestion to pause before sending next command for n seconds

–re-arm the devices
luup.variable_set(SS_SID,“Armed”,“1”,magnetDevice)
luup.variable_set(SS_SID,“Armed”,“1”,movementDevice)[/code]

Anyone more luup experienced that can chip in?

Henk

Try [tt]luup.call_action / SetArmed / newArmedValue [/tt] ?

When I look this topic, I see anyone know the difference between

luup.variable_set & luup.call_action

I don’t find what’s the difference.

Thank you

@fatal25,
Roughly, if you’re the consumer/user of a plugin then you should be using [tt]luup.call_action(…)[/tt] to interact with the actions/methods it exposes, and [tt]luup.variable_get(…)[/tt] to get back it’s [current] state.

If you’re the author of a plugin, then typically you’d use luup.variable_set(…) to set the internal state of the plugin.

At a high level, if you look at one of the actions/methods that a Plugin exposes, it has [roughly] the following form:

actionName(parameter1, parameter2, ... parameterN) { doSomething with the hardware device, potentially asynchronously, using the parameters luup.variable_set(..., resultingNewState) }

Using the above outline, if you were to just call [tt]luup.variable_set(…)[/tt] then the hardware device may never be contacted.

Thank you Guessed.