I flashed a Shelly 1L (without neutral) with ESPHome, and connected a regular two gang switch to it.
Both switch only do a toggle through the home assistant API in normal operations, with the relay being toggled only if HA is not connected :
binary_sensor: - platform: gpio name: Switch 1 pin: number: GPIO4 internal: True on_state: - homeassistant.service: service: switch.toggle data: entity_id: switch.light_bedroom_master_nightstand - platform: gpio name: Switch 2 pin: number: GPIO14 internal: True on_state: - if: condition: binary_sensor.is_on: ha_connected then: - if: condition: switch.is_off: relayid then: - switch.turn_on: relayid else: - homeassistant.service: service: light.toggle data: entity_id: light.light_bedroom_master_main else: - switch.toggle: relayid
Now as long as the relay is on, this works as expected.
But as soon as the relay is off for any reason it starts detecting ‘Switch 1’ toggling over and over, which toggles the nightstand light through home assistant. As soon as the relay is turned back on it starts behaving itself again.
Note that only Switch 1 is doing that, Switch 2 is fine meaning even if I shut HA off I can still operate the relay just fine through Switch 2, which fixes Switch 1 as soon as it goes on.
Any clue on why the state of the relay, which is a completely separate output not tied to these pins, would affect ‘Switch 1’ only ? Switch 2 is not affected.
I could have wired it wrong somehow but I can’t even think of what would lead to this weird behavior.