Blockly using Kaku Dusk Sensor

Moderator: leecollings

Post Reply
schijndela
Posts: 17
Joined: Thursday 05 July 2018 19:36
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10717
Contact:

Blockly using Kaku Dusk Sensor

Post by schijndela »

Hi all,

Recently I Installed a KaKu Dusk sensor which I want to use between a specific time so I thought by using a Blocky script this could easily be fixed. (Unfortunately I have no knowledge of using the other scripting possiblities).
Basically I try to achieve that between 9:00 AM and 18:00 PM If the KaKu sensor is switched on then my light should be turned on for 5 minutes.
Next if the Kaku switch is off then the lights should be turned off.

But after the Sensor is activated nothing happens, I only see some error messages in the log which I can't explain, perhaps one of you can tell me what is wrong with the used script.

Many thanks for your help in advance.
Attachments
Blockly script.jpg
Blockly script.jpg (98.86 KiB) Viewed 3645 times
Blockly error.jpg
Blockly error.jpg (232.31 KiB) Viewed 3645 times
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Blockly using Kaku Dusk Sensor

Post by waaren »

schijndela wrote: Sunday 12 July 2020 10:24 But after the Sensor is activated nothing happens, I only see some error messages in the log which I can't explain, perhaps one of you can tell me what is wrong with the used script.
You put the condition checks for state of Schemerschakelaar in the wrong blocks.
I also think the explicit switching Off is not needed as the light will already be switched Off after 5 minutes.

Try first using
Blockly.png
Blockly.png (33.69 KiB) Viewed 3641 times
and if that works try again without the elseif part.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
schijndela
Posts: 17
Joined: Thursday 05 July 2018 19:36
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10717
Contact:

Re: Blockly using Kaku Dusk Sensor

Post by schijndela »

Hi Waaren,

Thanks for your reply, you mention that I put the check for the schemerschakelaar in the wrong Blocks, could you please explain what you mean.
Did you meant that I first need begin with time in the If statement and than end it with the Schemerschakelaar?
I modified the switching off as you suggested, so now the Blocky looks like this.
Attachments
Blockly script v2.jpg
Blockly script v2.jpg (54.26 KiB) Viewed 3636 times
schijndela
Posts: 17
Joined: Thursday 05 July 2018 19:36
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10717
Contact:

Re: Blockly using Kaku Dusk Sensor

Post by schijndela »

I think I found the solution.
After modifying the Blockly Script and setting the time for just 1 minute for testing it worked.
Attachments
Blockly script v3.jpg
Blockly script v3.jpg (48.63 KiB) Viewed 3636 times
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Blockly using Kaku Dusk Sensor

Post by waaren »

schijndela wrote: Sunday 12 July 2020 11:49 Could you please explain what you mean.
You coded 'Schemerschakelaar = ' as one block and ' "On" and "time > 09:00 and time < 18:00" ' as another block

It should be

' Schemerschakelaar = "On" ' as one block and 'time > 09:00 and time < 18:00' as the other block

Also there are a lot of posts on this forum warning against using nested if else in Blockly.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
AllesVanZelf
Posts: 265
Joined: Monday 05 February 2018 8:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 12467
Location: Netherlands, near Haarlem
Contact:

Re: Blockly using Kaku Dusk Sensor

Post by AllesVanZelf »

Are your sure this is going to work?
If (schemerschakelaar = 'On') and (Time > 9 and Time < 18)
Do schemerschakelaar = 'On' for X minutes.

When sunset is before 18 the light goes On, then it goes Off after X minutes, but will go On at the same time because schemerschakelaar is still Off.
Or am I wrong here?
Domoticz 2020.1 (12230) on Raspberry Pi 3B with Raspian Buster. Besides Domoticz, Rpi is running Pi-Hole.
schijndela
Posts: 17
Joined: Thursday 05 July 2018 19:36
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10717
Contact:

Re: Blockly using Kaku Dusk Sensor

Post by schijndela »

Hi Waaren,

For some reason it isn't working, the lights go on even when the schemerschakelaar is off!?
No idea how this is possible if I take a look at the log file from the schemerschakelaar it doesn't mention an entry for switching on.
Apparently there are more reason why it don't work as I hoped

