Blocky script doesn't work like expected...

Moderator: leecollings

Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Blocky script doesn't work like expected...

Post by Nautilus »

Lebo2d9 wrote:Hi,
I have also a strange behavior with a nested if else-if
The 2 write to log are always executed.
Is this normal or have I done soemthing wrong?
K3rryBlue wrote:Seems that the structure is correct. Both conditions if vakanie=off and else if vakanie=on are different, it should never execute both. In either case if one is true the other is always wrong. Unless "on/off" is not valid for this switch.
The issue is most probably the simple (yet disappointing) fact that nested if's do not work in Domoticz's Blockly implementation (as it has been covered in numerous of these threads discussing various Blockly issues in Domoticz :D). If you write the logic with just one "if - else" then it should work (i.e. add the the first condition to both of the nested conditions to remove the first condition fully)...
Lebo2d9
Posts: 139
Joined: Tuesday 06 September 2016 20:39
Target OS: Raspberry Pi / ODroid
Domoticz version: L stab
Location: Belgium
Contact:

Re: Blocky script doesn't work like expected...

Post by Lebo2d9 »

Hi Nautilus,

I have solved it this way

Image

Thx for the replies

Koen
Domoicz on RPI3 (wifi) directly connected 3x ds18b20 for CV temp, Evohome (9 zone), 1 remote 220V switch based on ESP-12. RFXtrx433E, 16x AMST-606, 5 Somfy RTS motors
Domoticz on RPI3(wifi) as slave for terraruim control
More to come
Kubiekdriehoekje
Posts: 5
Joined: Friday 30 June 2017 19:43
Target OS: Linux
Domoticz version:
Contact:

Re: Blocky script doesn't work like expected...

Post by Kubiekdriehoekje »

Like Spitfire and others stated before else-if logic is broken:

The following example is how it should work:
ifelseifelseif.png
ifelseifelseif.png (34.75 KiB) Viewed 1012 times

Code: Select all

PRE:
	x=0
	y=0

Code: Select all

RUN 1:
	x == 0 && y == 0
	x -> 1
	
RUN 2:
	x == 1 && y == 0
	y -> 1
	
RUN 3:
	x == 1 && y == 1
	x -> 0
	y -> 0
But instead it behaves like this example:
ififif.png
ififif.png (37.24 KiB) Viewed 1012 times

Code: Select all

PRE:
	x=0
	y=0

Code: Select all

RUN 1:
	x == 0 && y == 0
	x -> 1
	x == 1 && y == 0
	y -> 1	
	x == 1 && y == 1
	x -> 0
	y -> 0
tjerk
Posts: 3
Joined: Sunday 23 December 2018 10:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Contact:

Re: Blocky script doesn't work like expected...

Post by tjerk »

I'm facing the same issue/bug with nested if statements as described in viewtopic.php?f=62&t=16455#p126119
After reading multiple threads (viewtopic.php?f=62&t=16271) I'm not using nested blocks anymore. Would be nice to have this feature in the future ;-)
Example which triggers both error logs:
Example nested blog with bug.png
Example nested blog with bug.png (90.49 KiB) Viewed 415 times
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest