I have 15 tuya thermostatic radiator valves, which are currently being controlled by homeassistant. Unfortunately they have a tendency to overshoot the target temperature, and it was reasonably straightforward to write a script that can monitor a single valve and turn if off and then back on in 30 secs (which closes the valve), if the target temperature is reached and the valve is open.
However, I would like to come up with a general solution that can monitor all 15 valves. From my reading of the automations it doesn’t seem like there is an easy way to have a single automation monitor all 15 valves separately, so I have been working on a script to loop through all the valves evaluating each one in turn, with the idea that I could run it every 5 minute and catch the valves that are overshooting. This seems less elegant, but should work, although I am having trouble getting my script to work correctly.
The script I have been trying to work on is below. The overall idea is it loops through all the valves in the group all_valves, and evaluates whether the current_temperature is greater than the (target) temperature, and if the valve is open, though I am having trouble getting the state_attr templates to evaluate correctly when using the variables I have defined - I am definitely a beginner and am probably making some sort of relatively elementary mistake with my value template.
alias: WIP Overshoot Monitor
sequence:
- variables:
entityids: '{{ expand(''group.all_valves'') | map(attribute=''entity_id'') | list }}'
- repeat:
count: '{{ entityids | count }}'
sequence:
- choose:
- conditions:
- condition: template
value_template: >-
{{
state_attr('{{entityids[repeat.index-1]}}','current_temperature')|int
>= state_attr('{{entityids[repeat.index-1]}}',
'temperature')|int }}
- condition: template
value_template: >-
{{ state_attr('{{entityids[repeat.index-1]}}','position') |
int > 40 }}
sequence:
- service: script.wip_overshoot_valve_interrupt
data:
service: script.wip_overshoot_valve_interrupt
data_template:
valvetointerrupt: >-
{{ state_attr('{{entityids[repeat.index-1]}}',
'friendly_name') }}
default: []
mode: single
My questions for more advanced HA user are:
-
Am I correct that there is not an easy way to do this with automations?
-
If so, or I suppose in addition, could anyone give me insight as to why my script is failing?
Thanks for any thoughts or insight!
Ted