Page 1 of 1

Blockly using Kaku Dusk Sensor

Posted: Sunday 12 July 2020 10:24
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.

Re: Blockly using Kaku Dusk Sensor

Posted: Sunday 12 July 2020 10:57
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 3966 times
and if that works try again without the elseif part.

Re: Blockly using Kaku Dusk Sensor

Posted: Sunday 12 July 2020 11:49
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.

Re: Blockly using Kaku Dusk Sensor

Posted: Sunday 12 July 2020 12:20
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.

Re: Blockly using Kaku Dusk Sensor

Posted: Sunday 12 July 2020 13:12
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.

Re: Blockly using Kaku Dusk Sensor

Posted: Monday 13 July 2020 11:51
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?

Re: Blockly using Kaku Dusk Sensor

Posted: Tuesday 14 July 2020 19:36
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.

Re: Blockly using Kaku Dusk Sensor

Posted: Tuesday 14 July 2020 19:58
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

Re: Blockly using Kaku Dusk Sensor

Posted: Friday 17 July 2020 19:15
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.

Re: Blockly using Kaku Dusk Sensor

Posted: Friday 17 July 2020 19:25
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..

Re: Blockly using Kaku Dusk Sensor

Posted: Friday 17 July 2020 19:26
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

Re: Blockly using Kaku Dusk Sensor

Posted: Friday 17 July 2020 19:30
by Treve
Try “If time>sunrise or time<sunset and schemerschakelaar=on”
Set enz.

Re: Blockly using Kaku Dusk Sensor

Posted: Friday 17 July 2020 19:41
by schijndela
You mean like this.
Unfortunately still the same. also with this setting one minute on one minute off.

Re: Blockly using Kaku Dusk Sensor

Posted: Friday 17 July 2020 20:01
by Treve
you have PB

Re: Blockly using Kaku Dusk Sensor

Posted: Saturday 18 July 2020 17:42
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