Hello,
I’m currently looking for the best way to update the heating mode of each heaters/zones in my apartment with an input_select. I’ll have 5 heater with 5 modes each, but hard configuring all the cases looks like overdoing it.
The input_select looks like this:
input_select:
heater_living_room:
name: Heater Living Room
options:
- Arret
- Confort
- Eco
- Hors Gel
- Confort -2
initial: Eco
icon: mdi:gauge
upon state changed, the following automation is started. This is where I’ll have 5*5 cases!
alias: Living Room Heater Select Eco
trigger:
platform: state
entity_id: input_select.heater_living_room
to: Eco
action:
- service: shell_command.living_room_2
this then triggers one of the following:
shell_command (only automation for case 2 is configured):
living_room_0: ‘echo 0aaaa > /dev/ttyUSB0’
living_room_1: ‘echo 1aaaa > /dev/ttyUSB0’
living_room_2: ‘echo 2aaaa > /dev/ttyUSB0’
living_room_3: ‘echo 3aaaa > /dev/ttyUSB0’
living_room_5: ‘echo 5aaaa > /dev/ttyUSB0’
(and thats only for one room)
So I was wondering
- if there is some kind of way to generalize the automation part, like being able to call the service with a variable based on the entity_id like this (names will need to be tweaked obviously):
alias: Living Room Heater Select Eco
trigger:
platform: state
entity_id: input_select.{%VARIABLE}
to: Eco
action:
- service: shell_command.{%VARIABLE}_2
and/or like this
living_room_{%VARIABLE}: ‘echo {%VARIABLE}aaaaa > /dev/ttyUSB0’
(this is obviously a completely wrong syntax)
- if there is also a way to match options from input_select (can’t use input_slider… or only with specific value like 0, 7, 4, 18, 20), with values to be used as variables for shell_command.
For some additional insight, I’m using an arduino connected in serial on HA and specific home made cards to create the 220V signal to control the heaters. Im passing the mode values to the 5 heaters by writing on /dev/ttyUSB0. Then the arduino pilots the High Voltage card (all is optocoupled) to generate the 220V signals, based on the ‘norme fil pilote’ we do have over here.
thanks a lot!