For my lights I'm using a Timer which switches the lights on after sunset, My goal was to use the sunset and sunrise option in Blockly so that's why i'm using the time > 09:11 and < 18:00 option in my test.
Attachments
Switches.jpg
Switches.jpg (162.16 KiB) Viewed 3580 times
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Blockly using Kaku Dusk Sensor

Post by waaren »

schijndela wrote: Tuesday 14 July 2020 19:36 For some reason it isn't working, the lights go on even when the schemerschakelaar is off!?
I don't know how your current Blockly looks like so kind of hard to comment or advise
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
schijndela
Posts: 17
Joined: Thursday 05 July 2018 19:36
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10717
Contact:

Re: Blockly using Kaku Dusk Sensor

Post by schijndela »

This is how my currently Blockly looks like.
But randomly the lights go on for a minute while the switch "Schemerschakelaar" is off.
Attachments
Kaku Dusk Sunrise - Sunset .jpg
Kaku Dusk Sunrise - Sunset .jpg (48.77 KiB) Viewed 3555 times
schijndela
Posts: 17
Joined: Thursday 05 July 2018 19:36
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10717
Contact:

Re: Blockly using Kaku Dusk Sensor

Post by schijndela »

I modified the If statement and replaced "and" with "or" sunrise and sunset can't be a the same time.
So, with the modified statement the lights go on for one minute and than go off for one minute..
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Blockly using Kaku Dusk Sensor

Post by waaren »

schijndela wrote: Friday 17 July 2020 19:15 This is how my currently Blockly looks like.
But randomly the lights go on for a minute while the switch "Schemerschakelaar" is off.
Nested if (else) blocks are not supported in domoticz Blockly
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
Treve
Posts: 107
Joined: Thursday 05 November 2015 10:37
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.11474
Location: Rotterdam, NL
Contact:

Re: Blockly using Kaku Dusk Sensor

Post by Treve »

Try “If time>sunrise or time<sunset and schemerschakelaar=on”
Set enz.
- RFXtrx433E,
- AEON Labs ZW090 Z-Stick Gen5 EU
- Hue v2.1
- Raspberry Pi 3 Model B, Raspbian Stretch Full on USB-Stick.
- Domoticz 4.11474
Devices: KaKu, Z-Wave, Hue.

for testing:
Raspberry 4, 2GB, SSD
Domoticz 2022.1
Ikea Hub, Fyrtur curtain
schijndela
Posts: 17
Joined: Thursday 05 July 2018 19:36
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10717
Contact:

Re: Blockly using Kaku Dusk Sensor

Post by schijndela »

You mean like this.
Unfortunately still the same. also with this setting one minute on one minute off.
Attachments
Kaku Dusk Sunrise - Sunset v2 .jpg
Kaku Dusk Sunrise - Sunset v2 .jpg (55.01 KiB) Viewed 3551 times
User avatar
Treve
Posts: 107
Joined: Thursday 05 November 2015 10:37
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.11474
Location: Rotterdam, NL
Contact:

Re: Blockly using Kaku Dusk Sensor

Post by Treve »

you have PB
- RFXtrx433E,
- AEON Labs ZW090 Z-Stick Gen5 EU
- Hue v2.1
- Raspberry Pi 3 Model B, Raspbian Stretch Full on USB-Stick.
- Domoticz 4.11474
Devices: KaKu, Z-Wave, Hue.

for testing:
Raspberry 4, 2GB, SSD
Domoticz 2022.1
Ikea Hub, Fyrtur curtain
schijndela
Posts: 17
Joined: Thursday 05 July 2018 19:36
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10717
Contact:

Re: Blockly using Kaku Dusk Sensor

Post by schijndela »

Hi All,

All my thanks go to Treve (Evert) he helped me out greatly, apparently by creating an additional Dummy switch the problem can be solved in Blockly.
I will attach a screenshot of the Blockly script which now works for me.
Next step is to fine-tune it a bit further
Attachments
Blockly Dusk.jpg
Blockly Dusk.jpg (42.69 KiB) Viewed 3506 times
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests