From 5ac24845960faecbf4baf9fc88f55ae59e59558b Mon Sep 17 00:00:00 2001 From: "@TribuneX" Date: Sun, 30 Jun 2024 20:45:25 +0200 Subject: [PATCH] feat: introduce blueprint for warm outside automation --- automation/environment/temperature.yaml | 31 +++--------- .../automation/temperature_outside.yaml | 49 +++++++++++++++++++ includes/binary_sensor.yaml | 7 +++ includes/exclude.yaml | 2 +- includes/sensors.yaml | 8 ++- 5 files changed, 71 insertions(+), 26 deletions(-) create mode 100644 blueprints/automation/temperature_outside.yaml diff --git a/automation/environment/temperature.yaml b/automation/environment/temperature.yaml index 53c1c77..e5c519f 100644 --- a/automation/environment/temperature.yaml +++ b/automation/environment/temperature.yaml @@ -1,32 +1,15 @@ - alias: "Temperature: Warmer outside" - initial_state: "on" - trigger: - - platform: numeric_state - entity_id: sensor.out_vs_in - above: 0 - condition: - condition: and - conditions: - - condition: state - entity_id: group.personen - state: "home" - - condition: numeric_state - entity_id: "sensor.outdoor_temperature" - above: "20" - - condition: state - entity_id: binary_sensor.balcony_door - state: "on" - action: - - service: notify.devices_user_1 - data: - title: "Doors" - message: "Close the living room doors, since it is {{states('sensor.out_vs_in')}}°C warmer outside." + use_blueprint: + path: temperature_outside.yaml + input: + out_vs_in: sensor.livingroom_out_vs_in + input_group_windows: binary_sensor.livingroom_doors - alias: "Temperature: Colder outside" initial_state: "on" trigger: - platform: numeric_state - entity_id: sensor.out_vs_in + entity_id: sensor.livingroom_out_vs_in below: -2 condition: condition: and @@ -44,7 +27,7 @@ - service: notify.devices_user_1 data: title: "Doors" - message: "Open the balcony door, since it is {{states('sensor.out_vs_in')}}°C colder outside." + message: "Open the balcony door, since it is {{states('sensor.livingroom_out_vs_in')}}°C colder outside." - alias: "Humidity warning" initial_state: "on" diff --git a/blueprints/automation/temperature_outside.yaml b/blueprints/automation/temperature_outside.yaml new file mode 100644 index 0000000..27dd07f --- /dev/null +++ b/blueprints/automation/temperature_outside.yaml @@ -0,0 +1,49 @@ +blueprint: + name: Warmer outside + description: Send notification if warmer outside + domain: automation + input: + out_vs_in: + name: Diff Temperature Sensor + description: The sensor calulating the diff betwenn a specific room and outdoor temperature + selector: + entity: + domain: sensor + input_group_windows: + name: Open Windows + description: The group of windows in the room + selector: + entity: + domain: binary_sensor + device_class: opening + +variables: + group_windows: !input input_group_windows + +trigger: + platform: numeric_state + entity_id: !input out_vs_in + above: 0 +condition: + condition: and + conditions: + - condition: state + entity_id: group.personen + state: "home" + - condition: numeric_state + entity_id: "sensor.outdoor_temperature" + above: "20" + - condition: state + entity_id: !input input_group_windows + state: "on" +action: + - service: notify.devices_user_1 + data: + title: "Doors" + message: > + Close the follwing doors, since it is {{states('sensor.livingroom_out_vs_in')}}°C warmer outside. + {%- for entity_id in states.[group_windows].attributes.entity_id if states(entity_id) == 'on' -%} + {%- if loop.first %} Open Doors: {% endif -%} + {{state_attr(entity_id, 'friendly_name') }} + {%- if not loop.last %}, {% endif -%} + {%- endfor -%} diff --git a/includes/binary_sensor.yaml b/includes/binary_sensor.yaml index d85414f..5685558 100644 --- a/includes/binary_sensor.yaml +++ b/includes/binary_sensor.yaml @@ -13,3 +13,10 @@ seconds: 60 value_template: > {{states('sensor.outdoor_illumination')|int < 8}} + +- platform: group + name: "Livingroom Doors" + device_class: opening + entities: + - binary_sensor.balcony_door + - binary_sensor.living_room_balcony_door diff --git a/includes/exclude.yaml b/includes/exclude.yaml index b416fba..9718a6d 100644 --- a/includes/exclude.yaml +++ b/includes/exclude.yaml @@ -1,7 +1,7 @@ entities: - sensor.network_in_eth0 - sensor.network_out_eth0 - - sensor.out_vs_in + - sensor.livingroom_out_vs_in - sensor.tribunex_home_assistant_last_build_state - sensor.illumination_gateway - sensor.palme_battery diff --git a/includes/sensors.yaml b/includes/sensors.yaml index a8042ec..825c78e 100644 --- a/includes/sensors.yaml +++ b/includes/sensors.yaml @@ -6,9 +6,15 @@ - platform: template sensors: # Inspired by https://community.home-assistant.io/t/temp-compare/19497 - out_vs_in: + livingroom_out_vs_in: value_template: "{{ (states('sensor.outdoor_temperature') | float) - (states('sensor.livingroom_temperature') | float) }}" friendly_name: "Temperature Diff" + unit_of_measurement: '°C' + + bedroom_out_vs_in: + value_template: "{{ (states('sensor.outdoor_temperature') | float) - (states('sensor.bedroom_temperature') | float) }}" + friendly_name: "Temperature Diff" + unit_of_measurement: '°C' robo: friendly_name: "Robo"