Blocky script doesn't work like expected...

andyk
Posts: 7
Joined: Friday 25 November 2016 0:03
Target OS: Raspberry Pi
Domoticz version: 3.5837
Location: Germany
Contact:

Blocky script doesn't work like expected...

Post by andyk » Sunday 05 March 2017 17:04

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 1790 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: 7
Joined: Friday 25 November 2016 0:03
Target OS: Raspberry Pi
Domoticz version: 3.5837
Location: Germany
Contact:

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

Post by andyk » Saturday 18 March 2017 16:09

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

cheers,
Andy

User avatar
K3rryBlue
Posts: 97
Joined: Tuesday 07 February 2017 23:13
Target OS: Raspberry Pi
Domoticz version: V3.80xx
Location: Netherlands
Contact:

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

Post by K3rryBlue » Saturday 18 March 2017 16:43

- 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 V3.6635, RPi2 -> Linux raspberrypi 4.4.47-v7+ , RFXCOM - RFXtrx433 USB 433.92MHz ,RAZBERRY2 and OpenZWave USB Version: 1.4-2363-g1f10253-dirty

Spitfire
Posts: 16
Joined: Thursday 29 December 2016 10:16
Target OS: Raspberry Pi
Domoticz version:
Contact:

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

Post by Spitfire » Sunday 26 March 2017 12:19

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: 97
Joined: Tuesday 07 February 2017 23:13
Target OS: Raspberry Pi
Domoticz version: V3.80xx
Location: Netherlands
Contact:

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

Post by K3rryBlue » Sunday 26 March 2017 13:00

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 V3.6635, RPi2 -> Linux raspberrypi 4.4.47-v7+ , RFXCOM - RFXtrx433 USB 433.92MHz ,RAZBERRY2 and OpenZWave USB Version: 1.4-2363-g1f10253-dirty

Spitfire
Posts: 16
Joined: Thursday 29 December 2016 10:16
Target OS: Raspberry Pi
Domoticz version:
Contact:

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

Post by Spitfire » Sunday 26 March 2017 15:23

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: 541
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 » Sunday 26 March 2017 18:20

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.
Domotica - Intel nuc Celeron, Domoticz - Windows, RFXTRX433E. 1-Wire USB. Lan Relay Boards, Aeon Z-Stick Gen 5, Evohome HGI80, Milight WiFi, MySensors Ethernet Gateway, Harmony Hub, Broadlink RM2, HA-Bridge with Amazon Echo / Alexa.

User avatar
PeGe
Posts: 28
Joined: Tuesday 31 January 2017 15:21
Target OS: Raspberry Pi
Domoticz version: V3.6328
Location: Sollentuna, Sweden
Contact:

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

Post by PeGe » Sunday 26 March 2017 19:09

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: 541
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 » Sunday 26 March 2017 19:50

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.
Domotica - Intel nuc Celeron, Domoticz - Windows, RFXTRX433E. 1-Wire USB. Lan Relay Boards, Aeon Z-Stick Gen 5, Evohome HGI80, Milight WiFi, MySensors Ethernet Gateway, Harmony Hub, Broadlink RM2, HA-Bridge with Amazon Echo / Alexa.

Spitfire
Posts: 16
Joined: Thursday 29 December 2016 10:16
Target OS: Raspberry Pi
Domoticz version:
Contact:

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

Post by Spitfire » Sunday 26 March 2017 22:31

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: 97
Joined: Tuesday 07 February 2017 23:13
Target OS: Raspberry Pi
Domoticz version: V3.80xx
Location: Netherlands
Contact:

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

Post by K3rryBlue » Monday 27 March 2017 0:10

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 V3.6635, RPi2 -> Linux raspberrypi 4.4.47-v7+ , RFXCOM - RFXtrx433 USB 433.92MHz ,RAZBERRY2 and OpenZWave USB Version: 1.4-2363-g1f10253-dirty

User avatar
mrf68
Posts: 224
Joined: Monday 23 February 2015 13:45
Target OS: Windows
Domoticz version: 3.4834
Location: Netherlands
Contact:

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

Post by mrf68 » Monday 27 March 2017 7:11

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 ;-) )
----------
3x RPi
1x W2k12 (vm)
3x RFXcom433e
1x Razberry board
KAKU: 9x APA3-1500R, 2x ACDB-7000C, 3x AMST-606, 1x APIR-2150, 1x AWS-3500, 1x ATMT-502
Z-wave: 8x Everspring AN145
Misc: 2x wireless doorbells

blauwebuis
Posts: 154
Joined: Wednesday 21 December 2016 10:11
Target OS: Raspberry Pi
Domoticz version: current
Contact:

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

Post by blauwebuis » Monday 27 March 2017 9:50

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: 175
Joined: Friday 23 December 2016 17:40
Target OS: Raspberry Pi
Domoticz version:
Location: Netherlands Purmerend
Contact:

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

Post by freijn » Monday 27 March 2017 20:50

THis is how I got it to work.

Image

Spitfire
Posts: 16
Joined: Thursday 29 December 2016 10:16
Target OS: Raspberry Pi
Domoticz version:
Contact:

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

Post by Spitfire » Tuesday 28 March 2017 18:49

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: 97
Joined: Tuesday 07 February 2017 23:13
Target OS: Raspberry Pi
Domoticz version: V3.80xx
Location: Netherlands
Contact:

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

Post by K3rryBlue » Tuesday 28 March 2017 19:27

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 V3.6635, RPi2 -> Linux raspberrypi 4.4.47-v7+ , RFXCOM - RFXtrx433 USB 433.92MHz ,RAZBERRY2 and OpenZWave USB Version: 1.4-2363-g1f10253-dirty

Spitfire
Posts: 16
Joined: Thursday 29 December 2016 10:16
Target OS: Raspberry Pi
Domoticz version:
Contact:

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

Post by Spitfire » Wednesday 29 March 2017 10:15

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: 132
Joined: Tuesday 06 September 2016 20:39
Target OS: Raspberry Pi
Domoticz version: L stab
Location: Belgium
Contact:

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

Post by Lebo2d9 » Wednesday 29 March 2017 10:58

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: 97
Joined: Tuesday 07 February 2017 23:13
Target OS: Raspberry Pi
Domoticz version: V3.80xx
Location: Netherlands
Contact:

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

Post by K3rryBlue » Wednesday 29 March 2017 14:53

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 V3.6635, RPi2 -> Linux raspberrypi 4.4.47-v7+ , RFXCOM - RFXtrx433 USB 433.92MHz ,RAZBERRY2 and OpenZWave USB Version: 1.4-2363-g1f10253-dirty

niceandeasy
Posts: 146
Joined: Thursday 28 January 2016 23:25
Target OS: Raspberry Pi
Domoticz version: 3.8153
Location: NL
Contact:

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

Post by niceandeasy » Wednesday 29 March 2017 18:36

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: No registered users and 4 guests