Page 1 of 1
Bathroom light on for a specific amount of time
Posted: Wednesday 25 October 2017 17:29
by kuifje
Hello there,
I have a question that I can not answer.
I want my bathroom light to stay on for 1 hour but when I turn it off within the hour the time set should go to nil.
Now I have build a working blocky but the time goes on after i turned of the light. When i turn the light on within the first time set, say after 50 minutes, then the light turns off in 10 minutes. I want the time to set again for a hour.
Is there anyone who knows how to build this in blocky?
Thanks in advance,
Herbert
Re: Bathroom light on for a specific amount of time
Posted: Wednesday 25 October 2017 17:48
by tozzke
You should change to the other If-block (with the blue icon on top) and add a variable like so:

In this case the 'Else if' turns the switch off again, but turning it off with this blockly results in the cancellation of the timed off from the first 'If' statement.
The variable prevents retriggering
Re: Bathroom light on for a specific amount of time
Posted: Wednesday 25 October 2017 23:42
by kuifje
Thanks tozzke i will give it a try,and it works like a charm.
greetings,
Herbert
Re: Bathroom light on for a specific amount of time
Posted: Wednesday 16 January 2019 18:29
by Antori91
Hello,
I've tried such Blockly in a Raspberry using the latest Domoticz release.
It doesn't work in my environment. The first time I switch ON "Hue gen2 3", I can see "TEST_badkamer" taking the value 1 (initial value 0) and then "Hue gen2 3" automatically switched OFF after 30 seconds.
BUT it seems the Else If code part is never executed when "Hue gen2 3" goes down. So the timer off cancellation never happens and because "TEST_badkamer" keeps the value 1 instead of going to zero, next time you switch ON "Hue gen2 3", it is for always.
Any idea?
Re: Bathroom light on for a specific amount of time
Posted: Wednesday 16 January 2019 19:11
by Antori91
Sorry, in fact IT JUST WORKS FINE !!
My Blockly had a nasty error in the Else If part (see below)

- Capture2.GIF (87.56 KiB) Viewed 1852 times
Re: Bathroom light on for a specific amount of time
Posted: Thursday 17 January 2019 8:48
by Antori91
Hello,
Finally, I've modified a little bit the code (remove second condition of the first if). See code below. I suggest this modification because :
- the code I've removed doesn't seem necessary to do the job,
- in case of unattended Domoticz shutdown when "Hue gen2 3" is ON, at Domoticz restart, "TEST_badkamer" will be still equal to 1. So, the next time you switch ON "Hue gen2 3", it is for ever (no timer countdown anymore) unless you manually switch OFF "Hue gen2 3".
PS: in my blockly version, ENTREE is "Hue gen2 3" and TWILIGHT is "TEST_badkamer"

- Capture3.GIF (71.71 KiB) Viewed 1830 times