Page 1 of 1

Blockly to switch lights when alarm = On

Posted: Monday 25 July 2016 9:53
by wormiedk
Hi there.

I tried creating a blockly script to make my lights turn on if the alarm is in the on state. My alarm is a simple threeway switch ("On", "Off", "Home on"), as I have not found a way to change the "armed" state of my home using a switch.

My current blockly looks like this. None of the events are ever triggered.
Screen Shot 2016-07-25 at 09.47.23.png
Screen Shot 2016-07-25 at 09.47.23.png (143.29 KiB) Viewed 1296 times
My devices look like this
Screen Shot 2016-07-25 at 09.47.45.png
Screen Shot 2016-07-25 at 09.47.45.png (29.17 KiB) Viewed 1296 times
Screen Shot 2016-07-25 at 09.47.36.png
Screen Shot 2016-07-25 at 09.47.36.png (32.02 KiB) Viewed 1296 times
Can anyone suggest how to fix the problem or suggest a Lua script alternative?
Could timers on a switch be conditional e.g. if "Alarm=On" the timer is active else it is not?

Re: Blockly to switch lights when alarm = On

Posted: Monday 25 July 2016 12:34
by mrf68
Hi,

the first line states ".... and Alarm = "On" "

A selector has numeric values, i.e. 0 for Off, 10 for Level1, etc. So I think your blockly needs to check not if it is "On" but if it is "10". And I expect it not to be text (that is not between quotes) but as a number.


I should test it before I post something here. :oops:
It works with the text blockly, so I need to investigate it some more.

Did you choose the blockly to be "Device" or "Time"? When I test it as Device, it doesn't work, but as Time it will.
selector.jpg
selector.jpg (8.82 KiB) Viewed 1273 times

Re: Blockly to switch lights when alarm = On

Posted: Tuesday 02 August 2016 21:32
by wormiedk
Thanks. I had my script set to "Both". I tried modifying it to time but it still did not work.

I got it working by adding an extra and testing if a light was off or on in each of the statements.

Re: Blockly to switch lights when alarm = On

Posted: Friday 19 August 2016 13:30
by maomanna
If Alarm is a multi selector, you need to set it as 0, 10 or 20.

You can also look at my blockly:
http://domoticz.com/forum/viewtopic.php ... 043#p71013