Page 1 of 1
Blocky 'if do' isn't working as expected.. any ideas?
Posted: Thursday 09 March 2017 23:41
by Swifty
So, I have some blocky set-up to notify when I (un)set my alarm system, and it pushes a notification to say it's been turned off.
I also have it configured to push a notification to say 'Alarm Silenced' - if the sirens are running (ie. alarm has been triggered), when it is disarmed.
However, for some reason the 'Alarm Silenced' notification is firing every time the alarm is disabled, even if SoundSiren (a switch for the sirens) is OFF.
Blocky looks like this;

- Capture.PNG (39.43 KiB) Viewed 1658 times
Any ideas why the 'If SoundSiren = ON' is firing even though 'SoundSiren' is OFF ?
Re: Blocky 'if do' isn't working as expected.. any ideas?
Posted: Friday 10 March 2017 0:16
by K3rryBlue
As far as i know you can't nest if statement in blockly. only as If....elseif
So you should program like:
Code: Select all
IF ( (securitystatus = disarmed) AND (soundsiren = off) AND (usevar = 0) ) DO => set uservar=1......... rest of your code
ELSEIF ( (securitystatus = disarmed) AND (soundsiren = on) AND (uservar=1) ) DO => set uservar = 0 ..... rest of your code
and make sure to use a uservar to avoid running into loops.
suppose you run into the 2nd IF, and put soundsiren = off, you will hit the 1st if on the next run.
Re: Blocky 'if do' isn't working as expected.. any ideas?
Posted: Friday 10 March 2017 13:44
by Swifty
Thanks - I hadn't even considered that nesting another IF wasn't supported!
I did some quick searching to see if this was in the pipeline to add, and it seems that ELSEIF also functions in an odd way;
https://www.domoticz.com/forum/viewtopic.php?t=10147
I'll take some time to digest your suggestion, and see if I can get this working properly when I return home!
Many thanks
Re: Blocky 'if do' isn't working as expected.. any ideas?
Posted: Friday 10 March 2017 13:55
by Egregius
Also, a IF/ELSEIF block doesn't work without ELSE part.
Re: Blocky 'if do' isn't working as expected.. any ideas?
Posted: Sunday 26 March 2017 12:28
by Spitfire
Domoticz blocky 'else if' handling is broken. Nothing should be run after a condition has been true. So avoid using blocky in cases like this use lua instead.
Re: Blocky 'if do' isn't working as expected.. any ideas?
Posted: Sunday 26 March 2017 13:01
by K3rryBlue
Blockly runs every 30 seconds. You need to build a condition, like cust var, to avoid a blockly will execute again. If what you're thinking is true every blockly would only execute once, which is not the case.