AutomationDataset/KaoruKanon/KaoruKanon_automations.yaml

845 lines
22 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

- alias: armed_away_alarm_when_people_away
description: ''
triggers:
- trigger: state
entity_id:
- person.kaoru
- person.papa
from: home
to: not_home
conditions:
- condition: and
conditions:
- condition: state
entity_id: person.kaoru
state: not_home
- condition: state
entity_id: person.papa
state: not_home
actions:
- action: alarm_control_panel.alarm_arm_away
metadata: {}
data:
code: secret code_alarm
target:
entity_id: alarm_control_panel.home_alarm
mode: single
- alias: disarm_alarm_when_people_home
description: ''
triggers:
- trigger: state
entity_id:
- person.kaoru
- person.papa
from: not_home
to: home
actions:
- action: alarm_control_panel.alarm_disarm
metadata: {}
data:
code: secret code_alarm
target:
entity_id: alarm_control_panel.home_alarm
mode: single
- alias: notify_when_alarm_triggered
triggers:
- trigger: state
entity_id: alarm_control_panel.home_alarm
to: triggered
actions:
- action: notify.mobile_app_phone
data:
message: ALARME L'alarm a été délenchée 🚨🚨
data:
ttl: 0
priority: high
channel: alarm_stream
- action: script.turn_on
metadata: {}
data: {}
target:
entity_id: script.alarm_sound_google_home
- alias: notify_when_alarm_armedaway
triggers:
- trigger: state
entity_id: alarm_control_panel.home_alarm
to: armed_away
actions:
- action: notify.mobile_app_phone
data:
message: 'ALARME: L''alarme est armée 🚨🔒'
- alias: trigger_alarm_armedaway_when_door_open
description: ''
triggers:
- trigger: state
entity_id:
- binary_sensor.porte_couloir_entree
to: 'on'
conditions:
- condition: state
entity_id: alarm_control_panel.home_alarm
state: armed_away
actions:
- action: alarm_control_panel.alarm_trigger
metadata: {}
data: {}
target:
entity_id: alarm_control_panel.home_alarm
mode: single
- alias: bruno_screenshot
mode: single
triggers:
- trigger: time_pattern
minutes: /5
actions:
- action: button.press
target:
entity_id: button.bruno_screenshot
conditions:
- condition: state
entity_id: switch.computer_papa
state: 'on'
- alias: rig_kaoru_screenshot
mode: single
triggers:
- trigger: time_pattern
minutes: /5
actions:
- action: button.press
target:
entity_id: button.rig_kaoru_screenshot
data: {}
conditions:
- condition: state
entity_id: switch.computer_rig_kaoru
state: 'on'
- alias: update_speed_fan
trigger:
- platform: state
entity_id: input_number.fan_speed
condition:
- condition: template
value_template: "{{ state_attr('automation.update_speed_fan_slider', 'last_triggered')\
\ is none or\n (as_timestamp(now()) - as_timestamp(state_attr('automation.update_speed_fan_slider',\
\ 'last_triggered')) > 1) }} "
action:
- service: fan.set_percentage
target:
entity_id: fan.xiaomi_smart_fan_2
data:
percentage: '{{ states(''input_number.fan_speed'') | int }}'
mode: single
- alias: update_speed_fan_slider
trigger:
- platform: state
entity_id: fan.xiaomi_smart_fan_2
condition:
- condition: template
value_template: "{{ state_attr('automation.update_speed_fan', 'last_triggered')\
\ is none or\n (as_timestamp(now()) - as_timestamp(state_attr('automation.update_speed_fan',\
\ 'last_triggered')) > 1) }}"
action:
- service: input_number.set_value
target:
entity_id: input_number.fan_speed
data:
value: '{{ state_attr(''fan.xiaomi_smart_fan_2'', ''percentage'') }}'
mode: single
- alias: update_fan_timer
description: ''
mode: single
trigger:
- platform: state
entity_id: input_number.fan_timer
condition: []
action:
- service: xiaomi_miio_fan.fan_set_delay_off
data:
entity_id: fan.xiaomi_smart_fan_2
delay_off_countdown: '{{ states(''input_number.fan_timer'') | int }}'
- alias: get_google_home_token_at_ha_restart
trigger:
- platform: homeassistant
event: start
action:
- service: shell_command.google_home_get_token
- alias: get_google_home_token_every_hour
trigger:
- platform: time_pattern
hours: '*'
action:
- service: shell_command.google_home_get_token
- alias: google_home_cuisine_start_timer
description: ''
triggers:
- trigger: state
entity_id:
- sensor.next_timer_cusine
to: null
conditions: []
actions:
- action: timer.start
metadata: {}
data:
duration: '{{ ( states(''sensor.next_timer_cusine'')|int/1000 - as_timestamp(now()))
| round() }}'
target:
entity_id: timer.timer_cuisine
mode: single
- alias: google_home_cuisine_stop_timer
description: ''
triggers:
- trigger: state
entity_id:
- sensor.next_timer_cusine
from: null
to: None
conditions: []
actions:
- action: timer.finish
metadata: {}
data: {}
target:
entity_id: timer.timer_cuisine
mode: single
- alias: purge_log_filesize
id: '3331821824310'
trigger:
platform: numeric_state
entity_id: sensor.home_assistant_log_size
above: 50
action:
service: shell_command.purge_log
- alias: Run Speedtest addon every 12 hours
trigger:
- platform: time_pattern
hours: /12
- trigger: homeassistant
event: start
action:
- service: hassio.addon_start
data:
addon: 6b87c29e_speedtest_addon
mode: single
- alias: backup_ha_monthly
trigger:
platform: time
at: 04:00:00
condition: '{{ now().day == 1 }}
'
action:
- action: hassio.backup_full
metadata: {}
data:
compressed: true
name: auto_monthly_backup_{{ states("sensor.date") | replace("-", "")}}_{{ states("sensor.time")
| replace(":", "") }}
- alias: auto_snapshot
trigger:
- platform: time
at: 00:00:00
action:
- service: hassio.backup_full
data:
name: auto_backup_{{ states("sensor.date") | replace("-", "")}}_{{ states("sensor.time")
| replace(":", "") }}
- alias: homeassistant_start
id: '7426848686945'
trigger:
platform: homeassistant
event: start
action:
- service: button.press
target:
entity_id: button.lenovotab_load_start_url
- alias: notify_tablet_unplugged
id: '3972668118831'
trigger:
platform: numeric_state
entity_id: sensor.lenovotab_batterie
below: 30
action:
service: notify.all_devices
data:
title: Chargement de la tablette...
message: 'Batterie {{ states(trigger.entity_id) }}%
'
- alias: back_home_tablet
id: '345538118831'
description: ''
triggers:
- trigger: state
entity_id:
- sensor.tablet_browser_path
for:
hours: 0
minutes: 5
seconds: 0
conditions:
- condition: and
conditions:
- condition: not
conditions:
- condition: state
entity_id: sensor.tablet_browser_path
state: /lovelace/home
- condition: not
conditions:
- condition: state
entity_id: sensor.tablet_browser_path
state: /lovelace/default_view
actions:
- action: browser_mod.navigate
metadata: {}
data:
browser_id:
- 6c1e502969ee705227e70afe410e1349
path: /lovelace/default_view?kiosk
- alias: tablet_turn_on_screen
id: '1745838569322'
description: turn on tab screen if pir detect human
triggers:
- trigger: state
entity_id:
- binary_sensor.pir_couloir1
to: 'on'
- trigger: state
entity_id:
- binary_sensor.pir_couloir2
to: 'on'
conditions:
- condition: state
entity_id: switch.lenovotab_screen
state: 'off'
actions:
- action: switch.turn_on
metadata: {}
data: {}
target:
entity_id: switch.lenovotab_screen
mode: single
- alias: tablet_turn_off_screen
id: '1745838644904'
description: turn off tab screen if pir detect no one
triggers:
- trigger: state
entity_id:
- binary_sensor.pir_couloir1
to: 'off'
- trigger: state
entity_id:
- binary_sensor.pir_couloir2
to: 'off'
conditions:
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.pir_couloir1
state: 'off'
- condition: state
entity_id: binary_sensor.pir_couloir2
state: 'off'
actions:
- action: switch.turn_off
metadata: {}
data: {}
target:
entity_id: switch.lenovotab_screen
mode: single
- alias: toggle_bureau
trigger:
- device_id: 3f7bf0b1d53cb13c4212ef835580c4ca
domain: zha
type: remote_button_short_press
subtype: remote_button_short_press
trigger: device
- device_id: d9bf413036f7a7482d2681625d07bf0d
domain: zha
type: remote_button_short_press
subtype: remote_button_short_press
trigger: device
- device_id: 880038593f81e164554c496e37d93153
domain: zha
type: remote_button_short_press
subtype: remote_button_short_press
trigger: device
condition: []
action:
- action: light.toggle
target:
entity_id: light.bureau
mode: single
- alias: toggle_plafond
trigger:
- device_id: 3f7bf0b1d53cb13c4212ef835580c4ca
domain: zha
type: remote_button_double_press
subtype: remote_button_double_press
trigger: device
- device_id: d9bf413036f7a7482d2681625d07bf0d
domain: zha
type: remote_button_double_press
subtype: remote_button_double_press
trigger: device
- device_id: 880038593f81e164554c496e37d93153
domain: zha
type: remote_button_double_press
subtype: remote_button_double_press
trigger: device
condition: []
action:
- action: light.toggle
target:
entity_id: light.plafond
- alias: turn_on_chambre
trigger:
- device_id: 3f7bf0b1d53cb13c4212ef835580c4ca
domain: zha
type: remote_button_long_press
subtype: button
trigger: device
- device_id: d9bf413036f7a7482d2681625d07bf0d
domain: zha
type: remote_button_long_press
subtype: button
trigger: device
- device_id: 880038593f81e164554c496e37d93153
domain: zha
type: remote_button_long_press
subtype: button
trigger: device
condition:
- condition: state
state: 'off'
entity_id: light.chambre
action:
- action: light.turn_on
target:
entity_id: light.chambre
mode: single
- alias: turn_off_chambre
trigger:
- device_id: 3f7bf0b1d53cb13c4212ef835580c4ca
domain: zha
type: remote_button_long_press
subtype: button
trigger: device
- device_id: d9bf413036f7a7482d2681625d07bf0d
domain: zha
type: remote_button_long_press
subtype: button
trigger: device
- device_id: 880038593f81e164554c496e37d93153
domain: zha
type: remote_button_long_press
subtype: button
trigger: device
condition:
- condition: state
state: 'on'
entity_id: light.chambre
action:
- action: light.turn_off
target:
entity_id: light.chambre
- alias: auto_turn_off_cuisine
description: ''
triggers:
- trigger: state
entity_id:
- light.switch_wall_cuisine
from: 'off'
to: 'on'
for:
hours: 0
minutes: 20
seconds: 0
conditions:
- condition: time
after: '22:00:00'
before: 07:00:00
- condition: state
entity_id: light.switch_wall_cuisine
state: 'on'
actions:
- action: light.turn_on
metadata: {}
data: {}
target:
entity_id: light.switch_wall_cuisine
mode: single
- alias: auto_turn_off_chambre_papa
description: ''
triggers:
- trigger: state
entity_id:
- light.switch_wall_chambre_papa
from: 'off'
to: 'on'
for:
hours: 0
minutes: 20
seconds: 0
conditions:
- condition: time
after: '22:00:00'
before: 07:00:00
- condition: state
entity_id: light.switch_wall_chambre_papa
state: 'on'
actions:
- action: light.turn_on
metadata: {}
data: {}
target:
entity_id: light.switch_wall_chambre_papa
mode: single
- alias: toggle_cuisine
description: ''
triggers:
- device_id: 631a266451fd7ad699e580f912b7fbf9
domain: zha
type: remote_button_short_press
subtype: left
trigger: device
conditions: []
actions:
- action: light.toggle
metadata: {}
data: {}
target:
entity_id: light.switch_wall_cuisine
mode: single
- alias: auto_turn_on_salle_de_bain
description: ''
triggers:
- trigger: state
entity_id:
- binary_sensor.pir_salle_de_bain
to: 'on'
conditions:
- condition: state
entity_id: light.switch_wall_salle_de_bain
state: 'off'
actions:
- action: light.turn_on
metadata: {}
data: {}
target:
entity_id: light.switch_wall_salle_de_bain
mode: single
- alias: auto_turn_off_salle_de_bain
description: ''
triggers:
- trigger: state
entity_id:
- binary_sensor.pir_salle_de_bain
to: 'off'
conditions:
- condition: state
entity_id: light.switch_wall_salle_de_bain
state: 'on'
actions:
- action: light.turn_off
metadata: {}
data: {}
target:
entity_id: light.switch_wall_salle_de_bain
mode: single
- alias: auto_turn_on_toilette
description: ''
triggers:
- trigger: state
entity_id:
- binary_sensor.pir_wc
to: 'on'
conditions:
- condition: state
entity_id: light.switch_wall_toilette
state: 'off'
actions:
- action: light.turn_on
metadata: {}
data: {}
target:
entity_id: light.switch_wall_toilette
mode: single
- alias: auto_turn_off_toilette
description: ''
triggers:
- trigger: state
entity_id:
- binary_sensor.pir_wc
to: 'off'
conditions:
- condition: state
entity_id: light.switch_wall_toilette
state: 'on'
actions:
- action: light.turn_off
metadata: {}
data: {}
target:
entity_id: light.switch_wall_toilette
mode: single
- alias: dismiss_lovelace_updated
id: '1309195316329'
mode: restart
trigger:
platform: event
event_type: lovelace_updated
action:
repeat:
count: 5
sequence:
- delay: 0.5
- service: browser_mod.notification
data:
duration: 1
message: ' '
- alias: notify_hass_update
id: '7958228563778'
trigger:
platform: state
entity_id:
- sensor.hass_release_notes
- sensor.hass_release_notes_beta
condition: '{{ state_attr(''sensor.template_updates'', ''home_assistant'') == 1
}}
'
action:
- service: homeassistant.update_entity
target:
entity_id:
- sensor.hass_release_notes
- sensor.hass_release_notes_beta
- delay:
minutes: 15
- service: notify.mobile_app_oneplus12
data:
title: '{% set installed = states(''sensor.current_version'') %} {{ states(''sensor.hass_release_notes'')
if version(installed).beta else states(''sensor.hass_release_notes'') }} disponible
{{ ''\U0001F389'' }}
'
message: Maintenir la touche enfoncée pour mettre à jour
data:
url: https://www.home-assistant.io/latest-release-notes/
actions:
- action: START_HA_UPDATE
title: Mise à jour
- alias: notify_hass_update_action
id: 0694774018396
trigger:
platform: event
event_type: mobile_app_notification_action
event_data:
action: START_HA_UPDATE
actions:
- action: update.install
data:
backup: true
target:
entity_id: update.home_assistant_core_update
- alias: notify_away_windows_open
description: send a notification if windows are opened while people are away
triggers:
- trigger: state
entity_id:
- person.kaoru
- person.papa
from: home
to: not_home
conditions:
- condition: and
conditions:
- condition: state
entity_id: person.kaoru
state: not_home
- condition: state
entity_id: person.papa
state: not_home
- condition: template
value_template: "{{ states.binary_sensor\n | selectattr('entity_id', 'match',\
\ '^binary_sensor\\.fenetre_')\n | selectattr('state', 'equalto', 'on')\n \
\ | list\n | count > 0 }}"
actions:
- action: notify.mobile_app_phone
metadata: {}
data:
message: "{% set ouvertures = states.binary_sensor | selectattr('entity_id',\
\ 'match', '^binary_sensor\\.fenetre_') | selectattr('state', 'equalto', 'on')\
\ | map(attribute='entity_id') | list %} \n{% set noms = ouvertures | map('replace',\
\ 'binary_sensor.fenetre_','') | map('replace', '_', ' ') | map('title') |\
\ list %} \n{% if noms | length == 1 %} La fenêtre {{ noms[0] }} est ouverte.\
\ {% else %} Les fenêtres {{ noms[:-1] | join(', ') }} et {{ noms[-1] }} sont\
\ ouvertes. {% endif %}"
title: ' Attention fenêtre encore ouverte ⚠️'
mode: single
- alias: notify_rainy_windows_open
description: send a notification if the windows are open the next time it rains
triggers:
- trigger: state
entity_id:
- sensor.meteo_france_next_rain
from: unknown
to: null
conditions:
- condition: template
value_template: "{{ states.binary_sensor\n | selectattr('entity_id', 'match',\
\ '^binary_sensor\\.fenetre_')\n | selectattr('state', 'equalto', 'on')\n \
\ | list\n | count > 0 }}"
actions:
- action: notify.mobile_app_phone
metadata: {}
data:
title: Il va pleuvoir 🌧️
message: '{% set ouvertures = states.binary_sensor | selectattr(''entity_id'',
''match'', ''^binary_sensor\.fenetre_'') | selectattr(''state'',''equalto'',
''on'') | map(attribute=''entity_id'') | list %} {% set noms = ouvertures |
map(''replace'', ''binary_sensor.fenetre_'','''') | map(''replace'', ''_'',
'' '') | map(''title'') | list %}
{% if noms | length == 1 %} La fenêtre {{ noms[0] }} est ouverte. {% else
%} Les fenêtres {{ noms[:-1] | join('', '') }} et {{ noms[-1] }} sont ouvertes.
{% endif %}'
mode: single
- alias: notify_low_battery
description: ''
triggers:
- trigger: time
at: 07:00:00
conditions:
- condition: template
value_template: "{% set batteries = states.sensor\n | selectattr('entity_id',\
\ 'match', '^sensor\\..*_batterie')\n | selectattr('state','<', '10')\n |\
\ map(attribute='entity_id')\n | list %}"
actions:
- action: notify.mobile_app_oneplus12
metadata: {}
data:
message: "{% set batteries = states.sensor | selectattr('entity_id', 'match','^sensor\\\
..*_batterie') | selectattr('state','<', '10') | map(attribute='entity_id')\
\ | list %}\n{% set noms = batteries | map('replace', 'sensor.', '') | map('replace','batterie',\
\ '') | map('replace', '_', ' ') | map('title') | list %}\n{% if noms\
\ | length == 1 %}\n La batterie {{ noms[0] }} est inférieure à 10%.\n{%\
\ else %}\n Les batteries sont inférieures à 10% :\n{% for nom in noms %}\n\
\ • {{ nom }}{% endfor %}\n{% endif %}"
title: "{% set batteries = states.sensor | selectattr('entity_id', 'match',\
\ '^sensor\\..*_batterie') | selectattr('state','<', '10') | map(attribute='entity_id')\
\ | list %}\n{% if noms | length == 1 %}\n Batterie faible \U0001FAAB⚠\n\
{% else %}\n Batteries faibles \U0001FAAB⚠\n{% endif %}"
mode: single
- alias: turn_off_gps_home_absence
trigger:
- platform: state
entity_id: person.kaoru
from: home
to: not_home
- platform: state
entity_id: person.papa
from: home
to: not_home
condition:
- condition: and
conditions:
- condition: state
entity_id: person.kaoru
state: not_home
- condition: state
entity_id: person.papa
state: not_home
action:
- service: light.turn_off
target:
entity_id: light.maison
- service: media_player.turn_off
target:
entity_id: media_player.samsung_tv_salon
- service: media_player.turn_off
target:
entity_id: media_player.samsung_tv_papa
- alias: turn_off_gps_papa_absence
trigger:
- platform: state
entity_id: person.papa
from: home
to: not_home
condition:
- condition: state
entity_id: person.papa
state: not_home
- condition: state
state: 'on'
entity_id: switch.computer_papa
action:
- action: switch.turn_off
target:
entity_id: switch.computer_papa
- service: media_player.turn_off
target:
entity_id: media_player.samsung_tv_papa
- service: light.turn_off
target:
entity_id: light.switch_wall_chambre_papa
- alias: turn_off_gps_william_absence
trigger:
- platform: state
entity_id: person.kaoru
from: home
to: not_home
condition:
- condition: state
entity_id: person.kaoru
state: not_home
actions:
- action: fan.turn_off
target:
entity_id: fan.xiaomi_smart_fan_2
- action: light.turn_off
target:
entity_id: light.chambre
mode: single
- alias: set_auto_off_smart_plug_spare
description: 'Lors de l''allumage ou de la modification de la durée, met à jour
auto_off.
'
triggers:
- entity_id:
- switch.smart_plug_spare_switch
to: 'on'
trigger: state
- entity_id: input_number.smart_plug_spare_duration
trigger: state
conditions: []
actions:
- target:
entity_id: input_datetime.smart_plug_spare_auto_off
data:
datetime: '{{ (now() + timedelta(minutes=states(''input_number.smart_plug_spare_duration'')
| int)) .strftime(''%Y-%m-%d %H:%M:%S'') }}
'
action: input_datetime.set_datetime
mode: single
- alias: turn_off_smart_plug_spare_switch
description: ''
triggers:
- trigger: time
at: input_datetime.smart_plug_spare_auto_off
conditions:
- condition: state
entity_id: switch.smart_plug_spare_switch
state: 'on'
actions:
- action: switch.turn_off
metadata: {}
data: {}
target:
entity_id: switch.smart_plug_spare_switch
mode: single