Hey all, I have a bunch of automations revolving around “People at home, open windows, outside temp, outside air quality”, all of them remember 0.100 releases or so
binary_sensor:
- platform: template
sensors:
# Returns true only when there is good air outside AND air outside is colder than inside
should_i_ventilate_home:
friendly_name: "Should I ventilate home?"
value_template: >-
{% if states('sensor.airly_pm2_5')|float > 15 -%}
False
{%- else -%}
{{ states('sensor.air_purifier_salon_temp')|float > states('sensor.airly_temperature')|float }}
{%- endif %}
# automations
- &window_template
alias: When back home- Open Window, it's chilly outside
trigger:
platform: state
entity_id: binary_sensor.people_at_home
from: "off"
to: "on"
condition:
condition: and
conditions:
- condition: state
entity_id: group.all_windows
state: "off"
- condition: state
entity_id: binary_sensor.should_i_ventilate_home
state: "on"
action:
- service: notify.notify_all_mobile_phones
data:
title: Otwórz okno
message: "It's chilly outside, You can open window!"
data:
tag: "home-ventillation"
- <<: *window_template
alias: Close Window, it's hot outside
trigger:
platform: state
entity_id: binary_sensor.should_i_ventilate_home
from: "on"
to: "off"
condition:
condition: and
conditions:
- condition: state
entity_id: binary_sensor.people_at_home
state: "on"
- condition: state
entity_id: group.all_windows
state: "on"
action:
- service: notify.notify_all_mobile_phones
data:
title: Close the window
message: "It's hot outside"
data:
tag: "home-ventillation"
- alias: Close Window, air quality is bad
trigger:
platform: numeric_state
entity_id: sensor.airly_pm2_5
above: 20
for:
minutes: 5
condition:
condition: and
conditions:
- condition: state
entity_id: binary_sensor.people_at_home
state: "on"
- condition: state
entity_id: group.all_windows
state: "on"
action:
- service: notify.notify_all_mobile_phones
data:
title: Close the window
message: "Bad air quality outside"
data:
tag: "home-ventillation"
- alias: Empty apartament with open windows
trigger:
platform: state
entity_id: binary_sensor.people_at_home
from: "on"
to: "off"
condition:
condition: and
conditions:
- condition: state
entity_id: group.all_windows
state: "on"
action:
- service: notify.notify_all_mobile_phones
data:
title: Close the window
message: "You left the aparament and left windows open. Is it safe?"
data:
tag: "home-ventillation"
I’d like to modernize them and use recent features of Home Assistant (My guesstimate is choose
can fit nicely in some of them), what do You suggest to re-implement/refactor this and keep it 2021.6.x style?