Hi everybody,
[[UPDATE 1]] about querying the group, I found out that I can do this by using {{ states.group.testslider.attributes.entity_id }}
; this will output ('input_number.slider1', 'input_number.slider2')
. I’ll keep researching this while hopefully getting some input here as well
I guess what I am attempting to do is much easier in the US where most people have a thermostat and AC in their house that can be controlled; however, here (Germany) I only have one mobile AC - all other rooms are heated by stationary radiators (1-2 per room) and a handful of infrared heaters. I would like to both control as well as automate these radiators, which all have a zigbee controlled knob that measures current temperature as well as regulates each radiator. (sorry for the long intro)
Either way, that was just so that you understand what I am trying to achieve. Currently I do this with ioBroker
and node-red
, but I am in the process of switching entirely to home-assistant
. Each radiator will be controlled via zigbee2mqtt.
My attempt so far
- created two test inputs
slider1:
name: radiators/office
initial: 18
min: 5
max: 28
step: 1
slider2:
name: radiators/kitchen
inital: 16
min: 8
max: 25
step: 1
In templates
, I can get the current status of each slider by using {{ states.input_number.slider<n>.state }}
. So if I enter {{ states.input_number.slider1.state }}
, I currently get 6
, which is what I had set this slider to. So far, so good.
- created a group in
groups.yaml
testslider:
name: My sliders
entities:
- input_number.slider1
- input_number.slider2
Is it possible to do something like this (but not exactly like it, because it does not work) as an automation:
- id: 'someid'
alias "publish each slider value"
trigger:
{% for entity_id in group.testslider %} # so that I will get EACH new slider automatically
# when change in {{ states.input_number.slider<n> }}
action:
service: mqtt.publish
data:
topic: "{{ name.entity_id }}/set" # for example "radiators/office/set"
payload: "{{ states.input_number.slider<n> }}"
qos: 2
retain: true
I am aware that this is awful syntax, but I thought it might explain what I am trying to achieve; if not:
whenever any slider in that group changes it’s value, publish this value to “<that_sliders_name>/set”. So if I change slider1
from 6
to 12
, then mqtt.publish
{"topic": "radiators/office/set", "payload: 12, "qos": 2, "retain": true}
.
While I could just manually write an automation for each radiator, I am sure that this can somehow be achieved with jinja2. Also, I would later like to do the same for incoming values (so if somebody manually changed a radiator from 6 to 12 -triggering it to publish this via mqtt on its own- I want to update the slider’s value accordingly. I couldn’t even figure out how to query each entity_id in that group, but I’ll continue researching; though hopefully somebody on here can help me with a simple example automation that I can build upon for what I actually need to do
Thanks in advance for your help.