Page 1 of 1

[SOLVED] Newby Blocky: evaluation fails

Posted: Friday 27 January 2017 20:06
by michaelb
Hi,

I'm fairly good at programming but new to Domoticz and Blocky. I'm trying to create a script that turns on a light if the following conditions are met:
- Frontdoor [voordeur] (switch) set to open
- Time is between 22:00 and 23:59
- Light at staircase [trap] (dimmer) = off

Below the Blocky build (name=Voordeur):
Blocky Script
Blocky Script
BlockyFault.JPG (90.96 KiB) Viewed 819 times
When triggering the event (door opens) however the if's, other than the first are not correcty evaluated, so no matter what the time is, nor what the state of [trap] is, the action is performed always:

Logfile:

Code: Select all

2017-01-27 19:55:31.452 EventSystem: Event triggered: Voordeur_1 
2017-01-27 19:55:31.452 Voordeur open 
2017-01-27 19:55:31.453 Tijd 22:00-23:59 
2017-01-27 19:55:31.453 Licht bij trap is uit: tijdelijk aan 
What am I doing wrong?
Thanks in advance for the help.

Re: Newby Blocky: evaluation fails

Posted: Friday 27 January 2017 20:28
by StanHD
Nested Blockly doesn't work. You need to redo it with a single "If - Else If - Else If ..... Etc. " Block. It will work then. Have a look at recent Blockly examples on the forum.

Re: Newby Blocky: evaluation fails

Posted: Friday 27 January 2017 20:30
by Ben0it
Hi,

I had a similar problem using a nested « If-Do » with the settings icon (light gear over a blue square) inside a standard « If-Do » block. Actions were always run inside, disregard of the condition(s) of the « If ».

I couldn't solve this using Blockly, so I switched to LUA scripting, now it is fine.

Best Regards,

Re: Newby Blocky: evaluation fails

Posted: Friday 27 January 2017 21:20
by michaelb
Thanks for the quick response guys!

Per StanHD's advice I've rewritten the Blockly to one If/Else loop.

Works like a charm!

Michael