mirror of
https://github.com/basnijholt/adaptive-lighting.git
synced 2026-09-12 14:54:04 +02:00
115 lines
3.7 KiB
Markdown
115 lines
3.7 KiB
Markdown
---
|
|
icon: lucide/bot
|
|
---
|
|
|
|
# Automation Examples
|
|
|
|
Real-world automation examples showing how to integrate Adaptive Lighting with your Home Assistant setup.
|
|
|
|
<!-- CODE:START -->
|
|
<!-- from adaptive_lighting.docs_gen import _transform_readme_links -->
|
|
<!-- print(_transform_readme_links(include_section("../README.md", "automation-examples", strip_heading=True))) -->
|
|
<!-- CODE:END -->
|
|
<!-- OUTPUT:START -->
|
|
<!-- ⚠️ This content is auto-generated by `markdown-code-runner`. -->
|
|
<details markdown="1">
|
|
<summary>Reset the <code>manual_control</code> status of a light after an hour.</summary>
|
|
|
|
```yaml
|
|
- alias: "Adaptive lighting: reset manual_control after 1 hour"
|
|
mode: parallel
|
|
trigger:
|
|
platform: event
|
|
event_type: adaptive_lighting.manual_control
|
|
variables:
|
|
light: "{{ trigger.event.data.entity_id }}"
|
|
switch: "{{ trigger.event.data.switch }}"
|
|
action:
|
|
- delay: "01:00:00"
|
|
- condition: template
|
|
value_template: "{{ light in state_attr(switch, 'manual_control') }}"
|
|
- service: adaptive_lighting.set_manual_control
|
|
data:
|
|
entity_id: "{{ switch }}"
|
|
lights: "{{ light }}"
|
|
manual_control: false
|
|
```
|
|
|
|
</details>
|
|
|
|
<details markdown="1">
|
|
<summary>Toggle multiple Adaptive Lighting switches to "sleep mode" using an <code>input_boolean.sleep_mode</code>.</summary>
|
|
|
|
```yaml
|
|
- alias: "Adaptive lighting: toggle 'sleep mode'"
|
|
trigger:
|
|
- platform: state
|
|
entity_id: input_boolean.sleep_mode
|
|
- platform: homeassistant
|
|
event: start # in case the states aren't properly restored
|
|
variables:
|
|
sleep_mode: "{{ states('input_boolean.sleep_mode') }}"
|
|
action:
|
|
service: "switch.turn_{{ sleep_mode }}"
|
|
entity_id:
|
|
- switch.adaptive_lighting_sleep_mode_living_room
|
|
- switch.adaptive_lighting_sleep_mode_bedroom
|
|
```
|
|
|
|
Set your sunrise and sunset time based on your alarm. The below script sets sunset_time exactly 12 hours after the custom sunrise time.
|
|
|
|
```yaml
|
|
iphone_carly_wakeup:
|
|
alias: iPhone Carly Wakeup
|
|
sequence:
|
|
- condition: state
|
|
entity_id: input_boolean.carly_iphone_wakeup
|
|
state: "off"
|
|
- service: input_datetime.set_datetime
|
|
target:
|
|
entity_id: input_datetime.carly_iphone_wakeup
|
|
data:
|
|
time: '{{ now().strftime("%H:%M:%S") }}'
|
|
- service: input_boolean.turn_on
|
|
target:
|
|
entity_id: input_boolean.carly_iphone_wakeup
|
|
- repeat:
|
|
count: >
|
|
{{ (states.switch
|
|
| map(attribute="entity_id")
|
|
| select(">","switch.adaptive_lighting_al_")
|
|
| select("<", "switch.adaptive_lighting_al_z")
|
|
| join(",")
|
|
).split(",") | length }}
|
|
sequence:
|
|
- service: adaptive_lighting.change_switch_settings
|
|
data:
|
|
entity_id: switch.adaptive_lighting_al_den_ceilingfan_lights
|
|
sunrise_time: '{{ now().strftime("%H:%M:%S") }}'
|
|
sunset_time: >
|
|
{{ (as_timestamp(now()) + 12*60*60) | timestamp_custom("%H:%M:%S") }}
|
|
- service: script.turn_on
|
|
target:
|
|
entity_id: script.run_wakeup_routine
|
|
- service: input_boolean.turn_off
|
|
target:
|
|
entity_id:
|
|
- input_boolean.carly_iphone_winddown
|
|
- input_boolean.carly_iphone_bedtime
|
|
- service: input_datetime.set_datetime
|
|
target:
|
|
entity_id: input_datetime.wakeup_time
|
|
data:
|
|
time: '{{ now().strftime("%H:%M:%S") }}'
|
|
- service: script.adaptive_lighting_disable_sleep_mode
|
|
mode: queued
|
|
icon: mdi:weather-sunset
|
|
max: 10
|
|
```
|
|
|
|
</details>
|
|
|
|
<!-- OUTPUT:END -->
|
|
|
|
> [!TIP]
|
|
> **Have a useful automation?** Share your automation examples by [opening an issue](https://github.com/basnijholt/adaptive-lighting/issues) or submitting a pull request to the README.
|