I have an IR-controlled fan that I’m trying to automate.
The fan only supports a “toggle” command, so I have an IR transmitter in ESPHome that sends the same IR command for both “on” and “off”. This works, but the switch state in HA keeps getting out of sync with the real state.
Instead of a “toggle”, I want to implement discrete “on” and “off” commands that detect the current state of the fan and only trigger an IR transmission if the state needs to actually change.
I have a sensor driven by a power monitoring outlet that tells me if the fan is on or off based upon its power draw, so I know the current state of the fan.
I have set up a Template Switch for the fan using the state of that sensor, but it is still sending “on” and “off” commands to the ESPHome switch, which is still sending a “toggle” command.
What I want to do is configure a condition on one of these switches so that if they get sent a “turn on” command, but that sensor says its already “on”, then nothing actually happens.
Is that possible?