Page 1 of 2
Blocky script doesn't work like expected...
Posted: Sunday 05 March 2017 16:04
by andyk
Hi all,
I have created a blocky script to activate spots when movement is detected. I use a Fibaro Dimmer 2 for activating the spots; the sensor is a AeonLabs Multisensor 6. My blocky script looks like this:
- Screen Shot 2017-03-05 at 15.51.22.png (40.16 KiB) Viewed 4850 times
When the sensor detects movement, lights are switched on. Yay, so far so good. However, the time period of 30 seconds is never reached, as the lights switch of after about 10 - 11 seconds. Something is interfering with the script. However, I don't know what. I have checked the parameters of both the sensor and the dimmer, but can't seem to find the culprit what is causing this. Any suggestions ? I might have looked over some settings, but I'm running in circles here.
cheers,
Andy
Re: Blocky script doesn't work like expected...
Posted: Saturday 18 March 2017 15:09
by andyk
Sorry to bump this, but does anybody have a clue what may cause the above issue ?
cheers,
Andy
Re: Blocky script doesn't work like expected...
Posted: Saturday 18 March 2017 15:43
by K3rryBlue
- possible that the dimmer is part of a different script, with different conditions?
- if you increase after time, does the dimmer stay on longer?
Re: Blocky script doesn't work like expected...
Posted: Sunday 26 March 2017 12:19
by Spitfire
Domoticz blocky 'else if' handling is broken. Nothing should be run after a condition has been true. AFAIK it's been broken since day one...
Re: Blocky script doesn't work like expected...
Posted: Sunday 26 March 2017 13:00
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.
Re: Blocky script doesn't work like expected...
Posted: Sunday 26 March 2017 15:23
by Spitfire
K3rryBlue wrote: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.
Not sure if this was adressed to me but if so I'm talking about the fact that in an if-else if statement the "else if" statement is run even if the if statement before was true and that is by any standard computer language implementation purely wrong. Even if you do a test on googles own blocky site it works as it should
https://developers.google.com/blockly/
However Domoticz has it's own wrong implementation of Blocky in this case.
Re: RE: Re: Blocky script doesn't work like expected...
Posted: Sunday 26 March 2017 18:20
by StanHD
Spitfire wrote:Domoticz blocky 'else if' handling is broken. Nothing should be run after a condition has been true. AFAIK it's been broken since day one...
And yet so many of us are using Blockley successfully since day one. Different .... maybe, unusual ..... possibly, broken .... no, because it does work.
Re: Blocky script doesn't work like expected...
Posted: Sunday 26 March 2017 19:09
by PeGe
I don't buy that! - When a command/instruction as essential as the "else if" statement does not work as it should according to all accepted programming standards, that script interpreter is most definitely broken. Period!
The fact that a piece of software *can* still be used to a limited extent, although being severely crippled, does not justify the obvious lack of interrest in correcting such indisputable bugs.
/P-G
Re: RE: Re: Blocky script doesn't work like expected...
Posted: Sunday 26 March 2017 19:50
by StanHD
PeGe wrote:I don't buy that! - When a command/instruction as essential as the "else if" statement does not work as it should according to all accepted programming standards, that script interpreter is most definitely broken. Period!
The fact that a piece of software *can* still be used to a limited extent, although being severely crippled, does not justify the obvious lack of interrest in correcting such indisputable bugs.
/P-G
Please do not criticise the hard work of the developers in this way. Be constructive.
How about you "Fix" Blockley yourself because Domoticz is Open Source?
I have 30+ Blockley scripts working great. (Some reasonably complex).
I am not a software coder / developer, therefore I happily accept the hard work of others, even where there are some limitations.
Re: RE: Re: Blocky script doesn't work like expected...
Posted: Sunday 26 March 2017 22:31
by Spitfire
StanHD wrote:Spitfire wrote:Domoticz blocky 'else if' handling is broken. Nothing should be run after a condition has been true. AFAIK it's been broken since day one...
And yet so many of us are using Blockley successfully since day one. Different .... maybe, unusual ..... possibly, broken .... no, because it does work.
It's broken...period. I do not criticize the programmers (they really do a great job) I just tell that this single functionality is broken.
Re: Blocky script doesn't work like expected...
Posted: Monday 27 March 2017 0:10
by K3rryBlue
Hi Spitfire, do you have an example that shows what you're trying to tell.
Sofar I haven't had any issues with blocky inside domoticz, beside a missing "else".
However I do admit that I've added custom vars, to exclude accessing the else-if.
But this is mostly done because there is no ELSE possible.
Re: Blocky script doesn't work like expected...
Posted: Monday 27 March 2017 7:11
by mrf68
Could it that this Blockly is used as 'Time' instead of 'Device'? Whenever it runs and the status of the sensor is Off, it would start counting over and over again. I don't use Blockly myself anymore after learning some LUA and it looks to me that it uses the stat of 'otherdevices' instead of 'devicechanged'. (I hope,this makes sense
)
Re: Blocky script doesn't work like expected...
Posted: Monday 27 March 2017 9:50
by blauwebuis
Just to add that I do recognise this problem, and that I agree with Spitfire here.
I've created a blockly where the light would automatically turn on between sunset and 22:00, but only if I'm at home (using mobile phone presence detection script).
It's been behaving weirdly since day one, and I just couldn't understand why. I've tried to disable other Blocklies, etc.
Perhaps this is the cause.
I only use Blockly. And I really like that Domoticz even has Blocky, I think it's a unique selling point!
Re: Blocky script doesn't work like expected...
Posted: Monday 27 March 2017 20:50
by freijn
THis is how I got it to work.
Re: Blocky script doesn't work like expected...
Posted: Tuesday 28 March 2017 18:49
by Spitfire
K3rryBlue wrote:Hi Spitfire, do you have an example that shows what you're trying to tell.
Sofar I haven't had any issues with blocky inside domoticz, beside a missing "else".
However I do admit that I've added custom vars, to exclude accessing the else-if.
But this is mostly done because there is no ELSE possible.
If you take the thread starting example above and change it so "SensorHal1 = On" on BOTH the "if" and "else if" (stupid example but anyway) the following would happen:
Leveldimmer2_2 would be set to 40%
AND (this is not in practice in ANY prog language AFAIK, only the first one should be run!)
Leveldimmer2_2 would be set to Off after 30 seconds
As mentioned this is a stupid exampel since I would say that it's also a bug (from the one who wrote the script) if you have the EXACT same "if" as "else if" case BUT if you had added som other constraints to one of the cases like "daylight = on" you would still run both the "if" and the "else if" Do parts. Domticz "else if" handling is more like "or if"...
Don't know if my explanation was clear enough but it's what you get...
Re: Blocky script doesn't work like expected...
Posted: Tuesday 28 March 2017 19:27
by K3rryBlue
Hi Spitfire,
Now I got it. This explanation is clear enough.
And damn
you are right, I think either the name "ELSE IF" , or the interpreter is wrong.
The IF.... ELSE IF acts as 2 separate IF statements (nested IF).
If the IF statement is reached it should never reach the ELSE branch.
Re: Blocky script doesn't work like expected...
Posted: Wednesday 29 March 2017 10:15
by Spitfire
K3rryBlue wrote:Hi Spitfire,
Now I got it. This explanation is clear enough.
And damn
you are right, I think either the name "ELSE IF" , or the interpreter is wrong.
The IF.... ELSE IF acts as 2 separate IF statements (nested IF).
If the IF statement is reached it should never reach the ELSE branch.
Yes, spot on!
Re: Blocky script doesn't work like expected...
Posted: Wednesday 29 March 2017 10:58
by Lebo2d9
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?
Kind regards
Koen
Re: Blocky script doesn't work like expected...
Posted: Wednesday 29 March 2017 14:53
by K3rryBlue
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.
Re: Blocky script doesn't work like expected...
Posted: Wednesday 29 March 2017 18:36
by niceandeasy
The Aeon Multisensor 6 default config sends an ON when motion is detected and will send an OFF, 240 seconds after that.
This value of 240 secs is configurable. But configuring it is a bit of a hassle, because the sleep mode of the sensor. But it can be done.
I'd change this value to 30 secs, and associate this switch directly to the Figaro, in the zwave configuration. But if you really need it to go at 40%, create two blocklys, instead of direct association. One blockly for on at 40%, one blockly for off.