1065 lines
30 KiB
YAML
1065 lines
30 KiB
YAML
- alias: Air Quality Alerts (Hourly Notification)
|
||
description: 'Notify when air quality exceeds thresholds.
|
||
|
||
'
|
||
triggers:
|
||
- entity_id: sensor.air_monitor_lite_7f01_carbon_dioxide
|
||
above: 750
|
||
for: 01:00:00
|
||
trigger: numeric_state
|
||
- entity_id: sensor.pm25_5min_avg
|
||
above: 3
|
||
for: 01:00:00
|
||
trigger: numeric_state
|
||
- entity_id: sensor.pm10_5min_avg
|
||
above: 5
|
||
for: 01:00:00
|
||
trigger: numeric_state
|
||
- entity_id: sensor.air_monitor_lite_7f01_carbon_dioxide
|
||
above: 850
|
||
for: 00:05:00
|
||
trigger: numeric_state
|
||
- entity_id: sensor.pm25_5min_avg
|
||
above: 5
|
||
trigger: numeric_state
|
||
- entity_id: sensor.pm10_5min_avg
|
||
above: 15
|
||
trigger: numeric_state
|
||
conditions:
|
||
- condition: template
|
||
value_template: '{% set last = state_attr(''automation.air_quality_alerts_hourly_notification'',''last_triggered'')
|
||
%} {{ (now() - last).total_seconds() > 3600 if last else true }}
|
||
|
||
'
|
||
actions:
|
||
- data:
|
||
title: 🚨 Air Quality Alert
|
||
message: "{{ area_name(trigger.entity_id) or 'Home' }} – {{ state_attr(trigger.entity_id,'friendly_name')\
|
||
\ or trigger.entity_id.split('.')[-1] }} is elevated: {{ states(trigger.entity_id)\
|
||
\ }} {{ state_attr(trigger.entity_id,'unit_of_measurement') or '' }}. {% if\
|
||
\ trigger.for and trigger.for.total_seconds() >= 3600 %}\n Sustained WHO-level\
|
||
\ exceedance.\n{% else %}\n Air quality spike.\n{% endif %}\n"
|
||
action: notify.mobile_app_iphone_2023
|
||
mode: single
|
||
- alias: Voice Announcements
|
||
description: Add Voice Announcements to Living Room To-Do List
|
||
triggers:
|
||
- at: '17:55:00'
|
||
id: high_rates_start_warning
|
||
trigger: time
|
||
- at: '21:00:00'
|
||
id: high_rates_end_announcement
|
||
trigger: time
|
||
actions:
|
||
- choose:
|
||
- conditions:
|
||
- condition: trigger
|
||
id: high_rates_start_warning
|
||
sequence:
|
||
- data:
|
||
item: High power rates are in effect soon.
|
||
target:
|
||
entity_id: todo.living_room_notifications
|
||
action: todo.add_item
|
||
- conditions:
|
||
- condition: trigger
|
||
id: high_rates_end_announcement
|
||
sequence:
|
||
- data:
|
||
item: Power is cheap again.
|
||
target:
|
||
entity_id: todo.living_room_notifications
|
||
action: todo.add_item
|
||
mode: single
|
||
- alias: Dining Room Motion Lights
|
||
description: ''
|
||
triggers:
|
||
- entity_id: binary_sensor.dining_room_hue_motion_sensor
|
||
to: 'on'
|
||
trigger: state
|
||
- entity_id: binary_sensor.dining_room_hue_motion_sensor
|
||
to: 'off'
|
||
for: 00:10:00
|
||
trigger: state
|
||
conditions: []
|
||
actions:
|
||
- choose:
|
||
- conditions:
|
||
- condition: state
|
||
entity_id: binary_sensor.dining_room_hue_motion_sensor
|
||
state: 'on'
|
||
- condition: numeric_state
|
||
entity_id: sensor.dining_room_hue_motion_sensor_illuminance
|
||
below: 18
|
||
sequence:
|
||
- target:
|
||
entity_id: light.dining_room_lights
|
||
data: "{% if is_state('input_boolean.night_light_mode', 'on') %} {\n \"rgb_color\"\
|
||
: {{ states('input_text.night_light_color_tr').split(',') | map('int') |\
|
||
\ list }},\n \"brightness\": 255,\n \"transition\": 4\n} {% else %} {\n\
|
||
\ \"color_temp_kelvin\": 2700,\n \"brightness\": 255,\n \"transition\"\
|
||
: 4\n} {% endif %}\n"
|
||
action: light.turn_on
|
||
- conditions:
|
||
- condition: state
|
||
entity_id: binary_sensor.dining_room_hue_motion_sensor
|
||
state: 'off'
|
||
sequence:
|
||
- target:
|
||
entity_id: light.dining_room_lights
|
||
data:
|
||
transition: 4
|
||
action: light.turn_off
|
||
mode: restart
|
||
- alias: Downstairs Bathroom Motion Lights
|
||
description: ''
|
||
triggers:
|
||
- entity_id: binary_sensor.ikea_motion_2_occupancy
|
||
to: 'on'
|
||
trigger: state
|
||
- entity_id: binary_sensor.ikea_motion_2_occupancy
|
||
to: 'off'
|
||
trigger: state
|
||
- entity_id: binary_sensor.tuya_motion_1_occupancy
|
||
to: 'on'
|
||
trigger: state
|
||
- entity_id: binary_sensor.tuya_motion_1_occupancy
|
||
to: 'off'
|
||
trigger: state
|
||
actions:
|
||
- choose:
|
||
- conditions:
|
||
- condition: or
|
||
conditions:
|
||
- condition: state
|
||
entity_id: binary_sensor.ikea_motion_2_occupancy
|
||
state: 'on'
|
||
- condition: state
|
||
entity_id: binary_sensor.tuya_motion_1_occupancy
|
||
state: 'on'
|
||
sequence:
|
||
- target:
|
||
entity_id: light.downstairs_bathroom_lights
|
||
data:
|
||
transition: 1
|
||
brightness_pct: '{{ brightness_level }}'
|
||
action: light.turn_on
|
||
- conditions:
|
||
- condition: state
|
||
entity_id: binary_sensor.ikea_motion_2_occupancy
|
||
state: 'off'
|
||
- condition: state
|
||
entity_id: binary_sensor.tuya_motion_1_occupancy
|
||
state: 'off'
|
||
sequence:
|
||
- delay: 00:10:00
|
||
- condition: state
|
||
entity_id: binary_sensor.ikea_motion_2_occupancy
|
||
state: 'off'
|
||
- condition: state
|
||
entity_id: binary_sensor.tuya_motion_1_occupancy
|
||
state: 'off'
|
||
- target:
|
||
entity_id: light.downstairs_bathroom_lights
|
||
data:
|
||
transition: 4
|
||
action: light.turn_off
|
||
variables:
|
||
night_brightness: 20
|
||
day_brightness: 50
|
||
now_hour: '{{ now().hour }}'
|
||
is_night: '{{ now_hour >= 23 or now_hour < 6 }}'
|
||
brightness_level: '{{ night_brightness if is_night else day_brightness }}'
|
||
mode: restart
|
||
- alias: Downstairs Hallway Motion Lights
|
||
triggers:
|
||
- entity_id: binary_sensor.mmwave_1_presence
|
||
to: 'on'
|
||
trigger: state
|
||
- entity_id: binary_sensor.mmwave_1_presence
|
||
to: 'off'
|
||
for: 00:00:30
|
||
trigger: state
|
||
conditions:
|
||
- condition: state
|
||
entity_id: input_boolean.motion_lights_master_switch
|
||
state: 'on'
|
||
actions:
|
||
- choose:
|
||
- conditions:
|
||
- condition: state
|
||
entity_id: binary_sensor.mmwave_1_presence
|
||
state: 'on'
|
||
sequence:
|
||
- target:
|
||
entity_id: light.downstairs_hallway_lights
|
||
data: "{% if is_state('input_boolean.night_light_mode', 'on') %} {\n \"rgb_color\"\
|
||
: {{ states('input_text.night_light_color_tr').split(',') | map('int') |\
|
||
\ list }},\n \"brightness_pct\": 25\n} {% else %} {\n \"brightness_pct\"\
|
||
: 25,\n \"color_temp_kelvin\": 2700\n} {% endif %}\n"
|
||
action: light.turn_on
|
||
- conditions:
|
||
- condition: state
|
||
entity_id: binary_sensor.mmwave_1_presence
|
||
state: 'off'
|
||
sequence:
|
||
- target:
|
||
entity_id: light.downstairs_hallway_lights
|
||
action: light.turn_off
|
||
data: {}
|
||
mode: restart
|
||
- alias: Dryer Reminder After Wash
|
||
description: Sends hourly dryer reminders after washer finishes or when manually
|
||
turned on
|
||
triggers:
|
||
- alias: Washer finished
|
||
trigger: template
|
||
value_template: '{{ is_state(''sensor.washer_current_status'', ''end'') }}'
|
||
- alias: Reminder switch on
|
||
trigger: state
|
||
entity_id: input_boolean.dryer_reminder
|
||
to: 'on'
|
||
- alias: Reminder switch off
|
||
trigger: state
|
||
entity_id: input_boolean.dryer_reminder
|
||
to: 'off'
|
||
actions:
|
||
- choose:
|
||
- conditions:
|
||
- condition: trigger
|
||
id: Reminder switch off
|
||
sequence: []
|
||
- conditions:
|
||
- condition: trigger
|
||
id:
|
||
- Washer finished
|
||
- Reminder switch on
|
||
sequence:
|
||
- target:
|
||
entity_id: input_boolean.dryer_reminder
|
||
action: input_boolean.turn_on
|
||
- repeat:
|
||
sequence:
|
||
- target:
|
||
entity_id: todo.living_room_notifications
|
||
data:
|
||
item: Your dryer is ready to run!
|
||
action: todo.add_item
|
||
- delay: 01:00:00
|
||
until:
|
||
- condition: state
|
||
entity_id: input_boolean.dryer_reminder
|
||
state: 'off'
|
||
- condition: template
|
||
value_template: '{{ repeat.index >= 6 }}'
|
||
- target:
|
||
entity_id: input_boolean.dryer_reminder
|
||
action: input_boolean.turn_off
|
||
mode: restart
|
||
- alias: Front Lights - Sunset to Sunrise
|
||
trigger:
|
||
- platform: state
|
||
entity_id: sun.sun
|
||
condition: []
|
||
action:
|
||
- choose:
|
||
- conditions:
|
||
- condition: state
|
||
entity_id: sun.sun
|
||
state: above_horizon
|
||
sequence:
|
||
- service: light.turn_off
|
||
target:
|
||
entity_id: light.front_lights
|
||
- conditions:
|
||
- condition: state
|
||
entity_id: sun.sun
|
||
state: below_horizon
|
||
sequence:
|
||
- service: light.turn_on
|
||
target:
|
||
entity_id: light.front_lights
|
||
data:
|
||
color_temp_kelvin: 2700
|
||
brightness_pct: 5
|
||
mode: single
|
||
- alias: Laundry Room Motion Lights
|
||
description: ''
|
||
triggers:
|
||
- entity_id:
|
||
- binary_sensor.tuya_motion_2_occupancy
|
||
- binary_sensor.tuya_motion_3_occupancy
|
||
to: 'on'
|
||
trigger: state
|
||
- entity_id:
|
||
- binary_sensor.tuya_motion_2_occupancy
|
||
- binary_sensor.tuya_motion_3_occupancy
|
||
to: 'off'
|
||
trigger: state
|
||
actions:
|
||
- choose:
|
||
- conditions:
|
||
- condition: or
|
||
conditions:
|
||
- condition: state
|
||
entity_id: binary_sensor.tuya_motion_2_occupancy
|
||
state: 'on'
|
||
- condition: state
|
||
entity_id: binary_sensor.tuya_motion_3_occupancy
|
||
state: 'on'
|
||
sequence:
|
||
- target:
|
||
entity_id: light.laundry_room_lights
|
||
data:
|
||
brightness: 150
|
||
color_temp_kelvin: 4000
|
||
action: light.turn_on
|
||
- conditions:
|
||
- condition: state
|
||
entity_id: binary_sensor.tuya_motion_2_occupancy
|
||
state: 'off'
|
||
- condition: state
|
||
entity_id: binary_sensor.tuya_motion_3_occupancy
|
||
state: 'off'
|
||
sequence:
|
||
- delay: 00:01:00
|
||
- target:
|
||
entity_id: light.laundry_room_lights
|
||
data: {}
|
||
action: light.turn_off
|
||
mode: restart
|
||
- alias: Living Room Motion Lights
|
||
description: ''
|
||
triggers:
|
||
- entity_id: binary_sensor.hue_motion_sensor
|
||
to: 'on'
|
||
trigger: state
|
||
- entity_id: binary_sensor.hue_motion_sensor
|
||
to: 'off'
|
||
for: 00:10:00
|
||
trigger: state
|
||
conditions:
|
||
- condition: state
|
||
entity_id: input_boolean.motion_lights_master_switch
|
||
state: 'on'
|
||
actions:
|
||
- choose:
|
||
- conditions:
|
||
- condition: state
|
||
entity_id: binary_sensor.hue_motion_sensor
|
||
state: 'on'
|
||
- condition: numeric_state
|
||
entity_id: sensor.hue_motion_sensor_illuminance
|
||
below: 10
|
||
- condition: state
|
||
entity_id: input_boolean.night_light_mode
|
||
state: 'off'
|
||
sequence:
|
||
- target:
|
||
entity_id: light.living_room_accents
|
||
action: light.turn_on
|
||
data:
|
||
color_temp_kelvin: 2000
|
||
brightness_pct: 10
|
||
- target:
|
||
entity_id: light.living_room_accents
|
||
action: light.turn_on
|
||
data:
|
||
color_temp_kelvin: 2000
|
||
brightness_pct: 11
|
||
- target:
|
||
entity_id: light.living_room_lights
|
||
action: light.turn_on
|
||
data:
|
||
color_temp_kelvin: 2700
|
||
brightness_pct: 100
|
||
- conditions:
|
||
- condition: state
|
||
entity_id: binary_sensor.hue_motion_sensor
|
||
state: 'on'
|
||
- condition: numeric_state
|
||
entity_id: sensor.hue_motion_sensor_illuminance
|
||
below: 10
|
||
- condition: state
|
||
entity_id: light.living_room_lights
|
||
state: 'off'
|
||
sequence:
|
||
- target:
|
||
entity_id: light.living_room_lights
|
||
action: light.turn_on
|
||
data:
|
||
rgb_color: '{{ states(''input_text.night_light_color_hue'').split('','')
|
||
| map(''int'') | list }}
|
||
|
||
'
|
||
brightness_pct: 41
|
||
transition: 4
|
||
- conditions:
|
||
- condition: state
|
||
entity_id: binary_sensor.hue_motion_sensor
|
||
state: 'on'
|
||
- condition: numeric_state
|
||
entity_id: sensor.hue_motion_sensor_illuminance
|
||
below: 10
|
||
sequence:
|
||
- target:
|
||
entity_id: light.living_room_lights
|
||
action: light.turn_on
|
||
data:
|
||
rgb_color: '{{ states(''input_text.night_light_color_hue'').split('','')
|
||
| map(''int'') | list }}
|
||
|
||
'
|
||
transition: 4
|
||
- conditions:
|
||
- condition: state
|
||
entity_id: binary_sensor.hue_motion_sensor
|
||
state: 'off'
|
||
sequence:
|
||
- target:
|
||
entity_id: light.living_room_accents
|
||
action: light.turn_off
|
||
data:
|
||
transition: 10
|
||
- target:
|
||
entity_id: light.living_room_lights
|
||
action: light.turn_off
|
||
data:
|
||
transition: 10
|
||
mode: restart
|
||
- alias: Read Queued Announcements in Living Room
|
||
description: Announce pending to-do items from Living Room Notifications when Hue
|
||
motion sensor is on, with script logic embedded.
|
||
triggers:
|
||
- entity_id: binary_sensor.hue_motion_sensor
|
||
to: 'on'
|
||
trigger: state
|
||
- trigger: state
|
||
entity_id: todo.living_room_notifications
|
||
conditions:
|
||
- condition: and
|
||
conditions:
|
||
- condition: template
|
||
value_template: '{{ states.todo.living_room_notifications.state | int > 0 }}
|
||
|
||
'
|
||
- condition: state
|
||
entity_id: binary_sensor.hue_motion_sensor
|
||
state: 'on'
|
||
actions:
|
||
- data:
|
||
status: needs_action
|
||
target:
|
||
entity_id: todo.living_room_notifications
|
||
response_variable: living_room_notifications_data
|
||
action: todo.get_items
|
||
- variables:
|
||
notification_items: '{{ living_room_notifications_data[''todo.living_room_notifications''][''items'']
|
||
}}'
|
||
- repeat:
|
||
count: '{{ notification_items | length }}'
|
||
sequence:
|
||
- variables:
|
||
current_item_index: '{{ repeat.index - 1 }}'
|
||
current_todo_item: '{{ notification_items[current_item_index] }}'
|
||
- data:
|
||
media_player_entity_id: media_player.living_room_display
|
||
message: Attention! {{ current_todo_item.summary }}
|
||
target:
|
||
entity_id: tts.google_translate_en_com
|
||
action: tts.speak
|
||
- delay:
|
||
seconds: '{{ (current_todo_item.summary | length * 0.11) | round(0) + 2
|
||
}}'
|
||
- data:
|
||
item: '{{ current_todo_item.uid }}'
|
||
status: completed
|
||
target:
|
||
entity_id: todo.living_room_notifications
|
||
action: todo.update_item
|
||
mode: single
|
||
- alias: Low Humidity Alert (Hourly Notification)
|
||
description: 'Send a push notification if any humidity sensor goes below its threshold,
|
||
but no more than once per hour.
|
||
|
||
'
|
||
triggers:
|
||
- entity_id: sensor.sonoff_temp_humidity_2_humidity_2
|
||
below: 38
|
||
trigger: numeric_state
|
||
- entity_id: sensor.sonoff_snzb_02d_humidity_2
|
||
below: 36
|
||
trigger: numeric_state
|
||
conditions:
|
||
- condition: template
|
||
value_template: '{% set last = state_attr(''automation.low_humidity_alert_hourly_notification'',
|
||
''last_triggered'') %} {{ (now() - last).total_seconds() > 3600 if last else
|
||
true }}
|
||
|
||
'
|
||
actions:
|
||
- data:
|
||
title: 🚨 Low Humidity Alert
|
||
message: '{{ area_name(trigger.entity_id) }} humidity dropped below its threshold.
|
||
Current: {{ states(trigger.entity_id) }}%
|
||
|
||
'
|
||
action: notify.mobile_app_iphone_2023
|
||
mode: single
|
||
- alias: Master Bedroom Motion Light
|
||
description: ''
|
||
triggers:
|
||
- entity_id: binary_sensor.hue_motion_4
|
||
to: 'on'
|
||
trigger: state
|
||
- entity_id: binary_sensor.hue_motion_4
|
||
to: 'off'
|
||
for: 00:01:00
|
||
trigger: state
|
||
conditions:
|
||
- condition: state
|
||
entity_id: input_boolean.motion_lights_master_switch
|
||
state: 'on'
|
||
- condition: sun
|
||
after: sunset
|
||
after_offset: -01:00:00
|
||
before: sunrise
|
||
before_offset: 00:30:00
|
||
actions:
|
||
- choose:
|
||
- conditions:
|
||
- condition: state
|
||
entity_id: binary_sensor.hue_motion_4
|
||
state: 'on'
|
||
- condition: time
|
||
after: '20:00:00'
|
||
before: 06:00:00
|
||
sequence:
|
||
- target:
|
||
entity_id: light.ufo_lamp
|
||
data:
|
||
rgb_color:
|
||
- 255
|
||
- 0
|
||
- 0
|
||
brightness: 1
|
||
action: light.turn_on
|
||
- target:
|
||
entity_id: light.ufo_lamp
|
||
data:
|
||
rgb_color:
|
||
- 255
|
||
- 0
|
||
- 0
|
||
brightness: 255
|
||
action: light.turn_on
|
||
- action: switch.turn_off
|
||
target:
|
||
entity_id:
|
||
- switch.tr_plug_1
|
||
- switch.tr_plug_3
|
||
- switch.shelly_plug_1
|
||
- conditions:
|
||
- condition: state
|
||
entity_id: binary_sensor.hue_motion_4
|
||
state: 'on'
|
||
- condition: time
|
||
after: '15:00:00'
|
||
before: '20:00:00'
|
||
sequence:
|
||
- target:
|
||
entity_id: light.ufo_lamp
|
||
data:
|
||
color_temp_kelvin: 2000
|
||
brightness: 1
|
||
action: light.turn_on
|
||
- target:
|
||
entity_id: light.ufo_lamp
|
||
data:
|
||
color_temp_kelvin: 2000
|
||
brightness: 255
|
||
action: light.turn_on
|
||
- action: switch.turn_on
|
||
target:
|
||
entity_id:
|
||
- switch.tr_plug_1
|
||
- switch.tr_plug_3
|
||
- switch.shelly_plug_1
|
||
- conditions:
|
||
- condition: state
|
||
entity_id: binary_sensor.hue_motion_4
|
||
state: 'off'
|
||
sequence:
|
||
- target:
|
||
entity_id: light.ufo_lamp
|
||
data: {}
|
||
action: light.turn_off
|
||
- action: switch.turn_off
|
||
target:
|
||
entity_id:
|
||
- switch.tr_plug_1
|
||
- switch.tr_plug_3
|
||
- switch.shelly_plug_1
|
||
mode: restart
|
||
- alias: Master Closet Motion Lights
|
||
description: ''
|
||
triggers:
|
||
- entity_id: binary_sensor.ikea_motion_3_occupancy
|
||
to: 'on'
|
||
trigger: state
|
||
- entity_id: binary_sensor.ikea_motion_3_occupancy
|
||
to: 'off'
|
||
trigger: state
|
||
actions:
|
||
- choose:
|
||
- conditions:
|
||
- condition: state
|
||
entity_id: binary_sensor.ikea_motion_3_occupancy
|
||
state: 'on'
|
||
sequence:
|
||
- data:
|
||
entity_id: light.master_closet_lights
|
||
transition: 1
|
||
brightness: '{{ brightness_level }}'
|
||
action: light.turn_on
|
||
- conditions:
|
||
- condition: state
|
||
entity_id: binary_sensor.ikea_motion_3_occupancy
|
||
state: 'off'
|
||
sequence:
|
||
- delay: 00:00:30
|
||
- data:
|
||
entity_id: light.master_closet_lights
|
||
transition: 4
|
||
action: light.turn_off
|
||
variables:
|
||
night_brightness: 75
|
||
day_brightness: 255
|
||
now_hour: '{{ now().hour }}'
|
||
is_night: '{{ now_hour >= 23 or now_hour < 6 }}'
|
||
brightness_level: '{{ night_brightness if is_night else day_brightness }}'
|
||
mode: restart
|
||
- alias: Pantry motion lights
|
||
description: ''
|
||
triggers:
|
||
- entity_id: binary_sensor.ikea_motion_1_occupancy
|
||
to: 'on'
|
||
trigger: state
|
||
- entity_id: binary_sensor.ikea_motion_1_occupancy
|
||
to: 'off'
|
||
for: 00:00:30
|
||
trigger: state
|
||
actions:
|
||
- choose:
|
||
- conditions:
|
||
- condition: state
|
||
entity_id: binary_sensor.ikea_motion_1_occupancy
|
||
state: 'on'
|
||
sequence:
|
||
- target:
|
||
entity_id: light.pantry_lights
|
||
action: light.turn_on
|
||
data:
|
||
brightness: 38
|
||
- conditions:
|
||
- condition: state
|
||
entity_id: binary_sensor.ikea_motion_1_occupancy
|
||
state: 'off'
|
||
sequence:
|
||
- target:
|
||
entity_id: light.pantry_lights
|
||
action: light.turn_off
|
||
data: {}
|
||
mode: restart
|
||
- alias: HVAC for time-of-use rates
|
||
description: HVAC shallow, long cool in summer to take advantage of time-of-use
|
||
rates.
|
||
triggers:
|
||
- at:
|
||
- '21:50:00'
|
||
- '22:40:00'
|
||
- '23:30:00'
|
||
- '17:40:00'
|
||
- '17:55:00'
|
||
- '21:01:00'
|
||
trigger: time
|
||
conditions:
|
||
- condition: template
|
||
value_template: '{{ now().month in [5, 6, 7, 8, 9] }}'
|
||
actions:
|
||
- variables:
|
||
time_action_map:
|
||
'21:50': decrease_1
|
||
'22:40': decrease_1
|
||
'23:30': decrease_1
|
||
'17:40': decrease_1
|
||
'17:55': 'off'
|
||
'21:01': 'on'
|
||
current_time: '{{ now().strftime(''%H:%M'') }}'
|
||
- data:
|
||
action: '{{ time_action_map[current_time] }}'
|
||
action: python_script.hvac_pre_cool_and_time_of_use
|
||
mode: single
|
||
- alias: Projector IR control
|
||
triggers:
|
||
- topic: zigbee2mqtt/Button 1/action
|
||
trigger: mqtt
|
||
- entity_id:
|
||
- media_player.xbox_2
|
||
- media_player.living_room
|
||
trigger: state
|
||
actions:
|
||
- choose:
|
||
- conditions:
|
||
- condition: template
|
||
value_template: '{{ trigger.platform == ''mqtt'' and trigger.payload == ''single''
|
||
}}'
|
||
sequence:
|
||
- target:
|
||
entity_id: text.moes_ir_blaster_ir_code_to_send
|
||
data:
|
||
value: '{{ ir_on }}'
|
||
action: text.set_value
|
||
- conditions:
|
||
- condition: template
|
||
value_template: '{{ trigger.platform == ''mqtt'' and trigger.payload == ''double''
|
||
}}'
|
||
sequence:
|
||
- repeat:
|
||
count: 2
|
||
sequence:
|
||
- target:
|
||
entity_id: text.moes_ir_blaster_ir_code_to_send
|
||
data:
|
||
value: '{{ ir_off }}'
|
||
action: text.set_value
|
||
- delay:
|
||
milliseconds: 2000
|
||
- conditions:
|
||
- condition: template
|
||
value_template: "{{ trigger.platform == 'state'\n and trigger.to_state.state\
|
||
\ == 'on' }}\n"
|
||
sequence:
|
||
- target:
|
||
entity_id: text.moes_ir_blaster_ir_code_to_send
|
||
data:
|
||
value: '{{ ir_on }}'
|
||
action: text.set_value
|
||
- conditions:
|
||
- condition: template
|
||
value_template: "{{ trigger.platform == 'state'\n and trigger.to_state.state\
|
||
\ in ['off','standby','unavailable'] }}\n"
|
||
sequence:
|
||
- delay:
|
||
seconds: '{{ debounce_seconds }}'
|
||
- condition: template
|
||
value_template: "{{ states('media_player.xbox_2') == 'off'\n and states('media_player.living_room')\
|
||
\ in ['off','standby','unavailable'] }}\n"
|
||
- repeat:
|
||
count: 2
|
||
sequence:
|
||
- target:
|
||
entity_id: text.moes_ir_blaster_ir_code_to_send
|
||
data:
|
||
value: '{{ ir_off }}'
|
||
action: text.set_value
|
||
- delay:
|
||
milliseconds: 2000
|
||
mode: single
|
||
variables:
|
||
ir_on: B0UjixE8ApYGgAPgCwHgAxtAC0AB4AcH4AcBwB9AAUAL4AcDQAHAE0ABAbSg4HqHAgI8Ag==
|
||
ir_off: B3QjfRE9ApMGgAPgCwHgAxtAC0AB4A8HwAHAH0ABwAtAB8ADQAHgAwsBsqDg/YdghwICPQI=
|
||
debounce_seconds: 5
|
||
- alias: Schedule - Switches On/Off (with Month Filtering)
|
||
triggers:
|
||
- minutes: /1
|
||
trigger: time_pattern
|
||
actions:
|
||
- variables:
|
||
current_time: '{{ now().strftime(''%H:%M'') }}'
|
||
current_month: '{{ now().month }}'
|
||
- repeat:
|
||
for_each: '{{ schedule.keys() | list }}'
|
||
sequence:
|
||
- variables:
|
||
entity_id: '{{ repeat.item }}'
|
||
config: '{{ schedule[entity_id] }}'
|
||
- if:
|
||
- condition: template
|
||
value_template: '{{ not config.months or current_month in config.months
|
||
}}'
|
||
then:
|
||
- choose:
|
||
- conditions:
|
||
- condition: template
|
||
value_template: '{{ current_time == config.on }}'
|
||
sequence:
|
||
- target:
|
||
entity_id: '{{ entity_id }}'
|
||
action: switch.turn_on
|
||
- conditions:
|
||
- condition: template
|
||
value_template: '{{ current_time == config.off }}'
|
||
sequence:
|
||
- target:
|
||
entity_id: '{{ entity_id }}'
|
||
action: switch.turn_off
|
||
variables:
|
||
schedule:
|
||
switch.fan:
|
||
'on': '15:00'
|
||
'off': '22:00'
|
||
months:
|
||
- 6
|
||
- 7
|
||
- 8
|
||
- 9
|
||
mode: queued
|
||
- alias: Auto-set Night Light Mode
|
||
description: Enable night light mode at 7 PM and disable it at 8 AM
|
||
triggers:
|
||
- at:
|
||
- '23:00:00'
|
||
- 08:00:00
|
||
trigger: time
|
||
conditions: []
|
||
actions:
|
||
- variables:
|
||
time_action_map:
|
||
'23:00': turn_on
|
||
08:00: turn_off
|
||
current_time: '{{ now().strftime(''%H:%M'') }}'
|
||
- target:
|
||
entity_id: input_boolean.night_light_mode
|
||
action: input_boolean.{{ time_action_map[current_time] }}
|
||
mode: single
|
||
- alias: Auto turn off switches after delay
|
||
mode: restart
|
||
trigger:
|
||
- platform: state
|
||
entity_id:
|
||
- switch.tr_plug_4
|
||
- switch.ikea_smart_plug_1
|
||
- switch.ikea_smart_plug_3
|
||
to: 'on'
|
||
variables:
|
||
timeouts:
|
||
switch.tr_plug_4: 3600
|
||
switch.ikea_smart_plug_1: 14400
|
||
switch.ikea_smart_plug_3: 14400
|
||
triggered_switch: '{{ trigger.entity_id }}'
|
||
delay_seconds: '{{ timeouts[triggered_switch] }}'
|
||
action:
|
||
- delay:
|
||
seconds: '{{ delay_seconds }}'
|
||
- service: switch.turn_off
|
||
target:
|
||
entity_id: '{{ triggered_switch }}'
|
||
- alias: Tablet Charging Control
|
||
description: ''
|
||
triggers:
|
||
- entity_id: sensor.ipad_2023_battery_level
|
||
below: 50
|
||
id: ipad_low
|
||
trigger: numeric_state
|
||
- entity_id: sensor.ipad_2023_battery_level
|
||
above: 80
|
||
id: ipad_high
|
||
trigger: numeric_state
|
||
- entity_id: sensor.onn_battery_level
|
||
below: 50
|
||
id: onn_low
|
||
trigger: numeric_state
|
||
- entity_id: sensor.onn_battery_level
|
||
above: 80
|
||
id: onn_high
|
||
trigger: numeric_state
|
||
conditions: []
|
||
actions:
|
||
- choose:
|
||
- conditions:
|
||
- condition: template
|
||
value_template: '{{ trigger.id == ''ipad_low'' }}'
|
||
sequence:
|
||
- target:
|
||
entity_id: switch.smart_plug_4
|
||
action: switch.turn_on
|
||
data: {}
|
||
- conditions:
|
||
- condition: template
|
||
value_template: '{{ trigger.id == ''ipad_high'' }}'
|
||
sequence:
|
||
- target:
|
||
entity_id: switch.smart_plug_4
|
||
action: switch.turn_off
|
||
data: {}
|
||
- conditions:
|
||
- condition: template
|
||
value_template: '{{ trigger.id == ''onn_low'' }}'
|
||
sequence:
|
||
- target:
|
||
entity_id: switch.ikea_smart_plug_4
|
||
action: switch.turn_on
|
||
data: {}
|
||
- conditions:
|
||
- condition: template
|
||
value_template: '{{ trigger.id == ''onn_high'' }}'
|
||
sequence:
|
||
- target:
|
||
entity_id: switch.ikea_smart_plug_4
|
||
action: switch.turn_off
|
||
data: {}
|
||
mode: single
|
||
- alias: Tablet Charger or Battery Warning
|
||
description: Notify if any tablet charger is inactive or if any tablet is under
|
||
30% battery
|
||
triggers:
|
||
- entity_id: switch.smart_plug_4
|
||
for:
|
||
hours: 48
|
||
trigger: state
|
||
- entity_id: switch.ikea_smart_plug_4
|
||
for:
|
||
hours: 9
|
||
trigger: state
|
||
- entity_id: sensor.ipad_2023_battery_level
|
||
below: 30
|
||
trigger: numeric_state
|
||
- entity_id: sensor.onn_battery_level
|
||
below: 30
|
||
trigger: numeric_state
|
||
- entity_id: sensor.samsung_a9_battery_level
|
||
below: 30
|
||
trigger: numeric_state
|
||
conditions: []
|
||
actions:
|
||
- data:
|
||
message: '⚠️ Charger or battery issue: {% if states(''sensor.ipad_2023_battery_level'')|float
|
||
< 30 %} iPad: {{ states(''sensor.ipad_2023_battery_level'') }}% {% endif
|
||
%} {% if states(''sensor.onn_battery_level'')|float < 30 %} ONN: {{ states(''sensor.onn_battery_level'')
|
||
}}% {% endif %} {% if states(''sensor.samsung_a9_battery_level'')|float
|
||
< 30 %} A9: {{ states(''sensor.samsung_a9_battery_level'') }}% {% endif
|
||
%} Check charger activity and battery levels.
|
||
|
||
'
|
||
action: notify.mobile_app_iphone_2023
|
||
mode: single
|
||
- alias: Update Calendar
|
||
description: ''
|
||
triggers:
|
||
- trigger: time_pattern
|
||
minutes: /15
|
||
conditions: []
|
||
actions:
|
||
- action: homeassistant.update_entity
|
||
metadata: {}
|
||
data:
|
||
entity_id:
|
||
- calendar.family
|
||
mode: single
|
||
- alias: Upstairs Hallway Motion Lights
|
||
triggers:
|
||
- entity_id: binary_sensor.hue_motion_3
|
||
to: 'on'
|
||
trigger: state
|
||
actions:
|
||
- data:
|
||
entity_id:
|
||
- light.upstairs_hallway_lights
|
||
transition: 2
|
||
brightness: '{{ brightness_level }}'
|
||
action: light.turn_on
|
||
- wait_for_trigger:
|
||
- entity_id: binary_sensor.hue_motion_3
|
||
to: 'off'
|
||
trigger: state
|
||
- delay: 00:00:08
|
||
- data:
|
||
entity_id:
|
||
- light.upstairs_hallway_lights
|
||
transition: 4
|
||
action: light.turn_off
|
||
variables:
|
||
night_brightness: 20
|
||
day_brightness: 200
|
||
now_hour: '{{ now().hour }}'
|
||
is_night: '{{ now_hour >= 23 or now_hour < 6 }}'
|
||
brightness_level: '{{ night_brightness if is_night else day_brightness }}'
|
||
mode: restart
|
||
- alias: Water Leak Detected (Hourly Notification)
|
||
description: Send a push notification if any water sensor detects a leak, but no
|
||
more than once per hour.
|
||
triggers:
|
||
- entity_id:
|
||
- binary_sensor.ikea_leak_sensor_1_water_leak
|
||
- binary_sensor.ikea_leak_sensor_2_water_leak
|
||
- binary_sensor.ikea_leak_sensor_3_water_leak
|
||
- binary_sensor.ikea_leak_sensor_4_water_leak
|
||
- binary_sensor.ikea_leak_sensor_5_water_leak
|
||
- binary_sensor.ikea_leak_sensor_6_water_leak
|
||
- binary_sensor.ikea_leak_sensor_7_water_leak
|
||
- binary_sensor.ikea_leak_sensor_8_water_leak
|
||
- binary_sensor.ikea_leak_sensor_9_water_leak
|
||
- binary_sensor.ikea_leak_sensor_10_water_leak
|
||
- binary_sensor.tr_leak_1
|
||
- binary_sensor.tr_leak_2
|
||
- binary_sensor.tr_leak_3
|
||
- binary_sensor.tr_leak_4
|
||
to: 'on'
|
||
trigger: state
|
||
conditions:
|
||
- condition: template
|
||
value_template: '{% set last = state_attr(''automation.water_leak_detected_hourly_notification'',
|
||
''last_triggered'') %} {{ (now() - last).total_seconds() > 3600 if last else
|
||
true }}
|
||
|
||
'
|
||
actions:
|
||
- data:
|
||
title: 🚨 Water Leak Detected
|
||
message: 'One of the leak sensors has detected water!
|
||
|
||
'
|
||
action: notify.mobile_app_iphone_2023
|
||
mode: single
|
||
- alias: Sync Master Thermostat to Other Thermostats
|
||
trigger:
|
||
- platform: state
|
||
entity_id: climate.master_thermostat
|
||
attribute: temperature
|
||
condition:
|
||
- condition: template
|
||
value_template: '{{ states(''climate.master_thermostat'') is not none and state_attr(''climate.master_thermostat'',
|
||
''temperature'') is not none }}'
|
||
action:
|
||
- service: climate.set_temperature
|
||
target:
|
||
entity_id: climate.thermostat
|
||
data_template:
|
||
temperature: '{{ state_attr(''climate.master_thermostat'', ''temperature'')
|
||
| float }}'
|
||
- service: climate.set_temperature
|
||
target:
|
||
entity_id: climate.thermostat_2
|
||
data_template:
|
||
temperature: '{{ (state_attr(''climate.master_thermostat'', ''temperature'')
|
||
| float) + 2 }}'
|
||
- alias: Sync Thermostat to Master Thermostat
|
||
trigger:
|
||
- platform: state
|
||
entity_id: climate.thermostat
|
||
attribute: temperature
|
||
condition:
|
||
- condition: template
|
||
value_template: '{{ state_attr(''climate.master_thermostat'', ''temperature'')
|
||
| float != state_attr(''climate.thermostat'', ''temperature'') | float }}
|
||
|
||
'
|
||
action:
|
||
- service: climate.set_temperature
|
||
target:
|
||
entity_id: climate.master_thermostat
|
||
data_template:
|
||
temperature: '{{ state_attr(''climate.thermostat'', ''temperature'') | float
|
||
}}'
|