AutomationDataset/dadav/dadav_automations.yaml

1880 lines
56 KiB
YAML

- id: d84b108c-44e8-4df9-ba5d-2cb83f38dee9
alias: Auto security arming mode
description: 'When I turned on the auto security mode, I want the security
system to be turned on in these conditions:
- When I turned on the away mode
- When I''m sleeping (no devices online and it''s a certain time)'
trigger:
- alias: Away mode turned on
platform: state
entity_id:
- input_boolean.away_mode
from: 'off'
to: 'on'
id: Away mode turned on
- alias: Away mode turned off
platform: state
entity_id:
- input_boolean.away_mode
from: 'on'
to: 'off'
id: Away mode turned off
- alias: Night time check
platform: time_pattern
minutes: /5
id: Night time check
- alias: People home
platform: state
entity_id:
- binary_sensor.people_home
from: 'off'
to: 'on'
id: People are home
condition:
- condition: state
entity_id: input_boolean.auto_security_arming_mode
state: 'on'
action:
- choose:
- conditions:
- alias: Away mode turned on
condition: and
conditions:
- condition: trigger
id: Away mode turned on
- condition: template
value_template: '{{ not is_state(''alarm_control_panel.security_alarm'',
''armed_away'') }}'
sequence:
- alias: Turn on security alarm
service: alarm_control_panel.alarm_arm_away
target:
entity_id: alarm_control_panel.security_alarm
- conditions:
- alias: Away mode turned off
condition: and
conditions:
- condition: trigger
id: Away mode turned off
- condition: state
entity_id: alarm_control_panel.security_alarm
state: armed_away
sequence:
- &id001
alias: Arm home
service: alarm_control_panel.alarm_arm_home
target:
entity_id: alarm_control_panel.security_alarm
- conditions:
- alias: Night time
condition: and
conditions:
- condition: trigger
id: Night time check
- condition: state
entity_id: binary_sensor.probably_sleeping
state: 'on'
- condition: template
value_template: '{{ not is_state(''alarm_control_panel.security_alarm'',
''armed_night'') }}'
sequence:
- alias: Turn on security alarm
service: alarm_control_panel.alarm_arm_night
target:
entity_id: alarm_control_panel.security_alarm
- conditions:
- alias: Day time
condition: and
conditions:
- condition: trigger
id: Night time check
- condition: state
entity_id: binary_sensor.probably_sleeping
state: 'off'
- condition: state
entity_id: alarm_control_panel.security_alarm
state: armed_night
sequence:
- *id001
- conditions:
- alias: People are home
condition: and
conditions:
- condition: trigger
id: People are home
- condition: template
value_template: '{{ not is_state(''alarm_control_panel.security_alarm'',
''armed_home'') }}'
sequence:
- *id001
- id: 3619ec5b-8463-449a-8bf0-5bac911b1ee4
mode: parallel
max_exceeded: silent
alias: Door open notification automation
description: Send a notfication to my phone when the door is open.
trigger:
- platform: state
entity_id:
- binary_sensor.garage_door_contact
- binary_sensor.entrance_door_contact
- binary_sensor.storage_door1_contact
- binary_sensor.storage_door2_contact
action:
- variables:
entity_tag: '{{ ''open_door_tag_'' ~ trigger.entity_id }}'
- choose:
- conditions:
- condition: template
value_template: '{{ is_state(trigger.entity_id, ''on'') }}'
sequence:
- service: notify.mobile_app_pixel_7
data:
title: '{{states[trigger.entity_id].attributes.friendly_name}} is open.'
message: Open since {{ states('sensor.time') }}
data:
notification_icon: mdi:door-open
tag: '{{ entity_tag }}'
sticky: 'true'
actions:
- action: URI
title: Open
uri: entityId:{{trigger.entity_id}}
- conditions:
- condition: template
value_template: '{{ is_state(trigger.entity_id, ''off'') }}'
sequence:
- service: notify.mobile_app_pixel_7
data:
message: clear_notification
data:
tag: '{{ entity_tag }}'
- id: f8700e07-1e98-4c0e-bc76-72cb293811d9
mode: parallel
max_exceeded: silent
alias: Entity unavailable detection
description: This automation notfies me if an entity went unavailable. But also
it deletes the notification if the entity goes into normal state again. I don't
care then...
trigger:
- platform: event
event_type: state_changed
condition:
- condition: template
value_template: "{{\n trigger.event.data.new_state.state == 'unavailable'\n \
\ or trigger.event.data.old_state.state == 'unavailable'\n}}"
variables:
excluded_entities:
- light.lunch_light1
- select.lunch_light1_power_on_behavior
- update.lunch_light1
- light.lunch_light2
- select.lunch_light2_power_on_behavior
- update.lunch_light2
- light.lunch_light3
- select.lunch_light3_power_on_behavior
- update.lunch_light3
- light.bedroom_light1
- select.bedroom_light1_power_on_behavior
- update.bedroom_light1
- light.bedroom_light2
- select.bedroom_light2_power_on_behavior
- update.bedroom_light2
- light.bedroom_light3
- select.bedroom_light3_power_on_behavior
- update.bedroom_light3
- light.bedroom_lights
- button.lg_webos_tv_fa22_identify
- media_player.lg_webos_tv_fa22
- switch.lg_webos_tv_fa22_mute
action:
- variables:
entity_tag: '{{ ''unavailable_tag_'' ~ trigger.event.data.entity_id }}'
- choose:
- conditions:
- condition: template
value_template: "{{\n trigger.event.data.new_state.state == 'unavailable'\n\
\ and trigger.event.data.entity_id not in excluded_entities\n}}"
sequence:
- service: notify.mobile_app_pixel_7
data:
title: Entity {{states[trigger.event.data.entity_id].attributes.friendly_name}}
went unavailable.
message: Whats wrong?
data:
tag: '{{ entity_tag }}'
actions:
- action: URI
title: Open {{trigger.event.data.entity_id}}
uri: entityId:{{trigger.event.data.entity_id}}
- conditions:
- condition: template
value_template: "{{\n trigger.event.data.old_state.state == 'unavailable'\n\
\ and trigger.event.data.entity_id not in excluded_entities\n}}"
sequence:
- service: notify.mobile_app_pixel_7
data:
message: clear_notification
data:
tag: '{{ entity_tag }}'
- id: 659d017f-b25c-447d-8651-488e1a8c3c54
alias: Extractor hood power switcher
trigger:
- platform: state
entity_id: binary_sensor.kitchen_door_contact
action:
- choose:
- conditions: '{{trigger.to_state.state == ''on''}}'
sequence:
- service: homeassistant.turn_on
target:
entity_id: switch.kitchen_powerplug
- conditions: '{{trigger.to_state.state == ''off''}}'
sequence:
- service: homeassistant.turn_off
target:
entity_id: switch.kitchen_powerplug
- id: 0f2f1eeb-b028-470e-b835-cf2a0fb23a1d
mode: queued
max_exceeded: silent
alias: Fire detection automation
description: This automation detects unusualy high temperatures and sends me a notification
in multiple ways.
variables:
maybe_fire_temperature: '{{ states(''input_number.maybe_fire_temperature'') |
int }}'
trigger:
- platform: event
event_type: state_changed
condition:
- condition: template
value_template: "{{\n trigger.event.data.entity_id is match('^sensor\\.[a-z0-9_]+_(?:door|window|temp|co2meter)_temperature')\n\
\ and trigger.event.data.new_state.state | int(0) >= maybe_fire_temperature\n\
}}"
action:
- service: notify.mobile_app_pixel_7
data:
title: Possible fire detected
message: 'This entity triggered the automation was: {{trigger.event.data.entity_id}}'
data:
ttl: 0
priority: high
channel: alarm_stream
notification_icon: mdi:alarm-light
color: red
- service: hassio.addon_stdin
data:
addon: ad61c150_dss_voip
input:
call_sip_uri: secret emergency_sip_uri
message_tts: The sensor {{states[trigger.event.data.entity_id].attributes.friendly_name}}
is getting really hot. Please check it out.
- id: 77d67d99-e18d-4b2f-b4ea-c17b2facc68e
mode: queued
max_exceeded: silent
trace:
stored_traces: 25
alias: Garage detection alarm trigger
description: This automation detects suspicious activity in the garage room. When
this automation is triggered, a security alarm will be triggered.
trigger:
- platform: event
event_type: state_changed
event_data:
entity_id: binary_sensor.garage_door_contact
condition:
- condition: template
value_template: "{{\n trigger.event.data.old_state.state == 'off'\n and trigger.event.data.new_state.state\
\ == 'on'\n and is_state('input_boolean.watch_garage_activities', 'on')\n}}"
action:
- service: input_text.set_value
target:
entity_id: input_text.last_security_alarm_entity
data:
value: '{{state_attr(trigger.event.data.entity_id, ''friendly_name'')}}'
- service: alarm_control_panel.alarm_trigger
target:
entity_id: alarm_control_panel.security_alarm
- id: 20f819ae-a995-4690-b73f-ecab935f5405
alias: Gentle lights alarm automation
description: This automation slowly turns on the lights in my bedroom to help me
wake up in a gentle way.
variables:
transition_seconds: "{{\n states('input_number.wakeup_transition_minutes') |\
\ int(1) * 60\n}}"
wakeup_brightness: "{{\n states('input_number.wakeup_brightness') | int(1)\n\
}}"
trigger:
- platform: time
at: input_datetime.wakeup_time_workday
id: Work
- platform: time
at: input_datetime.wakeup_time
id: No Work
condition:
- condition: template
value_template: "{{\n is_state('light.bedroom_lights', 'off')\n and is_state('input_boolean.away_mode',\
\ 'off')\n and is_state('input_boolean.no_wakeup_mode', 'off')\n}}"
action:
- choose:
- conditions:
- alias: Workday
condition: and
conditions:
- condition: trigger
id: Work
- condition: state
entity_id: binary_sensor.must_work_today
state: 'on'
sequence:
- service: light.turn_on
target:
entity_id: light.bedroom_lights
data:
brightness_pct: 1
- service: light.turn_on
target:
entity_id: light.bedroom_lights
data:
brightness_pct: '{{ wakeup_brightness }}'
transition: '{{ transition_seconds }}'
- conditions:
- alias: No Workday
condition: and
conditions:
- condition: trigger
id: No Work
- condition: state
entity_id: binary_sensor.must_work_today
state: 'off'
sequence:
- service: light.turn_on
target:
entity_id: light.bedroom_lights
data:
brightness_pct: 1
- service: light.turn_on
target:
entity_id: light.bedroom_lights
data:
brightness_pct: '{{ wakeup_brightness }}'
transition: '{{ transition_seconds }}'
- id: 6b0f392f-9afd-4db4-bde7-f961f5391ada
mode: single
alias: High humdity in baths detection
description: 'This automation detects high humidity in my bathrooms.
High humidity is bad because it can lead to mold. I
should therefore always try to get it down to 50-60%.
Most problematic for this problem are baths, because
the humidity after taking is shower is usually very
high.'
variables:
high_humidity: '{{ states(''input_number.bathroom_setting_humidity_high'') | int
}}'
bath_sensors: &id002
- sensor.bath1_temp_humidity
high_humidity_sensors: "{% for i in bath_sensors %}\n {% if states(i) | int >=\
\ high_humidity %}\n - {{ states[i].attributes.friendly_name }} ({{ states(i)\
\ }}%)\n {% endif %}\n{% endfor %}"
trigger:
- platform: state
entity_id: *id002
condition: '{{ high_humidity_sensors != '''' and is_state(''binary_sensor.probably_sleeping'',
''off'') }}'
action:
- variables:
action_cooldown15: '{{ ''COOLDOWN15_'' ~ context.id }}'
action_cooldown60: '{{ ''COOLDOWN60_'' ~ context.id }}'
action_cooldown300: '{{ ''COOLDOWN300_'' ~ context.id }}'
- service: notify.mobile_app_pixel_7
data:
title: Some sensors with high humidity have been found!
message: "The humidity of the following sensors are\nhigher than {{high_humidity}}%:\n\
\ {{high_humidity_sensors}}"
data:
color: yellow
notification_icon: mdi:water-percent
actions:
- action: '{{ action_cooldown15 }}'
title: 15 mins
- action: '{{ action_cooldown60 }}'
title: 1 h
- action: '{{ action_cooldown300 }}'
title: 3 h
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ action_cooldown15 }}'
id: Option One
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ action_cooldown60 }}'
id: Option Two
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ action_cooldown300 }}'
id: Option Three
timeout: 01:00:00
continue_on_timeout: false
- choose:
- conditions: '{{ wait.trigger.id == ''Option One'' }}'
sequence:
- delay: 00:15
- conditions: '{{ wait.trigger.id == ''Option Two'' }}'
sequence:
- delay: 01:00
- conditions: '{{ wait.trigger.id == ''Option Two'' }}'
sequence:
- delay: 03:00
- id: b3cc80e4-4039-4052-81c9-f8c25b6bc07a
mode: single
alias: High humdity in garage detection
description: 'This automation detects high humidity in my garage.
High humidity is bad because it can lead to mold. I
should therefore always try to get it down to 50-60%.'
variables:
high_humidity: '{{ states(''input_number.garage_setting_humidity_high'') | int
| default(80) }}'
garage_sensors: &id003
- sensor.garage_temp_humidity
high_humidity_sensors: "{% for i in garage_sensors %}\n {% if states(i) | int\
\ >= high_humidity %}\n - {{ states[i].attributes.friendly_name }} ({{ states(i)\
\ }}%)\n {% endif %}\n{% endfor %}"
trigger:
- platform: state
entity_id: *id003
condition: '{{ high_humidity_sensors != '''' }}'
action:
- variables:
action_cooldown15: '{{ ''COOLDOWN15_'' ~ context.id }}'
action_cooldown60: '{{ ''COOLDOWN60_'' ~ context.id }}'
action_cooldown300: '{{ ''COOLDOWN300_'' ~ context.id }}'
- service: notify.mobile_app_pixel_7
data:
title: Some sensors with high humidity have been found!
message: "The humidity of the following sensors are\nhigher than {{high_humidity}}%:\n\
\ {{high_humidity_sensors}}"
data:
color: yellow
notification_icon: mdi:water-percent
actions:
- action: '{{ action_cooldown15 }}'
title: 15 mins
- action: '{{ action_cooldown60 }}'
title: 1 h
- action: '{{ action_cooldown300 }}'
title: 3 h
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ action_cooldown15 }}'
id: Option One
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ action_cooldown60 }}'
id: Option Two
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ action_cooldown300 }}'
id: Option Three
timeout: 01:00:00
continue_on_timeout: false
- choose:
- conditions: '{{ wait.trigger.id == ''Option One'' }}'
sequence:
- delay: 00:15
- conditions: '{{ wait.trigger.id == ''Option Two'' }}'
sequence:
- delay: 01:00
- conditions: '{{ wait.trigger.id == ''Option Two'' }}'
sequence:
- delay: 03:00
- id: 68229927-07bf-4342-800b-20a291ce5ed5
trace:
stored_traces: 25
alias: Intercom to chime pipeline
description: Triggers the chime if the intercom gets pressed.
triggers:
- trigger: state
entity_id:
- binary_sensor.vordereingang_ding_2
to: 'on'
actions:
- action: homeassistant.turn_on
target:
entity_id: switch.wohnzimmer_play_ding_sound
mode: single
- id: cc881516-1e51-4b9c-9542-c4b261ac98c9
mode: queued
max_exceeded: silent
trace:
stored_traces: 25
alias: Intrusion detection alarm trigger
description: "Detects unusual behaviour while I'm not at home or when I'm sleeping.\n\
When this automation is triggered, a security alarm will be triggered.\nThe following\
\ things are considered unusual:\n - A window was opened\n - A door was opened"
variables:
excluded_areas: '{{ states(''sensor.skip_security_in_areas'') }}'
trigger:
- platform: event
event_type: state_changed
condition:
- condition: template
value_template: "{{\n trigger.event.data.entity_id is match('^binary_sensor\\\
.[a-z0-9_]+_(?:door|window)[0-9]*_contact')\n and trigger.event.data.old_state.state\
\ == 'off'\n and trigger.event.data.new_state.state == 'on'\n}}"
- or:
- condition: state
entity_id: alarm_control_panel.security_alarm
state: armed_away
- and:
- condition: state
entity_id: alarm_control_panel.security_alarm
state: armed_night
- condition: template
value_template: "{{\n area_name(trigger.event.data.entity_id) not in excluded_areas\n\
}}"
action:
- service: input_text.set_value
target:
entity_id: input_text.last_security_alarm_entity
data:
value: '{{state_attr(trigger.event.data.entity_id, ''friendly_name'')}}'
- service: alarm_control_panel.alarm_trigger
target:
entity_id: alarm_control_panel.security_alarm
- id: 20f51e6a-1018-4ce5-bd7d-9e702ad1b3be
mode: single
alias: Leaving but something is still open
description: This automation sends me a notification if I leave the house and there
are still any windows or doors open.
trigger:
- platform: state
entity_id: binary_sensor.people_home
to: 'off'
for: 00:00:30
condition: '{{ is_state(''binary_sensor.everything_closed'', ''off'') }}'
action:
- service: notify.mobile_app_pixel_7
data:
title: Door or window still open
message: "The following entities are still open, you might want to close them:\n\
\ {{ states('sensor.open_windows') }}\n {{ states('sensor.open_doors') }}"
data:
notification_icon: mdi:alert
- id: 6467257e-8844-4d73-8ea2-cebb140f9a3e
mode: single
alias: Light still on reminder
description: 'This automation reminds me to turn off some lights.
Sometimes I turn on a light and forget to turn it off again.
This automations aims to prevent this.'
trigger:
- platform: state
entity_id: light.all_lights
to: 'on'
for: 00:{{ '%0.2d' | format(states('input_number.light_reminder_time')|int) }}:00
condition: '{{ is_state(''input_boolean.light_reminder'', ''on'') }}'
action:
- variables:
action_cooldown15: '{{ ''CLOSE_COOLDOWN15_'' ~ context.id }}'
action_cooldown60: '{{ ''CLOSE_COOLDOWN60_'' ~ context.id }}'
action_cooldown300: '{{ ''CLOSE_COOLDOWN300_'' ~ context.id }}'
- alias: Keep sending notifications until its closed again
repeat:
until:
- condition: state
entity_id: light.all_lights
state: 'off'
sequence:
- service: notify.mobile_app_pixel_7
data:
title: There is still some light turned on...
message: "You might want to turn these off:\n {{ states('sensor.turned_on_lights')\
\ }}"
data:
color: yellow
notification_icon: mdi:lightbulb-on
actions:
- action: '{{ action_cooldown15 }}'
title: 15 mins
- action: '{{ action_cooldown60 }}'
title: 1 h
- action: '{{ action_cooldown300 }}'
title: 3 h
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ action_cooldown15 }}'
id: Option One
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ action_cooldown60 }}'
id: Option Two
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ action_cooldown300 }}'
id: Option Three
timeout: 01:00:00
continue_on_timeout: false
- choose:
- conditions: '{{ wait.trigger.id == ''Option One'' }}'
sequence:
- delay: 00:15
- conditions: '{{ wait.trigger.id == ''Option Two'' }}'
sequence:
- delay: 01:00
- conditions: '{{ wait.trigger.id == ''Option Three'' }}'
sequence:
- delay: 03:00
- id: e150671f-893e-426d-99c6-9f4e9eaf4d80
mode: single
alias: Low disc space detection
description: 'This automation notifies me when the disc space is below a
certain threshold.'
trigger:
- platform: numeric_state
entity_id: sensor.disk_use_percent
above: input_number.low_disc_space_threshold
for:
minutes: 5
action:
- variables:
action_cooldown15: '{{ ''COOLDOWN15_'' ~ context.id }}'
action_cooldown60: '{{ ''COOLDOWN60_'' ~ context.id }}'
action_cooldown300: '{{ ''COOLDOWN300_'' ~ context.id }}'
- service: notify.mobile_app_pixel_7
data:
title: Low disc space detected!
message: There is almost no more available disc space for homeassistant.
data:
color: yellow
notification_icon: mdi:disc-alert
actions:
- action: '{{ action_cooldown15 }}'
title: 15 mins
- action: '{{ action_cooldown60 }}'
title: 1 h
- action: '{{ action_cooldown300 }}'
title: 3 h
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ action_cooldown15 }}'
id: Option One
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ action_cooldown60 }}'
id: Option Two
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ action_cooldown300 }}'
id: Option Three
timeout: 01:00:00
continue_on_timeout: false
- choose:
- conditions: '{{ wait.trigger.id == ''Option One'' }}'
sequence:
- delay: 00:15
- conditions: '{{ wait.trigger.id == ''Option Two'' }}'
sequence:
- delay: 01:00
- conditions: '{{ wait.trigger.id == ''Option Two'' }}'
sequence:
- delay: 03:00
- id: 68229927-07bf-4342-800b-20a291ce5ed6
trace:
stored_traces: 25
alias: Mute chime on open door
description: Turns off the chime if the door gets opened.
triggers:
- trigger: state
entity_id: event.vordereingang_intercom_unlock
actions:
- action: siren.turn_off
target:
entity_id: siren.wohnzimmer_siren
mode: single
- id: 66c3956a-4dd6-4af0-8e5d-45354b8af18a
alias: Bath ofen switcher
trigger:
- platform: state
entity_id: binary_sensor.bath1_window_contact
action:
- choose:
- conditions: '{{trigger.to_state.state == ''on''}}'
sequence:
- service: homeassistant.turn_off
target:
entity_id: switch.bath1_powerplug
- id: 40c147c1-b3a1-4214-b002-7bf7d4af65d0
alias: Office 1 light switcher
description: This automation tries to predict how much light I need in my office
and sets up the lights as needed.
variables:
office_devices: &id004
- device_tracker.daniel_tower
- device_tracker.t2978124
trigger:
- alias: Door opened
platform: state
entity_id:
- binary_sensor.office1_door_contact
from: 'off'
to: 'on'
id: Door opened
- alias: Door closed
platform: state
entity_id:
- binary_sensor.office1_door_contact
from: 'on'
to: 'off'
id: Door closed
- alias: Sun is gone, need light
platform: state
entity_id:
- binary_sensor.need_light
from: 'off'
to: 'on'
id: Need light
- alias: Sun is up, don't need light
platform: state
entity_id:
- binary_sensor.need_light
from: 'on'
to: 'off'
id: Dont need light
- alias: Device turned on
platform: state
entity_id: *id004
from: not_home
to: home
id: Device turned on
- alias: Chair moved
platform: state
entity_id: sensor.office1_chair_action
id: Chair movement
condition:
- condition: state
entity_id: input_boolean.office1_manage_lights
state: 'on'
action:
- choose:
- conditions:
- alias: Device turned on, turn light off
condition: and
conditions:
- condition: trigger
id: Device turned on
- condition: state
entity_id: input_boolean.office1_device_on_lights_off
state: 'on'
- condition: state
entity_id: light.office1_light
state: 'on'
sequence:
- alias: Turn off the lights
service: light.turn_off
target:
entity_id: light.office1_light
- conditions:
- alias: Chair movement detected, turn light off when device is on
condition: and
conditions:
- condition: trigger
id: Chair movement
- condition: state
entity_id: input_boolean.office1_when_sitting_lights_off
state: 'on'
- condition: state
entity_id: light.office1_light
state: 'on'
- condition: state
entity_id: *id004
match: any
state: home
sequence:
- alias: Turn off the lights
service: light.turn_off
target:
entity_id: light.office1_light
- conditions:
- alias: Door opened
condition: and
conditions:
- condition: trigger
id: Door opened
- condition: state
entity_id: binary_sensor.need_light
state: 'on'
sequence:
- alias: Turn on the lights
service: light.turn_on
target:
entity_id: light.office1_light
- conditions:
- alias: Door closed and devices went offline 2 mins ago
condition: and
conditions:
- condition: trigger
id: Door closed
- condition: state
entity_id: light.office1_light
state: 'on'
- condition: state
entity_id: *id004
state: not_home
- condition: template
value_template: "{% set now_ts = as_timestamp(now()) %} {% set found_device\
\ = false %} {% for dev in office_devices %}\n {% if (now_ts - as_timestamp(state_attr(dev,\
\ \"last_time_reachable\"))) < 120 %}\n {% set found_device = true\
\ %}\n {% endif %}\n{% endfor %} {% if found_device %}\n {{ true }}\n\
{% endif %}"
sequence:
- alias: Turn off the lights
service: light.turn_off
target:
entity_id: light.office1_light
- conditions:
- alias: Door closed and devices are offline
condition: and
conditions:
- condition: trigger
id: Door closed
- condition: state
entity_id: light.office1_light
state: 'on'
- condition: state
entity_id: *id004
state: not_home
sequence:
- alias: Wait 2 mins
delay: 120
- alias: Check if devices are still offline
choose:
- conditions:
- condition: state
entity_id: *id004
state: not_home
sequence:
- alias: Turn off the lights
service: light.turn_off
target:
entity_id: light.office1_light
- conditions:
- alias: Door closed and devices are still online
condition: and
conditions:
- condition: trigger
id: Door closed
- condition: state
entity_id: light.office1_light
state: 'on'
- condition: state
entity_id: *id004
match: any
state: home
sequence:
- alias: Turn off the lights
service: light.turn_off
target:
entity_id: light.office1_light
- id: 9dd7eb2d-79ee-43f9-955d-d5e70d2ea3df
alias: Office 1 light button
description: This automation handels the actions for my ikea button.
trigger:
- alias: Button1 on
platform: state
entity_id: sensor.office1_button1_action
to: 'on'
id: Button1 on
- alias: Button1 off
platform: state
entity_id: sensor.office1_button1_action
to: 'off'
id: Button1 off
- alias: Button1 left
platform: state
entity_id: sensor.office1_button1_action
to: arrow_left_click
id: Button1 left
- alias: Button1 right
platform: state
entity_id: sensor.office1_button1_action
to: arrow_right_click
id: Button1 right
action:
- choose:
- conditions:
- alias: On button clicked
condition: trigger
id: Button1 on
- alias: But only if the light is off
condition: state
entity_id: light.office1_light
state: 'off'
sequence:
- alias: Turn on the office1 light
service: light.turn_on
entity_id: light.office1_light
data:
brightness_pct: 100
transition: 1
- conditions:
- alias: Off button clicked
condition: trigger
id: Button1 off
- alias: But only if the light is on
condition: state
entity_id: light.office1_light
state: 'on'
sequence:
- alias: Turn off the office1 light
service: light.turn_off
entity_id: light.office1_light
data:
transition: 1
- conditions:
- alias: Left button clicked
condition: trigger
id: Button1 left
- alias: But only if the light is on
condition: state
entity_id: light.office1_light
state: 'on'
sequence:
- alias: Decrease the brightness
service: light.turn_on
entity_id: light.office1_light
data:
brightness_step_pct: -20
transition: 1
- conditions:
- alias: Right button clicked
condition: trigger
id: Button1 right
sequence:
- alias: Increase the brightness
service: light.turn_on
entity_id: light.office1_light
data:
brightness_step_pct: 20
transition: 1
- id: 45fc0aae-094e-4298-a033-fd155b30fd65
alias: Office 1 light button2
description: This automation handels the actions for my second ikea button.
trigger:
- alias: Button2 on
platform: state
entity_id: sensor.office1_button2_action
to: 'on'
id: Button2 on
- alias: Button2 off
platform: state
entity_id: sensor.office1_button2_action
to: 'off'
id: Button2 off
- alias: Button2 left
platform: state
entity_id: sensor.office1_button2_action
to: arrow_left_click
id: Button2 left
- alias: Button2 right
platform: state
entity_id: sensor.office1_button2_action
to: arrow_right_click
id: Button2 right
action:
- choose:
- conditions:
- alias: On button clicked
condition: trigger
id: Button2 on
- alias: But only if the light is off
condition: state
entity_id: light.office1_light2
state: 'off'
sequence:
- alias: Turn on the office1 light
service: light.turn_on
entity_id: light.office1_light2
data:
brightness_pct: 100
transition: 1
- conditions:
- alias: Off button clicked
condition: trigger
id: Button2 off
- alias: But only if the light is on
condition: state
entity_id: light.office1_light2
state: 'on'
sequence:
- alias: Turn off the office1 light
service: light.turn_off
entity_id: light.office1_light2
data:
transition: 1
- conditions:
- alias: Left button clicked
condition: trigger
id: Button2 left
- alias: But only if the light is on
condition: state
entity_id: light.office1_light2
state: 'on'
sequence:
- alias: Decrease the brightness
service: light.turn_on
entity_id: light.office1_light2
data:
brightness_step_pct: -20
transition: 1
- conditions:
- alias: Right button clicked
condition: trigger
id: Button2 right
sequence:
- alias: Increase the brightness
service: light.turn_on
entity_id: light.office1_light2
data:
brightness_step_pct: 20
transition: 1
- id: 379f4de2-2c0d-412e-a1e4-0626b5713ece
alias: Office 2 light switcher
description: This automation is a simple button / light connector.
trigger:
- platform: state
entity_id:
- sensor.office2_button_action
to: single
id: Single Click
- platform: state
entity_id:
- sensor.office2_button_action
to: double
id: Double Click
- platform: state
entity_id:
- sensor.office2_button_action
to: triple
id: Triple Click
action:
- choose:
- conditions:
- condition: trigger
id: Single Click
sequence:
- alias: Toggle the lights
service: light.toggle
target:
entity_id: light.office2_light
data:
brightness_pct: 100
- conditions:
- condition: trigger
id: Double Click
sequence:
- alias: Toggle the lights
service: light.turn_on
target:
entity_id: light.office2_light
data:
brightness_pct: 50
- conditions:
- condition: trigger
id: Triple Click
sequence:
- alias: Toggle the lights
service: light.turn_on
target:
entity_id: light.office2_light
data:
brightness_pct: 25
- id: ae1ed701-d3b1-49d3-b12b-1c63db33ca90
alias: Phone deflection switcher
description: When I turned on the away mode, I want all calls to be deflected to
my mobile phone.
trigger:
- alias: Away mode turned on
platform: state
entity_id:
- input_boolean.away_mode
from: 'off'
to: 'on'
id: Away mode turned on
- alias: Away mode turned off
platform: state
entity_id:
- input_boolean.away_mode
from: 'on'
to: 'off'
id: Away mode turned off
- alias: People are home
platform: state
entity_id:
- binary_sensor.people_home
from: 'off'
to: 'on'
id: People are home
action:
- choose:
- conditions:
- alias: Away mode turned on
condition: and
conditions:
- condition: trigger
id: Away mode turned on
- condition: state
entity_id: switch.fritz_box_6660_cable_call_deflection_2
state: 'off'
sequence:
- alias: Turn on the deflection
service: switch.turn_on
target:
entity_id: switch.fritz_box_6660_cable_call_deflection_2
- conditions:
- alias: Away mode turned off
condition: and
conditions:
- condition: trigger
id: Away mode turned off
- &id005
condition: state
entity_id: switch.fritz_box_6660_cable_call_deflection_2
state: 'on'
sequence:
- &id006
alias: Turn off the deflection
service: switch.turn_off
target:
entity_id: switch.fritz_box_6660_cable_call_deflection_2
- conditions:
- alias: People are home
condition: and
conditions:
- condition: trigger
id: People are home
- *id005
sequence:
- *id006
- id: 68229927-07bf-4342-800b-20a291ce5ed4
trace:
stored_traces: 25
alias: Security alarm triggered
description: This automation gets triggered, when a security issue was detected.
trigger:
- platform: state
entity_id: alarm_control_panel.security_alarm
to: triggered
action:
- variables:
action_disarm: '{{ ''DISARM_'' ~ context.id }}'
- service: notify.mobile_app_pixel_7
data:
title: Security alarm triggered
message: The entity {{states('input_text.last_security_alarm_entity')}} triggered
the security alarm.
data:
ttl: 0
priority: high
channel: alarm_stream
notification_icon: mdi:alarm-light
color: red
confirmation: true
actions:
- action: '{{ action_disarm }}'
title: Disarm
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_received
event_data:
title: Security alarm triggered
timeout: 00:00:15
continue_on_timeout: true
- choose:
- alias: When notification wasnt received
conditions:
- alias: Phone is off and probably sleeping
condition: and
conditions:
- condition: template
value_template: '{{ not wait.trigger }}'
- condition: state
entity_id: binary_sensor.probably_sleeping
state: 'on'
sequence:
- alias: Call phone via sip
service: hassio.addon_stdin
data:
addon: ad61c150_dss_voip
input:
call_sip_uri: secret emergency_sip_uri
message_tts: The entity {{states('input_text.last_security_alarm_entity')}}
triggered the security alarm.
- alias: Turn on lights with breathe effect
service: light.turn_on
data:
effect: breathe
brightness_pct: 100
target:
entity_id: light.all_lights
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ action_disarm }}'
id: Disarm
timeout: 00:01:00
continue_on_timeout: false
- choose:
- alias: When disarm button was pressed
conditions: '{{ wait.trigger.id == ''Disarm'' }}'
sequence:
- alias: Disarm the security alarm
service: alarm_control_panel.alarm_disarm
target:
entity_id: alarm_control_panel.security_alarm
- id: c0771d1b-92cc-4ed6-a227-229b13981c2f
mode: queued
max_exceeded: silent
trace:
stored_traces: 25
alias: Storage detection alarm trigger
description: This automation detects suspicious activity in the storage room. When
this automation is triggered, a security alarm will be triggered.
trigger:
- platform: event
event_type: state_changed
event_data:
entity_id: binary_sensor.storage_door1_contact
- platform: event
event_type: state_changed
event_data:
entity_id: binary_sensor.storage_door2_contact
condition:
- condition: template
value_template: "{{\n trigger.event.data.old_state.state == 'off'\n and trigger.event.data.new_state.state\
\ == 'on'\n and is_state('input_boolean.watch_storage_activities', 'on')\n\
}}"
action:
- service: input_text.set_value
target:
entity_id: input_text.last_security_alarm_entity
data:
value: '{{state_attr(trigger.event.data.entity_id, ''friendly_name'')}}'
- service: alarm_control_panel.alarm_trigger
target:
entity_id: alarm_control_panel.security_alarm
- id: 62f17829-bce4-495f-b1d5-b6798a9281a1
alias: Thermostat switcher
description: 'When I turned on the away mode, I want all thermostats to be turned
off.
When I return, I want them to be in the old state again.
And when I open a window, I want the thermostat to turn off as long as it is still
open.'
variables:
all_thermostats: &id007
- climate.bad
- climate.buro_1
- climate.buro_2
- climate.esszimmer_1
- climate.esszimmer_2
- climate.schlafzimmer_1
- climate.schlafzimmer_2
- climate.wohnzimmer
trigger:
- alias: Away mode turned on
platform: state
entity_id:
- input_boolean.away_mode
from: 'off'
to: 'on'
id: Away mode turned on
- alias: Away mode turned off
platform: state
entity_id:
- input_boolean.away_mode
from: 'on'
to: 'off'
id: Away mode turned off
- alias: People are home
platform: state
entity_id:
- binary_sensor.people_home
from: 'off'
to: 'on'
id: People are home
- alias: Office 1 window opened
platform: state
entity_id:
- binary_sensor.office1_window_contact
from: 'off'
to: 'on'
id: Office 1 window opened
for: 00:00:10
- alias: Office 1 window closed
platform: state
entity_id:
- binary_sensor.office1_window_contact
from: 'on'
to: 'off'
id: Office 1 window closed
- alias: Lunch door opened
platform: state
entity_id:
- binary_sensor.lunch_door_contact
from: 'off'
to: 'on'
id: Lunch door opened
for: 00:00:10
- alias: Lunch door closed
platform: state
entity_id:
- binary_sensor.lunch_door_contact
from: 'on'
to: 'off'
id: Lunch door closed
- alias: Bath1 window opened
platform: state
entity_id:
- binary_sensor.bath1_window_contact
from: 'off'
to: 'on'
id: Bath1 window opened
for: 00:00:10
- alias: Bath1 window closed
platform: state
entity_id:
- binary_sensor.bath1_window_contact
from: 'on'
to: 'off'
id: Bath1 window closed
- alias: Bedroom window opened
platform: state
entity_id:
- binary_sensor.bedroom_window_contact
- binary_sensor.bedroom_door_contact
from: 'off'
to: 'on'
id: Bedroom window opened
for: 00:00:10
- alias: Bedroom window closed
platform: state
entity_id:
- binary_sensor.bedroom_window_contact
- binary_sensor.bedroom_door_contact
from: 'on'
to: 'off'
id: Bedroom window closed
- alias: Time check
platform: time_pattern
minutes: /3
id: Time check
action:
- choose:
- conditions:
- alias: Office 1 window opened
condition: and
conditions:
- condition: or
conditions:
- condition: trigger
id: Office 1 window opened
- condition: and
conditions:
- condition: trigger
id: Time check
- condition: state
entity_id:
- binary_sensor.office1_window_contact
state: 'on'
- condition: state
entity_id:
- climate.buro_1
state: heat
sequence:
- service: scene.create
data:
scene_id: office1_thermostat
snapshot_entities:
- climate.buro_1
- alias: Turn off the thermostat
service: climate.turn_off
target:
entity_id:
- climate.buro_1
- conditions:
- alias: Office 1 window closed again
condition: and
conditions:
- condition: or
conditions:
- condition: trigger
id: Office 1 window closed
- condition: and
conditions:
- condition: trigger
id: Time check
- condition: state
entity_id:
- input_boolean.away_mode
state: 'off'
- condition: state
entity_id:
- binary_sensor.office1_window_contact
state: 'off'
- condition: state
entity_id:
- climate.buro_1
state: 'off'
sequence:
- service: scene.turn_on
target:
entity_id: scene.office1_thermostat
- conditions:
- alias: Office 2 door opened
condition: and
conditions:
- condition: or
conditions:
- condition: trigger
id: Office 2 door opened
- condition: and
conditions:
- condition: trigger
id: Time check
- condition: state
entity_id:
- binary_sensor.office2_door_contact
state: 'on'
- condition: state
entity_id:
- climate.buro_2
state: heat
sequence:
- service: scene.create
data:
scene_id: office2_thermostat
snapshot_entities:
- climate.buro_2
- alias: Turn off the thermostat
service: climate.turn_off
target:
entity_id:
- climate.buro_2
- conditions:
- alias: Office 2 door closed again
condition: and
conditions:
- condition: or
conditions:
- condition: trigger
id: Office 2 door closed
- condition: and
conditions:
- condition: trigger
id: Time check
- condition: state
entity_id:
- input_boolean.away_mode
state: 'off'
- condition: state
entity_id:
- binary_sensor.office2_door_contact
state: 'off'
- condition: state
entity_id:
- climate.buro_2
state: 'off'
sequence:
- service: scene.turn_on
target:
entity_id: scene.office2_thermostat
- conditions:
- alias: Lunch door opened
condition: and
conditions:
- condition: or
conditions:
- condition: trigger
id: Lunch door opened
- condition: and
conditions:
- condition: trigger
id: Time check
- condition: state
entity_id:
- binary_sensor.lunch_door_contact
state: 'on'
- condition: state
entity_id:
- climate.wohnzimmer
- climate.esszimmer_1
- climate.esszimmer_2
match: any
state: heat
sequence:
- service: scene.create
data:
scene_id: lunch_living_thermostat
snapshot_entities:
- climate.wohnzimmer
- climate.esszimmer_1
- climate.esszimmer_2
- alias: Turn off the thermostat
service: climate.turn_off
target:
entity_id:
- climate.wohnzimmer
- climate.esszimmer_1
- climate.esszimmer_2
- conditions:
- alias: Lunch door closed again
condition: and
conditions:
- condition: or
conditions:
- condition: trigger
id: Lunch door closed
- condition: and
conditions:
- condition: trigger
id: Time check
- condition: state
entity_id:
- input_boolean.away_mode
state: 'off'
- condition: state
entity_id:
- binary_sensor.lunch_door_contact
state: 'off'
- condition: state
entity_id:
- climate.wohnzimmer
- climate.esszimmer_1
- climate.esszimmer_2
state: 'off'
sequence:
- service: scene.turn_on
target:
entity_id: scene.lunch_living_thermostat
- conditions:
- alias: Bath1 window opened
condition: and
conditions:
- condition: or
conditions:
- condition: trigger
id: Bath1 window opened
- condition: and
conditions:
- condition: trigger
id: Time check
- condition: state
entity_id:
- binary_sensor.bath1_window_contact
state: 'on'
- condition: state
entity_id:
- climate.bad
state: heat
sequence:
- service: scene.create
data:
scene_id: bad_thermostat
snapshot_entities:
- climate.bad
- alias: Turn off the thermostat
service: climate.turn_off
target:
entity_id:
- climate.bad
- conditions:
- alias: Bath1 window closed again
condition: and
conditions:
- condition: or
conditions:
- condition: trigger
id: Bath1 window closed
- condition: and
conditions:
- condition: trigger
id: Time check
- condition: state
entity_id:
- input_boolean.away_mode
state: 'off'
- condition: state
entity_id:
- binary_sensor.bath1_window_contact
state: 'off'
- condition: state
entity_id:
- climate.bad
state: 'off'
sequence:
- service: scene.turn_on
target:
entity_id: scene.bad_thermostat
- conditions:
- alias: Bedroom window opened
condition: and
conditions:
- condition: or
conditions:
- condition: trigger
id: Bedroom window opened
- condition: and
conditions:
- condition: trigger
id: Time check
- condition: state
entity_id:
- binary_sensor.bedroom_window_contact
- binary_sensor.bedroom_door_contact
state: 'on'
- condition: and
conditions:
- condition: trigger
id: Time check
- condition: state
entity_id:
- binary_sensor.bath1_window_contact
state: 'on'
- condition: state
entity_id:
- input_boolean.combine_bath_and_bedroom
state: 'on'
- condition: state
entity_id:
- climate.schlafzimmer_1
- climate.schlafzimmer_2
match: any
state: heat
sequence:
- service: scene.create
data:
scene_id: bedroom_thermostat
snapshot_entities:
- climate.schlafzimmer_1
- climate.schlafzimmer_2
- alias: Turn off the thermostat
service: climate.turn_off
target:
entity_id:
- climate.schlafzimmer_1
- climate.schlafzimmer_2
- conditions:
- alias: Bedroom window closed again
condition: and
conditions:
- condition: or
conditions:
- condition: state
entity_id:
- input_boolean.combine_bath_and_bedroom
state: 'off'
- condition: and
conditions:
- condition: state
entity_id:
- input_boolean.combine_bath_and_bedroom
state: 'on'
- condition: state
entity_id:
- binary_sensor.bath1_window_contact
state: 'off'
- condition: or
conditions:
- condition: trigger
id: Bedroom window closed
- condition: and
conditions:
- condition: trigger
id: Time check
- condition: state
entity_id:
- input_boolean.away_mode
state: 'off'
- condition: state
entity_id:
- binary_sensor.bedroom_window_contact
- binary_sensor.bedroom_door_contact
state: 'off'
- condition: state
entity_id:
- climate.schlafzimmer_1
- climate.schlafzimmer_2
state: 'off'
sequence:
- service: scene.turn_on
target:
entity_id: scene.bedroom_thermostat
- conditions:
- alias: Away mode turned on
condition: and
conditions:
- condition: trigger
id: Away mode turned on
- condition: state
entity_id: *id007
match: any
state: heat
sequence:
- service: scene.create
data:
scene_id: before
snapshot_entities: *id007
- alias: Turn off the thermostats
service: climate.turn_off
target:
entity_id: *id007
- conditions:
- alias: Away mode turned off
condition: and
conditions:
- condition: trigger
id: Away mode turned off
- condition: state
entity_id: *id007
match: any
state: 'off'
sequence:
- service: scene.turn_on
target:
entity_id: scene.before
- conditions:
- condition: trigger
id: People are home
sequence:
- service: input_boolean.turn_off
target:
entity_id: input_boolean.away_mode
- id: 356696e4-4423-4863-8f28-a02ec1ef18ac
mode: queued
alias: Trash reminder
description: This automation reminds me to put the trash outside
trigger:
- platform: calendar
event: start
entity_id: calendar.trash
offset: -08:00:00
action:
- service: notify.mobile_app_pixel_7
data:
title: '{{ trigger.calendar_event.summary }}'
message: '{{ trigger.calendar_event.description }}'
data:
notification_icon: mdi:trash-can
- service: persistent_notification.create
data:
title: '{{ trigger.calendar_event.summary }}'
message: '{{ trigger.calendar_event.description }}'
- id: 8511c2ca-4ea3-429f-b3a3-e35bd6289e67
mode: single
alias: Window or door open for too long reminder
description: 'This automation reminds me to close an open window or door.
Sometimes I open a window or door to let some fresh air in
and forget to close it again. This automations aims to prevent
this.'
trigger:
- platform: state
entity_id: binary_sensor.everything_closed
to: 'off'
for: 00:{{ '%0.2d' | format(states('input_number.max_open_window_or_door_time')|int)
}}:00
condition: '{{ states(''input_boolean.summer_mode'') == states(''binary_sensor.outside_warmer_than_inside'')
and is_state(''binary_sensor.probably_sleeping'', ''off'') }}'
action:
- variables:
action_cooldown15: '{{ ''CLOSE_COOLDOWN15_'' ~ context.id }}'
action_cooldown60: '{{ ''CLOSE_COOLDOWN60_'' ~ context.id }}'
action_cooldown300: '{{ ''CLOSE_COOLDOWN300_'' ~ context.id }}'
- alias: Keep sending notifications until its closed again
repeat:
until:
- condition: state
entity_id: binary_sensor.everything_closed
state: 'on'
sequence:
- service: notify.mobile_app_pixel_7
data:
title: Close windows and doors now!
message: "The following entities are still open, you might want to close\
\ them:\n {{ states('sensor.open_windows') }}\n {{ states('sensor.open_doors')\
\ }}"
data:
color: yellow
notification_icon: mdi:window-open
actions:
- action: '{{ action_cooldown15 }}'
title: 15 mins
- action: '{{ action_cooldown60 }}'
title: 1 h
- action: '{{ action_cooldown300 }}'
title: 3 h
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ action_cooldown15 }}'
id: Option One
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ action_cooldown60 }}'
id: Option Two
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ action_cooldown300 }}'
id: Option Three
timeout: 01:00:00
continue_on_timeout: false
- choose:
- conditions: '{{ wait.trigger.id == ''Option One'' }}'
sequence:
- delay: 00:15
- conditions: '{{ wait.trigger.id == ''Option Two'' }}'
sequence:
- delay: 01:00
- conditions: '{{ wait.trigger.id == ''Option Three'' }}'
sequence:
- delay: 03:00