5.9 KiB
Home-Assistant Sunrise Alarm
Turn your smart lights into a natural alarm clock
This project is made up of two blueprints
sunrise-simulation.yaml: This script turns any compatible light (or group of lights) into a soft-sunrise / sunset alarm. It gradually ramps the brightness and the colour temperature over a user-defined period.sunrise-alarm.yaml: Thin wrapper that calls the simulation script when the alarm occurs (or some configured time before/after).
1. What it is & how it works
| Component | Purpose | What it does |
|---|---|---|
| sunrise-simulation (script) | The “engine” that gradually lights up (or down) your bulbs | Uses a repeat loop to turn the selected lights on/off and slowly increase/decrease brightness over a configurable time span. The brightness and color curves can be configured to create more natural-looking sunrises. |
| sunrise-alarm (automation) | The “scheduler” that calls the simulation at a chosen time | Triggers the script at Alarm Time - Offset (e.g. 30min before the clock). An input_boolean lets you switch the alarm on/off. |
Note
Why two separate blueprints?
The simulation can be reused in any scenario (e.g. a “morning routine” or a “sunset-in-30-min” routine). The alarm automation is a thin wrapper that turns that simulation into a timed alarm.Scripts can also be stopped while the are executing, allowing you to stop the sunrise arc without turning the scheduler on and off.
Installation
sunrise-simulation
-
Import the sunrise script blueprint
-
Create a script from the blueprint
- In the “Create new script” dialog, name it
sunrise-simulation(you can give any name you like). - You'll be asked for a handful of variables - see section 3.1 for the defaults and meaning.
- Click Create - Home-Assistant will add a script entity called
script.sunrise-simulation(or whatever name you gave it).
- In the “Create new script” dialog, name it
sunrise-alarm
-
Import the alarm automation blueprint
-
Create the automation
- Pick an
input_datetimethat represents the clock you want to use as the alarm. - Pick an
input_booleanthat toggles the alarm on or off. - Choose an
offest_durationfor how long before/after to start the sunrise arc relative to the alarm time. You'll usually want this to be the same asdurationdefined in the previous script, this time negative, so that the peak (end) of the arc aligns with the alarm time. - Choose the
sunrise-simulationscript you created in the previous step for thealarm_scriptfield. - Save - you now have a ready-to-run alarm!
- Pick an
Tip
If you want a sunset alarm, simply copy the
sunrise-simulationscript (or create a new script from the blueprint if you want to define a different arc) and reverse it by setting direction with thereversedflag set totrue. You'll also want to create a new automation that calls it with a negativeoffset_duration.
Configurable variables
sunrise-simulation script variables
| Variable | Type | Default | Description |
|---|---|---|---|
lights |
list of entity_ids |
["light.kitchen"] |
All bulbs that should be part of the arc. |
total_duration |
integer | 30 |
Total time the arc takes on minutes. |
steps |
integer | 10 |
How many brightness steps the script performs. If your light(s) do not support transition you should set this higher for a more gradual change (max value is 100). |
start_brightness |
integer | 0 |
Brightness percentage at the very beginning of the arc. |
end_brightness |
integer | 100 |
Brightness percentage at the very end of the arc. |
start_temp |
integer | 2000 |
Color temperature (kelvin) at the very beginning of the arc. |
end_temp |
integer | 5000 |
Color temperature (kelvin) at the very end of the arc. |
reversed |
boolean | false |
If true, the script will run your arc in reverse (useful for easily defining sunsets). |
curve_type |
string | sigmoid |
linear, parabolic (quadratic), or sigmoid (an S-curve). As we don't perceive light intensity linearly, sigmoid or parabolic make for a more natural curve. |
sunrise-alarm automation variables
| Variable | Type | Default | Description |
|---|---|---|---|
alarm_time |
input_datetime |
— | The time you want the alarm to ring (e.g. 07:00 AM). |
offset_duration |
time |
"00:-30:00" |
How many minutes after alarm_time the sunrise arc should start. A negative value would start before the alarm. |
alarm_enabled |
input_boolean |
— | A switch that turns the whole alarm on/off. |
sunrise_script |
script |
— | The script instance created by the sunrise‑simulation blueprint (script.sunrise-simulation). |
The automation uses the following logic:
Alarm Time - Offsetfires the automation.- If
Alarm Enabledison, it calls the sunrise script. - If
Alarm Enabledisoff, nothing happens.
Warning
You may not be able to set negative duration values via the user interface. If so, you'll need to edit the YAML directly.
License
This repository is released under the MIT License.
Feel free to fork, modify, or redistribute the blueprints as long as you keep the same license.