AutomationDataset/marcocunha/marcocunha_automations.yaml

1690 lines
50 KiB
YAML

- id: clear_active_mode
alias: Clear Active Mode
mode: single
description: Clears Active Mode Input Helper
trigger:
- platform: time
at: 07:00:00
condition: []
action:
- service: input_text.set_value
metadata: {}
data:
value: ''
target:
entity_id: input_text.active_mode
- id: clear_force_hot_water_helpers
alias: Clear Force Hot Water Helpers
mode: single
description: Clears Force Hot Water Helpers
trigger:
- platform: time
at:
- 00:00:00
- '10:00:00'
- '20:00:00'
condition: []
action:
- action: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.force_hot_water_off
- action: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.force_hot_water_on
- id: control_hot_water_schedule
alias: Control hot water based on schedule and solar energy production
description: Control hot water based on schedule and solar energy production
mode: single
trigger:
- platform: state
entity_id:
- schedule.hotwater_schedule
- platform: state
entity_id:
- input_boolean.force_hot_water_off
- platform: state
entity_id:
- input_boolean.force_hot_water_on
- platform: time_pattern
minutes: /15
condition: []
action:
- choose:
- conditions:
- condition: state
alias: Force the hot water to be switched off
entity_id: input_boolean.force_hot_water_off
state: 'on'
sequence:
- service: switch.turn_off
data: {}
target:
entity_id: switch.hot_water
- conditions:
- condition: state
alias: Force the hot water to be switched on
entity_id: input_boolean.force_hot_water_on
state: 'on'
sequence:
- service: switch.turn_on
data: {}
target:
entity_id: switch.hot_water
- conditions:
- condition: or
alias: Hot water schedule is ON or we have energy excess.
conditions:
- condition: state
entity_id: schedule.hotwater_schedule
state: 'on'
alias: Hot Water schedule is ON
- condition: template
value_template: '{{ states(''sensor.energy_consumption_mean_over_last_10_minutes'')|float
< -2000 }}'
alias: We have energy excess
- condition: template
value_template: "{{ states('sensor.resistencia_termoacumulador_temperature')\
\ <\n states('input_number.desired_hot_water_temperature') }}"
alias: Current temperature lower than desired temperature
sequence:
- service: switch.turn_on
data: {}
target:
entity_id: switch.hot_water
- conditions:
- condition: or
alias: Hot water schedule is OFF or has reached the desired temperature
conditions:
- condition: state
entity_id: schedule.hotwater_schedule
state: 'off'
alias: Hot Water schedule is OFF
- condition: template
value_template: "{{ states('sensor.resistencia_termoacumulador_temperature')\
\ >=\n states('input_number.desired_hot_water_temperature') }}"
alias: Actual temperature higher than desired temperature
sequence:
- service: switch.turn_off
data: {}
target:
entity_id: switch.hot_water
- id: control_swimming_pool_pump_based_schedule
alias: Control swimming pool pump based on schedule
description: Control swimming pool pump based on schedule
mode: single
trigger:
- platform: state
entity_id:
- schedule.swimming_pool_pump_schedule
condition: []
action:
- choose:
- conditions:
- condition: state
entity_id: schedule.swimming_pool_pump_schedule
state: 'on'
alias: Swimming pool pump schedule is ON
sequence:
- alias: Turn on pump
service: switch.turn_on
target:
device_id: 11352414f861aaceba25adee16b975f5
- conditions:
- condition: state
entity_id: schedule.swimming_pool_pump_schedule
state: 'off'
alias: Swimming pool pump schedule is OFF
sequence:
- alias: Turn off pump
service: switch.turn_off
target:
device_id: 11352414f861aaceba25adee16b975f5
- id: delete_cameras_snapshots
alias: Delete snapshot cameras
trigger:
- platform: homeassistant
event: start
- platform: time_pattern
hours: '7'
minutes: '0'
seconds: '0'
action:
- service: delete.files_in_folder
data:
folder: /config/www/doorbell/
time: 604800
only_extensions:
- .png
- .jpg
- id: fetch_periodically_alarm_status
alias: Fetch periodically alarm status
mode: single
max_exceeded: silent
trigger:
- platform: homeassistant
event: start
- platform: time_pattern
minutes: /10
condition:
- condition: or
alias: TV is off or macmini is not visible
conditions:
- condition: state
entity_id: media_player.lg_webos_tv_oled48c16la
state: 'off'
- condition: not
conditions:
- condition: state
entity_id: media_player.lg_webos_tv_oled48c16la
attribute: source
state: HDMI 3
alias: Mac mini is visible, probably being used
action:
- service: rest_command.trigger_alarm_status_check
data: {}
- id: frigate_motion_detected
alias: Frigate Motion detected
mode: single
max_exceeded: silent
trigger:
platform: mqtt
topic: frigate/events
condition:
- condition: or
conditions:
- condition: state
entity_id: input_boolean.anyone_home
state: 'off'
- condition: state
entity_id: alarm_control_panel.ajax_security_system
state: armed_home
action:
- service: notify.ha_mobile_apps
data_template:
message: A {{trigger.payload_json["after"]["label"]}} was detected.
data:
image: http://192.168.1.146:5000/api/events/{{trigger.payload_json["after"]["id"]}}/thumbnail.jpg?format=android
tag: '{{trigger.payload_json["after"]["id"]}}'
when: '{{trigger.payload_json["after"]["start_time"]|int}}'
ttl: 0
priority: high
- id: motion_detected_back
alias: Motion detected - Back
mode: single
max_exceeded: silent
variables:
notify_device: notify.ha_mobile_apps
trigger_entity: binary_sensor.dvr_camera_traseiras_motion_alarm_2
doorbell_cam: camera.dvr_camera_traseiras_main_2
notification_title: Movimento Detectado - Traseiras
persistent_notification: false
image_file: /local/doorbell/{{ expand(trigger_entity)[0].last_changed | as_timestamp |
timestamp_custom("%Y-%m-%d_%H-%M-%S-%f") }}.jpg
llm_model: gemini-1.5-pro
llm_prompt: Atua como sendo o responsável pelo meu sistema de segurança em casa.
Descreve a imagem numa frase curta usando Português de Portugal. Se vires pessoas,
descreve-as.
trigger:
platform: state
entity_id:
- binary_sensor.dvr_camera_traseiras_motion_alarm_2
from: 'off'
to: 'on'
for: 00:00:02
condition:
- condition: or
conditions:
- condition: state
entity_id: input_boolean.anyone_home
state: 'off'
- condition: state
entity_id: alarm_control_panel.ajax_security_system
state: armed_home
action:
- action: camera.snapshot
data:
filename: /config/www/doorbell/{{ expand(trigger_entity)[0].last_changed | as_timestamp |
timestamp_custom("%Y-%m-%d_%H-%M-%S-%f") }}.jpg
target:
entity_id: '{{doorbell_cam}}'
- action: llmvision.image_analyzer
data:
remember: false
include_filename: false
target_width: 1280
max_tokens: 100
temperature: 0.2
expose_images: false
image_file: /config/www/doorbell/{{ expand(trigger_entity)[0].last_changed |
as_timestamp | timestamp_custom("%Y-%m-%d_%H-%M-%S-%f") }}.jpg
provider: 01JFTMMBPD3Y5F42RRWGGZ8W73
message: '{{llm_prompt}}'
model: '{{ llm_model }}'
response_variable: llm_response
- service: notify.ha_mobile_apps
data:
title: '{{ notification_title }}'
message: '{{llm_response.response_text}}'
data:
tag: '{{ notification_title }}'
persistent: '{{ persistent_notification }}'
image: '{{ image_file }}'
ttl: 0
priority: high
actions:
- action: URI
title: Open Camera
uri: app://com.mm.android.DMSS
- delay:
minutes: 3
- id: motion_detected_frente
alias: Motion detected - Frente
mode: single
max_exceeded: silent
variables:
notify_device: notify.ha_mobile_apps
trigger_entity: binary_sensor.dvr_camera_frente_motion_alarm
doorbell_cam: camera.dvr_camera_frente_main
notification_title: Movimento Detectado na Frente
persistent_notification: false
image_file: /local/doorbell/{{ expand(trigger_entity)[0].last_changed | as_timestamp |
timestamp_custom("%Y-%m-%d_%H-%M-%S-%f") }}.jpg
llm_model: gemini-1.5-pro
llm_prompt: Atua como sendo o responsável pelo meu sistema de segurança em casa.
Descreve a imagem numa frase curta usando Português de Portugal. Se vires pessoas,
descreve-as.
trigger:
platform: state
entity_id:
- binary_sensor.dvr_camera_frente_motion_alarm
from: 'off'
to: 'on'
for: 00:00:02
condition:
- condition: or
conditions:
- condition: state
entity_id: input_boolean.anyone_home
state: 'off'
- condition: state
entity_id: alarm_control_panel.ajax_security_system
state: armed_home
action:
- action: camera.snapshot
data:
filename: /config/www/doorbell/{{ expand(trigger_entity)[0].last_changed | as_timestamp |
timestamp_custom("%Y-%m-%d_%H-%M-%S-%f") }}.jpg
target:
entity_id: '{{doorbell_cam}}'
- action: llmvision.image_analyzer
data:
remember: false
include_filename: false
target_width: 1280
max_tokens: 100
temperature: 0.2
expose_images: false
image_file: /config/www/doorbell/{{ expand(trigger_entity)[0].last_changed |
as_timestamp | timestamp_custom("%Y-%m-%d_%H-%M-%S-%f") }}.jpg
provider: 01JFTMMBPD3Y5F42RRWGGZ8W73
message: '{{llm_prompt}}'
model: '{{ llm_model }}'
response_variable: llm_response
- service: notify.ha_mobile_apps
data:
title: '{{ notification_title }}'
message: '{{llm_response.response_text}}'
data:
tag: '{{ notification_title }}'
persistent: '{{ persistent_notification }}'
image: '{{ image_file }}'
ttl: 0
priority: high
actions:
- action: URI
title: Open Camera
uri: app://com.mm.android.DMSS
- delay:
minutes: 3
- id: motion_detected_garage
alias: Motion detected - Garage
mode: single
max_exceeded: silent
variables:
notify_device: notify.ha_mobile_apps
trigger_entity: binary_sensor.dvr_camera_garagem_motion_alarm_2
doorbell_cam: camera.dvr_camera_garagem_sub_4
notification_title: Movimento Detectado na Garagem
persistent_notification: false
image_file: /local/doorbell/{{ expand(trigger_entity)[0].last_changed | as_timestamp |
timestamp_custom("%Y-%m-%d_%H-%M-%S-%f") }}.jpg
llm_model: gemini-1.5-pro
llm_prompt: Atua como sendo o responsável pelo meu sistema de segurança em casa.
Descreve a imagem numa frase curta usando Português de Portugal. Se vires pessoas,
descreve-as.
trigger:
platform: state
entity_id:
- binary_sensor.dvr_camera_garagem_motion_alarm_2
from: 'off'
to: 'on'
for: 00:00:02
condition:
- condition: or
conditions:
- condition: state
entity_id: input_boolean.anyone_home
state: 'off'
- condition: state
entity_id: alarm_control_panel.ajax_security_system
state: armed_home
action:
- action: camera.snapshot
data:
filename: /config/www/doorbell/{{ expand(trigger_entity)[0].last_changed | as_timestamp |
timestamp_custom("%Y-%m-%d_%H-%M-%S-%f") }}.jpg
target:
entity_id: '{{doorbell_cam}}'
- action: llmvision.image_analyzer
data:
remember: false
include_filename: false
target_width: 1280
max_tokens: 100
temperature: 0.2
expose_images: false
image_file: /config/www/doorbell/{{ expand(trigger_entity)[0].last_changed |
as_timestamp | timestamp_custom("%Y-%m-%d_%H-%M-%S-%f") }}.jpg
provider: 01JFTMMBPD3Y5F42RRWGGZ8W73
message: '{{llm_prompt}}'
model: '{{ llm_model }}'
response_variable: llm_response
- service: notify.ha_mobile_apps
data:
title: '{{ notification_title }}'
message: '{{llm_response.response_text}}'
data:
tag: '{{ notification_title }}'
persistent: '{{ persistent_notification }}'
image: '{{ image_file }}'
ttl: 0
priority: high
actions:
- action: URI
title: Open Camera
uri: app://com.mm.android.DMSS
- delay:
minutes: 3
- id: motion_detected_swimming_pool
alias: Motion detected - Swimming pool
mode: single
max_exceeded: silent
variables:
notify_device: notify.ha_mobile_apps
trigger_entity: binary_sensor.dvr_camera_piscina_motion_alarm_2
doorbell_cam: camera.dvr_camera_piscina_main_2
notification_title: Movimento Detectado na Piscina
persistent_notification: false
image_file: /local/doorbell/{{ expand(trigger_entity)[0].last_changed | as_timestamp |
timestamp_custom("%Y-%m-%d_%H-%M-%S-%f") }}.jpg
llm_model: gemini-1.5-pro
llm_prompt: Atua como sendo o responsável pelo meu sistema de segurança em casa.
Descreve a imagem numa frase curta usando Português de Portugal. Se vires pessoas,
descreve-as.
trigger:
platform: state
entity_id:
- binary_sensor.dvr_camera_piscina_motion_alarm_2
from: 'off'
to: 'on'
for: 00:00:02
condition:
- condition: or
conditions:
- condition: state
entity_id: input_boolean.anyone_home
state: 'off'
- condition: state
entity_id: alarm_control_panel.ajax_security_system
state: armed_home
action:
- action: camera.snapshot
data:
filename: /config/www/doorbell/{{ expand(trigger_entity)[0].last_changed | as_timestamp |
timestamp_custom("%Y-%m-%d_%H-%M-%S-%f") }}.jpg
target:
entity_id: '{{doorbell_cam}}'
- action: llmvision.image_analyzer
data:
remember: false
include_filename: false
target_width: 1280
max_tokens: 100
temperature: 0.2
expose_images: false
image_file: /config/www/doorbell/{{ expand(trigger_entity)[0].last_changed |
as_timestamp | timestamp_custom("%Y-%m-%d_%H-%M-%S-%f") }}.jpg
provider: 01JFTMMBPD3Y5F42RRWGGZ8W73
message: '{{llm_prompt}}'
model: '{{ llm_model }}'
response_variable: llm_response
- service: notify.ha_mobile_apps
data:
title: '{{ notification_title }}'
message: '{{llm_response.response_text}}'
data:
tag: '{{ notification_title }}'
persistent: '{{ persistent_notification }}'
image: '{{ image_file }}'
ttl: 0
priority: high
actions:
- action: URI
title: Open Camera
uri: app://com.mm.android.DMSS
- delay:
minutes: 3
- id: motion_detected_tablet
alias: Motion detected - Tablet
mode: single
max_exceeded: silent
variables:
notify_device: notify.ha_mobile_apps
trigger_entity: binary_sensor.wallpanel_samsung_tab_s_10_5_motion_detected
doorbell_cam: camera.wallpanel_samsung
notification_title: Movimento Detectado
notification_message: Tablet
persistent_notification: false
image_file: /local/doorbell/{{ expand(trigger_entity)[0].last_changed | as_timestamp |
timestamp_custom("%Y-%m-%d_%H-%M-%S-%f") }}.jpg
trigger:
platform: state
entity_id:
- binary_sensor.wallpanel_samsung_tab_s_10_5_motion_detected
to: 'on'
for: 00:00:02
condition:
- condition: or
conditions:
- condition: state
entity_id: input_boolean.anyone_home
state: 'off'
- condition: state
entity_id: alarm_control_panel.ajax_security_system
state: armed_home
action:
- data_template:
entity_id: camera.wallpanel_samsung
filename: /config/www/doorbell/{{ expand(trigger_entity)[0].last_changed | as_timestamp |
timestamp_custom("%Y-%m-%d_%H-%M-%S-%f") }}.jpg
service: camera.snapshot
- service: notify.ha_mobile_apps
data:
title: '{{ notification_title }}'
message: '{{ notification_message }}'
data:
tag: '{{ notification_title }}'
persistent: '{{ persistent_notification }}'
image: '{{ image_file }}'
ttl: 0
priority: high
- delay:
minutes: 3
- id: notify_swimming_pool_daily_working_hours
alias: Swimming pool daily working hours
description: Send a message about the daily operation time of the swimming pool
pump
variables:
send_notification: true
notify_device: notify.ha_mobile_apps
notification_title: Bomba da Piscina
persistent_notification: false
trigger:
- platform: time_pattern
hours: '21'
minutes: '30'
seconds: '0'
action:
- alias: Inform swimming pool pump was turned off due to time usage
service: notify.ha_mobile_apps
data:
title: '{{ notification_title }}'
message: '{{ ''A bomba hoje trabalhou: '' ~ states(''sensor.swimming_pool_pump_on_today'')|float ~
''h.''}}'
data:
tag: '{{ notification_title }}'
persistent: '{{ persistent_notification }}'
ttl: 0
priority: high
- id: offline_detection_for_z2m_devices_with_sensor
alias: Offline detection for Z2M devices with sensor z2m_offline_devices
description: Offline detection for Z2M devices with sensor z2m_offline_devices
mode: single
trigger:
- platform: state
entity_id:
- sensor.z2m_offline_devices
from: null
to: null
condition: []
action:
- service: notify.marco
metadata: {}
data:
message: The following Zigbee Devices are offline {{states('sensor.z2m_offline_devices')}}
- id: open_office_cover_if_is_too_dark
alias: Open office cover when it is too dark
description: If it is too dark, it automatically adjusts the shutter position.
mode: single
trigger:
- platform: state
entity_id:
- binary_sensor.sensor_occupancy_office_occupancy
to: 'on'
for:
hours: 0
minutes: 0
seconds: 0
alias: When someone in the office
- platform: numeric_state
entity_id: sensor.sensor_presence_office_illuminance
for:
hours: 0
minutes: 2
seconds: 0
below: 350
alias: When it is too dark
condition:
- condition: sun
before: sunset
after: sunrise
- condition: state
entity_id: switch.plug_monitor
state: 'on'
alias: Monitor is On
- condition: state
entity_id: input_boolean.anyone_home
state: 'on'
- condition: numeric_state
entity_id: cover.estores_escritorio
attribute: current_position
below: 75
alias: Curtains are below 75
action:
- service: cover.set_cover_position
data:
position: 75
target:
entity_id: cover.estores_escritorio
- id: remote_toggle_garage
alias: Toggle garage using remote.tuya.garagem
mode: single
trigger:
- platform: device
domain: mqtt
device_id: 149b39eaad8da492f392577d03198112
type: action
subtype: 1_single
discovery_id: 0xa4c1387d28db6c69 action_1_single
action:
- service: script.garage
data: {}
- id: remote_toggle_gate_button_3
alias: Toggle gate door using remote.tuya.garagem button 3
mode: single
trigger:
- platform: device
domain: mqtt
device_id: 149b39eaad8da492f392577d03198112
type: action
subtype: 3_single
action:
- service: switch.toggle
data: {}
target:
entity_id: switch.portao_exterior_switch_0
- id: remote_tuya_button_2
alias: Open and close garage using remote.tuya.garagem button 2
mode: single
trigger:
- platform: device
domain: mqtt
device_id: 149b39eaad8da492f392577d03198112
type: action
subtype: 2_single
action:
- service: script.garage
data: {}
alias: Open garage door
- delay:
hours: 0
minutes: 0
seconds: 30
milliseconds: 0
- service: script.garage
data: {}
alias: Close garage door
- id: send_notification_garage_door_is_open
alias: The garage door is open for a while
mode: restart
max_exceeded: silent
variables:
notify_device: notify.ha_mobile_apps
trigger_entity: binary_sensor.sensor_garage_door_contact
notification_title: Garagem Aberta
persistent_notification: true
trigger:
- platform: state
entity_id:
- binary_sensor.sensor_garage_door_contact
to: 'on'
for: 00:15:00
- platform: time_pattern
minutes: /20
- platform: state
entity_id:
- alarm_control_panel.ajax_security_system
to: armed_home
condition:
- condition: or
conditions:
- condition: state
entity_id: binary_sensor.sensor_garage_door_contact
state: 'on'
for:
hours: 0
minutes: 45
seconds: 0
alias: Door open for more than 45min
- condition: and
alias: Door open and nobody home
conditions:
- condition: state
entity_id: binary_sensor.sensor_garage_door_contact
state: 'on'
- condition: or
conditions:
- condition: state
entity_id: input_boolean.anyone_home
state: 'off'
- condition: state
entity_id: alarm_control_panel.ajax_security_system
state: armed_home
action:
- alias: Set up variables for the actions
variables:
action_close: '{{ ''CLOSE_GARAGE_'' ~ context.id }}'
action_ignore: '{{ ''IGNORE_'' ~ context.id }}'
- alias: Ask to close the garage door
service: notify.ha_mobile_apps
data:
title: '{{ notification_title }}'
message: Garagem aberta. Pretendes fechar?
data:
tag: '{{ notification_title }}'
persistent: '{{ persistent_notification }}'
ttl: 0
priority: high
actions:
- action: '{{ action_close }}'
title: Fechar
- action: '{{ action_ignore }}'
title: Ignorar
- alias: Wait for a response
wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ action_close }}'
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ action_ignore }}'
- alias: Perform the action
choose:
- conditions: '{{ (wait.trigger.event.data.action == action_close) and (is_state(''binary_sensor.sensor_garage_door_contact'',
''on'')) }}'
sequence:
- service: script.garage
data: {}
- id: send_notification_high_humidy_wc_servico
alias: Send notification if humitidy of WC Serviço is high
mode: restart
max_exceeded: silent
variables:
notification_title: Humidade WC Serviço
persistent_notification: false
trigger:
- platform: numeric_state
entity_id: sensor.wc_temperature_humidity_sensor_humidity
for:
hours: 0
minutes: 15
seconds: 0
above: 90
- platform: time_pattern
minutes: /10
condition:
- condition: numeric_state
entity_id: sensor.wc_temperature_humidity_sensor_humidity
above: 90
action:
- alias: Set up variables for the actions
variables:
action_ack: '{{ ''ACK_'' ~ context.id }}'
message: '{{ ''Humidade na WC Serviço demasiado alta: '' ~ states(''sensor.wc_temperature_humidity_sensor_humidity'') ~
''%. Liga a ventilação.''}}'
- alias: Send notification
service: notify.ha_mobile_apps
data:
title: '{{ notification_title }}'
message: '{{ message }}'
data:
tag: '{{ notification_title }}'
persistent: '{{ persistent_notification }}'
ttl: 0
priority: high
- id: send_notification_high_humidy_wc_suite
alias: Send notification if humitidy of WC Suite is high
mode: restart
max_exceeded: silent
variables:
notification_title: Humidade WC Suite
persistent_notification: false
trigger:
- platform: numeric_state
entity_id: sensor.sensor_temperature_humidity_wc_suite_humidity
for:
hours: 0
minutes: 15
seconds: 0
above: 90
- platform: time_pattern
minutes: /10
condition:
- condition: numeric_state
entity_id: sensor.sensor_temperature_humidity_wc_suite_humidity
above: 90
action:
- alias: Set up variables for the actions
variables:
action_ack: '{{ ''ACK_'' ~ context.id }}'
message: '{{ ''Humidade na WC Suite demasiado alta: '' ~ states(''sensor.sensor_temperature_humidity_wc_suite_humidity'') ~
''%. Liga a ventilação.''}}'
- alias: Send notification
service: notify.ha_mobile_apps
data:
title: '{{ notification_title }}'
message: '{{ message }}'
data:
tag: '{{ notification_title }}'
persistent: '{{ persistent_notification }}'
ttl: 0
priority: high
- id: send_notification_toaster_is_on
alias: Send notification if toaster is on
mode: restart
max_exceeded: silent
variables:
notify_device: notify.ha_mobile_apps
trigger_entity: switch.torradeira_plug
notification_title: Torradeira ligada
persistent_notification: true
trigger:
- platform: state
entity_id:
- switch.torradeira_plug
to: 'on'
for: 00:05:00
- platform: time_pattern
minutes: /5
condition:
- condition: state
entity_id: switch.torradeira_plug
state: 'on'
for:
hours: 0
minutes: 5
seconds: 0
action:
- alias: Set up variables for the actions
variables:
action_turnoff: '{{ ''TURN_OFF_'' ~ context.id }}'
action_ignore: '{{ ''IGNORE_'' ~ context.id }}'
- alias: Ask to turn off the toaster
service: notify.ha_mobile_apps
data:
title: '{{ notification_title }}'
message: Torradeira ligada por mais de 5 minutos. Pretende desligar?
data:
tag: '{{ notification_title }}'
persistent: '{{ persistent_notification }}'
ttl: 0
priority: high
actions:
- action: '{{ action_turnoff }}'
title: Desligar
- action: '{{ action_ignore }}'
title: Ignorar
- alias: Wait for a response
wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ action_turnoff }}'
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ action_ignore }}'
- alias: Perform the action
choose:
- conditions: '{{ wait.trigger.event.data.action == action_turnoff }}'
sequence:
- service: switch.turn_off
data: {}
target:
entity_id: switch.torradeira_plug
- id: set_anyone_home_off
alias: Anyone at home OFF
description: Set anyone_home to OFF when both are not at home
mode: single
trigger:
- platform: state
entity_id:
- person.marco_cunha
- person.darlene_parreira
to: not_home
condition:
- condition: and
conditions:
- condition: state
entity_id: person.marco_cunha
state: not_home
- condition: state
entity_id: person.darlene_parreira
state: not_home
action:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.anyone_home
- id: set_anyone_home_on
alias: Anyone at home ON
description: Set anyone_home to on when anyone is at home
mode: single
trigger:
- platform: state
entity_id:
- person.darlene_parreira
- person.marco_cunha
to: home
condition:
- condition: or
conditions:
- condition: state
entity_id: person.marco_cunha
state: home
- condition: state
entity_id: person.darlene_parreira
state: home
action:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.anyone_home
- id: set_both_home_off
alias: Both at home OFF
description: Set both_home to OFF when both are not at home
mode: single
trigger:
- platform: state
entity_id:
- person.marco_cunha
- person.darlene_parreira
to: not_home
condition:
- condition: or
conditions:
- condition: state
entity_id: person.marco_cunha
state: not_home
- condition: state
entity_id: person.darlene_parreira
state: not_home
action:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.both_home
- id: set_both_home_on
alias: Both at home ON
description: Set both_home to on when both at home
mode: single
trigger:
- platform: state
entity_id:
- person.darlene_parreira
- person.marco_cunha
to: home
condition:
- condition: and
conditions:
- condition: state
entity_id: person.marco_cunha
state: home
- condition: state
entity_id: person.darlene_parreira
state: home
action:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.both_home
- id: toaster_turn_off_automatically
alias: Turn off toaster automatically after 10min
mode: restart
max_exceeded: silent
variables:
notify_device: notify.ha_mobile_apps
trigger_entity: switch.torradeira_plug
notification_title: Torradeira desligada
persistent_notification: false
trigger:
- platform: state
entity_id:
- switch.torradeira_plug
to: 'on'
for: 00:10:00
- platform: time_pattern
minutes: /10
condition:
- condition: state
entity_id: switch.torradeira_plug
state: 'on'
for:
hours: 0
minutes: 10
seconds: 0
action:
- service: switch.turn_off
data: {}
target:
entity_id: switch.torradeira_plug
- alias: Notify toaster is off
service: notify.ha_mobile_apps
data:
title: '{{ notification_title }}'
message: Torradeira desligada automaticamente.
data:
tag: '{{ notification_title }}'
persistent: '{{ persistent_notification }}'
ttl: 0
priority: NORMAL
- id: turn_off_christmas_tree
alias: Turn off christmas tree
description: Turn off christmas tree at 23:01 or if no-one at home
mode: single
trigger:
- platform: time_pattern
hours: '23'
minutes: '1'
seconds: '0'
- platform: state
entity_id:
- input_boolean.anyone_home
to: 'off'
condition:
- condition: or
conditions:
- condition: state
entity_id: input_boolean.anyone_home
state: 'off'
- condition: time
after: '23:01:00'
alias: After 23:01h
action:
- type: turn_off
device_id: 5ba8c8993aef8a0ad6b1f06452ff8288
entity_id: switch.christmas_tree_socket_1
domain: switch
- id: turn_off_entrance_ambient_light_when_no_motion_is_detected
alias: Turn off Entrance Ambient Lights if no motion is detected
description: ''
mode: single
actions:
- alias: Turn off lights
parallel:
- action: light.turn_off
metadata: {}
data: {}
target:
entity_id: light.candeeiro_ambiente_2
- action: light.turn_off
metadata: {}
data: {}
target:
entity_id: light.switch_tomada_poltrona
triggers:
- minutes: /20
trigger: time_pattern
conditions:
- condition: numeric_state
entity_id: sensor.motion_sensor_illuminance
above: 50
- id: turn_off_office_leds_if_no_motion_detected
alias: Turn off Office LEDs if no motion is detected
description: ''
mode: single
trigger:
- platform: state
entity_id:
- sensor.sensor_presence_office_motion_state
to: none
for:
hours: 0
minutes: 5
seconds: 0
- platform: state
entity_id:
- binary_sensor.sensor_presence_office_presence
to: 'off'
for:
hours: 0
minutes: 5
seconds: 0
condition:
- condition: state
entity_id: light.light_office_leds
state: 'on'
action:
- service: light.turn_off
target:
device_id:
- 5e1d63d99c520bcaf7ab65d64a32e26d
data: {}
- id: turn_off_swimming_pool_pump_according_to_energy_usage
alias: Turn off swimming pool pump according to the energy usage
description: Turn off swimming pool pump according to the energy usage
mode: restart
max_exceeded: silent
variables:
send_notification: false
notify_device: notify.ha_mobile_apps
trigger_entity: binary_sensor.sensor_garage_door_contact
notification_title: Bomba da Piscina
persistent_notification: false
trigger:
- platform: numeric_state
entity_id: sensor.energy_consumption_mean_over_last_10_minutes
above: -300
alias: Not enough energy to have the swimming pool pump working
- platform: time_pattern
minutes: /20
condition:
- condition: and
conditions:
- condition: or
alias: Worked desired time or not enough energy production
conditions:
- condition: template
value_template: '{{states(''sensor.swimming_pool_pump_on_today'')|float >
states(''input_number.swimming_pool_minimum_duration_h'')|float}}'
alias: Swimming pool pump has been running for the required time
- condition: numeric_state
entity_id: sensor.energy_consumption_mean_over_last_10_minutes
above: -150
alias: Not enough power for the swimming pool pump
- condition: numeric_state
entity_id: sensor.bomba_piscina_switch_0_power
above: 0
alias: Swimming pool pump working
- condition: state
entity_id: schedule.swimming_pool_pump_schedule
state: 'off'
alias: Swimming pool pump schedule is OFF
action:
- alias: Set up variables for the actions
variables:
message: '{{ ''Produção demasiado baixa, consumo: '' ~ states(''sensor.energy_consumption_mean_over_last_10_minutes'') ~
''W. Desligada automaticamente.''}}'
- alias: Perform the action
service: switch.turn_off
target:
device_id: 11352414f861aaceba25adee16b975f5
- if: '{{ send_notification == true }}'
then:
- alias: Send a message to mobile app
choose:
- conditions:
- condition: template
value_template: '{{states(''sensor.swimming_pool_pump_on_today'')|float
> states(''input_number.swimming_pool_minimum_duration_h'')|float}}'
alias: Swimming Pool pump already worked the desired time
sequence:
- alias: Inform swimming pool pump was turned off due to time usage
service: notify.ha_mobile_apps
data:
title: '{{ notification_title }}'
message: '{{ ''Bomba já trabalhou : '' ~ states(''sensor.swimming_pool_pump_on_today'')|float ~
''h. Desligada automaticamente.''}}'
data:
tag: '{{ notification_title }}'
persistent: '{{ persistent_notification }}'
ttl: 0
priority: high
- conditions:
- condition: numeric_state
entity_id: sensor.average_consumption_inc_pool_pump
above: -150
sequence:
- alias: Inform swimming pool pump was turned off due to energy usage
service: notify.ha_mobile_apps
data:
title: '{{ notification_title }}'
message: '{{ message }}'
data:
tag: '{{ notification_title }}'
persistent: '{{ persistent_notification }}'
ttl: 0
priority: high
- id: turn_off_ventax_wc_guests
alias: Turn off ventax if humitidy of WC Guests is normal
mode: restart
max_exceeded: silent
variables:
notification_title: Humidade WC Serviço
persistent_notification: false
send_notification: false
trigger:
- platform: template
value_template: '{{ states(''sensor.wc_temperature_humidity_sensor_humidity'')
| float(0) < states(''input_number.bathroom_max_humidity_percentage'') | float(0)
}}'
for:
hours: 0
minutes: 10
seconds: 0
- platform: time_pattern
minutes: /20
condition:
- alias: DND is enabled or the humidity is at a normal level
or:
- condition: state
entity_id: schedule.dnd_schedule
state: 'on'
alias: DND is enabled
- and:
- condition: template
value_template: "{{ states('sensor.wc_temperature_humidity_sensor_humidity')\
\ | float(0)<\n states('input_number.bathroom_max_humidity_percentage')\
\ | float(0) }}"
- condition: state
entity_id: fan.multiswitch_wc_guests_center
state: 'on'
action:
- alias: Set up variables for the actions
variables:
action_ack: '{{ ''ACK_'' ~ context.id }}'
message: '{{ ''Humidade na WC Serviço normal: '' ~ states(''sensor.wc_temperature_humidity_sensor_humidity'') ~
''%. Ventilação desligada.''}}'
- if: '{{ send_notification == true }}'
then:
- alias: Send notification
service: notify.ha_mobile_apps
data:
title: '{{ notification_title }}'
message: '{{ message }}'
data:
tag: '{{ notification_title }}'
persistent: '{{ persistent_notification }}'
ttl: 0
priority: high
- alias: Perform the action
service: fan.turn_off
target:
entity_id: fan.multiswitch_wc_guests_center
- id: turn_off_ventax_wc_suite
alias: Turn off ventax if humitidy of WC Suite is normal
mode: restart
max_exceeded: silent
variables:
notification_title: Humidade WC Suite
persistent_notification: false
send_notification: false
trigger:
- platform: template
value_template: '{{ states(''sensor.sensor_temperature_humidity_wc_suite_humidity'')
| float(0) < states(''input_number.bathroom_max_humidity_percentage'') | float(0)
}}'
for:
hours: 0
minutes: 10
seconds: 0
- platform: time_pattern
minutes: /20
condition:
- alias: DND is enabled or the humidity is at a normal level
or:
- condition: state
entity_id: schedule.dnd_schedule
state: 'on'
alias: DND is enabled
- and:
- condition: template
value_template: "{{ states('sensor.sensor_temperature_humidity_wc_suite_humidity')\
\ | float(0) <\n states('input_number.bathroom_max_humidity_percentage')\
\ | float(0) }}"
- condition: state
entity_id: fan.multiswitch_wc_suite_ventax
state: 'on'
action:
- alias: Set up variables for the actions
variables:
action_ack: '{{ ''ACK_'' ~ context.id }}'
message: '{{ ''Humidade na WC Suite normal: '' ~ states(''sensor.sensor_temperature_humidity_wc_suite_humidity'') ~
''%. Ventilação desligada.''}}'
- if: '{{ send_notification == true }}'
then:
- alias: Send notification
service: notify.ha_mobile_apps
data:
title: '{{ notification_title }}'
message: '{{ message }}'
data:
tag: '{{ notification_title }}'
persistent: '{{ persistent_notification }}'
ttl: 0
priority: high
- alias: Perform the action
service: fan.turn_off
target:
entity_id: fan.multiswitch_wc_suite_ventax
- id: turn_on_christmas_tree
alias: Turn on christmas tree
description: Turn on christmas tree if anyone at home after sunset
mode: single
trigger:
- platform: sun
event: sunset
offset: 00:20:00
- platform: state
entity_id:
- input_boolean.anyone_home
to: 'on'
condition:
- condition: and
conditions:
- condition: state
entity_id: input_boolean.anyone_home
state: 'on'
- condition: sun
after: sunset
after_offset: 00:20:00
before: sunrise
- condition: time
before: '23:00:00'
alias: Before 23h
action:
- type: turn_on
device_id: 5ba8c8993aef8a0ad6b1f06452ff8288
entity_id: switch.christmas_tree_socket_1
domain: switch
- id: turn_on_coffee_machine_led_when_door_is_open
alias: Turn on coffee machine LED when door is open
mode: single
trigger:
- platform: state
entity_id:
- binary_sensor.sensor_motion_coffee_machine_occupancy
from: 'off'
to: 'on'
alias: Door opened
action:
- service: script.turn_on
target:
entity_id: script.turn_on_coffee_machine_led
data:
variables:
duration: 10
- id: turn_on_entrance_ambient_lights_when_motion_is_detected
alias: Turn on entrance ambient lights if motion is detected
description: ''
mode: single
triggers:
- trigger: state
entity_id:
- binary_sensor.motion_sensor_occupancy
condition:
- condition: numeric_state
entity_id: sensor.motion_sensor_illuminance
below: 30
- condition: not
alias: Active mode is not SLEEP
conditions:
- condition: state
entity_id: input_text.active_mode
state: SLEEP
actions:
- alias: Turn on lights
parallel:
- action: light.turn_on
metadata: {}
data: {}
target:
entity_id: light.candeeiro_ambiente_2
- action: light.turn_on
metadata: {}
data: {}
target:
entity_id: light.switch_tomada_poltrona
- id: turn_on_external_led_if_entrance_door_is_open
alias: Turn on external led if entrance door is open
mode: single
trigger:
- platform: state
entity_id:
- binary_sensor.door_entrance_contact
to: 'on'
from: 'off'
alias: Entrance door opened
condition:
- condition: sun
after: sunset
before: sunrise
action:
- service: script.turn_on_exterior_led
data:
duration: 15
- id: turn_on_external_led_if_motion_detected_frente
alias: Turn on external led if motion is detected in Frente
mode: single
max_exceeded: silent
variables:
camera: frente
trigger:
- platform: mqtt
topic: frigate/events
payload: frente/new
value_template: '{{ value_json[''after''][''camera''] | lower | replace(''-'',''_'')
}}/{{ value_json[''type'']}}'
condition:
- condition: or
alias: It must be a person or a car detected
conditions:
- condition: template
value_template: '{{ trigger.payload_json[''after''][''label''] == ''person''
}}'
alias: A Person
- condition: template
value_template: '{{ trigger.payload_json[''after''][''label''] == ''car'' }}'
alias: A Car
- condition: template
value_template: '{{ trigger.payload_json[''after''][''entered_zones'']|length
> 0 }}'
alias: Must entered a zone, otherwise ignore it
action:
- service: script.turn_on_exterior_led
data:
duration: 10
- id: turn_on_external_led_if_motion_detected_garagem
alias: Turn on external led if motion is detected in Garage
mode: single
max_exceeded: silent
variables:
camera: garagem
trigger:
- platform: mqtt
topic: frigate/events
payload: garagem/new
value_template: '{{ value_json[''after''][''camera''] | lower | replace(''-'',''_'')
}}/{{ value_json[''type'']}}'
condition:
- condition: or
alias: It must be a person or a car detected
conditions:
- condition: template
value_template: '{{ trigger.payload_json[''after''][''label''] == ''person''
}}'
alias: A Person
- condition: template
value_template: '{{ trigger.payload_json[''after''][''label''] == ''car'' }}'
alias: A Car
- condition: template
value_template: '{{ trigger.payload_json[''after''][''entered_zones'']|length
> 0 }}'
alias: Must entered a zone, otherwise ignore it
action:
- service: script.turn_on_exterior_led
data:
duration: 10
- id: turn_on_external_led_when_garage_door_is_open
alias: Turn on external LED when garage door is open
mode: single
trigger:
- platform: state
entity_id:
- binary_sensor.sensor_garage_door_contact
from: 'off'
to: 'on'
alias: Garage door opened
condition:
- condition: sun
after: sunset
before: sunrise
action:
- service: script.turn_on
target:
entity_id: script.turn_on_exterior_led
data:
variables:
duration: 15
- id: turn_on_external_led_when_outside_gate_is_open
alias: Turn on external LED when outside gate is open
mode: single
trigger:
- platform: state
entity_id:
- switch.portao_exterior_switch_0
from: null
to: 'on'
alias: Outside gate opened
condition:
- condition: sun
after: sunset
before: sunrise
action:
- service: script.turn_on
target:
entity_id: script.turn_on_exterior_led
data:
variables:
duration: 15
- id: turn_on_office_leds_if_motion_detected
alias: Turn on Office LEDs if motion is detected
description: ''
mode: single
trigger:
- platform: state
entity_id:
- sensor.sensor_presence_office_motion_state
to: large
- platform: state
entity_id:
- sensor.sensor_presence_office_motion_state
to: static
- platform: state
entity_id:
- binary_sensor.sensor_presence_office_presence
to: 'on'
condition:
- condition: numeric_state
entity_id: sensor.sensor_presence_office_illuminance
below: 800
action:
- service: light.turn_on
data:
brightness: 20
target:
device_id: 5e1d63d99c520bcaf7ab65d64a32e26d
- id: turn_on_swimming_pool_pump_according_to_energy_usage
alias: Turn on swimming pool pump according to the energy usage & schedule
description: Turn on swimming pool pump according to the energy usage & schedule
mode: single
variables:
send_notification: false
notify_device: notify.ha_mobile_apps
notification_title: Bomba da Piscina
persistent_notification: false
trigger:
- platform: time_pattern
minutes: /10
- platform: state
entity_id:
- schedule.swimming_pool_pump_schedule
condition:
- condition: or
conditions:
- condition: and
alias: Energy consumption conditions
conditions:
- condition: template
value_template: '{{states(''sensor.swimming_pool_pump_on_today'')|float <=
states(''input_number.swimming_pool_minimum_duration_h'')|float}}'
alias: Swimming Pool pump working for less than X time
- condition: numeric_state
entity_id: sensor.average_consumption_inc_pool_pump
below: -150
alias: Enough energy to have the swimming pool pump working
- condition: numeric_state
entity_id: sensor.bomba_piscina_switch_0_power
below: 0.1
alias: Pump turned off
- condition: time
after: 08:00:00
- condition: state
entity_id: schedule.swimming_pool_pump_schedule
state: 'on'
alias: Swimming pool pump schedule is ON
action:
- alias: Perform the action
service: switch.turn_on
target:
device_id: 11352414f861aaceba25adee16b975f5
- if: '{{ send_notification == true }}'
then:
- alias: Inform swimming pool pump was turned on
service: notify.ha_mobile_apps
data:
title: '{{ notification_title }}'
message: Bomba da piscina ligada
data:
tag: '{{ notification_title }}'
persistent: '{{ persistent_notification }}'
ttl: 0
priority: high
- id: turn_on_ventax_high_humidy_wc_guests
alias: Turn on ventax if humitidy of WC Guests is high
mode: restart
max_exceeded: silent
variables:
notification_title: Humidade WC Guests
persistent_notification: false
send_notification: false
trigger:
- platform: template
value_template: '{{ states(''sensor.wc_temperature_humidity_sensor_humidity'')
| float(0) >= states(''input_number.bathroom_max_humidity_percentage'') | float(0)
}}'
for:
hours: 0
minutes: 5
seconds: 0
- platform: time_pattern
minutes: /20
condition:
- condition: template
value_template: "{{ states('sensor.wc_temperature_humidity_sensor_humidity') |\
\ float(0) >=\n states('input_number.bathroom_max_humidity_percentage')\
\ | float(0) }}"
- condition: state
entity_id: fan.multiswitch_wc_guests_center
state: 'off'
- condition: state
entity_id: schedule.dnd_schedule
state: 'off'
action:
- alias: Set up variables for the actions
variables:
action_ack: '{{ ''ACK_'' ~ context.id }}'
message: '{{ ''Humidade na WC Serviço demasiado alta: '' ~ states(''sensor.wc_temperature_humidity_sensor_humidity'') ~
''%. Ventilação ligada.''}}'
- if: '{{ send_notification == true }}'
then:
- alias: Send notification
service: notify.ha_mobile_apps
data:
title: '{{ notification_title }}'
message: '{{ message }}'
data:
tag: '{{ notification_title }}'
persistent: '{{ persistent_notification }}'
ttl: 0
priority: high
- alias: Perform the action
service: fan.turn_on
target:
entity_id: fan.multiswitch_wc_guests_center
- id: turn_on_ventax_high_humidy_wc_suite
alias: Turn on ventax if humitidy of WC Suite is high
mode: restart
max_exceeded: silent
variables:
notification_title: Humidade WC Suite
persistent_notification: false
send_notification: false
trigger:
- platform: template
value_template: '{{ states(''sensor.sensor_temperature_humidity_wc_suite_humidity'')
| float(0)>= states(''input_number.bathroom_max_humidity_percentage'') | float(0)}}'
for:
hours: 0
minutes: 5
seconds: 0
- platform: time_pattern
minutes: /20
condition:
- condition: template
value_template: "{{ states('sensor.sensor_temperature_humidity_wc_suite_humidity')\
\ | float(0) >=\n states('input_number.bathroom_max_humidity_percentage')\
\ | float(0)}}"
- condition: state
entity_id: fan.multiswitch_wc_suite_ventax
state: 'off'
- condition: state
entity_id: schedule.dnd_schedule
state: 'off'
action:
- alias: Set up variables for the actions
variables:
action_ack: '{{ ''ACK_'' ~ context.id }}'
message: '{{ ''Humidade na WC Suite demasiado alta: '' ~ states(''sensor.sensor_temperature_humidity_wc_suite_humidity'') ~
''%. Ventilação ligada.''}}'
- if: '{{ send_notification == true }}'
then:
- alias: Send notification
service: notify.ha_mobile_apps
data:
title: '{{ notification_title }}'
message: '{{ message }}'
data:
tag: '{{ notification_title }}'
persistent: '{{ persistent_notification }}'
ttl: 0
priority: high
- alias: Perform the action
service: fan.turn_on
target:
entity_id: fan.multiswitch_wc_suite_ventax