Simple If alarm is "Armed" then run scene code help needed

Hello

I have put together a scene that begins the welcome home process when I open the garage door (turns off the alarm, unlocks the door, lights etc) The scene is working beautifully with one small issue. I only want the scene to run when the alarm system is in its “Armed” state. ie I dont want the door lock and lights etc to fire every time I open the garage door. I know its a simple If -then statement but I can’t figure out what I’ve done wrong.
I have done a fair bit of snooping around on the forum and have managed to piece together some code to put in the luup portion of my scene but I keep getting 'code failed" when I run it in the test loop code section. Could someone take a quick look and kindly let me know what might be wrong. I am using the DSC plugin which creates a 'system" panel that contains the variables for the alarm. Looking at the json files I was able to get the service ID for the panel and the device ID for the system is 94. Many thanks in advance

[code]local alarmstatus = luup.variable_get(“urn:micasaverde-com:serviceId:AlarmPartition2”, “ArmMode”, 94)

if “alarmstatus” = “Armed” then
return true
else
return false
end[/code]

Remove the quotes from around [tt]“alarmstatus”[/tt], since it’s the value of the [tt]alarmstatus[/tt] variable you want to compare against the [tt]“Armed”[/tt] string.

Right now, you’re comparing two string constants, of different values, and they’ll never match.

Also, comparison is written == not =.

Thanks to you both! Making both of those suggested changes worked perfectly. Now the house doesn’t begin a concert of lights and doors whenever we open the garage door

One more question -any code I had to run the scene should be put after the “if then” statement is that correct? My understanding that if the condition isn’t met then return false aborts the scene and nothing after that runs. If it returns true then it continues to execute the rest of the scene? Am I correct in thinking that whatever is placed in the luup code section is executed first before anything else that we may have programmed into the scene?

Thanks again for your time!

If you’ve built a declarative Scene, through the normal “UI-based” scene editor, then that scene will run after this bit of Luup code returns with “[tt]return true[/tt]”.

If it returns with “[tt]return false[/tt]”, then the declarative Scene code won’t run at all.

Now, if you need to write Luup code as part of your scene, then it looks more like:

[code]local alarmstatus = luup.variable_get(“urn:micasaverde-com:serviceId:AlarmPartition2”, “ArmMode”, 94)

if (alarmstatus == “Armed”) then

– Put lines of Custom Luup-based scene code here, before the “return true”

return true
– Code at this line will never be run
else
return false
– Code at this line will never be run
end

– Code at this line will never be run[/code]

@futzle, thanks for catching the extra problem that I missed, somewhat important that part too!

[quote=“guessed, post:5, topic:172662”]If you’ve built a declarative Scene, through the normal “UI-based” scene editor, then that scene will run after this bit of Luup code returns with “[tt]return true[/tt]”.

If it returns with “[tt]return false[/tt]”, then the declarative Scene code won’t run at all.

Now, if you need to write Luup code as part of your scene, then it looks more like:

[code]local alarmstatus = luup.variable_get(“urn:micasaverde-com:serviceId:AlarmPartition2”, “ArmMode”, 94)

if (alarmstatus == “Armed”) then

– Put lines of Custom Luup-based scene code here, before the “return true”

return true
– Code at this line will never be run
else
return false
– Code at this line will never be run
end

– Code at this line will never be run[/code]

@futzle, thanks for catching the extra problem that I missed, somewhat important that part too![/quote]

Hi

Been fumbling with the code to disarm the Vista20P without success. The above code queries the status of the alarm system. The missing code part is disarming the alarm system.

Can anyone help? Wanted to turn the alarm off when the door pin has been successfully entered. Trying to use lup. Thanks in advance

Don

EDIT: I found this code in the forum but it doesn’t seem to work to disarm the alarm system:

luup.call_action(“urn:micasaverde-com:serviceId:AlarmPartition2”, “RequestArmMode”, { State=“Disarm”, PINCode=“XXXX” } , Device_ID)

2nd Edit:

I guess the correct code/ that works/is:

luup.call_action(“urn:micasaverde-com:serviceId:AlarmPartition2”, “RequestArmMode”, { State=“Disarmed”, PINCode=“XXXX” } , Device_ID)

State should have been “Disarmed” not “Disarm”!!

Thanks to Guessed…

[quote=“Don Diego, post:6, topic:172662”][quote=“guessed, post:5, topic:172662”]If you’ve built a declarative Scene, through the normal “UI-based” scene editor, then that scene will run after this bit of Luup code returns with “[tt]return true[/tt]”.

If it returns with “[tt]return false[/tt]”, then the declarative Scene code won’t run at all.

Now, if you need to write Luup code as part of your scene, then it looks more like:

[code]local alarmstatus = luup.variable_get(“urn:micasaverde-com:serviceId:AlarmPartition2”, “ArmMode”, 94)

if (alarmstatus == “Armed”) then

– Put lines of Custom Luup-based scene code here, before the “return true”

return true
– Code at this line will never be run
else
return false
– Code at this line will never be run
end

– Code at this line will never be run[/code]

@futzle, thanks for catching the extra problem that I missed, somewhat important that part too![/quote]

Hi

Been fumbling with the code to disarm the Vista20P without success. The above code queries the status of the alarm system. The missing code part is disarming the alarm system.

Can anyone help? Wanted to turn the alarm off when the door pin has been successfully entered. Trying to use lup. Thanks in advance

Don

EDIT: I found this code in the forum but it doesn’t seem to work to disarm the alarm system:

luup.call_action(“urn:micasaverde-com:serviceId:AlarmPartition2”, “RequestArmMode”, { State=“Disarm”, PINCode=“XXXX” } , Device_ID)

2nd Edit:

I guess the correct code/ that works/is:

luup.call_action(“urn:micasaverde-com:serviceId:AlarmPartition2”, “RequestArmMode”, { State=“Disarmed”, PINCode=“XXXX” } , Device_ID)

State should have been “Disarmed” not “Disarm”!!

Thanks to Guessed…[/quote]

All–

Now that I can disarm the alarm the next question regards putting the alarm in the away mode. I tried to sued the following code but it seems not to work. Any ideas? This should be easy.

luup.call_action(“urn:micasaverde-com:serviceId:AlarmPartition2”, “RequestArmMode”, { State=“Away”, PINCode=“XXXX” } , Device_ID)

Thanks in advance.

Don

To set to Armed AWAY … you should use:
RequestQuickArmMode with a state of Armed

If you have an exit door zone … then RequestArmMode will always put the alarm in Armed Stay, even though you ask for Armed Away.

[quote=“RichardTSchaefer, post:8, topic:172662”]To set to Armed AWAY … you should use:
RequestQuickArmMode with a state of Armed

If you have an exit door zone … then RequestArmMode will always put the alarm in Armed Stay, even though you ask for Armed Away.[/quote]

Hi Richard –

Thanks for your help… it works great… Based on your post here is what I tried to implement to enable the AWAY mode:

luup.call_action(“urn:micasaverde-com:serviceId:AlarmPartition2”, “RequestQuickArmMode”, { State=“Armed”, PINCode=“XXXX” } , DEVICEID)

Thanks again,

  Don

The Pin code is not needed for the RequestQuickArmMode action, it’s just ignored.