Hey, I have lately been looking into improving my wake-up and good-night light automations. Their function is pretty obvious: slowly fade in in the morning and slowly fade out at night.
(Those who have colour-lamps and have not noticed yet: Take a look at the “flux light adjustment” component!)
My current setup is made a bit complex, but it works nicely and in the basics, that’s what I want to keep. On the frontend it shows up as following:
- Template Sensor: Reads out the following inputs (2+3) as time-format (HH:MM)
- Input-Slider: Sets the hour to call the service
- Input-Slider: Sets the minute to call the service
- Template Sensor: Shows if today is a workday (for wakeup) or if tomorrow is a workday (for sleep)
- Input-Select: Gives me a couple options to choose, workdays only, everyday or manualy selected only
— These work in conjunction with Nr. 2+3, except Selected only. - 7x an input-boolean followed by input_text for every day in the week. The input-boolean works as “override” on-off and text for the time to use instead.
So far, so good. Now what did bother me here? It’s the way I trigger the automation and how it works with setting the scene. See, scenes have the option to set a transition-time. Since it’s supposed to be a soft wake-up/good-night, they are quite longer than a few seconds. That means, if I want to set a wake-up time, I have to manualy adjust the time for when the automation should trigger, instead of when I set my alarm to wake me up. It’s a bit confusing for anyone else than me, apparently. I want my lights to go on early, and at their peak my alarm should go off.
After messing with templates, I managed to set my sliders accordingly. So actualy my setup is like this now:
-
Template Sensor: Showing me the time I have set using my sliders. This is the time I want to get up.
-
(not displayed) Template Sensor: Correcting the time in order to call the lights early by using this line of code:
sensor:
platform: template
sensors:
alarm_start:
entity_id: input_number.alarm_hour, input_number.alarm_minute
value_template: ‘{% if states(“input_number.alarm_minute”)|int < 30 %}{{ “%02d:%02d” | format(states(“input_number.alarm_hour”)|int - 1, states(“input_number.alarm_minute”)|int + 30) }}{% else %}{{ “%02d:%02d” | format(states(“input_number.alarm_hour”)|int, states(“input_number.alarm_minute”)|int - 30) }}{% endif %}’
(sorry for bad format, I can’t seem to fix it)
Then, in my automation I call it using this condition, along with time_pattern as trigger:
- condition: template
value_template: "{{ states.sensor.time.state == states('sensor.alarm_start') }}"
This works perfectly with my two sliders, which are the easiest way to adjust time. However I don’t want sliders for all my week’s overrides, they clutter up my page and make it look messy. I have concidered moving from input_text to input_datetime, however, both give me headaches. I have not been able to find a solution on how to alter these two inputs into what I need - or alter it in any way.
Is there a way, similar to the above sollution, that I can use to change input_time? So that when I set time to “06:30” that I have a sensor that translates it to “06:00” for my automation?