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;
Any ideas why the 'If SoundSiren = ON' is firing even though 'SoundSiren' is OFF ?
Blocky 'if do' isn't working as expected.. any ideas?
Moderator: leecollings
- K3rryBlue
- Posts: 77
- Joined: Tuesday 07 February 2017 22:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V4.10xx
- Location: Netherlands
- Contact:
Re: Blocky 'if do' isn't working as expected.. any ideas?
As far as i know you can't nest if statement in blockly. only as If....elseif
So you should program like:
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.
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
suppose you run into the 2nd IF, and put soundsiren = off, you will hit the 1st if on the next run.
Domoticz V4.10717, RPi2 -> Linux raspberrypi 4.4.47-v7+ , RFXCOM - RFXtrx433 USB 433.92MHz ,RAZBERRY2 and OpenZWave USB Version: 1.4-2363-g1f10253-dirty
-
- Posts: 76
- Joined: Saturday 31 December 2016 21:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Blocky 'if do' isn't working as expected.. any ideas?
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

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
- Egregius
- Posts: 2589
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Blocky 'if do' isn't working as expected.. any ideas?
Also, a IF/ELSEIF block doesn't work without ELSE part.
-
- Posts: 20
- Joined: Thursday 29 December 2016 9:16
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Blocky 'if do' isn't working as expected.. any ideas?
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.
- K3rryBlue
- Posts: 77
- Joined: Tuesday 07 February 2017 22:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V4.10xx
- Location: Netherlands
- Contact:
Re: Blocky 'if do' isn't working as expected.. any ideas?
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.
Domoticz V4.10717, RPi2 -> Linux raspberrypi 4.4.47-v7+ , RFXCOM - RFXtrx433 USB 433.92MHz ,RAZBERRY2 and OpenZWave USB Version: 1.4-2363-g1f10253-dirty
Who is online
Users browsing this forum: No registered users and 1 guest