Physical switch and virtual switch

hi… i have a physical switch connected to binary_sensor from electric fan… and i have a virtual switch from esp32c3 connected to a 3v relay… im just worry THAT if i physically activate the switch and also activated the virtual switch… it will conflict and damage the fan motor… for example…

if i press the physical switch to let say first button which is the low speed of electric fan… which activated the relay for low speed… now if i activated the virtual switch third button which activated the relay for high speed… this is what i worry that the electric fan will have two different speed powering the motor…

is this okay and safe… very sorry but im a bit newbie to esphome and esp32 coding and my understanding is a bit low…

btw… both binary_sensor and virtual switch is working fine… but i just have not tested activating both… for now i just disconnect the physical switch to binary_sensor… so the fan is only working from virtual switch…

my solution is… my virtual switch which is a number slider… everytime i change it by sliding… i turn off ALL the relay first… with a delay… then turn on the relay which i selected in the slider number… is this the proper solution?

i have an automation from HA that when aircon turn off the fan will automatically turn on to low speed then after 30 minutes switch to medium speed then after 30 minutes switch to high speed… then when aircon turn on the fan will turn off…

thanks in advance…

Looks like you need to add the interlock option in your EspHome config for the switch if I understood correctly.

thanks for the reply… just read the interlock… seems the solution i needed…

with INTERLOCK and my solution to turn off all relay first before activating any relay to make it sure it is safe and only one relay is activated at a given time… i will update the result… thanks so much…

1 Like