Created
February 8, 2024 19:26
-
-
Save uherting/23ad1e1260b842a847ea84455c0f9bd1 to your computer and use it in GitHub Desktop.
Test TRVs on runaway condition aka test all climate devices if the 'as is' temperature is way higher than the target temperature.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
domain: automation | |
name: Test TRVs on runaway condition (This is still considered to be a alpha version!!!) | |
description: >- | |
Regularly test all climate devices if the 'as is' temperature is way higher than the target temperature. | |
***Blueprint Revision:*** *1 / 2024-02-05* | |
source_url: https://gist.github.com/uherting/... | |
input: | |
threshold: | |
name: TRV warning level threshold in percent | |
description: Test TRVs on runaway condition. The runaway condition might be that the 'as is' temperature is way higher than the target temperature or way to low. | |
default: 22 | |
selector: | |
number: | |
min: 5 | |
max: 30 | |
unit_of_measurement: "%" | |
mode: slider | |
step: 0.5 | |
time: | |
name: Time to run detection on | |
description: "Detection is run at configured time" | |
default: "18:00:00" | |
selector: | |
time: {} | |
weekday: | |
name: Weekday(s) to run detection on | |
description: "Detection is run at configured time on the selected weekday(s)" | |
default: | |
- mon | |
- tue | |
- wed | |
- thu | |
- fri | |
- sat | |
- sun | |
selector: | |
select: | |
custom_value: false | |
mode: dropdown | |
multiple: true | |
options: | |
- label: Monday | |
value: mon | |
- label: Tuesday | |
value: tue | |
- label: Wednesday | |
value: wed | |
- label: Thursday | |
value: thu | |
- label: Friday | |
value: fri | |
- label: Saturday | |
value: sat | |
- label: Sunday | |
value: sun | |
exclude: | |
name: Excluded sensors (optional) | |
description: (???) sensors (e.g. ???) to exclude from detection. | |
default: [] | |
selector: | |
entity: | |
device_class: battery | |
multiple: true | |
bullet: | |
name: Bullet point icon | |
description: "Bullet point icon to list detected sensors" | |
default: "⦿" | |
selector: | |
text: | |
message: | |
name: Detection message | |
description: | | |
Detection message shown for a detected runaway condition. | |
The message can be freely formatted and supports the following placeholders: | |
!!bullet!! - is replaced with the choosen bullet point icon | |
!!sensor!! - is replaced with the name of the sensor | |
!!state!! - is replaced with the battery state in percent | |
!!temp_tgt!! - is replaced with the target temperature | |
!!temp_as_is!! - is replaced with the current temperature | |
default: "!!bullet!! !!entity_id!! !!sensor_name!!: TGT=!!temp_tgt!! IS:!!temp_as_is!! next mode = !!next_mode!!" | |
selector: | |
text: | |
order: | |
name: Sorting of messages | |
description: | | |
Sorting of messages is posible by the following criteria: | |
Alphabetical - sort alphabetical by sensor name | |
default: "name" | |
selector: | |
select: | |
custom_value: false | |
mode: dropdown | |
multiple: false | |
options: | |
- label: Alphabetical | |
value: name | |
actions: | |
name: Actions | |
description: | |
Notifications or similar to be run. {{sensors}} is replaced with | |
the names of sensors being in the runaway condition {{threshold}} is replaced with the threshold warning value. | |
selector: | |
action: {} | |
variables: | |
weekday: !input weekday | |
threshold: !input threshold | |
exclude: !input exclude | |
bullet: !input bullet | |
message: !input message | |
order: !input order | |
sensors: " | |
{# preparation #} | |
{% set mode_caller = 'off' %} | |
{% set accpted_incr = (threshold / 100) + 1.0 %} | |
{# go through all entities of the domain X #} | |
{% set domain = 'climate' %} | |
{% set result = namespace(sensors=[]) %} | |
{% for sensor in states[domain] %} | |
{% set temperature_tgt = state_attr(sensor.entity_id, 'temperature') %} | |
{% set temperature_as_is = state_attr(sensor.entity_id, 'current_temperature') %} | |
{# only add the entity to the result var if certain conditions apply #} | |
{% if | |
( | |
(mode_caller == 'off' ) | |
and | |
((temperature_tgt * accpted_incr) < temperature_as_is) | |
) | |
%} | |
{% set result.sensors = | |
result.sensors + [dict( | |
name = sensor.name, | |
entity_id= sensor.entity_id, | |
state = sensor.state, | |
temperature_tgt = state_attr(sensor.entity_id, 'temperature'), | |
temperature_as_is = state_attr(sensor.entity_id, 'current_temperature'), | |
next_mode = mode_caller | |
)] | |
%} | |
{% endif %} | |
{% endfor %} | |
{% set sensors = result.sensors | sort(attribute=order) %} | |
{# sort the sensors according the sort attribute #} | |
{% set sensors = result.sensors | sort(attribute=order) %} | |
{# do the formatting #} | |
{% set ns = namespace(sensor_names ='', line_cnt=0) %} | |
{% for sensor in sensors %} | |
{% set ns.sensor_names = | |
ns.sensor_names + (message | |
| replace('!!bullet!!', bullet) | |
| replace('!!entity_id!!', sensor.entity_id) | |
| replace('!!sensor_name!!', sensor.name) | |
| replace('!!state!!', sensor.state) | |
| replace('!!temp_tgt!!', sensor.temperature_tgt) | |
| replace('!!temp_as_is!!', sensor.temperature_as_is) | |
| replace('!!next_mode!!', sensor.next_mode) | |
~ '\n') | |
%} | |
{% set ns.line_cnt = ns.line_cnt + 1 %} | |
{% endfor %} | |
{{ ns.sensor_names }} | |
" | |
trigger: | |
- platform: time | |
at: !input time | |
condition: | |
condition: and | |
conditions: | |
- "{{ sensors | length > 1 }}" | |
- condition: time | |
weekday: !input weekday | |
action: !input actions | |
mode: single |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment