AutomationDataset/Fouppy/Fouppy_automations.yaml

553 lines
15 KiB
YAML

- alias: 'Control switches: kitchen Rodret dimmer switch sink'
mode: restart
max_exceeded: silent
triggers:
- trigger: event
event_type: zha_event
event_data:
command: 'on'
cluster_id: 6
endpoint_id: 1
id: press-on-zha
- trigger: event
event_type: zha_event
event_data:
command: 'off'
cluster_id: 6
endpoint_id: 1
id: press-off-zha
- trigger: event
event_type: zha_event
event_data:
command: move_with_on_off
cluster_id: 8
endpoint_id: 1
id: hold-on-zha
- trigger: event
event_type: zha_event
event_data:
command: move
cluster_id: 8
endpoint_id: 1
id: hold-off-zha
- trigger: event
event_type: zha_event
event_data:
command: stop_with_on_off
endpoint_id: 1
cluster_id: 8
id: release-zha
variables:
helper_force_brightness: false
helper_hold_delay: 0.1
helper_hold_dim_step: 4
light: light.kitchen_sink
remote_devices:
- df5b9b63c997a2417895397f2d10f3bf
remote_devices_names: '{{ remote_devices | map(''device_attr'', ''name'') | list
}}'
actions:
- choose:
- conditions:
- condition: trigger
id: press-on-zha
sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ helper_force_brightness }}'
sequence:
- action: light.turn_on
target:
entity_id: light.kitchen_sink
data:
brightness_pct: 50
default:
- action: light.turn_on
target:
entity_id: light.kitchen_sink
data: {}
- conditions:
- condition: trigger
id: press-off-zha
sequence:
- action: light.turn_off
target:
entity_id: light.kitchen_sink
data: {}
- conditions:
- condition: trigger
id: hold-on-zha
sequence:
- repeat:
while:
- condition: trigger
id: hold-on-zha
sequence:
- parallel:
- action: light.turn_on
target:
entity_id: light.kitchen_sink
data:
brightness_step_pct: '{{ helper_hold_dim_step }}'
transition: '{{ helper_hold_delay }}'
- delay: '{{ helper_hold_delay }}'
- conditions:
- condition: trigger
id: hold-off-zha
sequence:
- variables:
brightness_pct: '{{ iif(is_state(light, ''on''), state_attr(light, ''brightness''),
0) * 100 / 255 }}'
total_iterations_to_zero: '{{ (brightness_pct / helper_hold_dim_step) |
round(0, ''ceil'') }}'
- repeat:
count: '{{ total_iterations_to_zero - 1 }}'
sequence:
- parallel:
- action: light.turn_on
target:
entity_id: light.kitchen_sink
data:
brightness_step_pct: '{{ helper_hold_dim_step | int * -1 }}'
transition: '{{ helper_hold_delay }}'
- delay: '{{ helper_hold_delay }}'
- action: light.turn_on
target:
entity_id: light.kitchen_sink
data:
brightness_pct: 1
transition: '{{ helper_hold_delay }}'
conditions:
- condition: template
value_template: '{{ (trigger.event.data.device_id in remote_devices) }}'
- alias: 'Control switches: kitchen Rodret dimmer switch counters'
mode: restart
max_exceeded: silent
triggers:
- trigger: event
event_type: zha_event
event_data:
command: 'on'
cluster_id: 6
endpoint_id: 1
id: press-on-zha
- trigger: event
event_type: zha_event
event_data:
command: 'off'
cluster_id: 6
endpoint_id: 1
id: press-off-zha
- trigger: event
event_type: zha_event
event_data:
command: move_with_on_off
cluster_id: 8
endpoint_id: 1
id: hold-on-zha
- trigger: event
event_type: zha_event
event_data:
command: move
cluster_id: 8
endpoint_id: 1
id: hold-off-zha
- trigger: event
event_type: zha_event
event_data:
command: stop_with_on_off
endpoint_id: 1
cluster_id: 8
id: release-zha
variables:
helper_force_brightness: false
helper_hold_delay: 0.1
helper_hold_dim_step: 4
light: light.kitchen_countertop
remote_devices:
- df5b9b63c997a2417895397f2d10f3bf
remote_devices_names: '{{ remote_devices | map(''device_attr'', ''name'') | list
}}'
actions:
- choose:
- conditions:
- condition: trigger
id: press-on-zha
sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ helper_force_brightness }}'
sequence:
- action: light.turn_on
target:
entity_id: light.kitchen_countertop
data:
brightness_pct: 50
default:
- action: light.turn_on
target:
entity_id: light.kitchen_countertop
data: {}
- conditions:
- condition: trigger
id: press-off-zha
sequence:
- action: light.turn_off
target:
entity_id: light.kitchen_countertop
data: {}
- conditions:
- condition: trigger
id: hold-on-zha
sequence:
- repeat:
while:
- condition: trigger
id: hold-on-zha
sequence:
- parallel:
- action: light.turn_on
target:
entity_id: light.kitchen_countertop
data:
brightness_step_pct: '{{ helper_hold_dim_step }}'
transition: '{{ helper_hold_delay }}'
- delay: '{{ helper_hold_delay }}'
- conditions:
- condition: trigger
id: hold-off-zha
sequence:
- variables:
brightness_pct: '{{ iif(is_state(light, ''on''), state_attr(light, ''brightness''),
0) * 100 / 255 }}'
total_iterations_to_zero: '{{ (brightness_pct / helper_hold_dim_step) |
round(0, ''ceil'') }}'
- repeat:
count: '{{ total_iterations_to_zero - 1 }}'
sequence:
- parallel:
- action: light.turn_on
target:
entity_id: light.kitchen_countertop
data:
brightness_step_pct: '{{ helper_hold_dim_step | int * -1 }}'
transition: '{{ helper_hold_delay }}'
- delay: '{{ helper_hold_delay }}'
- action: light.turn_on
target:
entity_id: light.kitchen_countertop
data:
brightness_pct: 1
transition: '{{ helper_hold_delay }}'
conditions:
- condition: template
value_template: '{{ (trigger.event.data.device_id in remote_devices) }}'
- alias: 'Control switches: office Rodret dimmer switch bookcases'
mode: restart
max_exceeded: silent
triggers:
- trigger: event
event_type: zha_event
event_data:
command: 'on'
cluster_id: 6
endpoint_id: 1
id: press-on-zha
- trigger: event
event_type: zha_event
event_data:
command: 'off'
cluster_id: 6
endpoint_id: 1
id: press-off-zha
- trigger: event
event_type: zha_event
event_data:
command: move_with_on_off
cluster_id: 8
endpoint_id: 1
id: hold-on-zha
- trigger: event
event_type: zha_event
event_data:
command: move
cluster_id: 8
endpoint_id: 1
id: hold-off-zha
- trigger: event
event_type: zha_event
event_data:
command: stop_with_on_off
endpoint_id: 1
cluster_id: 8
id: release-zha
variables:
helper_force_brightness: false
helper_hold_delay: 0.1
helper_hold_dim_step: 4
light: light.office_bookcases
remote_devices:
- 8b9d1a82015ce6dcacc147b0beba435a
remote_devices_names: '{{ remote_devices | map(''device_attr'', ''name'') | list
}}'
actions:
- choose:
- conditions:
- condition: trigger
id: press-on-zha
sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ helper_force_brightness }}'
sequence:
- action: light.turn_on
target:
entity_id: light.office_bookcases
data:
brightness_pct: 50
default:
- action: light.turn_on
target:
entity_id: light.office_bookcases
data: {}
- conditions:
- condition: trigger
id: press-off-zha
sequence:
- action: light.turn_off
target:
entity_id: light.office_bookcases
data: {}
- conditions:
- condition: trigger
id: hold-on-zha
sequence:
- repeat:
while:
- condition: trigger
id: hold-on-zha
sequence:
- parallel:
- action: light.turn_on
target:
entity_id: light.office_bookcases
data:
brightness_step_pct: '{{ helper_hold_dim_step }}'
transition: '{{ helper_hold_delay }}'
- delay: '{{ helper_hold_delay }}'
- conditions:
- condition: trigger
id: hold-off-zha
sequence:
- variables:
brightness_pct: '{{ iif(is_state(light, ''on''), state_attr(light, ''brightness''),
0) * 100 / 255 }}'
total_iterations_to_zero: '{{ (brightness_pct / helper_hold_dim_step) |
round(0, ''ceil'') }}'
- repeat:
count: '{{ total_iterations_to_zero - 1 }}'
sequence:
- parallel:
- action: light.turn_on
target:
entity_id: light.office_bookcases
data:
brightness_step_pct: '{{ helper_hold_dim_step | int * -1 }}'
transition: '{{ helper_hold_delay }}'
- delay: '{{ helper_hold_delay }}'
- action: light.turn_on
target:
entity_id: light.office_bookcases
data:
brightness_pct: 1
transition: '{{ helper_hold_delay }}'
conditions:
- condition: template
value_template: '{{ (trigger.event.data.device_id in remote_devices) }}'
- alias: 'Leaving: ask to turn off everything'
triggers:
- trigger: state
entity_id: person.fouppy
from: home
- trigger: state
entity_id: person.moom
from: home
conditions:
- condition: state
entity_id:
- binary_sensor.no_one_home
- binary_sensor.anything_on
state: 'on'
actions:
- delay: 00:05:00
- condition: state
entity_id: binary_sensor.no_one_home
state: 'on'
- action: notify.phone_fouppy
data:
message: No one is home, turn off everything?
data:
actions:
- action: TURN_OFF_EVERYTHING
title: Turn off everything
activationMode: background
authenticationRequired: false
destructive: true
- alias: 'Leaving: turn off everything after notification'
triggers:
trigger: event
event_type: mobile_app_notification_action
event_data:
action: TURN_OFF_EVERYTHING
actions:
action: script.leaving
- alias: 'System: warning about high CPU usage'
triggers:
trigger: numeric_state
entity_id: sensor.system_monitor_processor_use
above: 70
for:
hours: 4
actions:
action: notify.phone_fouppy
data:
title: System
message: CPU usage has been above 70% for 4 hours! ⚠️🖥
- alias: 'System: warning about high CPU temperature'
triggers:
trigger: numeric_state
entity_id: sensor.cpu_temperature_mean
above: 70
for:
hours: 4
actions:
action: notify.phone_fouppy
data:
title: System
message: CPU temperature has been above 70 °C for 4 hours! ⚠️
- alias: 'System: battery level low'
triggers:
trigger: time
at: '14:30:00'
variables:
min_battery_level: 50
notify_service: notify.phone_fouppy
battery_ids: ''
current: ''
actions:
- variables:
battery_ids: "{% set ns = namespace(battery=[]) %} {% for s in states.sensor\
\ if 'battery_level' in s.entity_id %}\n {% set ns.battery = ns.battery +\
\ [s] %}\n{% endfor %} {{ ns.battery | map(attribute='entity_id') | list }}\n"
- alias: Repeat
repeat:
count: '{{ battery_ids | length }}'
sequence:
- variables:
current: '{{ battery_ids[repeat.index - 1] }}'
- condition: template
value_template: '{{ ''iphone'' not in current and ''1+8'' not in current }}'
- condition: template
value_template: '{{ 0 < (states(current) | float) < (min_battery_level | float
) }}'
- action: '{{ notify_service }}'
data:
title: System
message: 'Battery level low of {{ current }}: {{ states(current) }}%! ⚠️'
- alias: 'System: SpeedTest'
triggers:
- trigger: time_pattern
hours: /1
conditions: []
actions:
- action: script.update_speedtest
mode: single
- alias: 'Utilities: washing machine or dishwasher started or finished'
triggers:
- trigger: state
entity_id: binary_sensor.dishwasher
- trigger: state
entity_id: binary_sensor.washing_machine
variables:
from_state: '{{ trigger.from_state.state }}'
to_state: '{{ trigger.to_state.state }}'
name: '{{ trigger.entity_id.split(''.'', 1)[1] }}'
conditions: '{{ (to_state == ''on'' and from_state == ''off'') or (to_state == ''off''
and from_state == ''on'') }}'
actions:
action: input_datetime.set_datetime
data:
entity_id: input_datetime.{{ name }}_{{ to_state }}
timestamp: '{{ now().timestamp() }}'
- alias: 'Utilities: washing machine notification'
triggers:
trigger: state
entity_id: binary_sensor.washing_machine
from: 'on'
to: 'off'
actions:
action: script.utility_notification
data:
name: Washing machine
emojis: 👚👕
- alias: 'Utilities: dishwasher notification'
triggers:
trigger: state
entity_id: binary_sensor.dishwasher
from: 'on'
to: 'off'
actions:
action: script.utility_notification
data:
name: Dishwasher
emojis: 🍽🍳
- alias: 'Utilities: switch mosquito plug on'
mode: single
triggers:
- trigger: time
at: '20:00:00'
actions:
- action: switch.turn_on
target:
entity_id: switch.living_room_mosquito_plug
- alias: 'Utilities: switch mosquito plug off'
mode: single
triggers:
- trigger: time
at: 08:00:00
actions:
- action: switch.turn_off
target:
entity_id: switch.living_room_mosquito_plug
- alias: 'Work: Fouppy left work notification for MooM'
triggers:
trigger: state
entity_id: person.fouppy
from: Fouppy Work
conditions:
condition: time
after: '15:00:00'
before: '22:00:00'
actions:
action: notify.phone_moom
data:
title: Work
message: Fouppy has left work! ♥️🎉
- alias: 'Work: MooM left work notification for Fouppy'
triggers:
trigger: state
entity_id: person.moom
from: MooM Work
conditions:
condition: time
after: '15:00:00'
before: '22:00:00'
actions:
action: notify.phone_fouppy
data:
title: Work
message: MooM has left work! ♥️🎉