I have a Ventilation System that runs with a physical switch that turns from 0, 1, 2, 3 each increasing the speed of the system. Now I want to replace this physical switch with a relay controlled by home assistant. I have come so far to know how to add the rpi_gpio switches to my configuration.yaml and see them on my dashboard. In this way I can turn them all on or off.
But now I want to make sure that only one of the three switches may be turned on.
Goal:
when turning on switch 1, then 2 and 3 should be turned off.
when turning on switch 2, then 1 and 3 should be turned off.
when turning on switch 3, then 1 and 2 should be turned off.
I have already added a helper that has the four desired values and i can slide between them.
How do I get the helper to control my switches now?
I have tried implementing a disable switch boolean when other is turned on from this topic: Disable a switch if another switch is turned on
But I seem to not be able to implement it right. If I try putting the code in my configuration.yaml I get errors about the syntax.
So I have tried different ways on achieving my goal. But failed so far. Please help. I’m pretty new to Home Assistant.
Do you have a better idea for my topic?
Thanks in advance.
My specs running on a Raspberry Pi Zero (Only one I have at the moment)
core-2021.11.5
supervisor-2021.10.8
Host: Home Assistant OS 6.6
trigger:
- platform: state # trigger on any change of the input number
entity_id: input_number.zuluft
action:
- service: switch.turn_off
target:
entity_id:
- switch.zuluft_1
- switch.zuluft_2
- switch.zuluft_3
- condition: numeric_state # stop here with all switches off if input number = 0
entity_id: input_number.zuluft
above: 0
- service: switch.turn_on # otherwise turn the required switch on
target:
entity_id: "switch.zuluft_{{ states('input_number.zuluft')|int }}"
Thanks tom_l for that advice that works great with the slider.
But I also wanted to make sure no one can accidentally trigger multiple switches at once. That is why I included code, in my automations, to adjust the input number and to turn off all other switches.
Can I achieve this in your one automation as well?
Then I would add the other triggers like so
trigger:
- platform: state # trigger on any change of the input number
entity_id: input_number.zuluft
- platform: state
entity_id: switch.zuluft_1
to: 'on'
- platform: state
entity_id: switch.zuluft_2
to: 'on'
- platform: state
entity_id: switch.zuluft_3
to: 'on'
But how can I set the service for my input number?
In my automations, that I made, I knew exactly when switch 1 was pressed and then adjusted the input number like so.
I don’t know what physical switches/relays you are using but if you use two physical toggle switches and put the first speed on the normal closed of the first, the open of the first to the input of the second switch and the speed 2 on the normal closed of the second and speed 3 on the open of the second, in this case you only need two relays/switches and you can never activate two speeds… This is how also blinds are typically wired…