Blocky script doesn't work like expected...

Moderator: leecollings

andyk
Posts: 12
Joined: Thursday 24 November 2016 23:03
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11506
Location: Germany
Contact:

Blocky script doesn't work like expected...

Post 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
Screen Shot 2017-03-05 at 15.51.22.png (40.16 KiB) Viewed 4842 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
andyk
Posts: 12
Joined: Thursday 24 November 2016 23:03
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11506
Location: Germany
Contact:

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

Post by andyk »

Sorry to bump this, but does anybody have a clue what may cause the above issue ?

cheers,
Andy
User avatar
K3rryBlue
Posts: 77
Joined: Tuesday 07 February 2017 22:13
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10xx
Location: Netherlands
Contact:

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

Post 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?
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
Spitfire
Posts: 20
Joined: Thursday 29 December 2016 9:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post 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...
User avatar
K3rryBlue
Posts: 77
Joined: Tuesday 07 February 2017 22:13
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10xx
Location: Netherlands
Contact:

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

Post 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.
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
Spitfire
Posts: 20
Joined: Thursday 29 December 2016 9:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post 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.
User avatar
StanHD
Posts: 347
Joined: Friday 12 July 2013 16:09
Target OS: Windows
Domoticz version:
Location: East Sussex, UK
Contact:

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

Post 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.
Domoticz Main - Intel nuc, Windows, RFXTRX433E. Lan Relay Boards, Aeon Z-Stick Gen 5, Evohome HGI80, Milight WiFi, MySensors Ethernet Gateway, Harmony Hub
Python:- Broadlink RM2, Sonos
HA-Bridge - Amazon Echo / Alexa
User avatar
PeGe
Posts: 25
Joined: Tuesday 31 January 2017 14:21
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.6328
Location: Sollentuna, Sweden
Contact:

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

Post 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
User avatar
StanHD
Posts: 347
Joined: Friday 12 July 2013 16:09
Target OS: Windows
Domoticz version:
Location: East Sussex, UK
Contact:

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

Post 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.
Domoticz Main - Intel nuc, Windows, RFXTRX433E. Lan Relay Boards, Aeon Z-Stick Gen 5, Evohome HGI80, Milight WiFi, MySensors Ethernet Gateway, Harmony Hub
Python:- Broadlink RM2, Sonos
HA-Bridge - Amazon Echo / Alexa
Spitfire
Posts: 20
Joined: Thursday 29 December 2016 9:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post 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.
User avatar
K3rryBlue
Posts: 77
Joined: Tuesday 07 February 2017 22:13
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10xx
Location: Netherlands
Contact:

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

Post 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.
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
mrf68

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

Post 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 ;-) )
blauwebuis
Posts: 331
Joined: Wednesday 21 December 2016 9:11
Target OS: Raspberry Pi / ODroid
Domoticz version: current
Contact:

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

Post 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!
freijn
Posts: 536
Joined: Friday 23 December 2016 16:40
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Netherlands Purmerend
Contact:

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

Post by freijn »

THis is how I got it to work.

Image
Spitfire
Posts: 20
Joined: Thursday 29 December 2016 9:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post 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... :)
User avatar
K3rryBlue
Posts: 77
Joined: Tuesday 07 February 2017 22:13
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10xx
Location: Netherlands
Contact:

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

Post 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.
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
Spitfire
Posts: 20
Joined: Thursday 29 December 2016 9:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post 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! :D
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,

I have also a strange behavior with a nested if else-if

Image

The 2 write to log are always executed.
Is this normal or have I done soemthing wrong?

Kind regards
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
User avatar
K3rryBlue
Posts: 77
Joined: Tuesday 07 February 2017 22:13
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10xx
Location: Netherlands
Contact:

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

Post 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.
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
niceandeasy
Posts: 102
Joined: Thursday 28 January 2016 22:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: NL
Contact:

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

Post 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.
Post Reply

Who is online

Users browsing this forum: peterbos and 1 guest