---
icon: lucide/bot
---
# Automation Examples
Real-world automation examples showing how to integrate Adaptive Lighting with your Home Assistant setup.
Reset the manual_control status of a light after an hour.
```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
```
Toggle multiple Adaptive Lighting switches to "sleep mode" using an input_boolean.sleep_mode.
```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
```
---
## Additional Examples
### Enable Sleep Mode at Bedtime
```yaml
automation:
- alias: "Enable sleep mode at bedtime"
trigger:
- platform: time
at: "22:00:00"
action:
- service: switch.turn_on
target:
entity_id:
- switch.adaptive_lighting_sleep_mode_bedroom
- switch.adaptive_lighting_sleep_mode_living_room
```
### Disable Sleep Mode in the Morning
```yaml
automation:
- alias: "Disable sleep mode in the morning"
trigger:
- platform: time
at: "07:00:00"
action:
- service: switch.turn_off
target:
entity_id:
- switch.adaptive_lighting_sleep_mode_bedroom
- switch.adaptive_lighting_sleep_mode_living_room
```
### Pause Adaptation During Movie Mode
```yaml
automation:
- alias: "Movie mode - pause adaptation"
trigger:
- platform: state
entity_id: input_boolean.movie_mode
to: "on"
action:
- service: switch.turn_off
target:
entity_id: switch.adaptive_lighting_living_room
- service: light.turn_on
target:
entity_id: light.living_room
data:
brightness_pct: 10
color_temp_kelvin: 2200
- alias: "Movie mode - resume adaptation"
trigger:
- platform: state
entity_id: input_boolean.movie_mode
to: "off"
action:
- service: switch.turn_on
target:
entity_id: switch.adaptive_lighting_living_room
```
### Sync Sleep Mode with Bedtime Routine
```yaml
automation:
- alias: "Bedtime routine activates sleep mode"
trigger:
- platform: state
entity_id: input_boolean.bedtime
to: "on"
action:
- service: switch.turn_on
target:
entity_id:
- switch.adaptive_lighting_sleep_mode_bedroom
- switch.adaptive_lighting_sleep_mode_hallway
- service: light.turn_on
target:
entity_id: light.bedroom
```
### Reset Manual Control When Leaving Home
```yaml
automation:
- alias: "Reset manual control when leaving"
trigger:
- platform: state
entity_id: person.your_name
from: "home"
action:
- service: adaptive_lighting.set_manual_control
data:
entity_id: switch.adaptive_lighting_living_room
manual_control: false
```
### Adjust Settings Based on Weather
```yaml
automation:
- alias: "Cloudy day - increase brightness"
trigger:
- platform: state
entity_id: weather.home
condition:
- condition: state
entity_id: weather.home
state: "cloudy"
action:
- service: adaptive_lighting.change_switch_settings
data:
entity_id: switch.adaptive_lighting_living_room
min_brightness: 40
max_brightness: 100
```