Shelly 1 & ESPHome - Bathroom Fan Control

Hi All,

I’ve hooked up a Shelly 1 to my bathroom extractor fan - previously it ran whenever the bathroom lights were on, which seemed unnecessary, so now I have a humidity sensor in there and use HA to turn it on when needed.
I had hoped to make use of the switched live signal that came from the light switch (previously going to the fan to turn it on with the lights) as a signal to the Shelly, so that I could also identify if the bathroom lights were on or off - this part however does not seem to be functioning… and I can’t work out why!

The circuit in use:

I should note the ‘3 pole switch’ before the fan/shelly is just an isolator switch - so assume that isn’t even there for this purpose :slight_smile:

I was hoping that the SW port of the Shelly could be used to detect 240v live when the light gets turned on, but this doesn’t appear to be the case - I get no output at all from the Shelly when the light it toggled. (Manual relay control of the fan works fine though)

My code (simplified to just toggle the fan on/off with the light switch signal):

# Device Specific Config
switch:
  - platform: gpio
    pin: GPIO4
    name: "Ensuite Extractor Fan"
    restore_mode: ALWAYS_OFF
    id: shelly_relay
    
binary_sensor:
  - platform: gpio
    internal: true
    pin:
      number: GPIO5
    # small delay to prevent debouncing
    filters:
      - delayed_on_off: 50ms
    # config for state change of input button
    on_state:
        then:
          - switch.toggle: shelly_relay
    id: button

Can anyone see any reason why this setup wouldn’t work ?