This is so awesome thank you.
Im going to create a “Sunrise” light group and test that out.
This is so awesome thank you.
Im going to create a “Sunrise” light group and test that out.
Hello everyone,
I think I’ve understood the automation/script so far now. The start time has to be set before the actual alarm. And as far before as the sum of the 3 alarm lengths? Right? I have an iPhone and now have a shortcut that sends me the next alarm in HA (so dynamic). Now I would have to manipulate this time to use it in the automation. Wouldn’t it be possible to calculate the start time for sunrise? In other words, 6:00 alarm, so phase 1 10min + phase 2 10min + phase 3 5min = 25min, so the start time would be at 5:35. Wouldn’t that be easier in general? Or have I misunderstood something?
And thank you very much for the great work so far
This automation is not linked to your phone / HA app whatsoever. It is just a sunrise effect. You need a datetime helper to start it at the time when you would like it to turn on and start getting brighter. How long it takes to get through all the steps and the timeout at the end is up to you.
You should consider there is no actual audio alarm associated with this blueprint. The idea is that the sunrise is queuing your body to wake up naturally, so you’re you’re not jerked awake by an annoying audio alarm. However, until you get used to it, I’d set an audio alarm as a backup.
I have a time and a template helper to do what you want:
time:
template:
{{ (states('sensor.dave_s_s22_next_alarm') | as_timestamp
- state_attr('input_datetime.daves_next_alarm_offset', 'timestamp')) | as_datetime | as_local }}
I can look into changing how the trigger works if this is what the majority wants. It shouldn’t be to difficult to accomplish. I was thinking the below where the trigger time would be calculated by subtracting rise 1,2,3 and timeout would be after the the set datetime sensor is set for.
Example:
on and rise 1 | rise 2 | rise 3 | datetime sensor | timeout
-10 | -10 | -10 | 7:00 | +10
I think it would complement your blueprint nicely. Maybe two input fields or a checkbox depending on how you want to use the time, either as a start time or as an end point.
My idea is based on the fact that I want to be woken up dynamically by the light and then in an “emergency” the normal alarm clock will still go off. Apple has the Health app which doesn’t wake you up like a normal alarm clock and I think a light alarm clock would be a great addition to that.
Thanks Dave, but it would be ideal if it worked like that
Looked into the configuration in my post above and found that you cannot template a time or time_pattern trigger, so doing the math for the sunrise effects and trigger based on that is not done easily. It could probably be done, but it would get inconviently complex.
Easiest way would be to create a second calculated input_datetime helper which is set by the blueprint after it has been set up with alarm input_datetime helper. You would need 2 datetime helpers for each instance of the blueprint with alarm times.
Thanks for this nice blueprint. I’ve got it up and running.
Now I’m trying to change it a little bit to get a sunset animation… But I’m struggling as it seems that it is not that easy to just change the target brightness and temperature in reverse.
Do you have any hints on how to achieve a sunset?
Sunset would require some modification to the script. You’d have to Take Control
of the blueprint and turn into an automation so that you can feed both the Warmest Kelvin
and Coolest Kelvin
into the the script. The blueprint make some assumptions here.
The script would require reversing min_brightness
and max_brightness
as well as changing max_brightness_pct
to min_brightness_pct
and reversing the direction of the step so that the kelvin_step
and bright_step
reverse their current direction.
This is just after a quick look at the script again, but more may be required.
Thank you @steriku
With some time and the help of MS Copilot I built a script, which I can call by pressing a button or by some other kind of action.
Here’s the script code:
blueprint:
name: Light Sunset
author: MS27HA
description: 'Script to simulate a sunset with a linear transition of color temperature and brightness.'
domain: script
homeassistant:
min_version: 2024.9.0
input: {}
fields:
target_kelvin:
description: Warmest Kelvin value. This is the end value - most orange/red
selector:
color_temp:
unit: kelvin
min: 2000
max: 6500
default: 2000
name: Warmest Kelvin
start_kelvin:
description: This is the start value.
selector:
color_temp:
unit: kelvin
min: 2000
max: 6500
default: 2500
name: Coolest Kelvin
max_brightness_pct:
description: Maximum brightness in percent to start from
selector:
number:
min: 1
max: 100
default: 100
name: Max Brightness
alarm_length:
description: This is the start to finish time. Take this into account when setting up the automation this script is called by.
selector:
number:
min: 1
max: 60
default: 10
name: Alarm Length
steps_per_minute:
description: How many steps per minute
selector:
number:
min: 1
max: 12
default: 12
name: Steps Per minute
target_light:
description: A single light or group
selector:
entity:
filter:
domain: light
name: Target Light
variables:
steps: '{{ alarm_length * steps_per_minute }}'
max_brightness: '{{ max_brightness_pct * 2.55 }}'
min_brightness: 0
kelvin_step: '{{ (float(start_kelvin) - float(target_kelvin)) / steps }}'
bright_step: '{{ (float(max_brightness) - float(min_brightness)) / float(steps) }}'
start_time: '{{ as_timestamp(now()) }}'
individual_step: '{{ 60 / steps_per_minute }}'
sequence:
- service: light.turn_on
target:
entity_id: '{{ target_light }}'
data:
brightness_pct: '{{ max_brightness_pct }}'
color_temp_kelvin: '{{ start_kelvin }}'
transition: 1
- delay: 1
- repeat:
count: '{{ steps }}'
sequence:
- variables:
steps_to_now: '{{ repeat.index }}'
brightness: '{{ [float(max_brightness) - (bright_step * steps_to_now), 0] | max | round(0, "ceil") }}'
kelvin: '{{ float(start_kelvin) - (kelvin_step * steps_to_now) }}'
- choose:
- conditions:
- condition: template
value_template: '{{ brightness <= 0 }}'
sequence:
- service: light.turn_off
target:
entity_id: '{{ target_light }}'
default:
- service: light.turn_on
target:
entity_id: '{{ target_light }}'
data:
brightness: '{{ brightness }}'
color_temp_kelvin: '{{ kelvin }}'
transition: '{{ individual_step }}'
- delay:
seconds: '{{ individual_step }}'
Is there an easy way to enable this automation only when you’re home? Imagine you travel for couple of days, the lights shouldn’t turn on when there is nobody home
You can use the workday integration for this. There is a field built into the blueprint for it. Just configure the days you’re gone to be a holiday.
Essentially this is just a binary sensor. You can create your own binary sensor to detect when you’re device is home or not and use that instead.