AutomationDataset/skdw/skdw_automations.yaml

472 lines
14 KiB
YAML

- id: kitchen_hood
alias: YAML Kitchen Hood Control
description: Automatically manages the kitchen hood state based on whether the cooktop
is on or off and the status of the countertop lights.
trigger:
- platform: state
entity_id: binary_sensor.cooktop_power
to: 'on'
alias: When cooktop turned ON
- platform: state
entity_id: binary_sensor.cooktop_power
to: 'off'
alias: When cooktop turned OFF
- platform: state
entity_id: light.kitchen_countertop
to: 'off'
alias: When countertop turned OFF
condition:
alias: Conditions per trigger
condition: or
conditions:
- condition: and
alias: When cooktop turned ON and outlet is OFF
conditions:
- condition: trigger
id: 0
- condition: state
entity_id: switch.outlet_kitchen_hood
state: 'off'
- condition: and
alias: When cooktop turned OFF and outlet is ON and countertop is OFF
conditions:
- condition: trigger
id: 1
- condition: state
entity_id: switch.outlet_kitchen_hood
state: 'on'
- condition: state
entity_id: light.kitchen_countertop
state: 'off'
- condition: and
alias: When countertop turned ON and outlet is ON
conditions:
- condition: trigger
id: 2
- condition: state
entity_id: switch.outlet_kitchen_hood
state: 'on'
action:
- service: '{{ ''switch.turn_on'' if(trigger.to_state.state == ''on'') else ''switch.turn_off''
}}'
alias: Toggle the hood outlet
target:
entity_id: switch.outlet_kitchen_hood
mode: single
- id: home_presence_count_enabled
alias: Home presence - count enabled switches
description: Count enabled switches for home presence estimation
mode: queued
max: 50
trigger:
- platform: state
entity_id: include ../entities/home_presence.yaml
condition: '{{ trigger.from_state.state = trigger.to_state.state and trigger.from_state.state
in [''off'', ''on''] and trigger.to_state.state in [''off'', ''on''] }}'
action:
- action: '{{ ''counter.decrement'' if trigger.to_state.state == ''off'' else ''counter.increment''
}}'
target:
entity_id: counter.switches_enabled
- id: hvac_turn_off
alias: YAML HVAC turn off on leak sensor
trigger:
- platform: state
entity_id: binary_sensor.air_cond_leakage
to: 'on'
condition:
not:
- condition: state
entity_id: climate.air_conditioner
state: 'off'
action:
- service: climate.set_hvac_mode
target:
entity_id: climate.air_conditioner
data:
hvac_mode: 'off'
- service: notify.mobile_app_iphone_kamil
data:
message: Air conditioner turned off - the water container is full
mode: single
- id: lights_dim_on_toggle
alias: YAML Lights - dim on toggle
description: Adjusts lights brightness and temperature to day/night time
trigger:
- platform: state
entity_id:
- input_boolean.lights_dim
action:
- variables:
entities:
- id: light.wardrobe_ceiling
previous_state: '{{ states(''light.wardrobe_ceiling'') }}'
- id: light.wardrobe_clothes
previous_state: '{{ states(''light.wardrobe_clothes'') }}'
- id: light.bathroom_ceiling
previous_state: '{{ states(''light.bathroom_ceiling'') }}'
- id: light.bathroom_mirror
previous_state: '{{ states(''light.bathroom_mirror'') }}'
color_temp_kelvin: '{{ 3600 if (states(''input_boolean.lights_dim'') == ''on'')
else 2000 }}'
brightness_pct: '{{ 30 if (states(''input_boolean.lights_dim'') == ''on'') else
1 }}'
- service: light.turn_on
data:
color_temp_kelvin: '{{ color_temp_kelvin }}'
brightness_pct: '{{ brightness_pct }}'
target:
entity_id: '{{ entities | map(attribute=''id'') | list }}'
- delay:
seconds: 2
- service: light.turn_off
target:
entity_id: '{{ entities | selectattr(''previous_state'', ''eq'', ''off'') |
map(attribute=''id'') | list }}'
mode: single
- id: lights_dim_on_morning
alias: YAML lights - dim on morning
trigger:
- platform: time
at: 06:30:00
action:
- service: input_boolean.turn_on
target:
entity_id:
- input_boolean.lights_dim
mode: single
- id: lights_dim_on_evening
alias: YAML lights - dim on evening
trigger:
- platform: time
at: '22:00:00'
action:
- service: input_boolean.turn_off
target:
entity_id:
- input_boolean.lights_dim
mode: single
- id: lights_switch2light
alias: YAML Lights - On switch toggle light
variables:
lights: include ../entities/lights.yaml
switches: include ../entities/switches.yaml
mode: parallel
max: 20
trigger:
- platform: state
entity_id: include ../entities/switches.yaml
condition:
- condition: template
value_template: '{{ states(lights[switches.index(trigger.entity_id)]) == trigger.from_state.state
}}'
- condition: template
value_template: '{{ trigger.to_state.state == ''on'' or trigger.to_state.state
== ''off'' }}'
action:
- service: '{{ ''light.turn_on'' if(trigger.to_state.state == ''on'') else ''light.turn_off''
}}'
target:
entity_id: '{{ lights[switches.index(trigger.entity_id)] }}'
- id: lights_light2switch
alias: YAML Lights - On light toggle switch
variables:
lights: include ../entities/lights.yaml
switches: include ../entities/switches.yaml
mode: parallel
max: 20
trigger:
- platform: state
entity_id: include ../entities/lights.yaml
condition:
- condition: template
value_template: '{{ states(switches[lights.index(trigger.entity_id)]) == trigger.from_state.state
}}'
- condition: template
value_template: '{{ trigger.to_state.state == ''on'' or trigger.to_state.state
== ''off'' }}'
action:
- service: '{{ ''switch.turn_on'' if(trigger.to_state.state == ''on'') else ''switch.turn_off''
}}'
target:
entity_id: '{{ switches[lights.index(trigger.entity_id)] }}'
- id: light-tripleclick
alias: YAML actions on light switch triple click
description: Automates actions triggered on light switch triple-click
variables:
switches: include ../entities/light_tripleclick_switches.yaml
actions: include ../entities/light_tripleclick_actions.yaml
trigger:
- platform: state
entity_id: include ../entities/light_tripleclick_switches.yaml
action:
- wait_template: '{{ states(trigger.entity_id) = trigger.to_state.state }}'
timeout:
seconds: 1
continue_on_timeout: false
- wait_template: '{{ states(trigger.entity_id) == trigger.to_state.state }}'
timeout:
seconds: 1
continue_on_timeout: false
- delay:
milliseconds: 500
- action: '{{ actions[switches.index(trigger.entity_id)][''action''] }}'
target:
entity_id: '{{ actions[switches.index(trigger.entity_id)][''target''] }}'
mode: single
max_exceeded: silent
- id: media_radio_fm_update
alias: Radio FM station update
mode: single
triggers:
- entity_id: input_select.radio_fm
trigger: state
variables:
preset_id: '{{ state_attr(''input_select.radio_fm'', ''options'').index(trigger.to_state.state)
+ 1 }}'
actions:
- action: media_player.onkyo_command
data:
entity_id: media_player.pioneer_onkyo
iscp_command: preset
iscp_value: '{{ preset_id }}'
- id: media-radio-net
alias: YAML Media - Play Radio NET
mode: single
triggers:
- trigger: state
entity_id: input_select.media_radio_net
variables:
stations: include ../entities/media_radio_net_stations.yaml
actions:
- alias: Check the media player availability
if:
- condition: template
value_template: '{{ has_value(''media_player.pioneer_dlna'') == False }}'
then:
- stop: Target media_player.pioneer_dlna is not available
- alias: Get the NET radio station
variables:
station: '{{ stations | selectattr(''name'', ''eq'', trigger.to_state.state)
| first }}'
- alias: Play NET media
action: media_player.play_media
target:
entity_id: media_player.pioneer_dlna
data:
media_content_id: '{{ station[''url''] }}'
media_content_type: audio/aac
- id: media-radio-net-select-return
alias: YAML Media - Radio NET selector reset to 'Other'
mode: single
triggers:
- trigger: state
entity_id: media_player.pioneer_dlna
attribute: media_content_id
variables:
radio_net_stations: include ../entities/media_radio_net_stations.yaml
radio_net_stations_urls: '{{ radio_net_stations | map(attribute=''url'') | list
}}'
conditions:
- '{{ trigger.to_state.state not in radio_net_stations_urls }}'
actions:
- action: input_select.select_option
target:
entity_id: input_select.media_radio_net
data:
option: Other
- id: media_sound_mode
alias: Sound Mode update
mode: single
triggers:
- entity_id: input_select.sound_mode
trigger: state
variables:
listening_mode_value:
Auto: auto-surround
Extended: all-ch-stereo
Surround: dolby-atmos
Desk: full-mono
cmt_message:
Auto: CMT00000000000000000000000000
Extended: CMT00000000000000000000000000
Surround: CMT00000000000000000000000000
Desk: CMT00010100010000000000000000
tcl_message:
Auto: TCL000000+02-01000000000-01000000000000000
Extended: TCL-0C000+02+0E+0A000000-04000000000000000
Surround: TCL000000+02-01000000000-01000000000000000
Desk: TCL000-01+02+18000000000-04000000000000000
actions:
- action: media_player.onkyo_command
data:
entity_id: media_player.pioneer_onkyo
iscp_command: listening-mode
iscp_value: '{{ listening_mode_value[trigger.to_state.state] }}'
- action: media_player.onkyo_message
data:
entity_id: media_player.pioneer_onkyo
iscp_message: '{{ cmt_message[trigger.to_state.state] }}'
- action: media_player.onkyo_message
data:
entity_id: media_player.pioneer_onkyo
iscp_message: '{{ tcl_message[trigger.to_state.state] }}'
- id: mqtt_knob
alias: MQTT knob
mode: queued
triggers:
- topic: zigbee2mqtt/Remote Bathroom audio knob
trigger: mqtt
- topic: zigbee2mqtt/Remote Bedroom audio knob
trigger: mqtt
conditions:
- condition: template
value_template: '{{ ''action'' in trigger.payload_json }}'
actions:
- variables:
media_player_entity: '{{ ''media_player.pioneer_onkyo_zone_2'' if (trigger.id
== ''0'') else ''media_player.pioneer_onkyo_zone_3'' }}'
command: '{{ trigger.payload_json.action }}'
step_size: '{{ trigger.payload_json.action_step_size }}'
step_percent: '{% if is_number(step_size) %} {{ (step_size * 0.0005 ) | float
}} {% else %} {{ 0 }} {% endif %}'
- choose:
- conditions:
- condition: template
value_template: '{{ command == ''toggle'' }}'
sequence:
- if:
- condition: template
value_template: '{{ states(media_player_entity) == "on" }}'
then:
- target:
entity_id: '{{ media_player_entity }}'
data: {}
action: media_player.turn_off
else:
- target:
entity_id: '{{ media_player_entity }}'
data: {}
action: media_player.turn_on
enabled: true
- conditions:
- condition: template
value_template: '{{ states(media_player_entity) == "on" }}'
- condition: template
value_template: '{{ command == ''brightness_step_down'' }}'
sequence:
- target:
entity_id: '{{ media_player_entity }}'
data:
volume_level: '{{ state_attr(media_player_entity, ''volume_level'') - step_percent
}}'
action: media_player.volume_set
- conditions:
- condition: template
value_template: '{{ states(media_player_entity) == "on" }}'
- condition: template
value_template: '{{ command == ''brightness_step_up'' }}'
sequence:
- target:
entity_id: '{{ media_player_entity }}'
data:
volume_level: '{{ state_attr(media_player_entity, ''volume_level'') + step_percent
}}'
action: media_player.volume_set
- alias: Remote menu publish MQTT
id: mqtt_remote_menu_publish
description: ''
mode: parallel
max: 20
triggers:
- trigger: state
entity_id: sensor.remote_menu_line_1
- trigger: state
entity_id: sensor.remote_menu_line_2
- trigger: state
entity_id: sensor.remote_menu_line_3
- trigger: state
entity_id: sensor.remote_menu_line_4
- trigger: state
entity_id: sensor.remote_menu_line_5
conditions: []
actions:
- action: mqtt.publish
metadata: {}
data:
evaluate_payload: false
qos: '1'
retain: false
topic: homeassistant/remote_menu/line_{{ trigger.id }}
payload: '{{ trigger.to_state.state }}'
- id: presence-lights
alias: YAML Presence lights
description: Automates lights basing on user presence
variables:
sensors: include ../entities/presence_sensors.yaml
lights:
- light.living_room_sofa
- light.living_room_desk
- light.kitchen_countertop
trigger:
- platform: state
entity_id: include ../entities/presence_sensors.yaml
condition:
- condition: state
entity_id: input_boolean.presence_lights
state: 'on'
action:
- service: '{{ ''light.turn_on'' if(trigger.to_state.state == ''on'') else ''light.turn_off''
}}'
target:
entity_id: '{{ lights[sensors.index(trigger.entity_id)] }}'
mode: parallel
- id: presence-speakers
alias: YAML Presence speakers
description: Automates sound mode basing on user presence
variables:
presence_sensors: include ../entities/presence_sensors.yaml
sound_modes:
- Auto
- Desk
- Extended
trigger:
- platform: state
entity_id: include ../entities/presence_sensors.yaml
to: 'on'
condition:
- condition: state
entity_id: input_boolean.presence_speakers
state: 'on'
action:
- service: input_select.select_option
data:
option: '{{ sound_modes[presence_sensors.index(trigger.entity_id)] }}'
target:
entity_id: input_select.sound_mode
mode: single
- id: on-startup
alias: On Startup
mode: single
triggers:
- trigger: homeassistant
event: start
conditions: null
actions:
- alias: Populate input_select.media_radio_net options
sequence:
- variables:
stations: include ../entities/media_radio_net_stations.yaml
stations_names: '{{ (stations | map(attribute=''name'') | list) + [''Other'']
}}'
- service: input_select.set_options
target:
entity_id: input_select.media_radio_net
data:
options: '{{ stations_names }}'
- action: frontend.set_theme
metadata: {}
data:
mode: dark
name: skynet