AutomationDataset/RafhaanShah/RafhaanShah_automations.yaml

2200 lines
58 KiB
YAML

- alias: 'Sleeping: Asleep Automations State'
description: When asleep, set automations state
trigger:
platform: state
entity_id: input_boolean.sleeping
from: 'off'
to: 'on'
action:
- service: automation.turn_on
data:
entity_id:
- automation.alarm_pre_morning_heating_bedroom
- automation.alarm_pre_morning_heating_living_room
- automation.alarm_pre_morning_blanket
- automation.alarm_pre_morning_lights
- alias: 'Sleeping: Asleep Blanket'
description: When asleep, turn the blanket off
trigger:
platform: state
entity_id: input_boolean.sleeping
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: switch.plug5_power
state: 'on'
action:
- service: switch.turn_off
data:
entity_id: switch.plug5_power
- alias: 'Sleeping: Asleep Heating'
description: When asleep, turn the heating off
trigger:
platform: state
entity_id: input_boolean.sleeping
from: 'off'
to: 'on'
action:
- service: climate.turn_off
data:
entity_id: all
- alias: 'Sleeping: Asleep Media Volumes'
description: When sleeping, set low volumes for media players
trigger:
platform: state
entity_id: input_boolean.sleeping
from: 'off'
to: 'on'
action:
- service: media_player.volume_set
data:
entity_id:
- media_player.bathroom_mini
- media_player.guest_room_mini
- media_player.speaker
- media_player.living_room_display
volume_level: 0.15
- alias: 'Sleeping: Asleep Rain Warning'
description: When asleep, if the window is open and rainy, warn
trigger:
platform: state
entity_id: input_boolean.sleeping
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: binary_sensor.living_room_window_sensor_contact
state: 'on'
- condition: state
entity_id: weather.pirateweather
state: rainy
action:
- service: notify.mobile_app_rafs_phone
data:
title: Rain warning
message: May rain overnight, window is open
- alias: 'Light: Guest Room Motion Off'
description: When guest room has no motion, if lights are on, turn off
trigger:
platform: state
entity_id: binary_sensor.guest_room_motion_sensor_occupancy
from: 'on'
to: 'off'
for:
minutes: 10
condition:
- condition: state
entity_id: light.guest_room
state: 'on'
action:
- service: light.turn_off
data:
entity_id: light.guest_room
- alias: 'Light: Guest Room No Motion'
description: When guest room lights turn on, if there is no motion, turn off
trigger:
platform: state
entity_id: light.guest_room
from: 'off'
to: 'on'
for:
minutes: 10
condition:
- condition: state
entity_id: binary_sensor.guest_room_motion_sensor_occupancy
state: 'off'
for:
minutes: 5
action:
- service: light.turn_off
data:
entity_id: light.guest_room
- alias: 'Light: Hallway Motion On'
description: When someone is in the hallway, and it is dark, turn on the lights
mode: restart
trigger:
- platform: state
entity_id: binary_sensor.bathroom_door_sensor_contact
from:
- 'on'
- 'off'
to:
- 'on'
- 'off'
- platform: state
entity_id: binary_sensor.bedroom_door_sensor_contact
from:
- 'on'
- 'off'
to:
- 'on'
- 'off'
- platform: state
entity_id: binary_sensor.front_door_sensor_contact
from:
- 'on'
- 'off'
to:
- 'on'
- 'off'
- platform: state
entity_id: binary_sensor.guest_room_door_sensor_contact
from:
- 'on'
- 'off'
to:
- 'on'
- 'off'
- platform: state
entity_id: binary_sensor.living_room_door_sensor_contact
from:
- 'on'
- 'off'
to:
- 'on'
- 'off'
- platform: state
entity_id: light.bathroom
from:
- 'on'
- 'off'
to:
- 'on'
- 'off'
- platform: state
entity_id: light.guest_room
from:
- 'on'
- 'off'
to:
- 'on'
- 'off'
condition:
- '{{ state_attr(''sun.sun'', ''elevation'') <= states(''input_number.sunset_elevation'')|float
}}'
- '{{ (state_attr(''light.hallway_2'', ''brightness'') | int(0)) <= 3 }}'
action:
- service: light.turn_on
data:
entity_id: light.hallway_2
brightness: 3
- delay:
seconds: 15
- condition: '{{ (state_attr(''light.hallway_2'', ''brightness'') | int(0)) <= 3
}}'
- service: light.turn_off
data:
entity_id: light.hallway_2
- alias: 'Light: Living Room Sunset'
description: At sunset, turn on living room evening scene
trigger:
- platform: template
value_template: '{{ state_attr(''sun.sun'', ''elevation'') <= states(''input_number.sunset_elevation'')|float
}}'
- platform: numeric_state
entity_id: sensor.hue_motion_sensor_1_illuminance
below: 400
for:
minutes: 10
condition:
- condition: time
after: '14:30:00'
- condition: state
entity_id: input_boolean.at_home
state: 'on'
- condition: state
entity_id: light.living_room
state: 'off'
- condition: not
conditions:
- condition: state
entity_id: media_player.lg_tv
attribute: source
state:
- Apple TV
- Prime Video
- BBC iPlayer
- Netflix
- Disney+
- Plex
- ITVX
action:
- service: scene.turn_on
data:
transition: 300
entity_id: '{% if is_state(''media_player.lg_tv'', ''off'') %}scene.living_room_evening
{% else %}scene.living_room_evening_tv{% endif %}'
- alias: 'Sleeping: Awake Automations State'
description: When awake, set automations state
trigger:
platform: state
entity_id: input_boolean.sleeping
from: 'on'
to: 'off'
action:
- service: automation.turn_off
data:
entity_id:
- automation.alarm_pre_morning_heating_bedroom
- automation.alarm_pre_morning_heating_living_room
- automation.alarm_pre_morning_blanket
- automation.alarm_pre_morning_lights
- alias: 'Sleeping: Awake Heating'
description: When awake, turn the heating off
trigger:
platform: state
entity_id: input_boolean.sleeping
from: 'on'
to: 'off'
condition:
- or:
- condition: state
entity_id: switch.plug5_power
state: 'on'
- condition: state
entity_id: input_boolean.electric_blanket_morning
state: 'on'
action:
- service: switch.turn_off
data:
entity_id: switch.plug5_power
- service: input_boolean.turn_off
data:
entity_id: input_boolean.electric_blanket_morning
- alias: 'Sleeping: Awake Heating'
description: When awake, turn the heating off
trigger:
platform: state
entity_id: input_boolean.sleeping
from: 'on'
to: 'off'
condition:
- condition: state
entity_id: climate.bedroom_heater
state: heat
action:
- service: climate.turn_off
data:
entity_id: climate.bedroom_heater
- alias: 'Sleeping: Awake Lights'
description: When awake, set the lights to the correct state
trigger:
platform: state
entity_id: input_boolean.sleeping
from: 'on'
to: 'off'
action:
- service: switch.turn_off
data:
entity_id: switch.adaptive_lighting_sleep_mode_bathroom
- service: light.turn_on
data:
entity_id: light.bedside_lamp
brightness_pct: 100
transition: 60
- delay:
hours: 1
- service: light.turn_off
data:
entity_id: light.bedroom
- alias: 'Sleeping: Awake Media Volumes'
description: When awake, set normal volumes for media players
trigger:
platform: state
entity_id: input_boolean.sleeping
from: 'on'
to: 'off'
action:
- service: media_player.volume_set
data:
entity_id:
- media_player.bathroom_mini
- media_player.guest_room_mini
volume_level: 0.3
- service: media_player.volume_set
data:
entity_id:
- media_player.speaker
volume_level: 0.45
- service: media_player.volume_set
data:
entity_id:
- media_player.living_room_display
volume_level: 0.35
- alias: 'Presence: Away Heating'
description: When away, turn heating off
trigger:
platform: state
entity_id: input_boolean.at_home
from: 'on'
to: 'off'
action:
- service: climate.turn_off
data:
entity_id: all
- alias: 'Presence: Away Lights'
description: When away, turn lights off
trigger:
platform: state
entity_id: input_boolean.at_home
from: 'on'
to: 'off'
action:
- service: light.turn_off
data:
entity_id: all
- alias: 'Vacuum: Away Schedule'
description: At scheduled times, if not home and not run today, start cleaning
trigger:
platform: time
at: '15:00:00'
condition:
- condition: time
weekday:
- mon
- wed
- fri
- condition: state
entity_id: input_boolean.at_home
state: 'off'
- condition: numeric_state
entity_id: sensor.robovac_last_run
above: 0
action:
- service: vacuum.start
data:
entity_id: vacuum.robovac
- alias: 'Presence: Away Set Away'
description: When away for 5 minutes, set away
trigger:
platform: state
entity_id: group.all_people
from: home
for:
minutes: 5
action:
- service: input_boolean.turn_off
data:
entity_id: input_boolean.at_home
- alias: 'Presence: Away Update GPS Lynn'
description: When disconnected from WiFi, request GPS update
trigger:
platform: state
entity_id: device_tracker.lynns_phone_wifi
from: home
for:
minutes: 10
action:
- service: script.update_location_lynn
- alias: 'Presence: Away Update GPS Raf'
description: When disconnected from WiFi, request GPS update
trigger:
platform: state
entity_id: device_tracker.rafs_phone_wifi
from: home
for:
minutes: 10
action:
- service: script.update_location_raf
- alias: 'Presence: Away Vacuum'
description: When away, if RoboVac scheduled, start cleaning
trigger:
platform: state
entity_id: input_boolean.at_home
from: 'on'
to: 'off'
condition:
- condition: state
entity_id: input_boolean.vacuum_clean
state: 'on'
- condition: numeric_state
entity_id: sensor.robovac_last_run
above: 0
action:
- service: vacuum.start
data:
entity_id: vacuum.robovac
- service: input_boolean.turn_off
data:
entity_id: input_boolean.vacuum_clean
- alias: 'Presence: Away Vacuum Notification'
description: When away, if vacuum has not run recently, send a notification
trigger:
platform: state
entity_id: input_boolean.at_home
from: 'on'
to: 'off'
condition:
- condition: numeric_state
entity_id: automation.presence_away_vacuum_notification
above: 0
value_template: '{{ (now().date() - state.attributes.last_triggered.date()).days
}}'
- condition: state
entity_id: input_boolean.vacuum_clean
state: 'off'
- condition: numeric_state
entity_id: sensor.robovac_last_run
above: 0
- condition: time
weekday:
- sat
- sun
action:
- variables:
action_run: '{{ ''VACUUM_RUN_'' ~ context.id }}'
action_run_short: '{{ ''VACUUM_RUN_SHORT_'' ~ context.id }}'
- service: notify.mobile_app_rafs_phone
data:
title: Start RoboVac Cleaning Session?
message: Last run {{ states('sensor.robovac_last_run') }} day(s) ago
data:
actions:
- action: '{{ action_run_short }}'
title: Quick
- action: '{{ action_run }}'
title: Full
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ action_run }}'
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ action_run_short }}'
timeout:
minutes: 30
continue_on_timeout: false
- service: vacuum.start
data:
entity_id: vacuum.robovac
- choose:
- conditions: '{{ wait.trigger.event.data.action == action_run_short }}'
sequence:
- delay:
minutes: 30
- service: vacuum.return_to_base
entity_id: vacuum.robovac
- alias: 'Travel: Back Automations State'
description: When back home, set automations state
trigger:
platform: state
entity_id: input_boolean.away
from: 'on'
to: 'off'
action:
- service: automation.turn_on
data:
entity_id:
- automation.vacuum_home_schedule
- automation.vacuum_away_schedule
- automation.presence_home_set_at_home
- alias: 'Safety: Bathroom Humidity'
description: When humidity is too high, send a notification
trigger:
platform: numeric_state
entity_id:
- sensor.bathroom_sensor_humidity
above: 80
for:
minutes: 15
action:
- service: notify.telegram_raf
data:
message: 'High Humidity: {{ trigger.to_state.name }}'
- alias: 'Media: Bathroom Off'
description: When bathroom lights turn off, if speaker is playing, pause
trigger:
platform: state
entity_id: light.bathroom
from: 'on'
to: 'off'
condition:
- condition: state
entity_id: media_player.bathroom_mini
state: playing
action:
- service: media_player.media_pause
data:
entity_id: media_player.bathroom_mini
- alias: 'Climate: Bedroom Door Open'
description: When heater turns on, if door open, send a notification
trigger:
platform: state
entity_id: climate.bedroom_heater
to: heat
for:
minutes: 5
condition:
- condition: state
entity_id: binary_sensor.bedroom_door_sensor_contact
state: 'on'
action:
- service: notify.telegram_raf
data:
message: Bedroom Heater is on with the door open
- alias: 'Climate: Bedroom Heater Morning'
description: At 7:30 AM, if sleeping and cold, turn on the bedroom heater
trigger:
platform: time
at: 07:30:00
condition:
- condition: state
entity_id: input_boolean.sleeping
state: 'on'
- '{{ (state_attr(''climate.bedroom_heater'', ''current_temperature'')) < (state_attr(''climate.bedroom_heater'',
''temperature'')) }}'
action:
- service: climate.turn_on
data:
entity_id: climate.bedroom_heater
- alias: 'Switch: Bedroom'
description: When bedroom switch pressed, toggle lights
trigger:
- platform: state
entity_id: sensor.bedroom_switch_action
to: 'on'
- platform: state
entity_id: sensor.bedroom_switch_action
to: 'off'
action:
- service_template: light.turn_{{trigger.to_state.state}}
entity_id: light.ceiling_3
- alias: 'Security: Blink Disarmed'
description: When Blink is disarmed for too long, send a notification
mode: restart
trigger:
- platform: state
entity_id: alarm_control_panel.blink_rafs_flat
to: disarmed
for:
minutes: 20
- platform: state
entity_id: alarm_control_panel.blink_rafs_flat
to: disarmed
for:
minutes: 40
- platform: state
entity_id: alarm_control_panel.blink_rafs_flat
to: disarmed
for:
minutes: 60
action:
- variables:
action_arm: '{{ ''BLINK_ARM_'' ~ context.id }}'
- service: notify.mobile_app_rafs_phone
data:
title: Arm Blink?
message: System has been disarmed for {{ (trigger.for.seconds / 60) | int }}
minutes
data:
actions:
- action: '{{ action_arm }}'
title: Arm
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ action_arm }}'
timeout:
minutes: 30
continue_on_timeout: false
- service: alarm_control_panel.alarm_arm_away
data:
entity_id: alarm_control_panel.blink_rafs_flat
- alias: 'Light: Living Room Bright Sun'
description: If it's bright enough outside, turn off the living room lights
trigger:
- platform: numeric_state
entity_id: sensor.hue_motion_sensor_1_illuminance
above: 600
for:
minutes: 10
condition:
- condition: time
after: 05:00:00
before: '14:30:00'
- condition: state
entity_id: input_boolean.at_home
state: 'on'
- condition: numeric_state
entity_id: automation.light_living_room_bright_sun
above: 0
value_template: '{{ (now().date() - state.attributes.last_triggered.date()).days
}}'
- condition: state
entity_id: light.desk_area
state: 'on'
action:
- service: light.turn_off
data:
entity_id: light.desk_area
- alias: 'System: Certificate Expiry'
description: When certificate is close to expiring, send a notification
trigger:
- platform: time
at: 09:00:00
condition: '{{ ((strptime(states(''sensor.cert_expiry_home_assistant'') | truncate(10,
True, ''''), ''%Y-%m-%d'').date() - strptime(states(''sensor.date''), ''%Y-%m-%d'').date()).days)
< 7 }}'
action:
- service: notify.telegram_raf
data:
message: 'Home Assistant Certificate Expiring On: {{ trigger.to_state.state
}}'
- alias: 'System: Certificate Renew'
description: When certificate is close to expiring, renew
trigger:
- platform: time
at: 03:00:00
condition: '{{ ((strptime(states(''sensor.cert_expiry_home_assistant'') | truncate(10,
True, ''''), ''%Y-%m-%d'').date() - strptime(states(''sensor.date''), ''%Y-%m-%d'').date()).days)
< 30 }}'
action:
- service: hassio.addon_start
data:
addon: core_letsencrypt
- alias: 'Keyboard Remote: Chromecast Forward'
description: When forward button pressed, if on Chromecast, forward
trigger:
platform: event
event_type: keyboard_remote_command_received
event_data:
device_name: flirc.tv flirc Keyboard
key_code: 208
condition:
- condition: state
entity_id: media_player.lg_tv
attribute: source
state: Chromecast
- condition: not
conditions:
- condition: state
entity_id: media_player.living_room_tv
state: 'off'
action:
- service: script.media_seek
data:
seek_amount: 15
media_player: media_player.living_room_tv
- alias: 'Keyboard Remote: Chromecast Rewind'
description: When rewind button pressed, if on Chromecast, rewind
trigger:
platform: event
event_type: keyboard_remote_command_received
event_data:
device_name: flirc.tv flirc Keyboard
key_code: 168
condition:
- condition: state
entity_id: media_player.lg_tv
attribute: source
state: Chromecast
- condition: not
conditions:
- condition: state
entity_id: media_player.living_room_tv
state: 'off'
action:
- service: script.media_seek
data:
seek_amount: -15
media_player: media_player.living_room_tv
- alias: 'Media: Notification Clear'
description: When media stops, send clear command
triggers:
- trigger: state
to: 'off'
entity_id:
- media_player.speaker
- media_player.bedroom_tv
- media_player.bedroom_display
- media_player.bathroom_mini
- media_player.home_group
- media_player.living_room_display
- trigger: state
to: idle
entity_id:
- media_player.spotify_raf
condition:
- condition: state
entity_id: person.raf
state: home
action:
- service: joaoapps_join.rafs_phone_send_tasker
data:
command: '{{ ''homemedia=:=clear=:='' ~ trigger.to_state.object_id }}'
- alias: 'Calendar: Contacts Event'
description: When there is an event related to a contact, send a notification
trigger:
platform: calendar
entity_id: calendar.birthdays
event: start
action:
- service: calendar.get_events
target:
entity_id:
- calendar.birthdays
data:
duration:
hours: 24
response_variable: agenda
- service: notify.mobile_app_rafs_phone
data:
title: Someone's birthday!
message: '{% for event in agenda["calendar.birthdays"]["events"] %} {{ event.summary}}:
{{ event.description }}<br> {% endfor %}'
- alias: 'Security: Door Open'
description: When front door opens, if away, send notification
trigger:
platform: state
entity_id: binary_sensor.front_door_sensor_contact
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: input_boolean.at_home
state: 'off'
action:
- service: notify.telegram_raf
data:
message: 'Alert: Front door has been opened'
- alias: 'Security: Door Open Long'
description: When Front Door is open for too long, send a notification
trigger:
platform: state
entity_id: binary_sensor.front_door_sensor_contact
from: 'off'
to: 'on'
for:
minutes: 15
action:
- service: notify.telegram_raf
data:
message: Front Door has been open for 15+ minutes
- alias: 'Climate: Electric Blanket on Morning'
description: When blanket is on, toggle the morning entity
trigger:
platform: state
entity_id: switch.plug5_power
from: 'off'
to: 'on'
for:
minutes: 10
condition:
- condition: time
after: '21:00:00'
before: 03:00:00
action:
- service: input_boolean.turn_on
data:
entity_id: input_boolean.electric_blanket_morning
- alias: 'Climate: Electric Blanket on Time'
description: When blanket is on for too long, turn it off
trigger:
platform: state
entity_id: switch.plug5_power
from: 'off'
to: 'on'
for:
minutes: 20
action:
- service: switch.turn_off
data:
entity_id: switch.plug5_power
- id: vacuum_error
alias: 'Vacuum: Error'
description: When Vacuum has an error state, send a notification
trigger:
platform: state
entity_id: vacuum.robovac
to: error
for:
minutes: 5
action:
- service: notify.telegram_raf
data:
message: Vacuum has an error
- alias: 'Climate: Evening Heating Bedroom'
description: At 11:30 PM, if home and cold, turn on the bedroom heater
trigger:
platform: time
at: '23:30:00'
condition:
- condition: state
entity_id: input_boolean.at_home
state: 'on'
- '{{ (state_attr(''climate.bedroom_heater'', ''current_temperature'')) < (state_attr(''climate.bedroom_heater'',
''temperature'')) }}'
action:
- service: climate.turn_on
data:
entity_id: climate.bedroom_heater
- alias: 'Climate: Evening Heating Living Room'
description: At 9:30 PM, if home and cold, turn off living room heater
trigger:
platform: time
at: '21:30:00'
condition:
- condition: state
entity_id: input_boolean.at_home
state: 'on'
- condition: state
entity_id: climate.living_room_heater
state: heat
action:
- service: climate.turn_off
data:
entity_id: climate.living_room_heater
- id: vacuum_finish_cleaning
alias: 'Vacuum: Finish Cleaning'
description: When Vacuum has been cleaning for long enough, dock or stop it
trigger:
platform: numeric_state
entity_id: sensor.robovac_runtime_today
above: 0.75
condition:
- '{{ trigger.from_state.state not in [''unknown'', ''unavailable'', ''none''] }}'
- '{{ trigger.to_state.state not in [''unknown'', ''unavailable'', ''none''] }}'
- '{{ trigger.from_state.state != trigger.to_state.state }}'
action:
- service: vacuum.return_to_base
entity_id: vacuum.robovac
- alias: 'Presence: Guest Mode Automations State'
description: When guest mode is toggled, toggle specified automations
trigger:
platform: state
entity_id: input_boolean.guest_mode
to:
- 'on'
- 'off'
from:
- 'on'
- 'off'
action:
- service: automation.turn_{{ trigger.from_state.state }}
data:
entity_id:
- automation.light_guest_room_motion_off
- automation.light_guest_room_no_motion
- alias: 'Switch: Guest Room'
description: When guest room switch pressed, toggle lights
trigger:
- platform: state
entity_id: sensor.guest_room_switch_action
to: 'on'
- platform: state
entity_id: sensor.guest_room_switch_action
to: 'off'
action:
- service_template: light.turn_{{trigger.to_state.state}}
entity_id: light.ceiling_4
- alias: 'Switch: Hallway'
description: When button pressed once, toggle lights
trigger:
- platform: state
entity_id: sensor.hallway_switch_action
to: single_left
- platform: state
entity_id: sensor.hallway_switch_action
to: single_right
action:
- service: light.toggle
data:
entity_id: light.hallway
brightness_pct: 100
- alias: 'Presence: Home Bathroom Lights'
description: When home, turn bathroom lights on
trigger:
platform: state
entity_id: input_boolean.at_home
from: 'off'
to: 'on'
action:
- service: scene.turn_on
data:
entity_id: scene.bathroom_normal
- alias: 'Presence: Home Bedroom Heater'
description: When home in the evening, if cold, turn heater on
trigger:
platform: state
entity_id: input_boolean.at_home
from: 'off'
to: 'on'
condition:
- condition: time
after: '21:30:00'
before: 05:30:00
- '{{ (state_attr(''climate.bedroom_heater'', ''current_temperature'')) < (state_attr(''climate.bedroom_heater'',
''temperature'')) }}'
action:
- service: climate.turn_on
data:
entity_id: climate.bedroom_heater
- alias: 'Presence: Home Bedroom Lights'
description: When home in the evening, turn bedroom lights on
trigger:
platform: state
entity_id: input_boolean.at_home
from: 'off'
to: 'on'
condition:
- '{{ state_attr(''sun.sun'', ''elevation'') <= states(''input_number.sunset_elevation'')|float
}}'
action:
- service: scene.turn_on
data:
entity_id: scene.bedroom_evening
- alias: 'Presence: Home Check At Home'
description: When detected at home but not set, check if at home
trigger:
- platform: state
entity_id: person.raf
to: home
for:
minutes: 5
- platform: state
entity_id: person.lynn
to: home
for:
minutes: 10
condition:
- condition: state
entity_id: input_boolean.at_home
state: 'off'
action:
- variables:
action_turn_on: '{{ ''AT_HOME_TURN_ON_'' ~ context.id }}'
- service: notify.mobile_app_rafs_phone
data:
title: Detected 'at_home' is off
message: "Raf: {{ states('person.raf') }} \nLynn: {{ states('person.lynn') }}"
data:
actions:
- action: '{{ action_turn_on }}'
title: Turn On
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ action_turn_on }}'
timeout:
minutes: 30
continue_on_timeout: false
- service: input_boolean.turn_on
data:
entity_id: input_boolean.at_home
- alias: 'Security: Home Disarm Blink'
description: When door opens while home, disarm Blink for some time, and re-arm
mode: restart
trigger:
platform: state
entity_id: binary_sensor.front_door_sensor_contact
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: person.raf
state: home
action:
- service: alarm_control_panel.alarm_disarm
data:
entity_id: alarm_control_panel.blink_rafs_flat
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.front_door_sensor_contact
to: 'off'
for:
minutes: 5
timeout:
minutes: 15
continue_on_timeout: true
- repeat:
while:
- condition: state
entity_id: alarm_control_panel.blink_rafs_flat
state: disarmed
- condition: template
value_template: '{{ repeat.index <= 11 }}'
sequence:
- service: alarm_control_panel.alarm_arm_away
data:
entity_id: alarm_control_panel.blink_rafs_flat
- delay:
minutes: 2
- alias: 'Presence: Home Living Room Heater'
description: When home during the day, if cold, turn heater on
trigger:
platform: state
entity_id: input_boolean.at_home
from: 'off'
to: 'on'
condition:
- condition: time
after: 05:30:00
before: '21:30:00'
- '{{ (state_attr(''climate.living_room_heater'', ''current_temperature'')) < (state_attr(''climate.living_room_heater'',
''temperature'')) }}'
action:
- service: climate.turn_on
data:
entity_id: climate.living_room_heater
- alias: 'Presence: Home Living Room Lights'
description: When home in the evening, turn living room lights on
trigger:
platform: state
entity_id: input_boolean.at_home
from: 'off'
to: 'on'
condition:
- '{{ state_attr(''sun.sun'', ''elevation'') <= states(''input_number.sunset_elevation'')|float
}}'
action:
- service: scene.turn_on
data:
entity_id: scene.living_room_evening
- alias: 'Vacuum: Home Schedule'
description: At scheduled times, if not run today, start cleaning
trigger:
platform: time
at: '18:15:00'
condition:
- condition: time
weekday:
- mon
- wed
- fri
- condition: numeric_state
entity_id: sensor.robovac_last_run
above: 0
action:
- service: vacuum.start
data:
entity_id: vacuum.robovac
- alias: 'Presence: Home Set At Home'
description: When door opens after being away, set at home
trigger:
- platform: state
entity_id: binary_sensor.front_door_sensor_contact
from: 'off'
to: 'on'
- platform: state
entity_id: group.all_people
to: home
condition:
- condition: state
entity_id: input_boolean.at_home
state: 'off'
action:
- service: input_boolean.turn_on
data:
entity_id: input_boolean.at_home
- alias: 'Presence: Home Update GPS Lynn'
description: When potentially home, update GPS
trigger:
- platform: state
entity_id: input_boolean.at_home
from: 'off'
to: 'on'
- platform: state
entity_id: binary_sensor.front_door_motion_sensor_occupancy
from: 'off'
to: 'on'
condition:
- condition: numeric_state
entity_id: automation.test_automation
above: 15
value_template: '{{ (now() - state.attributes.last_triggered) / timedelta(minutes=1)
}}'
- condition: numeric_state
entity_id: sensor.rafs_flat_lynn_distance
below: 10.0
- not:
- condition: state
entity_id: person.lynn
state: home
action:
- service: script.update_location_lynn
- alias: 'Presence: Home Update GPS Raf'
description: When potentially home, update GPS
trigger:
- platform: state
entity_id: input_boolean.at_home
from: 'off'
to: 'on'
- platform: state
entity_id: binary_sensor.front_door_motion_sensor_occupancy
from: 'off'
to: 'on'
condition:
- condition: numeric_state
entity_id: automation.test_automation
above: 15
value_template: '{{ (now() - state.attributes.last_triggered) / timedelta(minutes=1)
}}'
- condition: numeric_state
entity_id: sensor.rafs_flat_raf_distance
below: 10.0
- not:
- condition: state
entity_id: person.raf
state: home
action:
- service: script.update_location_raf
- alias: 'Presence: Home WiFi Raf'
description: When home, turn on WiFi
trigger:
- platform: state
entity_id: person.raf
to: home
- platform: state
entity_id: input_boolean.at_home
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: device_tracker.rafs_phone_wifi
state: not_home
action:
- service: joaoapps_join.rafs_phone_send_tasker
data:
command: wifi-on
- alias: 'Switch: Kitchen'
description: When button pressed once, toggle lights
trigger:
- platform: state
entity_id: sensor.kitchen_switch_action
to: single_left
- platform: state
entity_id: sensor.kitchen_switch_action
to: singe_right
action:
- service: light.toggle
entity_id: light.kitchen
- alias: 'Vacuum: Last Run'
description: When Vacuum has been cleaning, set the last run date
trigger:
platform: numeric_state
entity_id: sensor.robovac_runtime_today
above: 0.4
condition:
- '{{ trigger.from_state.state not in [''unknown'', ''unavailable'', ''none''] }}'
- '{{ trigger.to_state.state not in [''unknown'', ''unavailable'', ''none''] }}'
- '{{ trigger.from_state.state != trigger.to_state.state }}'
action:
- service: input_datetime.set_datetime
entity_id: input_datetime.robovac_last_run
data_template:
date: '{{ states(''sensor.date'') }}'
- alias: 'Keyboard Remote: LG TV Netflix Login'
description: When stop button is pressed, if on Netflix, login
trigger:
platform: event
event_type: keyboard_remote_command_received
event_data:
device_name: flirc.tv flirc Keyboard
key_code: 83
condition:
- condition: state
entity_id: media_player.lg_tv
attribute: source
state: Netflix
action:
- delay:
milliseconds: 100
- service: webostv.button
entity_id: media_player.lg_tv
data:
button: secret lg_tv_netflix_login_1
- delay:
milliseconds: 100
- service: webostv.button
entity_id: media_player.lg_tv
data:
button: secret lg_tv_netflix_login_2
- delay:
milliseconds: 100
- service: webostv.button
entity_id: media_player.lg_tv
data:
button: secret lg_tv_netflix_login_3
- delay:
milliseconds: 100
- service: webostv.button
entity_id: media_player.lg_tv
data:
button: secret lg_tv_netflix_login_4
- alias: 'TV: LG TV On'
description: When TV on command received, send WOL packet
trigger:
platform: webostv.turn_on
entity_id: media_player.lg_tv
action:
- service: wake_on_lan.send_magic_packet
data:
mac: secret mac_lg_tv
- alias: 'Keyboard Remote: LG TV Play Pause'
description: When play pause button pressed, toggle play pause on unsupported sources
trigger:
platform: event
event_type: keyboard_remote_command_received
event_data:
device_name: flirc.tv flirc Keyboard
key_code: 164
condition:
- condition: state
entity_id: media_player.lg_tv
attribute: source
state:
- Chromecast
- Prime Video
- Plex
action:
- delay:
seconds: 1
- service: media_player.media_play_pause
target:
entity_id: media_player.lg_tv
- alias: 'Climate: Living Room Open Window'
description: When window is open, turn heater off
trigger:
platform: state
entity_id: binary_sensor.living_room_window_sensor_contact
from: 'off'
to: 'on'
for:
minutes: 1
condition:
- condition: state
entity_id: climate.living_room_heater
state: heat
action:
- service: climate.turn_off
data:
entity_id: climate.living_room_heater
- alias: 'Climate: Living Room Window Open'
description: When heater turns on, if window open, turn heater off
trigger:
platform: state
entity_id: climate.living_room_heater
to: heat
for:
minutes: 1
condition:
- condition: state
entity_id: binary_sensor.living_room_window_sensor_contact
state: 'on'
action:
- service: climate.turn_off
data:
entity_id: climate.living_room_heater
- alias: 'Zone: Lynn Home'
description: Send a notification when at home
trigger:
platform: state
entity_id: person.lynn
to: home
for:
seconds: 10
condition:
- not:
- condition: state
entity_id: person.raf
state: home
- condition: numeric_state
entity_id: sensor.raf_lynn_distance
above: 1
action:
- service: notify.mobile_app_rafs_phone
data:
title: Location Update
message: Lynn has arrived at home
- alias: 'Button: Lynns PC Button'
description: When Lynns PC Button is pressed, turn on the PC
trigger:
- platform: state
entity_id: sensor.lynns_pc_button_action
to: single
action:
- service: switch.turn_on
entity_id: switch.lynns_pc_power
- alias: 'Zone: Lynn Work'
description: Send a notification when at work
trigger:
- platform: state
entity_id: person.lynn
to: Lynn's Work
for:
seconds: 10
variables:
message_verb: arrived at
- platform: state
entity_id: person.lynn
from: Lynn's Work
for:
seconds: 10
variables:
message_verb: left
condition:
- condition: state
entity_id: binary_sensor.workday_sensor
state: 'on'
- not:
- condition: time
after: '11:00:00'
before: '15:00:00'
action:
- service: notify.mobile_app_rafs_phone
data:
title: Location Update
message: Lynn has {{ message_verb }} the office
- alias: 'Media: Max Volumes'
description: When media volume changes too high, if sleeping, set it lower
trigger:
- platform: numeric_state
attribute: volume_level
above: 0.16
entity_id:
- media_player.bathroom_mini
- media_player.guest_room_mini
- media_player.speaker
- media_player.living_room_display
variables:
volume: 0.15
- platform: numeric_state
attribute: volume_level
above: 0.41
entity_id:
- media_player.bedroom_display
variables:
volume: 0.3
condition:
- condition: template
value_template: '{{ trigger.to_state.state != ''off'' }}'
- condition: state
entity_id: input_boolean.sleeping
state: 'on'
action:
- service: media_player.volume_set
data:
entity_id: '{{ trigger.entity_id }}'
volume_level: '{{ volume }}'
- alias: 'Light: Living Room Morning'
description: When bedroom door opens in the morning, if dark, turn on living room
lights
trigger:
platform: state
entity_id: binary_sensor.bedroom_door_sensor_contact
from: 'off'
to: 'on'
condition:
- condition: numeric_state
entity_id: sensor.hue_motion_sensor_1_illuminance
below: 350
- condition: time
after: 06:00:00
before: '12:00:00'
- condition: numeric_state
entity_id: automation.light_living_room_morning
above: 0
value_template: '{{ (now().date() - state.attributes.last_triggered.date()).days
}}'
- condition: state
entity_id: light.desk_area
state: 'off'
action:
- service: scene.turn_on
data:
transition: 60
entity_id: scene.living_room_evening
- alias: 'Light: Bathroom Morning Bedroom Door'
description: When bedroom door opens in the morning, turn on bathroom normal scene
trigger:
platform: state
entity_id: binary_sensor.bedroom_door_sensor_contact
from: 'off'
to: 'on'
condition:
- condition: time
after: 06:00:00
before: '12:00:00'
- condition: numeric_state
entity_id: automation.light_bathroom_morning_bedroom_door
above: 0
value_template: '{{ (now().date() - state.attributes.last_triggered.date()).days
}}'
- condition: numeric_state
entity_id: automation.light_bathroom_morning_guest_room_door
above: 0
value_template: '{{ (now().date() - state.attributes.last_triggered.date()).days
}}'
action:
- service: switch.turn_off
data:
entity_id: switch.adaptive_lighting_sleep_mode_bathroom
- delay:
seconds: 1
- service: scene.turn_on
data:
entity_id: scene.bathroom_normal
- alias: 'Light: Bathroom Morning Guest Room Door'
description: When guest room door opens in the morning, turn on bathroom normal
scene
trigger:
platform: state
entity_id: binary_sensor.guest_room_door_sensor_contact
from: 'off'
to: 'on'
condition:
- condition: time
after: 06:00:00
before: '12:00:00'
- condition: numeric_state
entity_id: automation.light_bathroom_morning_guest_room_door
above: 0
value_template: '{{ (now().date() - state.attributes.last_triggered.date()).days
}}'
- condition: numeric_state
entity_id: automation.light_bathroom_morning_bedroom_door
above: 0
value_template: '{{ (now().date() - state.attributes.last_triggered.date()).days
}}'
action:
- service: switch.turn_off
data:
entity_id: switch.adaptive_lighting_sleep_mode_bathroom
- delay:
seconds: 1
- service: scene.turn_on
data:
entity_id: scene.bathroom_normal
- alias: 'Alarm: Morning Sleeping State'
description: At alarm time, turn off sleeping state if still on after delay
trigger:
platform: time
at: input_datetime.morning_alarm
action:
- delay: 00:30:00
- service: input_boolean.turn_off
data:
entity_id: input_boolean.sleeping
- alias: 'Light: Bathroom Motion Off'
description: When bathroom has no motion for 20 minutes, if lights are on, turn
off
trigger:
platform: state
entity_id: binary_sensor.bathroom_motion_sensor_occupancy
from: 'on'
to: 'off'
for:
minutes: 15
condition:
- condition: state
entity_id: light.bathroom
state: 'on'
action:
- service: light.turn_off
data:
entity_id: light.bathroom
- alias: 'Light: Bathroom Motion On'
description: When bathroom has motion, if lights are off, turn on bathroom normal
scene
trigger:
platform: state
entity_id: binary_sensor.bathroom_motion_sensor_occupancy
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: light.bathroom
state: 'off'
action:
- service: scene.turn_on
data:
entity_id: scene.bathroom_normal
- alias: 'Mount Media: Mount'
description: When Home Assistant starts, mount network share into /media
trigger:
platform: homeassistant
event: start
action:
- service: shell_command.mount_media
- alias: 'TV: Music Off'
description: When TV turns on, if music is playing, turn it off
trigger:
platform: state
entity_id: media_player.lg_tv
from: 'off'
for:
seconds: 30
condition:
- condition: state
entity_id: media_player.speaker
state: playing
action:
- service: media_player.media_pause
data:
entity_id: media_player.speaker
- alias: 'Light: Living Room Night'
description: When lights are off at night, turn off the heating
trigger:
platform: state
entity_id: light.living_room
from: 'on'
to: 'off'
condition:
- condition: time
after: '21:00:00'
before: 03:00:00
- condition: state
entity_id: media_player.lg_tv
state: 'off'
action:
- service: climate.turn_off
data:
entity_id: climate.living_room_heater
- alias: 'Media: Notification Notify'
description: When media title changes, send notify command
trigger:
platform: state
attribute: media_title
entity_id:
- media_player.speaker
- media_player.bedroom_tv
- media_player.bedroom_display
- media_player.bathroom_mini
- media_player.home_group
- media_player.living_room_display
condition:
- condition: state
entity_id: person.raf
state: home
- condition: template
value_template: '{{ trigger.to_state.state != ''off'' and trigger.to_state.media_title
is not none }}'
- condition: state
entity_id: media_player.lg_tv
state: 'off'
action:
- service: joaoapps_join.rafs_phone_send_tasker
data:
command: '{{ ''homemedia=:=notify=:='' ~ trigger.to_state.object_id }}'
- alias: 'Media: Notification Notify Spotify'
description: When spotify is on Speaker, send notify command
trigger:
platform: state
attribute: media_title
entity_id:
- media_player.spotify_raf
condition:
- condition: state
entity_id: media_player.spotify_raf
attribute: source
state: Speaker
- condition: state
entity_id: person.raf
state: home
- condition: state
entity_id: media_player.lg_tv
state: 'off'
- condition: template
value_template: '{{ trigger.to_state.state != ''idle'' and trigger.to_state.media_title
is not none }}'
action:
- service: joaoapps_join.rafs_phone_send_tasker
data:
command: '{{ ''homemedia=:=notify=:='' ~ trigger.to_state.object_id }}'
- alias: 'Light: Bathroom No Motion'
description: When bathroom lights turn on, if there is no motion for 20 minutes,
turn off
trigger:
platform: state
entity_id: light.bathroom
from: 'off'
to: 'on'
for:
minutes: 15
condition:
- condition: state
entity_id: binary_sensor.bathroom_motion_sensor_occupancy
state: 'off'
for:
minutes: 10
action:
- service: light.turn_off
data:
entity_id: light.bathroom
- alias: 'TV: Off Chromecast'
description: When TV turns off, if Chromecast is on, turn it off
trigger:
- platform: state
entity_id: media_player.lg_tv
to: 'off'
- platform: state
entity_id: media_player.lg_tv
attribute: source
not_to: Chromecast
condition:
- condition: not
conditions:
- condition: state
entity_id: media_player.living_room_tv
state: 'off'
action:
- service: media_player.turn_off
entity_id: media_player.living_room_tv
- alias: 'TV: Off Scene'
description: When TV turns off, if evening, activate evening scene
trigger:
platform: state
entity_id: media_player.lg_tv
to: 'off'
for:
seconds: 15
condition:
- '{{ state_attr(''sun.sun'', ''elevation'') <= states(''input_number.sunset_elevation'')|float
}}'
action:
- service: scene.turn_on
data:
entity_id: scene.living_room_evening
- alias: 'TV: On Scene'
description: When TV turns on, if lights on, activate tv scene
trigger:
platform: state
entity_id: media_player.lg_tv
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: light.floor_lamp
state: 'on'
action:
- service: scene.turn_on
data:
entity_id: scene.living_room_evening_tv
- alias: 'Security: Outdoor Motion'
description: When motion outside, if away, send notification
trigger:
platform: state
entity_id: binary_sensor.front_door_motion_sensor_occupancy
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: input_boolean.at_home
state: 'off'
action:
- service: notify.telegram_raf
data:
message: 'Alert: Motion detected outside'
- alias: 'Location: Owntracks Update Lynn'
description: When location changes, push to Owntracks
trigger:
platform: state
entity_id: device_tracker.lynns_phone_app
condition:
- condition: numeric_state
entity_id: person.lynn
attribute: gps_accuracy
above: 0
below: 101
- condition: template
value_template: '{{ (trigger.from_state.attributes.latitude != trigger.to_state.attributes.latitude)
or (trigger.from_state.attributes.longitude != trigger.to_state.attributes.longitude)
}}'
action:
- service: rest_command.owntracks_push_lynn
- alias: 'Location: Owntracks Update Raf'
description: When location changes, push to Owntracks
trigger:
platform: state
entity_id: person.raf
condition:
- condition: numeric_state
entity_id: person.raf
attribute: gps_accuracy
above: 0
below: 101
- condition: template
value_template: '{{ (trigger.from_state.attributes.latitude != trigger.to_state.attributes.latitude)
or (trigger.from_state.attributes.longitude != trigger.to_state.attributes.longitude)
}}'
action:
- service: rest_command.owntracks_push_raf
- alias: 'TV: Paused Chromecast'
description: When Chromecast is paused for too long, turn off the TV Screen
trigger:
- platform: state
entity_id: media_player.living_room_tv
to: paused
for:
seconds: 30
condition:
- condition: state
entity_id: media_player.lg_tv
attribute: source
state: Chromecast
action:
- service: script.tv_screen_off
- alias: 'Computer: Pi Off'
description: When the computer is off, turn off the Raspberry Pi
trigger:
platform: state
entity_id: binary_sensor.rafs_pc_power
from: 'on'
to: 'off'
for:
minutes: 2
action:
- service: script.pi_off
- alias: 'Computer: Pi On'
description: When the computer is on, turn on the Raspberry Pi
trigger:
platform: state
entity_id: binary_sensor.rafs_pc_power
from: 'off'
to: 'on'
for:
minutes: 2
action:
- service: script.pi_on
- alias: 'TV: Play Chromecast'
description: When Chromecast is playing, turn on the TV Screen
trigger:
- platform: state
entity_id: media_player.living_room_tv
from: paused
to: playing
condition:
- condition: state
entity_id: media_player.lg_tv
attribute: source
state: Chromecast
action:
- service: script.tv_screen_on
- alias: 'Alarm: Pre Morning Blanket'
description: At pre-alarm time, turn on the blanket
trigger:
platform: time
at: input_datetime.morning_alarm_pre
condition:
- condition: state
entity_id: input_boolean.electric_blanket_morning
state: 'on'
- condition: state
entity_id: switch.plug5_power
state: 'off'
action:
- service: switch.turn_on
data:
entity_id: switch.plug5_power
- service: input_boolean.turn_off
data:
entity_id: input_boolean.electric_blanket_morning
- alias: 'Alarm: Pre Morning Heating Bedroom'
description: At pre-alarm time, turn off bedroom heater
trigger:
platform: time
at: input_datetime.morning_alarm_pre
condition:
- condition: state
entity_id: climate.bedroom_heater
state: heat
action:
- service: climate.turn_off
data:
entity_id: climate.bedroom_heater
- alias: 'Alarm: Pre Morning Heating Living Room'
description: At pre-alarm time, if cold, turn on the living room heater
trigger:
platform: time
at: input_datetime.morning_alarm_pre
condition: '{{ (state_attr(''climate.living_room_heater'', ''current_temperature''))
< (state_attr(''climate.living_room_heater'', ''temperature'')) }}'
action:
- service: climate.turn_on
data:
entity_id: climate.living_room_heater
- alias: 'Alarm: Pre Morning Lights'
description: At pre-alarm time, turn on the lights
trigger:
platform: time
at: input_datetime.morning_alarm_pre
action:
- service: light.turn_on
data:
entity_id: light.bedside_lamp
brightness_pct: 100
transition: 1800
- alias: 'Travel: Proximity Away Mode'
description: When close to home, turn off away mode
trigger:
- platform: numeric_state
entity_id: sensor.rafs_flat_raf_distance
below: 2
- platform: numeric_state
entity_id: sensor.rafs_flat_lynn_distance
below: 2
condition:
- condition: state
entity_id: input_boolean.away
state: 'on'
action:
- service: input_boolean.turn_off
data:
entity_id: input_boolean.away
- alias: 'System: Public IP'
description: When public IP address changes, send a notification
trigger:
- platform: state
entity_id: sensor.public_ip
to: null
for:
minutes: 5
action:
- service: notify.telegram_raf
data:
message: 'IP changed: {{ trigger.to_state.state }}'
- alias: 'Zone: Raf Home'
description: Send a notification when at home
trigger:
platform: state
entity_id: person.raf
to: home
for:
seconds: 10
condition:
- not:
- condition: state
entity_id: person.lynn
state: home
- condition: numeric_state
entity_id: sensor.raf_lynn_distance
above: 1
action:
- service: notify.mobile_app_lynns_phone
data:
title: Location Update
message: Raf has arrived at home
- alias: 'Zone: Raf Work'
description: Send a notification when at work
trigger:
- platform: state
entity_id: person.raf
to: Raf's Work
for:
seconds: 10
variables:
message_verb: arrived at
- platform: state
entity_id: person.raf
from: Raf's Work
for:
seconds: 10
variables:
message_verb: left
condition:
- condition: state
entity_id: binary_sensor.workday_sensor
state: 'on'
- not:
- condition: time
after: '11:00:00'
before: '15:00:00'
action:
- service: notify.mobile_app_lynns_phone
data:
title: Location Update
message: Raf has {{ message_verb }} the office
- alias: 'Safety: Room Humidity'
description: When humidity is too high, send a notification
trigger:
platform: numeric_state
entity_id:
- sensor.bedroom_sensor_humidity
- sensor.guest_room_sensor_humidity
- sensor.living_room_sensor_humidity
above: 69
for:
minutes: 10
action:
- service: notify.telegram_raf
data:
message: 'High Humidity: {{ trigger.to_state.name }}'
- alias: 'Alarm: Set Pre Morning Alarm'
description: When morning alarm is set, set pre morning alarm
trigger:
platform: state
entity_id: input_datetime.morning_alarm
action:
- service: input_datetime.set_datetime
data:
entity_id: input_datetime.morning_alarm_pre
time: '{{ (strptime(states(''input_datetime.morning_alarm''), ''%H:%M:%S'')
- timedelta(minutes=30)).time() }}'
- alias: 'Light: Bathroom Door Sleeping'
description: When bedroom door opens, if sleeping, turn on bathroom midnight scene
trigger:
platform: state
entity_id: binary_sensor.bedroom_door_sensor_contact
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: input_boolean.sleeping
state: 'on'
- condition: time
after: '21:00:00'
before: 06:00:00
- condition: state
entity_id: light.bathroom
state: 'off'
action:
- service: scene.turn_on
data:
entity_id: scene.bathroom_midnight
- alias: 'Safety: Smoke'
description: When smoke is detected, send a notification
trigger:
platform: state
entity_id: binary_sensor.smoke_sensor_smoke
from: 'off'
to: 'on'
action:
- service: notify.telegram_raf
data:
message: 'Alert: Smoke Detected'
- alias: 'TV: Speakers Off'
description: When TV turns off, if speakers are on, turn off
trigger:
platform: state
entity_id: media_player.lg_tv
to: 'off'
for:
seconds: 15
condition:
- condition: state
entity_id: binary_sensor.tv_speaker_power
state: 'on'
action:
- service: switch.turn_off
data:
entity_id: switch.tv_speaker_power
- alias: 'TV: Speakers On'
description: When TV turns on, if speakers are off, turn on
trigger:
platform: state
entity_id: media_player.lg_tv
from: 'off'
to: 'on'
for:
seconds: 5
condition:
- condition: state
entity_id: binary_sensor.tv_speaker_power
state: 'off'
action:
- service: switch.turn_on
data:
entity_id: switch.tv_speaker_power
- alias: 'Media: Spotify Redirect Lynn'
description: When spotify plays on Living Room Display, redirect to Speaker
triggers:
- trigger: state
entity_id: media_player.spotify_lynn
attribute: source
to: Living Room Display
action:
- service: media_player.select_source
target:
entity_id: media_player.spotify_lynn
data:
source: Speaker
- service: media_player.volume_set
data:
volume_level: 0.4
target:
device_id: media_player.spotify_lynn
- alias: 'Media: Spotify Redirect Raf'
description: When spotify plays on Living Room Display, redirect to Speaker
triggers:
- trigger: state
entity_id: media_player.spotify_raf
attribute: source
to: Living Room Display
action:
- service: media_player.select_source
target:
entity_id: media_player.spotify_raf
data:
source: Speaker
- service: media_player.volume_set
data:
volume_level: 0.4
target:
device_id: media_player.spotify_raf
- id: vacuum_stuck_returning
alias: 'Vacuum: Stuck Returning'
description: When Vacuum has been returning for long enough, stop it
trigger:
platform: state
entity_id: vacuum.robovac
to: returning
for:
minutes: 20
action:
- service: vacuum.pause
entity_id: vacuum.robovac
- service: notify.telegram_raf
data:
message: Vacuum got stuck returning to base
- alias: 'Light: Bedroom Sunset'
description: At sunset, if home, turn on bedroom evening scene
trigger:
platform: template
value_template: '{{ state_attr(''sun.sun'', ''elevation'') <= states(''input_number.sunset_elevation'')|float
}}'
condition:
- condition: state
entity_id: input_boolean.at_home
state: 'on'
- condition: state
entity_id: light.bedroom
state: 'off'
action:
- service: scene.turn_on
data:
entity_id: scene.bedroom_evening
- alias: 'Log Level: System'
description: When the log level is set, changes the log level
trigger:
platform: state
entity_id: input_select.log_level
action:
- service: logger.set_default_level
data_template:
level: '{{ states(''input_select.log_level'') }}'
- alias: 'Test: Automation'
description: When something, if another thing, do the thing
trigger:
platform: state
entity_id: input_boolean.test_value
from: 'off'
to: 'on'
condition:
- condition: numeric_state
entity_id: automation.test_automation
above: 10
value_template: '{{ (now() - state.attributes.last_triggered) / timedelta(seconds=1)
}}'
action:
- service: notify.persistent_notification
data:
message: Test Automation
title: Automation fired
- alias: 'Travel: Travelling Automations State'
description: When travelling, set automations state
trigger:
platform: state
entity_id: input_boolean.away
from: 'off'
to: 'on'
action:
- service: automation.turn_off
data:
entity_id:
- automation.vacuum_home_schedule
- automation.vacuum_away_schedule
- automation.presence_home_set_at_home
- alias: 'Media: Notification TV Clear'
description: When TV is not playing, send clear command
trigger:
platform: state
entity_id: media_player.lg_tv
to: 'off'
condition:
- condition: state
entity_id: person.raf
state: home
action:
- service: joaoapps_join.rafs_phone_send_tasker
data:
command: homemedia=:=clear=:=lg_tv
- alias: 'Media: Notification TV Notify'
description: When TV is playing, send notify command
trigger:
platform: state
entity_id: media_player.lg_tv
attribute: source
for:
seconds: 10
condition:
- condition: state
entity_id: person.raf
state: home
- condition: not
conditions:
- condition: state
entity_id: media_player.lg_tv
state: 'off'
action:
- service: joaoapps_join.rafs_phone_send_tasker
data:
command: homemedia=:=tv=:=lg_tv
- alias: 'TV: Twitch Active'
description: When TV is on Twitch, keep the app active
mode: restart
trigger:
- platform: state
entity_id: media_player.lg_tv
attribute: source
to: Twitch
action:
- repeat:
while:
- condition: state
entity_id: media_player.lg_tv
attribute: source
state: Twitch
sequence:
- service: webostv.button
data:
entity_id: media_player.lg_tv
button: INFO
- delay: 00:01:00
- alias: 'Mount Media: Unmount'
description: When Home Assistant is about to shutdown, unmount network share in
/media
trigger:
platform: homeassistant
event: shutdown
action:
- service: shell_command.unmount_media
- alias: 'Safety: Water Leak'
description: When water leak is detected, send a notification
trigger:
platform: state
entity_id:
- binary_sensor.bathroom_water_sensor_water_leak
- binary_sensor.boiler_water_sensor_water_leak
- binary_sensor.kitchen_water_sensor_water_leak
from: 'off'
to: 'on'
action:
- service: notify.telegram_raf
data:
message: '"Alert: Water Leak: {{ trigger.to_state.name }}"'
- alias: 'Log Level: Zigbee2Mqtt'
description: When the log level is set, changes the log level
trigger:
platform: state
entity_id: input_select.zigbee2mqtt_log_level
action:
- service: mqtt.publish
data:
payload_template: '{{ states(''input_select.zigbee2mqtt_log_level'') }}'
topic: zigbee2mqtt/bridge/config/log_level