Background:
New to homeassistant, and just learning how it works (as well as being somewhat limited in my programming knowledge) I am adding a number of TUYA radiator valves, controlled by HA through zigbee2mqtt. While I am slowly switching over, eventually I should have a total of 15 valves scattered around the house. I am able to use MQTT.publish to push settings to individual valves.
alias: Set Away Temperature
sequence:
- service: mqtt.publish
data:
topic: zigbee2mqtt/Kitchen Playroom Valve/set
payload: '{"away_preset_temperature": 10}'
mode: single
However, I would love to be able to send settings to all 14 valves simultaneously, rather than having to create 14 separate scripts/automations. It would seem that the groups function of zigbee2mqtt would be helpful, but it does not seem to support these radiator valves currently, so I am trying to find another workaround
Question:
Is there some way to create a script or automation that can cycle through the list of valves, generating an MQTT.publish call for each of them? I have been playing with templates to try and generate a list of the MQTT.publish topics, but not having a ton of luck.
I know the scripting language does support looping, but having trouble figuring out how to directly apply it to my use case. The template below seems to generate the sequence of calls I would need, but it doesn’t seem that I can do this in a script (at least it won’t save or execute correctly).
{% for state in states.climate %}
- service: mqtt.publish
data:
topic: zigbee2mqtt/{{ state.name }}/set
payload: '{"away_preset_temperature": 12}'
{% endfor %}
Am I even possibly on the right track here? Or am I heading off into the wrong direction?