Sonoff 4CH

Trying to fit a number of Sonoff devices as slowly retro-fitting smart tech. It’s important for now though that the system is transparent.

I am planning a Sonoff 4Ch above the bathroom to control; lights, fan, heated mirror and towel radiator.

Eventually I may look for some more intelligent automation but for now I need the 3 relays for lights, fan and mirror to be linked to all come on together and when the original pull cord is used.

I think I have this now, but wondered if there was a smarter way to sync relays to follow each other?


    binary_sensor:
    - platform: gpio
      pin:
        number: GPIO3 #TX
        mode: INPUT_PULLUP
        inverted: True
      id: pullcord
      on_state:
        - light.toggle: light
    - platform: gpio
      pin:
        number: GPIO0
        mode: INPUT_PULLUP
        inverted: True
      id: sonoff_button_1
      on_press:
        - light.toggle: light
    - platform: gpio
      pin:
        number: GPIO9
        mode: INPUT_PULLUP
        inverted: True
      id: sonoff_button_2
      on_press:
        - switch.toggle: mirror
    - platform: gpio
      pin:
        number: GPIO10
        mode: INPUT_PULLUP
        inverted: True
      id: sonoff_button_3
      on_press:
        - switch.toggle: fan
    - platform: gpio
      pin:
        number: GPIO14
        mode: INPUT_PULLUP
        inverted: True
      id: sonoff_button_4
      on_press:
        - switch.toggle: towel
    - platform: gpio
      pin:
        number: GPIO12
      id: sonoff_relay1
      on_press:
        - switch.turn_on: mirror
        - switch.turn_on: fan
      on_release:
        - switch.turn_off: mirror
        - switch.turn_off: fan
    - platform: status
      id: status

    output:
    - platform: gpio
      pin: GPIO12
      id: relay_1

    switch:
    #- platform: gpio
    #  name: "Sonoff 4CH Relay 1 - Light"
    #  pin: GPIO12
    #  id: switch_1
    - platform: gpio
    #  name: "Sonoff 4CH Relay 2 - Mirror"
      pin: GPIO5
      id: mirror
    - platform: gpio
    #  name: "Sonoff 4CH Relay 3 - Fan"
      pin: GPIO4
      id: fan
    - platform: gpio
      name: "Bathroom Towel Radiator" # 4
      pin: GPIO15
      id: towel

    light:
    - platform: binary
      name: "Bathroom Light"
      id: light
      output: relay_1