Page 1 of 1
Sunset/sunrise blockly
Posted: Thursday 17 January 2019 17:01
by maceddy
I want my garden lights to go on or off only at certain times.
For example: if sunset is before 22:00 turn on the lights at sunset.
I wrote some blockly for this, but my garden lights are not being turned on.. I can not figure out what I am doing wrong...

- sunsetblockly.png (15.21 KiB) Viewed 5169 times
Re: Sunset/sunrise blockly
Posted: Thursday 17 January 2019 18:09
by tozzke
First of all... if you're only using one statement, you'll have to pick the other if-block without the blue gear icon on the top left.
Secondly you can't compare 'Sunset' directly to a specific time
this'll work better I guess:

Re: Sunset/sunrise blockly
Posted: Thursday 17 January 2019 19:30
by maceddy
I can see the logic in that. I am gonna try that! Thanks.
Re: Sunset/sunrise blockly
Posted: Friday 31 July 2020 22:59
by Plantje
Until what time does "> sunset" apply? I mean: at about 22.00 it is past sunset. But at 3 in the night it is also past sunset. However, after 9.00 in the morning, it is also past sunset....past sunrise as well.
I am asking this, because I'd like my bathroom lights to switch on to 100% when it is daytime and to 10% when it is nighttime.
Is it also possible to check if it is 2 hours past sunset? Or do I just have to make sure the action set will happen "after x minutes"?
Re: Sunset/sunrise blockly
Posted: Saturday 01 August 2020 0:15
by Treve
Plantje wrote: ↑Friday 31 July 2020 22:59
Until what time does "> sunset" apply? I mean: at about 22.00 it is past sunset. But at 3 in the night it is also past sunset. However, after 9.00 in the morning, it is also past sunset....past sunrise as well.
I am asking this, because I'd like my bathroom lights to switch on to 100% when it is daytime and to 10% when it is nighttime.
Is it also possible to check if it is 2 hours past sunset? Or do I just have to make sure the action set will happen "after x minutes"?
You can make use of a "dummy switch" and set timers in this switch, for instance A
daytime block, after Sunrise - set on, after Sunset - set off.
Now you will have a switch wich is on during Sunrise and Sunset.
For a
Nighttime block, set ,after Sunset on, after Sunrise set off.
Now you will have a switch wich is on during Sunset and Sunrise.
With this switch you can finish the block with other blockly components.
Re: Sunset/sunrise blockly
Posted: Saturday 01 August 2020 10:51
by Plantje
Quite weird to have a virtual switch to control an actual switch.
Anyway, thanks for the response, but I solved it by checking the LUX.

- Aantekening 2020-08-01 105046.png (80.86 KiB) Viewed 4065 times
Re: Sunset/sunrise blockly
Posted: Saturday 01 August 2020 13:59
by Treve
Because there is no linear connection from Lux to Sunset/Sunrise. Lots of people struggle with time calculations and use of a dummy makes the blockly quite easy.
Re: Sunset/sunrise blockly
Posted: Sunday 02 August 2020 10:02
by Plantje
I know time calculation is always a pain

I am in BI en proper reporting against time is always challenging!
However, in this case if I were to switch a light based on if it is after sunset or not then I fail to see why I would first switch a dummy switch based on if it is after sunset and then based on the dummy switch, switch the actual switch. It seems redundant.
Re: Sunset/sunrise blockly
Posted: Sunday 02 August 2020 10:23
by Treve
There are several roads that lead to Rome, I just try to make another way clear and not to offer a solution. In retrospect, my comment applies more to the "maceddy" problem. My point is that time-related problems can be (temporarily) solved and tested with dummies and variables. Then you can make an attempt to solve this neatly without the dummy(s) and variables.
Re: Sunset/sunrise blockly
Posted: Sunday 02 August 2020 10:26
by Plantje
Agreed.... let's not hijack this topic any further

Re: Sunset/sunrise blockly
Posted: Wednesday 22 December 2021 11:22
by phpieter
When one has setup a blockly like: time > sunset OR time < sunrise —> activate device.
You now wonder why its not working. And it looks like sunrise and sunset are being ignored. There is a good change you did not setup your location in the settings page of domoticz.
Longitude and Latitude are required for sunrise/sunset to work in blockly.