Files
ha-sunrise-alarm/README.md
2026-01-09 22:08:02 -05:00

114 lines
5.5 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# HomeAssistant SunriseAlarm
**Turn your smart lights into a natural alarm clock**
---
## Table of Contents
1. [What it is & how it works](#what-it-is-&-how-it-works)
2. [Twostep installation](#twostep-installation)
* 2.1[sunrisesimulation](#sunrisesimulation)
* 2.2[sunrisealarm](#sunrisealarm)
3. [Configurable variables](#configurable-variables)
* 3.1`sunrisesimulation` script variables
* 3.2`sunrisealarm` automation variables
4. [Customising the experience](#customising-the-experience)
5. [Troubleshooting & FAQ](#troubleshooting-&-faq)
6. [License](#license)
---
## 1. What it is & how it works
| Component | Purpose | What it does |
|-----------|---------|--------------|
| **sunrisesimulation** (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. |
| **sunrisealarm** (automation) | The “scheduler” that calls the simulation at a chosen time | Triggers the script at *AlarmTime Offset* (e.g. 30min before the clock). An `input_boolean` lets you switch the alarm on/off. |
> **Why two separate blueprints?**
> The simulation can be reused in any scenario (e.g. a “morning routine” or a “sunsetin30min” routine). The alarm automation is a thin wrapper that turns that simulation into a timed alarm.
---
## 2. Installation
### 2.1sunrisesimulation
1. **Import the blueprint**
<div>
<a href="https://my.home-assistant.io/redirect/blueprint_import/?blueprint_url=https://git.jaroszew.ski/patrick/ha-sunrise-alarm/raw/branch/main/sunrise-simulation.yaml">
<img src="https://my.home-assistant.io/badges/blueprint_import.svg" alt="Import sunrisesimulation">
</a>
</div>
2. **Create a script from the blueprint**
* In the “Create new script” dialog, name it **`sunrise-simulation`** (you can give any name you like).
* Youll be asked for a handful of variables see section3.1 for the defaults and meaning.
* Click **Create** HomeAssistant will add a script entity called `script.sunrise-simulation` (or whatever name you gave it).
---
### 2.2sunrisealarm
1. **Import the alarm automation blueprint**
<div>
<a href="https://my.home-assistant.io/redirect/blueprint_import/?blueprint_url=https://git.jaroszew.ski/patrick/ha-sunrise-alarm/raw/branch/main/sunrise-alarm.yaml">
<img src="https://my.home-assistant.io/badges/blueprint_import.svg" alt="Import sunrisealarm">
</a>
</div>
2. **Create the automation**
* Pick an `input_datetime` that represents the clock you want to use as the alarm.
* Pick an `input_boolean` that toggles the alarm on or off.
* Choose a `offset_duration`
* Choose the `sunrisesimulation` script you created in the previous step for the `alarm_script` field.
* Save you now have a readytorun alarm!
> **Tip** If you want a *sunset* alarm, simply copy the `sunrisesimulation` script (or create a new script from the blueprint if you want to define a different arc) and reverse it by setting direction with the `reversed` flag set to `true`. You'll also want to create a new automation that calls it with a negative `offset_duration`.
---
## 2.3Configurable variables
### 3.1sunrisesimulation script variables
| Variable | Type | Default | Description |
|----------|------|---------|-------------|
| `lights` | list of `entity_id`s | `["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.
### 3.2sunrisealarm 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 `sunrisesimulation` blueprint (`script.sunrise-simulation`). |
The automation uses the following logic:
1. `AlarmTime Offset` fires the automation.
2. If `AlarmEnabled` is `on`, it calls the sunrise script.
3. If `AlarmEnabled` is `off`, nothing happens.
---
## 6. 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.