Sonoff S31 Relay Immediately On?

Hi All,

Was curious how I could enable the S31 Relay to be immediately on when it comes up, right now its defaulting into the off state.

# Device Specific Config

uart:
  rx_pin: RX
  baud_rate: 4800
  
binary_sensor:
  - platform: gpio
    pin:
      number: GPIO0
      mode: INPUT_PULLUP
      inverted: True
    name: "Dishwasher S31 Button"
    on_press:
      - switch.toggle: relay

switch:
  - platform: gpio
    name: "Dishwasher S31 Relay"
    pin: GPIO12
    id: relay

sensor:
  - platform: cse7766
    update_interval: 2s
    current:
      name: "Dishwasher S31 Current"
    voltage:
      name: "Dishwasher S31 Voltage"
    power:
      name: "Dishwasher S31 Power"

status_led:
  pin:
    number: GPIO13

Use on_boot to turn on your relay: https://esphome.io/components/esphome.html#on-boot

Alternatively you can use restore_mode: RESTORE_DEFAULT_ON to restore it to the last state or if that is not possible to turn it on. https://esphome.io/components/switch/gpio.html#configuration-variables you can also use ALWAYS_ON which will have the same effect as switching it on with on_boot.

1 Like

Thank you worked perfectly and thanks for linking the documentation, learned a great deal.

Is there a way to make this configurable without having to re-upload esphome to the outlet? I am guessing not but still hoping :slight_smile: