AutomationDataset/jkfranks9/jkfranks9_automations.yaml

3511 lines
108 KiB
YAML

- id: '1608298913447'
alias: Zone Notification
description: ''
use_blueprint:
path: homeassistant/notify_leaving_zone.yaml
input:
person_entity: person.jon
zone_entity: zone.home
notify_device: a9570941d9dcebbd74ecb611f829a0f2
- id: '1655124375247'
alias: Kodi Test
description: ''
trigger:
- platform: device
device_id: 7000b71050bd8b00ed5ae05567e931c5
domain: kodi
entity_id: media_player.kodi
type: turn_on
condition: []
action:
- service: scene.turn_on
target:
entity_id: scene.lutron_dark
metadata: {}
mode: single
- id: '1737827992080'
alias: New automation
description: ''
triggers:
- trigger: conversation
command: testing
conditions: []
actions:
- action: assist_satellite.announce
metadata: {}
data:
message: Test is successful!
target:
entity_id: assist_satellite.home_assistant_voice_office_assist_satellite
mode: single
- alias: Transition To Sleep Mode
id: transition_to_sleep_mode
triggers:
- trigger: time
at: '20:00:00'
conditions:
- condition: state
entity_id: sensor.harmony_hub
state: PowerOff
- condition: state
entity_id: input_boolean.extended_away_mode
state: 'off'
- condition: state
entity_id: binary_sensor.penthouse_occupied
state: 'off'
actions:
- action: script.set_thermostat_preset
data:
thermostat_entity: climate.upstairs
preset: sleep
- alias: Get Downstairs Thermostat Temps
id: get_downstairs_thermostat_temps
use_blueprint:
path: climate/get_thermostat_temps.yaml
input:
climate_entity: climate.downstairs
- alias: Get Upstairs Thermostat Temps
id: get_upstairs_thermostat_temps
use_blueprint:
path: climate/get_thermostat_temps.yaml
input:
climate_entity: climate.upstairs
- alias: Set Minimum Attic Temperature
id: set_minimum_attic_temperature
use_blueprint:
path: climate/temp_extremes.yaml
input:
sensor_entity: sensor.attic_temp_min
result_entity: input_number.min_attic_temp
type: Min
- alias: Set Maximum Attic Temperature
id: set_maximum_attic_temperature
use_blueprint:
path: climate/temp_extremes.yaml
input:
sensor_entity: sensor.attic_temp_max
result_entity: input_number.max_attic_temp
type: Max
- alias: Set Minimum Garage Temperature
id: set_minimum_garage_temperature
use_blueprint:
path: climate/temp_extremes.yaml
input:
sensor_entity: sensor.garage_temp_min
result_entity: input_number.min_garage_temp
type: Min
- alias: Set Maximum Garage Temperature
id: set_maximum_garage_temperature
use_blueprint:
path: climate/temp_extremes.yaml
input:
sensor_entity: sensor.garage_temp_max
result_entity: input_number.max_garage_temp
type: Max
- alias: Set Minimum Outdoor Temperature
id: set_minimum_outdoor_temperature
use_blueprint:
path: climate/temp_extremes.yaml
input:
sensor_entity: sensor.porch_temp_min
result_entity: input_number.min_outdoor_temp
type: Min
- alias: Set Maximum Outdoor Temperature
id: set_maximum_outdoor_temperature
use_blueprint:
path: climate/temp_extremes.yaml
input:
sensor_entity: sensor.porch_temp_max
result_entity: input_number.max_outdoor_temp
type: Max
- alias: Turn Off Downstairs HVAC
id: turn_off_downstairs_hvac
trigger:
- platform: state
entity_id: binary_sensor.downstairs_doors_windows
from: 'off'
to: 'on'
for: 00:02:00
action:
- service: climate.turn_off
target:
entity_id: climate.downstairs
- alias: Turn On Downstairs HVAC
id: turn_on_downstairs_hvac
trigger:
- platform: state
entity_id: binary_sensor.downstairs_doors_windows
from: 'on'
to: 'off'
condition:
- condition: state
entity_id: climate.downstairs
state: 'off'
action:
- service: climate.turn_on
target:
entity_id: climate.downstairs
- alias: Calculate Astronomical Condition
id: calculate_astronomical_condition
triggers:
- trigger: sun
event: sunset
actions:
- variables:
first_hour: '{{ as_local(as_datetime(states(''sensor.astroweather_white_rabbit_gardens_sun_next_setting_astronomical''))).hour
}}'
- action: script.calculate_weather_metrics
data:
weather_entity: weather.astroweather_white_rabbit_gardens
forecast_type: hourly
first_hour: '{{ first_hour }}'
last_hour: 23
metrics_list:
- - input_number.average_astro_condition
- condition
- 50
- 0
- - input_number.average_astro_cloudless_percentage
- cloudless_percentage
- 50
- 0
- - input_number.average_astro_seeing_percentage
- seeing_percentage
- 50
- 0
- - input_number.average_astro_transparency_percentage
- transparency_percentage
- 50
- 0
- alias: Check Freezing Temperature
id: check_freezing_temperature
triggers:
- trigger: numeric_state
entity_id:
- sensor.openweathermap_temperature
- sensor.porch_sensor_temperature
below: 30
id: awake
- trigger: state
entity_id: input_boolean.nighttime
from: 'off'
to: 'on'
id: asleep
conditions: '{{ is_state(''input_boolean.nighttime'', ''off'') or trigger.id ==
''asleep'' }}'
actions:
- variables:
next_hour: '{% set curr_hour = as_local(as_datetime(now())).hour %} {% set curr_minute
= as_local(as_datetime(now())).minute %} {{ iif(curr_minute <= 55, curr_hour
+ 1, curr_hour + 2) }}
'
last_hour: '{{ iif(trigger.id == ''awake'', 0, 12) }}'
- action: script.calculate_weather_metrics
data:
weather_entity: weather.openweathermap
forecast_type: hourly
first_hour: '{{ next_hour }}'
last_hour: '{{ last_hour }}'
metrics_list:
- - input_number.minimum_outdoor_temperature
- temperature
- 33
- 120
- if:
- condition: numeric_state
entity_id: input_number.minimum_outdoor_temperature
below: 25
then:
- action: input_boolean.turn_on
target:
entity_id: input_boolean.freezing_temperature
- alias: Reset Freezing Temperature
id: reset_freezing_temperature
triggers:
- trigger: numeric_state
entity_id:
- sensor.openweathermap_temperature
- sensor.porch_sensor_temperature
above: 33
actions:
- action: input_boolean.turn_off
target:
entity_id: input_boolean.freezing_temperature
- alias: Check Salt System Low Temperature
id: check_salt_system_low_temperature
triggers:
- trigger: time
at: 06:00:00
actions:
- action: input_boolean.turn_off
target:
entity_id: input_boolean.salt_system_low_temperature
- action: script.calculate_weather_metrics
data:
weather_entity: weather.openweathermap
forecast_type: daily
num_days: 3
metrics_list:
- - input_number.minimum_daily_temperature
- templow
- 60
- 100
- - input_number.maximum_daily_temperature
- temperature
- 60
- 0
- if:
- condition: numeric_state
entity_id:
- input_number.minimum_daily_temperature
- input_number.maximum_daily_temperature
below: 55
then:
- action: input_boolean.turn_on
target:
entity_id: input_boolean.salt_system_low_temperature
- alias: Handle Device Initialization Catch 22
id: handle_device_initialization_catch_22
trigger:
- platform: homeassistant
event: start
action:
- service: input_boolean.turn_on
entity_id: input_boolean.device_initialization_catch_22
- delay: 00:01:30
- service: input_boolean.turn_off
entity_id: input_boolean.device_initialization_catch_22
- alias: Handle Power Outage
id: handle_power_outage
trigger:
- platform: state
entity_id: sensor.cyber1_status_data
to: OB DISCHRG
for: 00:01:00
- platform: homeassistant
event: start
condition:
- condition: state
entity_id: sensor.cyber1_status_data
state: OB DISCHRG
action:
- delay:
seconds: '{{ range(2, 15) | random }}'
- variables:
tag: power_out
title: 'Warning:'
message: Power is out, shutting down PC.
channel: critical
tag_registry_value: '{{ {''tag'': tag, ''clear_type'': ''auto'', ''title'':
title, ''message'': message, ''channel'': channel, ''timeout'': 0} }}'
notification_data: '{{ {''destination'': [''mobile''], ''title'': title, ''message'':
message, ''channel'': channel, ''timeout'': 0, ''tag'': tag} }}'
- action: input_datetime.set_datetime
target:
entity_id: input_datetime.ups_power_out
data_template:
datetime: '{{ now().strftime(''%Y-%m-%d %H:%M:%S'') }}'
- action: script.register_mobile_notification
data: '{{ tag_registry_value }}'
- action: script.send_notification
data: '{{ notification_data }}'
- action: recorder.disable
- action: script.turn_off_pc
- if:
- condition: state
entity_id: timer.vacuum
state: idle
then:
- action: vacuum.stop
entity_id: vacuum.ecovacs_deebot_none
- alias: Handle UPS Critical
id: handle_ups_critical
trigger:
- platform: numeric_state
entity_id: sensor.cyber1_battery_runtime
below: 420
- platform: homeassistant
event: start
condition:
- condition: numeric_state
entity_id: sensor.cyber1_battery_runtime
below: 420
action:
- delay:
seconds: '{{ range(2, 15) | random }}'
- variables:
tag: ups_battery
title: 'Warning:'
message: UPS battery is critical, shutting down RPi.
channel: critical
tag_registry_value: '{{ {''tag'': tag, ''clear_type'': ''auto'', ''title'':
title, ''message'': message, ''channel'': channel, ''timeout'': 0} }}'
notification_data: '{{ {''destination'': [''mobile''], ''title'': title, ''message'':
message, ''channel'': channel, ''timeout'': 0, ''tag'': tag} }}'
- action: input_datetime.set_datetime
target:
entity_id: input_datetime.ups_battery_critical
data_template:
datetime: '{{ now().strftime(''%Y-%m-%d %H:%M:%S'') }}'
- action: script.register_mobile_notification
data: '{{ tag_registry_value }}'
- action: script.send_notification
data: '{{ notification_data }}'
- delay: 3
- action: hassio.host_shutdown
- alias: Handle Power Restoration
id: handle_power_restoration
trigger:
- platform: state
entity_id: sensor.cyber1_status_data
to: OL CHRG
for: 00:02:00
- platform: homeassistant
event: start
condition:
- condition: state
entity_id: sensor.cyber1_status_data
state: OL CHRG
action:
- delay:
seconds: '{{ range(2, 15) | random }}'
- variables:
tag: power_restored
title: 'Attention:'
message: "{% set var = namespace(outage = '', critical = '') %} {% set prefix\
\ = 'Power is restored, turning on the PC (' %} {% set keys = state_attr('sensor.mobile_tag_registry_keys',\
\ 'tags') %} {% set var.outage = 'outage: ' ~ state_attr('input_datetime.ups_power_out',\
\ 'timestamp') | timestamp_custom %} {% if 'ups_battery' in keys %}\n {%\
\ set var.critical = ', critical: ' ~ state_attr('input_datetime.ups_battery_critical',\
\ 'timestamp') | timestamp_custom %}\n{% endif %}\n{{ prefix ~ var.outage\
\ ~ var.critical ~ ')' }}\n"
channel: standard
tag_registry_value: '{{ {''tag'': tag, ''clear_type'': ''manual'', ''title'':
title, ''message'': message, ''channel'': channel, ''timeout'': 0} }}'
notification_data: '{{ {''destination'': [''mobile''], ''title'': title, ''message'':
message, ''channel'': channel, ''timeout'': 0, ''tag'': tag} }}'
- action: script.register_mobile_notification
data: '{{ tag_registry_value }}'
- action: script.send_notification
data: '{{ notification_data }}'
- action: script.remove_mobile_notification
data:
tag: power_out
- action: script.remove_mobile_notification
data:
tag: ups_battery
- action: wake_on_lan.send_magic_packet
data:
mac: 98-EE-CB-A6-80-EA
- delay: 00:02:00
- action: recorder.enable
- action: vacuum.return_to_base
entity_id: vacuum.ecovacs_deebot_none
- action: input_boolean.turn_off
entity_id: input_boolean.theater_open
- action: remote.turn_off
entity_id: remote.harmony_hub
- alias: Reboot NUT Service
id: reboot_nut_service
trigger:
- platform: state
entity_id: sensor.cyber1_status
to: unavailable
- platform: homeassistant
event: start
condition:
- condition: state
entity_id: sensor.cyber1_status
state: unavailable
action:
- delay:
seconds: '{{ range(2, 15) | random }}'
- service: shell_command.reboot_nut_service
- alias: Open House
id: open_house
triggers:
- trigger: state
entity_id: person.jon
from: not_home
to: home
for: 00:00:05
actions:
- action: script.turn_on
target:
entity_id: script.open_garage_door_north
data:
variables:
use_info_message: false
- action: script.turn_off_extended_away_mode
- if:
- '{{ states(''sensor.downstairs_sensor_ambient_light'') | float(0) < states(''input_number.family_room_ambient_min'')
| float(0) }}'
then:
- action: light.turn_on
target:
entity_id:
- light.office_lamp
- light.driveway
- light.front_floodlight
- if:
- condition: state
entity_id: input_boolean.christmas_mode
state: 'off'
then:
- action: light.turn_on
target:
entity_id:
- light.family_room_lamp
- light.hallway_lamp
else:
- action: script.turn_on_christmas_lights
data:
variables:
additional_lights: daytime
- if:
- condition: state
entity_id: person.skylar
state: home
then:
- action: script.operate_preferred_studio_lamps
data:
operation: 'on'
- alias: Close House
id: close_house
mode: queued
triggers:
- trigger: state
entity_id: person.jon
from: home
to: not_home
for: 00:00:05
id: jon_left
- trigger: state
entity_id: sun.sun
from: above_horizon
to: below_horizon
id: sunset
- trigger: homeassistant
event: start
id: start
conditions:
- or:
- condition: state
entity_id: person.jon
state: not_home
- condition: state
entity_id: sun.sun
state: below_horizon
actions:
- delay:
seconds: '{{ range(2, 15) | random }}'
- action: script.turn_on
target:
entity_id: script.close_garage_door_north
data:
variables:
use_info_message: true
- action: script.turn_on
target:
entity_id: script.close_garage_door_south
data:
variables:
use_info_message: true
- if:
- '{{ trigger.id != ''sunset'' and not is_state(''person.jon'', ''home'') }}'
then:
- action: script.turn_on
entity_id: script.lock_pc
- if:
- '{{ is_state(''binary_sensor.adults_home'', ''off'') }}'
then:
- action: scene.turn_on
target:
entity_id:
- scene.lights_out
- scene.fans_off_downstairs
- scene.fans_off_upstairs
- action: script.turn_off_fan_lights
data:
light_entity: '{{ expand(state_attr(''light.ceiling_fan_lights'', ''entity_id''))
| map(attribute = ''entity_id'') | list }}'
- if:
- '{{ trigger.id != ''jon_left'' and states(''sun.sun'') == ''below_horizon''
}}'
then:
- action: light.turn_off
target:
entity_id:
- light.storage_lights
- light.outdoor_lights
- alias: Handle Guest Arrival Cleanup
id: handle_guest_arrival_cleanup
trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.guest_arrival_cleanup
action:
- service: script.turn_on
target:
entity_id: script.close_garage_door_north
data:
variables:
use_info_message: true
- action: light.turn_off
target:
entity_id:
- light.driveway
- light.front_floodlight
- alias: Enable Family Room AV
id: enable_family_room_av
triggers:
- trigger: time
at: 07:00:00
id: morning
- trigger: time
at: '16:00:00'
id: afternoon
conditions:
- or:
- and:
- condition: state
entity_id: binary_sensor.children_home
state: 'on'
- condition: trigger
id: morning
- condition: trigger
id: afternoon
actions:
- condition: state
entity_id: input_boolean.extended_away_mode
state: 'off'
- action: script.enable_family_room_av
- alias: Toggle Office occupied
id: toggle_office_occupied
triggers:
- trigger: state
entity_id: binary_sensor.office_human_sensor_presence
from: 'off'
to: 'on'
for: 00:02:00
id: 'on'
- trigger: state
entity_id: binary_sensor.office_human_sensor_presence
from: 'on'
to: 'off'
for: 00:15:00
id: 'off'
actions:
- action: input_boolean.turn_{{ trigger.id }}
target:
entity_id: input_boolean.office_occupied
- alias: Operate Office Fan
id: operate_office_fan
use_blueprint:
path: devices/operate_ceiling_fans.yaml
input:
sensor_entity: input_boolean.office_occupied
sensor_off_state: 'off'
temperature_entity: sensor.office_sensor_temperature
fan_entity: fan.office_fan
thresholds:
- 80
- 78
- 76
- alias: Operate Family Room Fan
id: operate_family_room_fan
use_blueprint:
path: devices/operate_ceiling_fans.yaml
input:
sensor_entity: binary_sensor.family_room_av_system
sensor_off_state: 'off'
temperature_entity: sensor.main_floor_temperature
fan_entity: fan.family_room_fan
thresholds:
- 80
- 78.5
- 74
- alias: Operate Theater Fan
id: operate_theater_fan
use_blueprint:
path: devices/operate_ceiling_fans.yaml
input:
sensor_entity: sensor.harmony_hub
sensor_off_state: PowerOff
temperature_entity: sensor.theater_temperature
fan_entity: fan.theater_fan
thresholds:
- 78
- 76
- 74
- alias: Turn Off Penthouse Fan
id: turn_off_penthouse_fan
trigger:
- platform: state
entity_id: switch.penthouse_fan
from: 'off'
to: 'on'
for: 00:40:00
action:
- service: switch.turn_off
entity_id: switch.penthouse_fan
- alias: Start Treadmill
id: start_treadmill
trigger:
- platform: numeric_state
entity_id: sensor.treadmill_current_consumption
above: 200
condition:
- condition: state
entity_id: input_boolean.treadmill_triggered
state: 'off'
action:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.treadmill_start
data_template:
datetime: '{{ now().strftime(''%Y-%m-%d %H:%M:%S'') }}'
- service: input_boolean.turn_on
target:
entity_id: input_boolean.treadmill_triggered
- alias: Detect Treadmill Power Unavailable
id: detect_treadmill_power_unavailable
trigger:
- platform: state
entity_id: sensor.treadmill_current_consumption
to: unavailable
condition:
- condition: state
entity_id: input_boolean.treadmill_triggered
state: 'on'
action:
- variables:
minutes_since_start: '{% from ''utilities.jinja'' import calc_time_diff %} {{
calc_time_diff(''input_datetime.treadmill_start'') | int(0) }}
'
default_minutes: '{{ states(''input_number.default_treadmill_minutes'') | int(0)
}}'
offset_minutes: 2
- if:
- '{{ minutes_since_start <= (default_minutes - offset_minutes) }}'
then:
- service: timer.start
data:
entity_id: timer.treadmill_power
duration: '{{ (default_minutes - minutes_since_start) * 60 }}'
else:
- service: automation.trigger
data:
entity_id: automation.stop_treadmill
skip_condition: false
- alias: Detect Treadmill Power Available
id: detect_treadmill_power_available
trigger:
- platform: state
entity_id: sensor.treadmill_current_consumption
from: unavailable
action:
- if:
- condition: state
entity_id: input_boolean.treadmill_triggered
state: 'on'
then:
- if:
- condition: state
entity_id: timer.treadmill_power
state: active
then:
- service: timer.cancel
entity_id: timer.treadmill_power
else:
- service: switch.turn_off
target:
entity_id: switch.treadmill
- alias: Handle Treadmill Power Timer
id: handle_treadmill_power_timer
trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.treadmill_power
action:
- service: automation.trigger
data:
entity_id: automation.stop_treadmill
skip_condition: false
- alias: Stop Treadmill
id: stop_treadmill
triggers:
- trigger: numeric_state
entity_id: sensor.treadmill_current_consumption
below: 7
conditions:
- condition: state
entity_id: input_boolean.treadmill_triggered
state: 'on'
actions:
- action: input_boolean.turn_off
target:
entity_id: input_boolean.treadmill_triggered
- action: switch.turn_off
target:
entity_id: switch.treadmill
- action: input_number.set_value
target:
entity_id: input_number.treadmill_daily_time
data:
value: '{% set start = as_timestamp(strptime(states(''input_datetime.treadmill_start''),
''%Y-%m-%d %H:%M:%S'')) %} {% set num = (now().timestamp() - start) // 60
%} {% set minutes = (num - (num % 5)) %} {{ minutes }}
'
- variables:
daily_calories: "{% set weight = states('sensor.smart_scale_p1_weight') | float(0)\
\ %} {% set speed = states('input_number.treadmill_speed') | float(0) %}\
\ {% set incline = states('input_number.treadmill_incline') | int(0) %} {%\
\ set time = states('input_number.treadmill_daily_time') | int(0) / 60\
\ %} {% set ctime = 1/60 %} {% set kph = speed * 1.609344 %} {% set\
\ ckph = 2.0 * 1.609344 %} {% set wkg = weight * 0.45359237 %} {%\
\ if states('input_number.treadmill_incline') | int(0) == 0 %}\n {% set cooldown\
\ = (((ckph**3 * 0.0215) - (ckph**2 * 0.1765) + (ckph * 0.8710) + 1.4577)\
\ * wkg * ctime) | int(0) %}\n {{ cooldown + (( (kph**3 * 0.0215) - \
\ (kph**2 * 0.1765) + (kph * 0.8710) + 1.4577) * wkg * time) | int(0) }}\n\
{% elif states('input_number.treadmill_incline') | int(0) == 1 %}\n {% set\
\ cooldown = (((ckph**3 * 0.0171) - (ckph**2 * 0.1062) + (ckph * 0.6080) +\
\ 1.8600) * wkg * ctime) | int(0) %}\n {{ cooldown + (( (kph**3 * 0.0171)\
\ - (kph**2 * 0.1062) + (kph * 0.6080) + 1.8600) * wkg * time) | int(0)\
\ }}\n{% elif states('input_number.treadmill_incline') | int(0) == 2 %}\n\
\ {% set cooldown = (((ckph**3 * 0.0184) - (ckph**2 * 0.1134) + (ckph * 0.6566)\
\ + 1.9200) * wkg * ctime) | int(0) %}\n {{ cooldown + (( (kph**3 * 0.0184)\
\ - (kph**2 * 0.1134) + (kph * 0.6566) + 1.9200) * wkg * time) | int(0)\
\ }}\n{% elif states('input_number.treadmill_incline') | int(0) == 3 %}\n\
\ {% set cooldown = (((ckph**3 * 0.0196) - (ckph**2 * 0.1205) + (ckph * 0.7053)\
\ + 1.9800) * wkg * ctime) | int(0) %}\n {{ cooldown + (( (kph**3 * 0.0196)\
\ - (kph**2 * 0.1205) + (kph * 0.7053) + 1.9800) * wkg * time) | int(0)\
\ }}\n{% elif states('input_number.treadmill_incline') | int(0) == 4 %}\n\
\ {% set cooldown = (((ckph**3 * 0.0208) - (ckph**2 * 0.1277) + (ckph * 0.7539)\
\ + 2.0400) * wkg * ctime) | int(0) %}\n {{ cooldown + (( (kph**3 * 0.0208)\
\ - (kph**2 * 0.1277) + (kph * 0.7539) + 2.0400) * wkg * time) | int(0)\
\ }}\n{% elif states('input_number.treadmill_incline') | int(0) == 5 %}\n\
\ {% set cooldown = (((ckph**3 * 0.0221) - (ckph**2 * 0.1349) + (ckph * 0.8025)\
\ + 2.1000) * wkg * ctime) | int(0) %}\n {{ cooldown + (( (kph**3 * 0.0221)\
\ - (kph**2 * 0.1349) + (kph * 0.8025) + 2.1000) * wkg * time) | int(0)\
\ }}\n{% endif %}\n"
- action: input_number.set_value
target:
entity_id: input_number.treadmill_daily_calories
data:
value: '{{ daily_calories }}'
- action: script.register_exercise_metrics
data:
exercise_type: treadmill
daily_calories: '{{ daily_calories }}'
- action: input_number.set_value
target:
entity_id: input_number.treadmill_usage_minutes
data:
value: '{{ states(''input_number.treadmill_usage_minutes'') | int(0) + states(''input_number.treadmill_daily_time'')
| int(0) }}'
- alias: Check Refrigerator Off
id: check_refrigerator_off
use_blueprint:
path: devices/monitor_device.yaml
input:
device_entity: switch.refrigerator
component_name: tplink
device_name: Refrigerator
- alias: Check Microwave Off
id: check_microwave_off
use_blueprint:
path: devices/monitor_device.yaml
input:
device_entity: switch.microwave
component_name: tplink
device_name: Microwave
- alias: Check Projector Off
id: check_projector_off
use_blueprint:
path: devices/monitor_device.yaml
input:
device_entity: switch.projector
component_name: sonoff
device_name: Projector
conditional_processing: '{{ states(''input_boolean.projector_plug_powered_off'')
}}'
- alias: Start Vacuum
id: start_vacuum
triggers:
- trigger: time
at: 03:00:00
conditions:
- condition: time
weekday:
- mon
- condition: state
entity_id: timer.vacuum
state: idle
actions:
- if:
- '{{ states(''vacuum.ecovacs_deebot_none'') != ''docked'' }}'
then:
- action: homeassistant.reload_config_entry
target:
entity_id: vacuum.ecovacs_deebot_none
- wait_template: '{{ is_state(''vacuum.ecovacs_deebot_none'', ''docked'') }}'
timeout:
seconds: 10
- if:
- '{{ states(''vacuum.ecovacs_deebot_none'') != ''docked'' }}'
then:
- action: script.send_notification
data:
destination:
- persistent
title: Device Alert
message: Vacuum not functioning good.
notification_id: vacuum_nfg
- stop: Vacuum not functioning good
- action: input_boolean.turn_off
entity_id:
- input_boolean.vacuum_kicked_off
- input_boolean.vacuum_finished
- action: timer.start
data:
entity_id: timer.vacuum
duration: 01:30:00
- delay:
milliseconds: 100
- action: vacuum.start
entity_id: vacuum.ecovacs_deebot_none
- alias: Stop Vacuum
id: stop_vacuum
triggers:
- trigger: event
event_type: timer.finished
event_data:
entity_id: timer.vacuum
- trigger: numeric_state
entity_id: sensor.ecovacs_deebot_battery
below: 20
conditions:
- condition: time
weekday:
- mon
actions:
- action: vacuum.return_to_base
entity_id: vacuum.ecovacs_deebot_none
- alias: Detect Vacuum Running
id: detect_vacuum_running
triggers:
- trigger: state
entity_id: vacuum.ecovacs_deebot_none
to: cleaning
conditions:
- condition: time
weekday:
- mon
- condition: state
entity_id: timer.vacuum
state: active
actions:
- action: input_boolean.turn_on
entity_id: input_boolean.vacuum_kicked_off
- alias: Detect Vacuum Finished
id: detect_vacuum_finished
triggers:
- trigger: state
entity_id: vacuum.ecovacs_deebot_none
to: docked
conditions:
- condition: time
weekday:
- mon
- condition: state
entity_id: input_boolean.vacuum_kicked_off
state: 'on'
actions:
- action: input_boolean.turn_on
entity_id: input_boolean.vacuum_finished
- alias: Start Washer
id: start_washer
trigger:
- platform: state
entity_id: sensor.washer_power_state
from:
- stop
- unknown
to: fill
action:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.washer_start
data_template:
datetime: '{{ now().strftime(''%Y-%m-%d %H:%M:%S'') }}'
- service: input_select.select_option
target:
entity_id: input_select.washer_load_size
data:
option: '*sensing*'
- service: input_boolean.turn_on
entity_id: input_boolean.backup_laundry_log
- service: script.log_laundry_event
data:
event_type: basic
prefix: Washer
message: 'starting: softener {{ states(''input_boolean.washer_fabric_softener'')
}}'
- alias: Set Washer Load Size
id: set_washer_load_size
triggers:
- trigger: state
entity_id: sensor.washer_power_state
from: fill
to: raise
conditions:
- condition: state
entity_id: input_select.washer_state
state: Wash Fill
actions:
- variables:
washer_fill_seconds: '{% set start = as_timestamp(strptime(states(''input_datetime.washer_start''),
''%Y-%m-%d %H:%M:%S'')) %} {% set seconds = (now().timestamp() - start) |
round(0) %} {{ seconds }}
'
- action: input_select.select_option
target:
entity_id: input_select.washer_load_size
data:
option: "{% if washer_fill_seconds >= 180 and washer_fill_seconds < 450 %}\n\
\ Small\n{% elif washer_fill_seconds >= 450 and washer_fill_seconds < 650\
\ %}\n Medium\n{% elif washer_fill_seconds >= 650 %}\n Large\n{% else %}\n\
\ Medium\n{% endif %}\n"
- action: input_number.set_value
target:
entity_id: input_number.washer_fill_seconds
data:
value: '{{ washer_fill_seconds }}'
- action: script.log_laundry_event
data:
event_type: fill_plus_load
prefix: Washer
message: fill time, load size
entity_id_1: input_number.washer_fill_seconds
entity_id_2: input_select.washer_load_size
- alias: Start Washer Wash Blackout Timer
id: start_washer_wash_blackout_timer
trigger:
- platform: state
entity_id: input_select.washer_state
from: Wash Fill
to: Wash
action:
- variables:
duration: 00:01:00
- service: timer.start
data:
entity_id: timer.washer_wash_blackout
duration: '{{ duration }}'
- service: script.log_laundry_event
data:
event_type: timer
prefix: Washer
message: timer started ({{ duration }})
entity_id_1: timer.washer_wash_blackout
- alias: Start Washer Rinse Fill Blackout Timer
id: start_washer_rinse_fill_blackout_timer
trigger:
- platform: state
entity_id: input_select.washer_state
from: Wash Drain
to: Rinse Fill
condition:
- condition: state
entity_id: input_boolean.washer_fabric_softener
state: 'on'
action:
- variables:
duration: '{% set load_size = states(''input_select.washer_load_size'') %} {{
iif(load_size == ''Small'', ''00:03:00'', iif(load_size == ''Large'', ''00:05:00'',
''00:04:00'')) }}
'
- service: timer.start
data:
entity_id: timer.washer_rinse_fill_blackout
duration: '{{ duration }}'
- service: script.log_laundry_event
data:
event_type: timer
prefix: Washer
message: timer started ({{ duration }})
entity_id_1: timer.washer_rinse_fill_blackout
- alias: Start Washer Rinse Blackout Timer
id: start_washer_rinse_blackout_timer
trigger:
- platform: state
entity_id: input_select.washer_state
from: Rinse Fill
to: Rinse
action:
- variables:
duration: 00:01:00
- service: timer.start
data:
entity_id: timer.washer_rinse_blackout
duration: '{{ duration }}'
- service: script.log_laundry_event
data:
event_type: timer
prefix: Washer
message: timer started ({{ duration }})
entity_id_1: timer.washer_rinse_blackout
- alias: Set Washer Operation
id: set_washer_operation
trace:
stored_traces: 20
trigger:
- platform: state
entity_id: sensor.washer_power_state
condition: '{{ trigger.from_state and trigger.from_state.state != ''unavailable''
}}'
action:
- delay: 00:00:01
- variables:
s: '{{ states(''input_select.washer_state'') }}'
- service: input_select.select_option
data:
entity_id: input_select.washer_state
option: "{# --Set variables-- #} {% set fr = trigger.from_state.state %} {%\
\ set to = trigger.to_state.state %} {% set t1 = states('timer.washer_rinse_fill_blackout')\
\ %} {% set t2 = states('timer.washer_rinse_blackout') %} {% set t3 = states('timer.washer_wash_blackout')\
\ %}\n{# --Ignore everything if one of the timers is running-- #} {% if t1\
\ == 'active' or t2 == 'active' or t3 == 'active' %} {{ s }}\n{# --Transition\
\ to new state based on current state and washer power state sensor change--\
\ #} {% elif fr in ['stop', 'unknown'] and to == 'fill' %} \
\ Wash Fill {% elif fr in ['fill', 'drop'] and to ==\
\ 'raise' and s == 'Wash Fill' %} Wash {% elif fr == 'raise'\
\ and to == 'drop' and s in ['Wash', 'Wash Drain'] %} Wash\
\ Drain {% elif fr in ['drop', 'raise'] and to == 'fill' and s == 'Wash\
\ Drain' %} Rinse Fill {% elif fr in ['fill', 'drop'] and to\
\ == 'raise' and s == 'Rinse Fill' %} Rinse {% elif fr == 'raise'\
\ and to == 'drop' and s == 'Rinse' %} Rinse\
\ Drain \n{# --Some washer power state sensor changes just remain in the\
\ current state-- #} {% elif fr == 'drop' and to in ['fill', 'raise'] %}\
\ {{ s }} {% elif fr == 'fill' and to in ['drop', 'raise'] %} {{ s }} {%\
\ elif fr == 'raise' and to in ['fill', 'drop'] %} {{ s }}\n{# --Catch-all,\
\ default to Off-- #} {% else %} Off {% endif %}\n"
- if:
- '{{ s != states(''input_select.washer_state'') }}'
then:
- service: script.log_laundry_event
data:
event_type: basic
prefix: Washer
message: state changed from {{ s }} to {{ states('input_select.washer_state')
}}
- if:
- '{{ is_state(''input_select.washer_state'', ''Off'') }}'
then:
- service: script.log_laundry_event
data:
event_type: basic
prefix: Washer
message: stopped
- service: script.update_laundry_history_time_ranges
data:
is_washer: true
start_time: '{{ state_attr(''input_datetime.washer_start'', ''timestamp'')
| int(0) }}'
stop_time: '{{ as_timestamp(now()) | round(0) }}'
- alias: Turn On Dryer Running
id: turn_on_dryer_running
triggers:
- trigger: template
value_template: "{{ states('sensor.dryer_sensor_temperature') not in ['unavailable',\
\ 'unknown'] and states('sensor.downstairs_temperature') not in ['unavailable',\
\ 'unknown'] and\n states('sensor.dryer_sensor_temperature') | int(0) > (states('sensor.downstairs_temperature')\
\ | int(0) + 30) }}\n"
actions:
- action: input_datetime.set_datetime
target:
entity_id: input_datetime.dryer_start
data_template:
datetime: '{{ now().strftime(''%Y-%m-%d %H:%M:%S'') }}'
- action: counter.reset
entity_id:
- counter.dryer_temperature_count
- counter.dryer_humidity_count
- action: input_boolean.turn_on
entity_id: input_boolean.dryer_running
- action: input_boolean.turn_on
entity_id: input_boolean.backup_laundry_log
- action: script.log_laundry_event
data:
event_type: basic
prefix: Dryer
message: '{% set intemp = states(''sensor.downstairs_temperature'') %} {% set
inhum = states(''sensor.downstairs_humidity'') %} {% set outtemp = states(''sensor.porch_sensor_temperature'')
%} {% set outhum = states(''sensor.openweathermap_humidity'') %}
starting: indoor ({{ intemp }}°, {{ inhum }}%); outdoor ({{ outtemp }}°, {{
outhum }} %)
'
- action: script.log_laundry_event
data:
event_type: metric
prefix: Dryer
message: temperature detected
entity_id_1: sensor.dryer_sensor_temperature
- action: timer.start
data:
entity_id: timer.dryer_done_failsafe
duration: 02:00:00
- alias: Reset Dryer Done Failsafe
id: reset_dryer_done_failsafe
triggers:
- trigger: event
event_type: timer.finished
event_data:
entity_id: timer.dryer_done_failsafe
actions:
- action: counter.reset
entity_id:
- counter.dryer_temperature_count
- counter.dryer_humidity_count
- alias: Register Dryer Event
id: register_dryer_event
triggers:
- trigger: template
value_template: '{{ states(''binary_sensor.dryer_humidity_falling'') == ''on''
and states(''sensor.dryer_sensor_humidity'') | int(0) <= 70 }}'
id: humidity
- trigger: state
entity_id: binary_sensor.dryer_temperature_falling
to: 'on'
id: temperature
conditions:
- condition: state
entity_id: input_boolean.dryer_running
state: 'on'
actions:
- if:
- '{{ trigger.id == ''temperature'' }}'
then:
- action: counter.increment
entity_id: counter.dryer_temperature_count
- action: script.log_laundry_event
data:
event_type: metric
prefix: Dryer
message: temperature falling
entity_id_1: sensor.dryer_sensor_temperature
else:
- action: counter.increment
entity_id: counter.dryer_humidity_count
- action: script.log_laundry_event
data:
event_type: metric
prefix: Dryer
message: humidity falling
entity_id_1: sensor.dryer_sensor_humidity
- alias: Turn Off Dryer Running
id: turn_off_dryer_running
trigger:
- platform: state
entity_id: binary_sensor.dryer_done
to: 'on'
condition:
- condition: state
entity_id: input_boolean.dryer_running
state: 'on'
action:
- service: input_boolean.turn_off
entity_id: input_boolean.dryer_running
- service: script.log_laundry_event
data:
event_type: basic
prefix: Dryer
message: stopped
- service: script.update_laundry_history_time_ranges
data:
is_washer: false
start_time: '{{ state_attr(''input_datetime.dryer_start'', ''timestamp'') |
int(0) }}'
stop_time: '{{ as_timestamp(now()) | round(0) }}'
- alias: Turn On Treadmill Fan
id: turn_on_treadmill_fan
trigger:
- platform: state
entity_id: input_boolean.treadmill_triggered
to: 'on'
action:
- choose:
- conditions:
- condition: numeric_state
entity_id: climate.downstairs
attribute: current_temperature
below: 70.0
sequence:
- delay: 00:10:00
- service: switch.turn_on
entity_id: switch.treadmill_fan
- conditions:
- condition: numeric_state
entity_id: climate.downstairs
attribute: current_temperature
below: 75.0
sequence:
- delay: 00:05:00
- service: switch.turn_on
entity_id: switch.treadmill_fan
default:
- service: switch.turn_on
entity_id: switch.treadmill_fan
- alias: Turn Off Treadmill Fan
id: turn_off_treadmill_fan
trigger:
- platform: state
entity_id: input_boolean.treadmill_triggered
to: 'off'
action:
- delay: 00:02:00
- service: switch.turn_off
entity_id: switch.treadmill_fan
- service: script.turn_on
entity_id: script.control_fan_for_temperature
data:
variables:
fan_entity_id: fan.office_fan
temperature_entity_id: sensor.main_floor_temperature
thresholds:
- 76
- 74
- 72
timeout: 360
- alias: Manage Echo Do Not Disturb
id: manage_echo_do_not_disturb
triggers:
- trigger: state
entity_id: input_boolean.nighttime
from: 'off'
to: 'on'
id: 'on'
- trigger: state
entity_id: input_boolean.nighttime
from: 'on'
to: 'off'
id: 'off'
actions:
- variables:
bedroom_echoes: '{{ [''switch.master_bedroom_echo_do_not_disturb_switch'', ''switch.studio_echo_do_not_disturb_switch'',
''switch.penthouse_echo_do_not_disturb_switch''] }}'
- repeat:
for_each: '{{ bedroom_echoes }}'
sequence:
- variables:
name: '{{ repeat.item.split(''.'')[1].split(''_'')[0] }}'
occupied_sensor: '{{ ''binary_sensor.'' ~ name ~ ''_occupied'' }}'
- if:
- '{{ iif(name == ''master'' or states(occupied_sensor) == ''on'') }}'
then:
- action: switch.turn_{{ trigger.id }}
target:
entity_id: '{{ repeat.item }}'
- alias: Update PC Lastboot
id: update_pc_lastboot
trigger:
- platform: state
entity_id: sensor.legion_t530_lastboot
to: null
condition: '{{ trigger.to_state.state not in [''unknown'', ''unavailable''] }}'
action:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.pc_lastboot
data:
timestamp: '{{ as_timestamp(states(''sensor.legion_t530_lastboot'')) }}'
- alias: Save Monthly Calories
id: save_monthly_calories
trigger:
- platform: state
entity_id: sensor.total_monthly_calories
condition:
- '{{ now().day == 1 }}'
- '{{ trigger.from_state and trigger.from_state.state | float(0) > 0.0 }}'
variables:
month: '{{ as_timestamp(trigger.from_state.last_changed) | timestamp_custom(''%b'')
| lower() }}'
action:
- service: system_log.write
data:
message: '{{ ''calories from state last changed/month: '' ~ trigger.from_state.last_changed
~ '' / '' ~ month }}'
level: debug
- service: input_number.set_value
target:
entity_id: input_number.calories_curr_year_{{ month }}
data:
value: '{{ trigger.from_state.state | float(0) }}'
- if:
- '{{ month == ''dec'' }}'
then:
- variables:
months:
- jan
- feb
- mar
- apr
- may
- jun
- jul
- aug
- sep
- oct
- nov
- dec
- repeat:
count: 12
sequence:
- service: input_number.set_value
target:
entity_id: input_number.calories_prev_year_{{ months[repeat.index-1] }}
data:
value: '{{ states(''input_number.calories_curr_year_'' + months[repeat.index-1])
}}'
- service: input_number.set_value
target:
entity_id: input_number.calories_curr_year_{{ months[repeat.index-1] }}
data:
value: 0
- alias: Copy Daily Steps
id: copy_daily_steps
trigger:
- platform: time
at: '23:59:00'
action:
- service: input_number.set_value
target:
entity_id: input_number.steps_daily
data:
value: '{{ states(''sensor.steps_daily'') }}'
- alias: Process Workout Exercise
id: process_workout_exercise
use_blueprint:
path: health/process_exercise.yaml
input:
exercise_type: workout
units_entity: input_number.workout_daily_time
- alias: Process Yard Work Exercise
id: process_yard_work_exercise
use_blueprint:
path: health/process_exercise.yaml
input:
exercise_type: yard_work
units_entity: input_number.yard_work_daily_time
- alias: Process Other Exercise
id: process_other_exercise
use_blueprint:
path: health/process_exercise.yaml
input:
exercise_type: other
units_entity: input_number.other_daily_time
- alias: Process Steps Exercise
id: process_steps_exercise
use_blueprint:
path: health/process_exercise.yaml
input:
exercise_type: steps
units_entity: input_number.steps_daily
- alias: Perform Startup Chores
id: perform_startup_chores
triggers:
- trigger: homeassistant
event: start
actions:
- action: shell_command.delete_junk_log_files
- action: input_boolean.turn_on
data:
entity_id: input_boolean.kodi_movie_list_restoration
- action: pyscript.restore_input_select_options
data:
entity: input_select.kodi_movies
file: /config/all_movies_backup
- wait_template: '{{ not is_state(''input_select.kodi_movies'', ''Select'') }}'
timeout: 00:00:10
- action: input_select.select_option
data:
entity_id: input_select.kodi_movies
option: '{{ states(''input_text.current_feature'') }}'
- action: input_boolean.turn_off
data:
entity_id: input_boolean.kodi_movie_list_restoration
- delay:
seconds: 30
- action: homeassistant.reload_config_entry
target:
entity_id: vacuum.ecovacs_deebot_none
- alias: Perform MQTT Chores
id: perform_mqtt_chores
triggers:
- trigger: mqtt
topic: homeassistant/status
payload: online
actions:
- variables:
vtrack_entities: "{% set var = namespace(vtrack = []) %} {% for state in states.input_boolean\
\ %}\n {% if 'Virtual' in state.name %}\n {% set var.vtrack = var.vtrack\
\ + [state.entity_id] %}\n {% endif %}\n{% endfor %} {% for state in states.input_boolean\
\ %}\n {% if 'NFC Tag' in state.name %}\n {% set var.vtrack = var.vtrack\
\ + [state.entity_id] %}\n {% endif %}\n{% endfor %}\n{{ var.vtrack }}\n"
- repeat:
for_each: '{{ vtrack_entities }}'
sequence:
- variables:
topic_suffix: '{{ repeat.item | replace(''input_boolean.'', '''') }}'
- if:
- '{{ states(repeat.item) == ''on'' }}'
then:
- action: mqtt.publish
data:
topic: '{{ ''homeassistant/device_tracker/'' ~ topic_suffix }}'
payload: home
else:
- action: mqtt.publish
data:
topic: '{{ ''homeassistant/device_tracker/'' ~ topic_suffix }}'
payload: not_home
- variables:
suffix: last_changed
items:
- '{{ ''ups_'' ~ suffix }}'
- '{{ ''garage_door_north_'' ~ suffix }}'
- '{{ ''garage_door_south_'' ~ suffix }}'
- '{{ ''treadmill_'' ~ suffix }}'
- '{{ ''washer_'' ~ suffix }}'
- '{{ ''workout_'' ~ suffix }}'
- repeat:
count: '{{ items | length }}'
sequence:
- action: script.set_up_mqtt_automated_config
data:
domain: sensor
unique_id: '{{ items[repeat.index - 1] }}'
device_class: timestamp
- alias: Perform Shutdown Chores
id: perform_shutdown_chores
trigger:
- platform: homeassistant
event: shutdown
action:
- service: shell_command.backup_log
- alias: Perform Daily Chores
id: perform_daily_chores
triggers:
- trigger: time
at: 01:01:01
actions:
- variables:
day_of_week: '{{ as_timestamp(now()) | timestamp_custom(''%w'') | int(0) }}'
day_of_month: '{{ now().day }}'
- action: input_boolean.turn_off
target:
entity_id: input_boolean.exercise_recordable
- action: input_number.set_value
target:
entity_id:
- input_number.treadmill_daily_time
- input_number.treadmill_daily_calories
- input_number.workout_daily_time
- input_number.workout_daily_calories
- input_number.yard_work_daily_time
- input_number.yard_work_daily_calories
- input_number.other_daily_time
- input_number.other_daily_calories
- input_number.steps_daily
- input_number.steps_daily_calories
data:
value: 0
- action: input_datetime.set_datetime
target:
entity_id: input_datetime.other_date
data:
timestamp: '{{ now().timestamp() }}'
- action: automation.turn_on
entity_id:
- automation.determine_cpap_filter_target_day
- automation.run_studio_motion_based_light
- automation.update_last_alexa_device
- if:
- condition: state
entity_id: update.zigbee2mqtt_update
state: 'off'
then:
- action: automation.turn_on
entity_id: automation.notify_zigbee_device_unavailable
- action: shell_command.backup_auto_scripts_log
- action: input_boolean.turn_off
entity_id: input_boolean.dryer_running
- if:
- condition: state
entity_id: input_boolean.backup_laundry_log
state: 'on'
then:
- action: shell_command.backup_laundry_log
- action: input_boolean.turn_off
entity_id: input_boolean.backup_laundry_log
- if:
- condition: state
entity_id: input_boolean.hockey_season
state: 'on'
then:
- if:
- condition: state
entity_id: input_boolean.hockey_canes_active
state: 'on'
then:
- action: homeassistant.update_entity
target:
entity_id: sensor.next_canes_game
continue_on_error: true
- if:
- condition: state
entity_id: input_boolean.hockey_flyers_active
state: 'on'
then:
- action: homeassistant.update_entity
target:
entity_id: sensor.next_flyers_game
continue_on_error: true
- action: input_number.set_value
target:
entity_id: input_number.f150_mileage
data:
value: '{{ states(''input_number.f150_mileage'') | int(0) + 32 }}'
- if:
- condition: state
entity_id: input_boolean.theater_open
state: 'on'
- condition: state
entity_id: binary_sensor.adults_home
state: 'off'
- condition: state
entity_id: sensor.harmony_hub
state: PowerOff
then:
- action: input_boolean.turn_off
target:
entity_id: input_boolean.theater_open
- action: input_boolean.turn_off
target:
entity_id: input_boolean.salt_system_low_temperature
- action: automation.turn_on
entity_id: automation.control_family_room_lamp
- action: automation.turn_off
entity_id: automation.control_christmas_lights
- action: watchman.report
data:
parse_config: false
create_file: true
- repeat:
for_each:
- david
- mike
- sarah
- skylar
sequence:
- if:
- '{{ not is_state(''person.'' ~ repeat.item, ''home'') }}'
then:
- action: input_select.select_first
target:
entity_id: '{{ ''input_select.'' ~ repeat.item ~ ''_guest_suite'' }}'
- if:
- '{{ day_of_week == 0 }}'
then:
- action: input_number.set_value
target:
entity_id:
- input_number.treadmill_weekly_time
- input_number.treadmill_weekly_calories
- input_number.workout_weekly_time
- input_number.workout_weekly_calories
- input_number.yard_work_weekly_time
- input_number.yard_work_weekly_calories
- input_number.other_weekly_time
- input_number.other_weekly_calories
- input_number.steps_weekly
- input_number.steps_weekly_calories
data:
value: 0
- action: script.generate_periodic_lists
data:
type: all
start_date: '{{ states(''sensor.date'') }}'
- action: script.generate_weekly_free_time_days
- action: script.generate_weekly_exercise_days
- if:
- '{{ day_of_month == 1 }}'
then:
- action: input_number.set_value
target:
entity_id:
- input_number.treadmill_monthly_time
- input_number.treadmill_monthly_calories
- input_number.workout_monthly_time
- input_number.workout_monthly_calories
- input_number.yard_work_monthly_time
- input_number.yard_work_monthly_calories
- input_number.other_monthly_time
- input_number.other_monthly_calories
- input_number.steps_monthly
- input_number.steps_monthly_calories
data:
value: 0
- action: counter.reset
target:
entity_id:
- counter.treadmill_days
- counter.workout_days
- counter.yard_work_days
- counter.other_days
- counter.steps_days
- counter.exercise_recordable
- action: shell_command.backup_exercise_log
- alias: Log Automations
id: log_automations
mode: queued
max: 200
trace:
stored_traces: 20
triggers:
- trigger: event
event_type: automation_triggered
conditions:
- condition: template
value_template: "{% set skip_list = [\n 'log_automations',\n\
\ 'log_scripts',\n 'set_maximum_attic_temperature',\
\ \n 'set_maximum_garage_temperature', \n \
\ 'set_maximum_outdoor_temperature',\n 'set_minimum_attic_temperature',\
\ \n 'set_minimum_garage_temperature', \n \
\ 'set_minimum_outdoor_temperature',\n 'set_washer_operation'\n\
\ ] %}\n{{ trigger.event.data.entity_id.split('.')[1] not\
\ in skip_list }}\n"
actions:
- action: notify.send_message
target:
entity_id: notify.automations_scripts
data:
message: '{{ as_timestamp(trigger.event.time_fired) | timestamp_custom(''%b
%d: %X'') }}: (A) {{ trigger.event.data.name }}
'
- alias: Log Scripts
id: log_scripts
mode: queued
max: 200
trace:
stored_traces: 20
triggers:
- trigger: event
event_type: script_started
conditions:
- condition: template
value_template: "{% set skip_list = [\n 'log_laundry_event',\n\
\ 'mobile_notification_worker',\n 'restore_lighting_on_resume',\n\
\ 'resume_cinema',\n 'resume_worker',\
\ \n 'set_datetime_offset_days', \n 'set_datetime_offset_months',\
\ \n 'set_datetime_offset_weeks', \n 'set_fan_to_speed',\
\ \n 'set_theater_dark',\n 'set_theater_dark_delay',\n\
\ 'set_theater_dim',\n 'set_theater_idle'\n\
\ ] %}\n{{ trigger.event.data.entity_id.split('.')[1] not\
\ in skip_list }}\n"
actions:
- action: notify.send_message
target:
entity_id: notify.automations_scripts
data:
message: '{{ as_timestamp(trigger.event.time_fired) | timestamp_custom(''%b
%d: %X'') }}: (S) {{ trigger.event.data.name }}
'
- alias: Change YAML Log Level
id: change_yaml_log_level
triggers:
- trigger: state
entity_id: input_select.yaml_log_level
actions:
- action: logger.set_level
data:
homeassistant.components.system_log.external: '{{ trigger.to_state.state }}'
- alias: Save Notifications On Create
id: save_notifications_on_create
mode: queued
triggers:
- trigger: persistent_notification
update_type:
- added
- updated
- current
conditions: '{{ trigger.notification.notification_id != ''config_entry_discovered''
}}'
actions:
- action: mqtt.publish
data_template:
topic: homeassistant/notifications/{{ trigger.notification.notification_id }}
payload: "{\n 'notification_id' : \"{{ trigger.notification.notification_id\
\ }}\",\n 'title' : \"{{ trigger.notification.title }}\",\n 'message' :\
\ \"{{ trigger.notification.message }}\"\n}"
retain: true
- alias: Remove Saved Notifications On Dismiss
id: remove_saved_notifications_on_dismiss
mode: queued
trigger:
- trigger: persistent_notification
update_type:
- removed
condition: '{{ trigger.notification.notification_id != ''config_entry_discovery''
}}'
action:
- service: mqtt.publish
data_template:
topic: homeassistant/notifications/{{ trigger.notification.notification_id }}
retain: true
- alias: Publish MQTT Automated States
id: publish_mqtt_automated_states
mode: parallel
triggers:
- trigger: state
entity_id: sensor.cyber1_status_data
to: OB DISCHRG
for: 00:01:00
id: ups
- trigger: state
entity_id: cover.garage_door_north
from: closed
to: open
id: garage_door_north
- trigger: state
entity_id: cover.garage_door_south
from: closed
to: open
id: garage_door_south
- trigger: state
entity_id: input_select.washer_state
from: 'Off'
not_to:
- Unknown
- unknown
- unavailable
id: washer
- trigger: state
entity_id: input_boolean.treadmill_triggered
from: 'off'
to: 'on'
id: treadmill
- trigger: numeric_state
entity_id: input_number.workout_daily_time
above: 0
id: workout
variables:
valid: '{{ trigger | default(none) is not none and trigger.to_state is defined
and trigger.from_state is defined }}
'
timestamp: '{{ (datetime | default(now())).isoformat() }}
'
unique_id: '{{ trigger.id }}_last_changed
'
conditions: '{{ valid }}'
actions:
- action: script.publish_mqtt_automated_states
data:
domain: sensor
unique_id: '{{ unique_id }}'
state: '{{ timestamp }}'
attributes: {}
- alias: Toggle Zigbee Unavailable Notification
id: toggle_zigbee_unavailable_notification
triggers:
- trigger: state
entity_id: update.zigbee2mqtt_update
from: 'off'
to: 'on'
id: 'off'
- trigger: state
entity_id: update.zigbee2mqtt_update
from: 'on'
to: 'off'
id: 'on'
actions:
- action: automation.turn_{{ trigger.id }}
entity_id: automation.notify_zigbee_device_unavailable
- alias: Toggle Hockey Hobby
id: toggle_hockey_hobby
triggers:
- trigger: state
entity_id: input_boolean.hockey_season
from: 'off'
to: 'on'
id: 'on'
- trigger: state
entity_id: input_boolean.hockey_season
from: 'on'
to: 'off'
id: 'off'
actions:
- action: automation.turn_{{ trigger.id }}
entity_id:
- automation.notify_next_canes_game
- automation.notify_next_flyers_game
- action: input_boolean.turn_{{ trigger.id }}
entity_id:
- input_boolean.hockey_canes_active
- input_boolean.hockey_flyers_active
- alias: Respond To Mobile Text
id: respond_to_mobile_text
mode: queued
triggers:
- trigger: state
entity_id: sensor.jon_galaxy_last_notification
to: null
variables:
title: '{{ state_attr(''sensor.jon_galaxy_last_notification'', ''android.title'')
}}'
text: '{{ state_attr(''sensor.jon_galaxy_last_notification'', ''android.text'')
}}'
category: '{{ state_attr(''sensor.jon_galaxy_last_notification'', ''category'')
}}'
persons: "{% set var = namespace(list = []) %} {% if 'Michael' in title or 'Michael'\
\ in text %}\n {% set var.list = var.list + ['Michael'] %}\n{% endif %} {%\
\ if 'Maryam' in title or 'Maryam' in text %}\n {% set var.list = var.list\
\ + ['Maryam'] %}\n{% endif %} {% if 'Sarah' in title or 'Sarah' in text %}\n\
\ {% set var.list = var.list + ['Sarah'] %}\n{% endif %} {% if 'David' in title\
\ or 'David' in text %}\n {% set var.list = var.list + ['David'] %}\n{% endif\
\ %} {% if var.list | length == 0 %}\n {% set var.list = var.list + ['Stranger']\
\ %}\n{% endif %}\n{{ var.list }}\n"
on_treadmill: '{{ states(''input_boolean.treadmill_triggered'') == ''on'' }}'
sleeping: '{{ states(''input_boolean.sleeptime'') == ''on'' }}'
driving: '{{ states(''binary_sensor.jon_driving'') == ''on'' }}'
conditions:
- and:
- '{{ category != ''email'' }}'
- '{{ persons[0] != ''Stranger'' }}'
- or:
- '{{ on_treadmill }}'
- '{{ sleeping }}'
- '{{ driving }}'
actions:
- repeat:
for_each: '{{ persons }}'
sequence:
- variables:
timer_entity: '{{ ''timer.text_response_delay_'' ~ repeat.item | lower }}'
- condition: '{{ states(timer_entity) == ''idle'' }}'
- variables:
number: "{% if repeat.item == 'Michael' %}\n 9199246845\n{% elif repeat.item\
\ == 'Maryam' %}\n 9197571974\n{% elif repeat.item == 'Sarah' %}\n 2522302146\n\
{% elif repeat.item == 'David' %}\n 2522991689\n{% else %}\n 0000000000\n\
{% endif %}\n"
activity: "{% if on_treadmill %}\n on the treadmill\n{% elif sleeping %}\n\
\ asleep, and dreaming of {{ ('sugarplums', 'aliens', 'flying', 'weasels',\
\ 'being lost in an everchanging city', 'trying to find a bathroom', 'ghosts\
\ messing with electricity') | random }}\n{% elif driving %}\n driving,\
\ or at least in a vehicle\n{% else %}\n unavailable for some unknown\
\ reason\n{% endif %}\n"
- action: notify.gmail
data:
title: ' '
target: '{{ number ~ ''@vtext.com'' }}'
message: '{{ ''Sorry, I am '' ~ activity ~ ''. I will respond when available.''
}}'
- action: timer.start
data:
entity_id: '{{ timer_entity }}'
duration: 300
- alias: Create Daily Mini ToDo List
id: create_daily_mini_todo_list
triggers:
- trigger: time
at: 05:00:00
actions:
- variables:
weekly_list_entities:
- sensor.mini_todo_weekly_cleaning_list
- sensor.mini_todo_weekly_other_list
- sensor.mini_todo_weekly_yard_work_list
start_date: '{% set day = now().isoweekday() %} {% set offset = iif(day <= 6,
day, 0) %} {{ as_datetime(states(''sensor.date'')) - timedelta(days = offset)
}}
'
- repeat:
for_each: '{{ weekly_list_entities }}'
sequence:
- if:
- '{{ states(repeat.item) in [''unknown'', ''unavailable''] }}'
then:
- variables:
type: '{{ repeat.item.split(''sensor.mini_todo_weekly_'')[-1] | replace(''_list'',
'''') }}'
- action: script.generate_periodic_lists
data:
type: '{{ type }}'
start_date: '{{ start_date }}'
- action: script.get_weather_metrics
- event: reset_mini_todo_items
- wait_template: '{{ state_attr(''sensor.daily_mini_todo_list'', ''items'') | count
== 0 }}'
- variables:
window_lower_bound: '{{ states(''input_datetime.mini_todo_start_time'') }}'
window_upper_bound: '{{ states(''input_datetime.mini_todo_end_time'') }}'
start_time: '{{ states(''sensor.date'') ~ '' '' ~ window_lower_bound }}'
end_time: '{{ states(''sensor.date'') ~ '' '' ~ window_upper_bound }}'
total_minutes: '{{ (((as_timestamp(end_time) - as_timestamp(start_time)) / 60)
- states(''input_number.mini_todo_downtime_minutes'') | int(0)) }}'
- action: input_number.set_value
target:
entity_id: input_number.mini_todo_available_minutes
data:
value: '{{ total_minutes }}'
- action: counter.reset
target:
entity_id: counter.mini_todo_tasks
- action: input_boolean.turn_off
data:
entity_id: input_boolean.mini_todo_major_item_added
- action: script.add_mini_todo_calendar_items
data:
window_lower_bound: '{{ window_lower_bound }}'
window_upper_bound: '{{ window_upper_bound }}'
start_time: '{{ start_time }}'
end_time: '{{ end_time }}'
- if:
- '{{ states(''input_number.mini_todo_weekly_exercise_days'') | int(0) | bitwise_and(2
** now().isoweekday()) > 0 }}'
then:
- variables:
last_treadmill: '{{ as_timestamp(states(''sensor.treadmill_last_changed''))
}}'
last_workout: '{{ as_timestamp(states(''sensor.workout_last_changed'')) }}'
exercise_type: '{{ iif(last_treadmill > last_workout, ''Workout'', ''Treadmill'')
}}'
current_minutes: '{{ states(''input_number.mini_todo_available_minutes'')
| int(0) }}'
exercise_minutes: '{{ iif(last_treadmill > last_workout, states(''input_number.variables_workout_time'')
| int(0) + 10, states(''input_number.default_treadmill_minutes'') | int(0)
+ 10) }}'
- service: input_number.set_value
target:
entity_id: input_number.mini_todo_available_minutes
data:
value: '{{ current_minutes - exercise_minutes }}'
- event: add_mini_todo_item
event_data:
value: '{{ ''ex:'' ~ exercise_type }}'
- action: counter.increment
target:
entity_id: counter.mini_todo_tasks
- if:
- '{{ states(''input_number.mini_todo_weekly_free_time_days'') | int(0) | bitwise_and(2
** now().isoweekday()) > 0 }}'
then:
- event: add_mini_todo_item
event_data:
value: ft:FREE TIME
- action: counter.increment
target:
entity_id: counter.mini_todo_tasks
- stop: Free day
- action: counter.reset
target:
entity_id: counter.mini_todo_attempts
- if:
- '{{ state_attr(''sensor.mini_todo_weekly_cleaning_list'', ''items'') | length
> 0 }}'
then:
- action: script.add_mini_todo_periodic_item
data:
type: cleaning
- if:
- '{{ state_attr(''sensor.mini_todo_weekly_yard_work_list'', ''items'') | length
> 0 }}'
then:
- action: script.add_mini_todo_periodic_item
data:
type: yard_work
- variables:
task_count: '{{ 5 - states(''counter.mini_todo_tasks'') | int(0) }}'
- repeat:
while: '{{ states(''input_number.mini_todo_available_minutes'') | int(total_minutes)
> 0 and states(''counter.mini_todo_tasks'') | int(0) < task_count and states(''counter.mini_todo_attempts'')
| int(0) <= 10 }}'
sequence:
- variables:
type: '{{ [''cleaning'', ''other'', ''yard_work'', ''major'', ''minor'']
| random }}'
- action: system_log.write
data:
message: '{{ ''iteration '' ~ repeat.index ~ '': type='' ~ type ~ '', avail=''
~ states(''input_number.mini_todo_available_minutes'') ~ '', tasks=''
~ states(''counter.mini_todo_tasks'') ~ '', attempts='' ~ states(''counter.mini_todo_attempts'')
}}'
level: debug
- delay:
milliseconds: 500
- choose:
- conditions: '{{ type in [''cleaning'', ''other'', ''yard_work''] }}'
sequence:
- if: '{{ range(2) | random > 0 }}'
then:
- action: script.add_mini_todo_periodic_item
data:
type: '{{ type }}'
- conditions: '{{ type in [''major'', ''minor''] }}'
sequence:
- if: '{{ range(2) | random > 0 }}'
then:
- action: script.add_mini_todo_project_item
data:
type: '{{ type }}'
- alias: Reload Unifi Integration
id: reload_unifi_integration
trigger:
- platform: event
event_type: system_log_event
event_data:
name: homeassistant.components.unifi
level: WARNING
condition: '{{ ''received 401 Unauthorized'' in trigger.event.data.message[0] }}'
action:
- action: counter.increment
target:
entity_id: counter.unifi_integration_errors
- if:
- condition: numeric_state
entity_id: counter.unifi_integration_errors
above: 5
then:
- action: homeassistant.reload_config_entry
target:
entity_id: sensor.udm_state
- action: counter.reset
target:
entity_id: counter.unifi_integration_errors
- alias: Reload Ecovacs Integration
id: reload_ecovacs_integration
triggers:
- trigger: state
entity_id:
- vacuum.ecovacs_deebot_none
- sensor.ecovacs_deebot_filter_lifespan
- sensor.ecovacs_deebot_main_brush_lifespan
- sensor.ecovacs_deebot_side_brush_lifespan
to: unavailable
for:
seconds: 30
actions:
- action: homeassistant.reload_config_entry
target:
entity_id: vacuum.ecovacs_deebot_none
- alias: Toggle Control Automation
id: toggle_control_automation
triggers:
- trigger: state
entity_id: input_boolean.christmas_mode
to: null
actions:
- variables:
toggle_operation: '{{ states(''input_boolean.christmas_mode'') }}'
- action: automation.turn_{{ toggle_operation }}
entity_id: automation.control_family_room_light_automations
- if:
- '{{ is_state_attr(''sun.sun'', ''rising'', false) and is_state(''sun.sun'',
''above_horizon'') }}'
then:
- action: automation.turn_{{ iif(toggle_operation == 'on', 'off', 'on') }}
entity_id: automation.control_family_room_lamp
- action: automation.turn_{{ iif(toggle_operation == 'on', 'on', 'off') }}
entity_id: automation.control_christmas_lights
- alias: Control Family Room Light Automations
id: control_family_room_light_automations
triggers:
- trigger: state
entity_id: sun.sun
to: null
- trigger: state
entity_id: sun.sun
attribute: rising
actions:
- if:
- '{{ is_state_attr(''sun.sun'', ''rising'', false) and is_state(''sun.sun'',
''above_horizon'') }}'
then:
- action: automation.turn_off
entity_id: automation.control_family_room_lamp
- if:
- condition: state
entity_id: binary_sensor.all_day_christmas_lights
state: 'off'
then:
- action: automation.turn_on
entity_id: automation.control_christmas_lights
else:
- action: automation.turn_on
entity_id: automation.control_family_room_lamp
- action: automation.turn_off
entity_id: automation.control_christmas_lights
- alias: Control Office Lamp
id: control_office_lamp
use_blueprint:
path: lighting/lux_light.yaml
input:
lux_sensor: sensor.office_sensor_ambient_light
light_target: light.office_lamp
min_lux_level: input_number.office_ambient_min
max_lux_level: input_number.office_ambient_max
check_theater: false
check_christmas: false
- alias: Control Hallway Lamp
id: control_hallway_lamp
use_blueprint:
path: lighting/lux_light.yaml
input:
lux_sensor: sensor.downstairs_sensor_ambient_light
light_target: light.hallway_lamp
min_lux_level: input_number.hallway_ambient_min
max_lux_level: input_number.hallway_ambient_max
check_theater: true
check_christmas: false
- alias: Control Family Room Lamp
id: control_family_room_lamp
use_blueprint:
path: lighting/lux_light.yaml
input:
lux_sensor: sensor.downstairs_sensor_ambient_light
light_target: light.family_room_lamp
min_lux_level: input_number.family_room_ambient_min
max_lux_level: input_number.family_room_ambient_max
check_theater: true
check_christmas: false
- alias: Control Christmas Lights
id: control_christmas_lights
use_blueprint:
path: lighting/lux_light.yaml
input:
lux_sensor: sensor.downstairs_sensor_ambient_light
light_target: light.family_room_lamp
min_lux_level: input_number.family_room_ambient_min
max_lux_level: input_number.family_room_ambient_max
check_theater: true
check_christmas: true
- alias: Control Voice Assistant Screens
id: control_voice_assistant_screens
triggers:
- trigger: numeric_state
entity_id: sensor.downstairs_sensor_ambient_light
below: input_number.family_room_ambient_min
id: dim
- trigger: numeric_state
entity_id: sensor.downstairs_sensor_ambient_light
above: input_number.family_room_ambient_max
id: bright
actions:
- if:
- '{{ trigger.id == ''dim'' }}'
then:
- action: scene.turn_on
target:
entity_id: scene.voice_assistants_on_dim
else:
- action: scene.turn_on
target:
entity_id: scene.voice_assistants_on_bright
- alias: Enable Extended Away Mode
id: enable_extended_away_mode
trigger:
- platform: time
at: input_datetime.extended_away_start
action:
- service: input_boolean.turn_on
entity_id: input_boolean.extended_away_mode
- service: script.set_extended_thermostat_holds
data:
heat_temp: '{{ states(''input_number.extended_hold_heat_temp'') }}'
cool_temp: '{{ states(''input_number.extended_hold_cool_temp'') }}'
- alias: Disable Extended Away Mode
id: disable_extended_away_mode
trigger:
- platform: time
at: input_datetime.extended_away_end
action:
- service: input_boolean.turn_off
entity_id: input_boolean.extended_away_mode
- service: script.remove_thermostat_hold
data:
thermostat_entity: climate.downstairs
extended: true
- service: script.remove_thermostat_hold
data:
thermostat_entity: climate.upstairs
extended: true
- alias: Control Nighttime During Extended Away
id: control_nighttime_during_extended_away
triggers:
- trigger: time
at: '22:00:00'
id: 'on'
- trigger: time
at: 05:30:00
id: 'off'
conditions:
- condition: state
entity_id: input_boolean.extended_away_mode
state: 'on'
actions:
- action: timer.start
data:
entity_id: timer.extended_away_nighttime
duration:
minutes: '{{ range(5, 90) | random }}'
- action: input_boolean.turn_{{ trigger.id }}
target:
entity_id: input_boolean.extended_away_nighttime
- alias: Handle Extended Away Nighttime Timer
id: handle_extended_away_nighttime_timer
triggers:
- trigger: event
event_type: timer.finished
event_data:
entity_id: timer.extended_away_nighttime
conditions:
- condition: state
entity_id: input_boolean.extended_away_mode
state: 'on'
actions:
- action: input_boolean.turn_{{ states('input_boolean.extended_away_nighttime')
}}
target:
entity_id: input_boolean.nighttime
- alias: Run Extended Away Lights
id: run_extended_away_lights
trigger:
- platform: state
entity_id: input_boolean.extended_away_mode
to: 'on'
- platform: state
entity_id: input_boolean.nighttime
to: 'off'
- platform: state
entity_id: sun.sun
to: below_horizon
- platform: homeassistant
event: start
condition:
- condition: state
entity_id: input_boolean.extended_away_mode
state: 'on'
- condition: state
entity_id: input_boolean.nighttime
state: 'off'
- condition: state
entity_id: sun.sun
state: below_horizon
action:
- delay:
seconds: '{{ range(2, 15) | random }}'
- variables:
group_id: light.away_lights
max_on: 3
normal_lights: '{{ [''light.family_room_lamp'', ''light.office_lamp''] }}'
group_lights_entities: '{{ expand(group_id) | map(attribute = ''entity_id'')
| list }}'
group_lights_filtered_entities: '{{ expand(group_id) | rejectattr(''entity_id'',
''in'', normal_lights) | map(attribute = ''entity_id'') | list }}'
- service: input_boolean.turn_off
entity_id: input_boolean.extended_away_early_return
- repeat:
sequence:
- variables:
lights_on_count: '{{ expand(group_id) | selectattr(''state'', ''eq'', ''on'')
| list | length }}'
lights_on_entities: '{{ expand(group_id) | selectattr(''state'', ''eq'',
''on'') | map(attribute = ''entity_id'') | list }}'
toggle_entity: "{% if lights_on_count > max_on %}\n {{ lights_on_entities\
\ | random }}\n{% else %}\n {{ group_lights_entities | random }}\n{%\
\ endif %}\n"
- service: homeassistant.toggle
data:
entity_id: '{{ toggle_entity }}'
- wait_template: '{{ is_state(''input_boolean.extended_away_mode'', ''off'')
}}'
timeout:
minutes: '{{ range(10, 60) | random }}'
- if:
- '{{ wait.completed }}'
then:
- service: input_boolean.turn_on
entity_id: input_boolean.extended_away_early_return
until:
- condition: template
value_template: "{{ is_state('input_boolean.extended_away_mode', 'off') or\n\
\ is_state('input_boolean.nighttime', 'on') or\n states('sun.sun') ==\
\ 'above_horizon' }}\n"
- if:
- condition: state
entity_id: input_boolean.extended_away_early_return
state: 'off'
then:
- service: homeassistant.turn_off
entity_id: light.away_lights
else:
- service: homeassistant.turn_on
data:
entity_id: '{{ normal_lights }}'
- service: homeassistant.turn_off
data:
entity_id: '{{ group_lights_filtered_entities }}'
- alias: Turn Off Extended Away Mode
id: turn_off_extended_away_mode
trigger:
- platform: template
value_template: '{{ states(''sensor.home_jon_distance'') | int(0) < 13000 }}'
condition: '{{ is_state(''sensor.home_jon_direction_of_travel'', ''towards'') }}'
action:
- service: script.turn_off_extended_away_mode
- alias: Run Studio Motion Based Light
id: run_studio_motion_based_light
trace:
stored_traces: 20
use_blueprint:
path: lighting/motion_light_with_fan.yaml
input:
motion_entity: binary_sensor.studio_motion_detector_occupancy
light_entity: light.studio_bath
fan_entity: switch.studio_fan
no_motion_wait_fan_off: 120
no_motion_wait_fan_on: 420
additional_fan_wait: 300
- alias: Run Laundry Room Motion Based Light
id: run_laundry_room_motion_based_light
trace:
stored_traces: 20
use_blueprint:
path: lighting/motion_light.yaml
input:
motion_entity: binary_sensor.laundry_room_motion_detector_occupancy
light_target:
entity_id: light.Laundry_room
no_motion_wait: 180
- alias: Run Master Bath Motion Based Light
id: run_master_bath_motion_based_light
trace:
stored_traces: 20
use_blueprint:
path: lighting/motion_light_with_fan.yaml
input:
motion_entity: binary_sensor.master_bath_motion_detector_occupancy
light_entity: light.master_vanity
fan_entity: switch.master_bath_fan
no_motion_wait_fan_off: 240
no_motion_wait_fan_on: 420
additional_fan_wait: 300
lux_entity: sensor.downstairs_sensor_ambient_light
min_lux_value: '{{ states(''input_number.master_suite_ambient_min'') | float(0)
}}'
- alias: Control Attic Light
id: control_attic_light
use_blueprint:
path: lighting/sensor_light.yaml
input:
sensor_entity: binary_sensor.attic_door_sensor_contact
light_target: light.attic
close_toggle: input_boolean.attic_door_close_toggle
- alias: Control Upstairs Entry Light
id: control_upstairs_entry_light
use_blueprint:
path: lighting/sensor_light.yaml
input:
sensor_entity: binary_sensor.upstairs_entry_sensor_contact
light_target: light.penthouse_hall
close_toggle: input_boolean.upstairs_entry_close_toggle
- alias: Control Master Closet Light
id: control_master_closet_light
use_blueprint:
path: lighting/sensor_light.yaml
input:
sensor_entity: binary_sensor.master_closet_sensor_contact
light_target: light.master_closet
- alias: Reset Attic Door Close Toggle
id: reset_attic_door_close_toggle
triggers:
- trigger: state
entity_id: light.attic
from: 'on'
to: 'off'
actions:
- delay: 00:00:01
- action: input_boolean.turn_off
target:
entity_id: input_boolean.attic_door_close_toggle
- alias: Reset Upstairs Entry Close Toggle
id: reset_upstairs_entry_close_toggle
triggers:
- trigger: state
entity_id: light.penthouse_hall
from: 'on'
to: 'off'
actions:
- delay: 00:00:01
- action: input_boolean.turn_off
target:
entity_id: input_boolean.upstairs_entry_close_toggle
- alias: Turn On Guest Lights At Dark
id: turn_on_guest_lights_at_dark
triggers:
- trigger: template
value_template: '{{ is_state_attr(''sun.sun'', ''rising'', false) and states(''sensor.downstairs_sensor_ambient_light'')
| float(0) < states(''input_number.studio_bedroom_ambient_min'') | float(0)
}}'
- trigger: homeassistant
event: start
conditions:
- condition: state
entity_id: binary_sensor.children_home
state: 'on'
- condition: state
entity_id: person.jon
state: home
- condition: state
entity_id: input_boolean.nighttime
state: 'off'
- condition: template
value_template: '{{ is_state_attr(''sun.sun'', ''rising'', false) and states(''sensor.downstairs_sensor_ambient_light'')
| float(0) < states(''input_number.studio_bedroom_ambient_min'') | float(0)
}}'
actions:
- delay:
seconds: '{{ range(2, 15) | random }}'
- action: script.operate_preferred_studio_lamps
data:
operation: 'on'
- alias: Turn Off Studio Night Light
id: turn_off_studio_night_light
triggers:
- trigger: time_pattern
minutes: 1
conditions:
- or:
- condition: state
entity_id: input_select.studio_guests
state: Empty
- '{{ states(''sensor.downstairs_sensor_ambient_light'') | float(0) >= states(''input_number.studio_bedroom_ambient_max'')
| float(0) }}'
actions:
- action: light.turn_on
target:
entity_id: light.studio_night_light
- delay:
milliseconds: 200
- action: light.turn_off
target:
entity_id: light.studio_night_light
- delay:
seconds: 10
- if:
- condition: state
entity_id: light.studio_night_light
state: 'on'
then:
- action: script.send_notification
data:
destination:
- persistent
title: Lighting Alert
message: Studio night light is still on. Perhaps millisecond delay is too
short.
notification_id: studio_night_light_on
- alias: Turn On Outdoor Christmas Lights
id: turn_on_outdoor_christmas_lights
triggers:
- trigger: template
value_template: '{{ states(''input_boolean.christmas_mode'') == ''on'' and states(''input_boolean.christmas_outdoor'')
== ''on'' and states(''sun.sun'') == ''below_horizon'' }}'
actions:
- action: light.turn_on
target:
entity_id: light.christmas_outdoor
- alias: Control All Day Christmas Lights
id: control_all_day_christmas_lights
triggers:
- trigger: time
at: 07:30:00
id: morning
- trigger: time
at: '22:30:00'
id: night
- trigger: homeassistant
event: start
id: start
conditions:
- or:
- and:
- condition: state
entity_id: person.jon
state: home
- condition: template
value_template: '{{ trigger.id != ''night'' }}'
- condition: time
after: 07:30:00
before: '22:29:59'
- condition: state
entity_id: binary_sensor.all_day_christmas_lights
state: 'on'
- and:
- condition: template
value_template: '{{ trigger.id != ''morning'' }}'
- condition: time
after: '22:30:00'
before: 07:29:59
- condition: state
entity_id: binary_sensor.all_day_christmas_lights
state: 'on'
actions:
- delay:
seconds: '{{ range(2, 15) | random }}'
- if:
- condition: time
after: 07:30:00
before: '22:29:59'
then:
- action: automation.turn_off
entity_id: automation.control_christmas_lights
- action: script.turn_on_christmas_lights
- action: light.turn_off
target:
entity_id: light.family_room_lamp
else:
- action: script.turn_off_christmas_lights
- action: automation.turn_on
entity_id: automation.control_christmas_lights
- alias: Reset Christmas Plugs
id: reset_christmas_plugs
triggers:
- trigger: state
entity_id: input_boolean.christmas_mode
to: 'off'
actions:
- variables:
christmas_plugs: '{{ expand(state_attr(''group.christmas_plugs'', ''entity_id''))
| map(attribute = ''entity_id'') | list }}'
- repeat:
for_each: '{{ christmas_plugs }}'
sequence:
- action: input_boolean.turn_off
target:
entity_id: '{{ repeat.item }}'
- alias: Turn On Office Bookcase Via Alexa
id: turn_on_office_bookcase_via_alexa
trigger:
- platform: state
entity_id: input_boolean.alexa_ha_plug
to: 'on'
action:
- service: media_player.play_media
target:
entity_id: media_player.family_room_echo
data:
media_content_id: HA Office Bookcase On
media_content_type: routine
metadata: {}
- alias: Turn Off Office Bookcase Via Alexa
id: turn_off_office_bookcase_via_alexa
trigger:
- platform: state
entity_id: input_boolean.alexa_ha_plug
to: 'off'
action:
- service: media_player.play_media
target:
entity_id: media_player.family_room_echo
data:
media_content_id: HA Office Bookcase Off
media_content_type: routine
metadata: {}
- alias: Stop Bath Time
id: stop_bath_time
trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.bath_time
action:
- service: automation.turn_on
entity_id: automation.run_studio_motion_based_light
- alias: Handle Guest Arrival
id: handle_guest_arrival
mode: queued
triggers:
- trigger: state
entity_id:
- person.david
- person.sarah
- person.mike
to: home
id: adult
- trigger: state
entity_id:
- person.skylar
to: home
id: child
actions:
- variables:
guest: '{{ trigger.to_state.attributes.friendly_name }}'
suite: '{{ states(''input_select.'' ~ guest | lower ~ ''_guest_suite'') }}'
- if:
- '{{ guest != ''Mike'' or now().hour >= 16 }}'
then:
- action: script.add_guest_to_suite
data:
guest: '{{ guest }}'
suite: '{{ suite }}'
- if:
- '{{ trigger.id == ''adult'' }}'
then:
- action: script.turn_on
target:
entity_id: script.open_garage_door_north
data:
variables:
use_info_message: true
- if:
- condition: state
entity_id: sun.sun
state: below_horizon
then:
- action: light.turn_on
target:
entity_id:
- light.driveway
- light.front_floodlight
- action: timer.start
data:
entity_id: timer.guest_arrival_cleanup
duration: 00:30:00
- alias: Handle Guest Departure
id: handle_guest_departure
mode: queued
triggers:
- trigger: state
entity_id:
- person.david
- person.sarah
- person.mike
from: home
id: adult
- trigger: state
entity_id:
- person.skylar
from: home
id: child
actions:
- variables:
guest: '{{ trigger.to_state.attributes.friendly_name }}'
suite: '{{ iif(guest in states(''input_select.studio_guests''), ''Studio'',
''Penthouse'') }}'
- action: script.remove_guest_from_suite
data:
guest: '{{ guest }}'
suite: '{{ suite }}'
- if:
- '{{ trigger.id == ''adult'' }}'
then:
- action: script.turn_on
target:
entity_id: script.close_garage_door_north
data:
variables:
use_info_message: true
- action: light.turn_off
target:
entity_id: light.outdoor_lights
- alias: Modify Occupied Guest Suites
id: modify_occupied_guest_suites
mode: queued
triggers:
- trigger: state
entity_id: input_select.david_guest_suite
to: null
id: David
- trigger: state
entity_id: input_select.mike_guest_suite
to: null
id: Mike
- trigger: state
entity_id: input_select.sarah_guest_suite
to: null
id: Sarah
- trigger: state
entity_id: input_select.skylar_guest_suite
to: null
id: Skylar
actions:
- condition: '{{ is_state(''person.'' ~ trigger.id | lower, ''home'') }}'
- action: script.remove_guest_from_suite
data:
guest: '{{ trigger.id }}'
suite: '{{ trigger.from_state.state }}'
- action: script.add_guest_to_suite
data:
guest: '{{ trigger.id }}'
suite: '{{ trigger.to_state.state }}'
- if:
- condition: state
entity_id: input_boolean.switch_guest_suites
state: 'on'
then:
- event: switch_guest_suites_complete
- alias: Modify Thermostat Hold Metrics
id: modify_thermostat_hold_metrics
mode: queued
triggers:
- trigger: state
entity_id: input_number.penthouse_nights_occupied
to: null
id: nights
- trigger: state
entity_id: sensor.david_temp_range
to: null
id: david
- trigger: state
entity_id: sensor.mike_temp_range
to: null
id: mike
- trigger: state
entity_id: sensor.sarah_temp_range
to: null
id: sarah
- trigger: state
entity_id: sensor.skylar_temp_range
to: null
id: skylar
conditions:
- or:
- '{{ trigger.id == ''nights'' and is_state(''binary_sensor.penthouse_occupied'',
''on'') }}'
- '{{ trigger.id != ''nights'' and trigger.id | title in states(''input_select.penthouse_guests'')
}}'
actions:
- if:
- condition: state
entity_id: timer.thermostat_metrics_delay
state: idle
then:
- action: timer.start
data:
entity_id: timer.thermostat_metrics_delay
duration:
minutes: '{{ states(''input_number.thermostat_metrics_delay_minutes'') }}'
- action: input_boolean.turn_on
target:
entity_id: input_boolean.thermostat_metrics_delay_timer_started
- alias: Handle Thermostat Metrics Delay Timer Expiration
id: handle_thermostat_metrics_delay_timer_expiration
triggers:
- trigger: event
event_type: timer.finished
event_data:
entity_id: timer.thermostat_metrics_delay
- trigger: homeassistant
event: start
conditions:
- condition: state
entity_id: timer.thermostat_metrics_delay
state: idle
- condition: state
entity_id: input_boolean.thermostat_metrics_delay_timer_started
state: 'on'
actions:
- action: script.modify_penthouse_thermostat_hold
- action: input_boolean.turn_off
target:
entity_id: input_boolean.thermostat_metrics_delay_timer_started
- alias: Handle Thermostat Hold Delay Timer Expiration
id: handle_thermostat_hold_delay_timer_expiration
triggers:
- trigger: event
event_type: timer.finished
event_data:
entity_id: timer.thermostat_hold_delay
- trigger: homeassistant
event: start
conditions:
- condition: state
entity_id: timer.thermostat_hold_delay
state: idle
- condition: state
entity_id: input_boolean.thermostat_hold_delay_timer_started
state: 'on'
actions:
- action: script.set_penthouse_thermostat_hold
- action: input_boolean.turn_off
target:
entity_id: input_boolean.thermostat_hold_delay_timer_started
- alias: Modify Active Studio Lamps
id: modify_active_studio_lamps
triggers:
- trigger: state
entity_id: input_select.preferred_studio_lamps
to: null
conditions: '{{ is_state(''binary_sensor.studio_occupied'', ''on'') and states(''sensor.downstairs_sensor_ambient_light'')
| float(0) < states(''input_number.studio_bedroom_ambient_min'') | float(0) }}'
actions:
- variables:
preference: '{{ states(''input_select.preferred_studio_lamps'') }}'
sarah_s_lamp_operation: '{{ iif(preference in [''Sarah\''s'', ''Both''], ''on'',
''off'') }}
'
skylar_s_lamp_operation: '{{ iif(preference in [''Skylar\''s'', ''Both''], ''on'',
''off'') }}
'
- action: light.turn_{{ sarah_s_lamp_operation }}
target:
entity_id: light.sarah_s_lamp
- action: light.turn_{{ skylar_s_lamp_operation }}
target:
entity_id: light.skylar_s_lamp
- alias: Toggle Virtual Device Tracker
id: toggle_virtual_device_tracker
mode: queued
triggers:
- trigger: state
entity_id:
- input_boolean.virtual_david
- input_boolean.virtual_maryam
- input_boolean.virtual_mike
- input_boolean.virtual_sarah
- input_boolean.virtual_skylar
to: null
actions:
- variables:
new_state: "{% if trigger.to_state.state == 'on' %}\n home\n{% else %}\n not_home\n\
{% endif %}\n"
topic_suffix: '{{ trigger.to_state.entity_id | replace(''input_boolean.'', '''')
}}'
- action: mqtt.publish
data:
topic: '{{ ''homeassistant/device_tracker/'' ~ topic_suffix }}'
payload: '{{ new_state }}'
- alias: Toggle Jon Phone Stationary Tracker
id: toggle_jon_phone_stationary_tracker
use_blueprint:
path: devices/update_phone_tracker.yaml
input:
wifi_entity: sensor.jon_galaxy_wifi_connection
ssid: White Rabbit
topic_suffix: jon_phone_stationary
- alias: Toggle Mike Phone Stationary Tracker
id: toggle_mike_phone_stationary_tracker
use_blueprint:
path: devices/update_phone_tracker.yaml
input:
wifi_entity: sensor.mike_galaxy_wifi_connection
ssid: White Rabbit
topic_suffix: mike_phone_stationary
- alias: Toggle Sarah Phone Stationary Tracker
id: toggle_sarah_phone_stationary_tracker
use_blueprint:
path: devices/update_phone_tracker.yaml
input:
wifi_entity: sensor.sarah_pixel_wi_fi_connection
ssid: White Rabbit
topic_suffix: sarah_phone_stationary
- alias: Toggle David Phone Stationary Tracker
id: toggle_david_phone_stationary_tracker
use_blueprint:
path: devices/update_phone_tracker.yaml
input:
wifi_entity: sensor.david_s_latest_phone_wi_fi_connection
ssid: White Rabbit
topic_suffix: david_phone_stationary
- alias: Handle Child Tag Scan
id: handle_child_tag_scan
triggers:
- trigger: tag
tag_id: 0c6d2dfd-4ad7-4281-9ec0-54756ed2d539
id: skylar
- trigger: state
entity_id: input_button.skylar_tag_scan
id: skylar_simulated
actions:
- variables:
tracker_entity: '{{ ''device_tracker.'' ~ trigger.id.split(''_'')[0] ~ ''_nfc_tag''
}}'
new_state: "{% if states(tracker_entity) != 'home' %}\n home\n{% else %}\n\
\ not_home\n{% endif %}\n"
topic_suffix: '{{ tracker_entity.split(''.'')[1] }}'
toggle_action: '{{ iif(new_state == ''home'', ''on'', ''off'') }}'
- action: mqtt.publish
data:
topic: '{{ ''homeassistant/device_tracker/'' ~ topic_suffix }}'
payload: '{{ new_state }}'
- alias: Set Sleep Start
id: set_sleep_start
triggers:
- trigger: state
entity_id: binary_sensor.jon_sleeping
to: 'on'
actions:
- action: input_datetime.set_datetime
target:
entity_id: input_datetime.sleep_start
data:
datetime: '{{ now().strftime(''%Y-%m-%d %H:%M:%S'') }}'
- alias: Handle Jon Awake
id: handle_jon_awake
triggers:
- trigger: state
entity_id: binary_sensor.jon_sleeping
from: 'on'
to: 'off'
actions:
- variables:
duration: '{{ ((as_timestamp(now().strftime(''%Y-%m-%d %H:%M:%S'')) - as_timestamp(states(''input_datetime.sleep_start'')))
/ 3600) | round(2) }}'
echo_list: '{{ expand(integration_entities(''alexa_media'') | select(''search'',
''media_player'')) | rejectattr(''attributes.friendly_name'', ''in'', [''This
Device'', ''Everywhere'']) | map(attribute = ''entity_id'') | list }}'
- action: input_boolean.turn_off
entity_id:
- input_boolean.nighttime
- input_boolean.sleeptime
- action: script.turn_on
target:
entity_id: script.reset_bedtime_environment
- action: input_number.set_value
target:
entity_id: input_number.sleep_duration
data:
value: '{{ duration }}'
- delay:
milliseconds: 500
- variables:
normal_volume: 0.5
quiet_volume: 0.3
- repeat:
for_each: '{{ echo_list }}'
sequence:
- variables:
volume: '{{ iif((repeat.item).split(''.'')[1] == ''master_bedroom_echo'',
quiet_volume, normal_volume) }}'
- if:
- '{{ not is_state_attr(repeat.item, ''volume_level'', volume) }}'
then:
- action: media_player.volume_set
target:
entity_id: '{{ repeat.item }}'
data:
volume_level: '{{ volume }}'
- repeat:
until: '{{ is_state(''switch.master_bedroom_echo_do_not_disturb_switch'', ''off'')
}}'
sequence:
- event: unused_event
- delay:
milliseconds: 10
- variables:
time: '{{ states(''sensor.sleep_duration_display'') }}'
hours: '{{ time.split('':'')[0] | int(0) }}'
minutes: '{{ time.split('':'')[1] | int(0) }}'
hours_str: '{{ iif(hours == 1, ''hour'', ''hours'') }}'
minutes_str: '{{ iif(minutes == 1, ''minute'', ''minutes'') }}'
keys: '{{ state_attr(''sensor.mobile_tag_registry_keys'', ''tags'') }}'
calendar: '{{ iif(''calendar_appointment'' in keys or ''calendar_home'' in keys,
true, false) }}'
- action: script.send_notification
data:
destination:
- voice_assistant
message: "{% set msg = 'Good morning. You slept ' ~ hours ~ ' ' ~ hours_str\
\ ~ iif(minutes | int(0) > 0, ' and ' ~ minutes ~ ' ' ~ minutes_str ~ '.',\
\ '.') %} {% if calendar == true %}\n {% set msg = msg + ' Also, check your\
\ phone for upcoming calendar items.' %}\n{% endif %}\n{{ msg }}\n"
room:
- master_bedroom
voice_type: tts
- if:
- condition: numeric_state
entity_id: sensor.downstairs_sensor_ambient_light
below: input_number.family_room_ambient_max
then:
- action: scene.turn_on
target:
entity_id: scene.voice_assistants_on_dim
else:
- action: scene.turn_on
target:
entity_id: scene.voice_assistants_on_bright
- wait_template: '{{ is_state(''script.modify_master_suite'', ''off'') }}'
- action: media_player.volume_set
target:
entity_id: media_player.master_bedroom_echo
data:
volume_level: '{{ normal_volume }}'
- action: script.turn_on_lights_per_conditions
data:
light_entity: light.kitchen_island
lux_entity: sensor.downstairs_sensor_ambient_light
min_lux_value: '{{ states(''input_number.kitchen_ambient_min'') | float(0) }}'
- alias: Resume Cinema
id: resume_cinema
trace:
stored_traces: 20
trigger:
- platform: state
entity_id: media_player.shield_tv
from:
- paused
- idle
to: playing
for: 00:00:02
condition:
- condition: state
entity_id: input_boolean.theater_open
state: 'on'
action:
- service: script.restore_lighting_on_resume
- alias: Close Cinema
id: close_cinema
trigger:
- platform: state
entity_id: sensor.harmony_hub
to: PowerOff
condition:
- condition: state
entity_id: input_boolean.theater_open
state: 'on'
action:
- service: script.close_cinema
- alias: Handle Cinema Usage Delay
id: handle_cinema_usage_delay
trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.cinema_usage_delay
action:
- if:
- '{{ states(''input_boolean.theater_open'') == ''off'' }}'
then:
- service: script.open_cinema
else:
- service: script.close_cinema
- alias: Handle Projector Error
id: handle_projector_error
triggers:
- trigger: event
event_type: system_log_event
event_data:
name: custom_components.epson_projector_link.projector.projector
level: ERROR
conditions: '{{ ''Lamp ON failure'' in trigger.event.data.message[0] }}'
actions:
- variables:
delay_time: 00:02:30
- action: input_boolean.turn_on
target:
entity_id: input_boolean.projector_error_handling
- action: script.send_notification
data:
destination:
- voice_assistant
message: Projector lamp error detected. Please wait a few minutes while I try
to fix it.
room:
- family_room
- theater
voice_type: announce
- delay: '{{ delay_time }}'
- action: script.send_notification
data:
destination:
- voice_assistant
message: I'm resetting the projector.
room:
- family_room
- theater
voice_type: tts
- action: input_boolean.turn_on
entity_id: input_boolean.projector_plug_powered_off
- action: switch.turn_off
entity_id: switch.projector
- delay: 00:00:30
- action: switch.turn_on
entity_id: switch.projector
- delay: 00:00:01
- action: input_boolean.turn_off
entity_id: input_boolean.projector_plug_powered_off
- action: script.send_notification
data:
destination:
- voice_assistant
message: I'm turning the projector back on. Keep your fingers crossed!
room:
- family_room
- theater
voice_type: tts
- delay: 00:00:05
- action: remote.send_command
entity_id: remote.harmony_hub
data:
command: PowerOn
device: Epson Projector
- wait_template: '{{ states(''media_player.epson_projector'') in [''warmup'', ''on'']
or is_state(''input_boolean.projector_active'', ''on'') }}'
timeout: '{{ delay_time }}'
- if:
- '{{ states(''media_player.epson_projector'') in [''warmup'', ''on''] or is_state(''input_boolean.projector_active'',
''on'') }}'
then:
- action: input_boolean.turn_off
target:
entity_id: input_boolean.projector_error_handling
- alias: Toggle Projector Active
id: toggle_projector_active
triggers:
- trigger: numeric_state
entity_id: sensor.projector_power
above: 250
for:
seconds: 10
id: 'on'
- trigger: numeric_state
entity_id: sensor.projector_power
below: 250
for:
seconds: 10
id: 'off'
actions:
- variables:
projector_state1: '{{ states(''media_player.epson_projector'') }}'
projector_error1: '{{ states(''input_boolean.projector_error_handling'') }}'
projector_active1: '{{ states(''input_boolean.projector_active'') }}'
- action: input_boolean.turn_{{ trigger.id }}
target:
entity_id: input_boolean.projector_active
- delay: 00:00:01
- variables:
projector_state2: '{{ states(''media_player.epson_projector'') }}'
projector_error2: '{{ states(''input_boolean.projector_error_handling'') }}'
projector_active2: '{{ states(''input_boolean.projector_active'') }}'
- action: system_log.write
data:
message: '{{ ''Projector active changed from '' ~ projector_active1 ~ '' to
'' ~ projector_active2 }}'
level: info
- alias: Determine Projector State
id: determine_projector_state
triggers:
- trigger: template
value_template: '{{ (states(''media_player.epson_projector'') in [''warmup'',
''on''] and is_state(''input_boolean.projector_error_handling'', ''off'')) or
is_state(''input_boolean.projector_active'', ''on'') }}'
id: success
- trigger: event
event_type: timer.finished
event_data:
entity_id: timer.projector_status
id: failure
actions:
- if:
- '{{ trigger.id == ''success'' }}'
then:
- action: timer.cancel
target:
entity_id: timer.projector_status
- action: script.turn_on
entity_id: script.perform_post_open_tasks
else:
- if:
- '{{ not (states(''media_player.epson_projector'') in [''warmup'', ''on'']
and is_state(''input_boolean.projector_error_handling'', ''off'')) or is_state(''input_boolean.projector_active'',
''on'') }}'
then:
- action: script.send_notification
data:
destination:
- voice_assistant
message: I'm sorry, but I failed to fix a projector lamp error.
room:
- family_room
- theater
voice_type: announce
- alias: Log Projector State
id: log_projector_state
triggers:
- trigger: state
entity_id: media_player.epson_projector
to: null
actions:
- action: system_log.write
data:
message: '{{ ''Projector state changed from '' ~ trigger.from_state.state ~
'' to '' ~ trigger.to_state.state }}'
level: info
- alias: Initialize Turn On Volume
id: initialize_turn_on_volume
trigger:
- platform: state
entity_id: media_player.marantz_sr7012
from: 'off'
to: 'on'
action:
- delay: 00:00:30
- service: media_player.volume_set
data:
entity_id: media_player.marantz_sr7012
volume_level: 0.6
- alias: Initialize Application Volume
id: initialize_application_volume
trigger:
- platform: state
entity_id: input_number.selected_app_volume
to: null
action:
- variables:
selected_app: '{{ states(''input_select.volume_application'').replace('' '',
''_'') | lower }}'
selected_app_volume_entity: '{{ ''input_number.'' ~ selected_app ~ ''_volume''
}}'
- service: script.set_application_volume
data:
volume_entity: '{{ selected_app_volume_entity }}'
volume: '{{ trigger.to_state.state }}'
- alias: Initialize Amazon Prime Volume
id: initialize_amazon_prime_volume
use_blueprint:
path: theater/shield_app_volume.yaml
input:
appl_name: Amazon Prime
- alias: Initialize AMC Plus Volume
id: initialize_amc_plus_volume
use_blueprint:
path: theater/shield_app_volume.yaml
input:
appl_name: AMC+
- alias: Initialize Disney Plus Volume
id: initialize_disney_plus_volume
use_blueprint:
path: theater/shield_app_volume.yaml
input:
appl_name: Disney+
- alias: Initialize ESPN Volume
id: initialize_espn_volume
use_blueprint:
path: theater/shield_app_volume.yaml
input:
appl_name: ESPN
- alias: Initialize HBO Max Volume
id: initialize_hbo_max_volume
use_blueprint:
path: theater/shield_app_volume.yaml
input:
appl_name: HBO Max
- alias: Initialize Hulu Volume
id: initialize_hulu_volume
use_blueprint:
path: theater/shield_app_volume.yaml
input:
appl_name: Hulu
- alias: Initialize Kodi Volume
id: initialize_kodi_volume
use_blueprint:
path: theater/shield_app_volume.yaml
input:
appl_name: Kodi
- alias: Initialize Netflix Volume
id: initialize_netflix_volume
use_blueprint:
path: theater/shield_app_volume.yaml
input:
appl_name: Netflix
- alias: Initialize Paramount Plus Volume
id: initialize_paramount_plus_volume
use_blueprint:
path: theater/shield_app_volume.yaml
input:
appl_name: Paramount+
- alias: Initialize Peacock Volume
id: initialize_peacock_volume
use_blueprint:
path: theater/shield_app_volume.yaml
input:
appl_name: Peacock
- alias: Initialize Youtube TV Volume
id: initialize_youtube_tv_volume
use_blueprint:
path: theater/shield_app_volume.yaml
input:
appl_name: Youtube TV
- alias: Initialize Bluray Volume
id: initialize_bluray_volume
use_blueprint:
path: theater/harmony_device_volume.yaml
input:
device_name: BD Player
- alias: Initialize Laserdisc Volume
id: initialize_laserdisc_volume
use_blueprint:
path: theater/harmony_device_volume.yaml
input:
device_name: LD Player
- alias: Save Feature Movie Name
id: save_feature_movie_name
trigger:
- platform: state
entity_id: input_select.kodi_movies
condition:
- condition: state
entity_id: input_boolean.kodi_movie_list_restoration
state: 'off'
- '{{ ( trigger.to_state.state ) != ( ''Select'' ) and ( trigger.to_state.state
) != ( ''unknown'' ) }}'
action:
- service: system_log.write
data:
message: 'feature movie name: ''{{ trigger.to_state.state }}'''
level: debug
- service: input_text.set_value
data_template:
entity_id: input_text.current_feature
value: '{{ ( trigger.to_state.state ) }}'
- alias: Process Kodi Command Result
id: process_kodi_command_result
mode: queued
triggers:
- trigger: event
event_type: kodi_call_method_result
event_data:
result_ok: true
input:
method: VideoLibrary.GetMovies
id: movies
- trigger: event
event_type: kodi_call_method_result
event_data:
result_ok: true
input:
method: VideoLibrary.GetMusicVideos
id: videos
- trigger: event
event_type: kodi_call_method_result
event_data:
result_ok: true
input:
method: VideoLibrary.GetMovieSets
id: sets
- trigger: event
event_type: kodi_call_method_result
event_data:
result_ok: false
id: bad
actions:
- choose:
- conditions: '{{ trigger.id == ''movies'' }}'
sequence:
- choose:
- conditions: '{{ trigger.event.data.result.limits.total == 1 }}'
sequence:
- action: script.process_single_kodi_movie_result
data:
result: '{{ trigger.event.data.result }}'
- conditions: '{{ trigger.event.data.result.limits.total > 1 }}'
sequence:
- action: script.process_all_kodi_movies_result
data:
result: '{{ trigger.event.data.result }}'
default:
- action: system_log.write
data:
message: Kodi GetMovies command returned 0 results.
level: warning
- conditions: '{{ trigger.id == ''videos'' }}'
sequence:
- action: script.process_kodi_videos_result
data:
result: '{{ trigger.event.data.result }}'
- conditions: '{{ trigger.id == ''sets'' }}'
sequence:
- action: input_boolean.turn_on
target:
entity_id: input_boolean.kodi_activated
default:
- action: system_log.write
data:
message: Kodi {{ trigger.event.data.input.method }} call failed.
level: warning
- alias: Handle Kodi Video Call Error
id: handle_kodi_video_call_error
triggers:
- trigger: event
event_type: system_log_event
event_data:
name: homeassistant.components.kodi.media_player
level: WARNING
conditions:
- '{{ ''TransportError trying to run API method media_player.kodi.VideoLibrary.GetMusicVideos''
in trigger.event.data.message[0] }}'
actions:
- action: input_boolean.turn_on
data:
entity_id: input_boolean.kodi_video_call_error
- alias: Update Last Alexa Device
id: update_last_alexa_device
mode: queued
triggers:
- trigger: state
entity_id:
- media_player.family_room_echo
- media_player.master_bedroom_echo
- media_player.office_echo
- media_player.penthouse_echo
- media_player.studio_echo
- media_player.theater_echo
attribute: last_called
to: true
actions:
- event: update_last_alexa_sensor
- alias: Update Last Nabu Device
id: update_last_nabu_device
triggers:
- trigger: state
entity_id:
- assist_satellite.family_room_nabu_assist_satellite
- assist_satellite.office_nabu_assist_satellite
- assist_satellite.studio_nabu_assist_satellite
- assist_satellite.theater_nabu_assist_satellite
from: listening
to: processing
actions:
- if:
- '{{ states(''input_text.last_nabu_device'') == trigger.entity_id }}'
then:
- action: input_text.set_value
target:
entity_id: input_text.last_nabu_device
data:
value: reset
- action: input_text.set_value
target:
entity_id: input_text.last_nabu_device
data:
value: '{{ trigger.entity_id }}'