I am a new guy at HA, just came from Hubitat elevation. I know there is a learning curve to get to use HA, but one of my automations is keeping me from turning the Hubitat Hub off…
Can someone help me set this automation?
My daughter has a Phillips Hue bulb and a xiaomi button by her bed.
When she goes to sleep, she presses the button, her light turns on at 50% brightness. It stays at that brightness for 15 min and then starts to dimm 5% each 5 minutes until it gets to 3% brightness.
When she wakes up in the morning, she presses the button and the light turns off.
Now the tricky part:
There are days when she takes longer to fall asleep, she is used to pressing the button again to toggle the light off and press it again so that the light will come back at 50% and restart the dimming process.
I just cant make it work!
Previous tries…
I did it with call service - lights:toggle - set brightness 45% / wait for 5 min / call service - lights: toggle - brightness 40% and so on… For some reason the light fails to return to 50% when the button is pressed again or fails to turn off.
Created helpers (timers) that would cycle each 5 min and trigger a brightness reduction… but this did not work at all…
I gave up doing it in the beutifull way… and decided to go “old school”.
Created an automation linking the button to the light just to toggle it.
Created a second automation that triggers a timer. This timer is used as a condition for the automation to keep running.
Created a third automation that reloads the second automation and cancels the timer if the light is turned off.
First automation:
Just toggles the light by the push of the button
I do, but to get to that I have to: Call Service - and choose lights toggle or lights ON. There’s no way to set brightness levels without influencing the light’s status.
Because of that, if my daughter decides to turn off the light while the automation was still running; the bulb would turn on again; when the time to change brightness arrives.
Is there any other way to set brightness levels, without having to call the bulb ON or Toggle?
I’ve done some testing, and maybe this is what you are looking for:
On a button press ( you’ll have to define that trigger)
It will check the current state.
if on it will go off
if off, it will set it once to 50% and wait a second
then it will repeat 9 times and at every cycle it checks if the light is on if yes, a decrease of 5% over a time of 2,5 minutes if no. stop it.
Again… I’m new to this and not used to having to turn on a ligtht every time I want to change its brightness.
In this automation the issue was that if the light was turned off while the automation was still running, it would turn back on when the time came.
Using a brightness change without having to turn the light on would prevent that.
But again. It can be done by just pausing or triggering the automation….
Thank you this script (did not try automation) worked for me, since Tasmota only support limited transition times of max 30seconds or something along those lines.