Gosund SW1 + ESPHome Status LED

I just installed 4 Gosund SW1 switches in my house and used Tuya-Convert to get them provisioned on ESPHome to integrate with Home-Assistant, I am using the following YAML configuration in ESPHome for all 4 switches:

esphome:
  name: guest_room_switch
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Guest Switch Fallback Hotspot"
    password: !secret backup_ap_password

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: !secret api_password

ota:
  password: !secret ota_password
  
# TODO: Figure out how to get the status_led to turn off when the lights are off, right now this LED stays on continuously
status_led:
  pin:
    number: GPIO02
    inverted: no
    

binary_sensor:
  - platform: gpio
    name: "Guest Room Switch Button"
    pin:
      number: GPIO00
      mode: INPUT_PULLUP
      inverted: True
    on_press:
      - switch.toggle: relay

switch:
  - platform: gpio
    name: "Guest Room Switch Relay"
    id: relay
    pin: GPIO14

sensor:
  - platform: wifi_signal
    name: "Guest Room Switch WiFi signal"
    update_interval: 60s

  - platform: uptime
    name: "Guest Room Switch uptime"
    
text_sensor:
  - platform: version
    name: "Guest Room Switch ESPHome version"

The problem is the status_led remains “ON” continuously. Ideally I’d like the original behavior back whereby when the lights are ON the LED is ON, and when the lights are OFF the LED is OFF. I do realized the purpose of the status_led is to report if there are issues, so I suspect I want both behaviors both the status_led to report issues, but also behave like it was originally intended, if no issues the LED should be OFF when the lights are OFF, but should be ON when the lights are ON, unless there is a status that might cause it to blink otherwise. Any suggestions on how I might be able to get this to behave?

Thank you,
-Chris

Hi,
maybe you can use the information from this site:
https://templates.blakadder.com/gosund_SW1.html
For your configuration i would set inverted: yes for the LED. I have no idea if your Gosund SW1 has 2 LED’s, but the Tasmota template configure a green and a red one.

Hi S_E_B,

I did see that guide, and I have tried using GPIO16 per that document and that simply changed the color from green to red, also when I set inverted: yes the led stays off, no changes when switching the lights on or off, this happens in both cases (GPIO02 & GPIO16).

-Chris

Can you try this?

esphome:
  name: guest_room_switch
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Guest Switch Fallback Hotspot"
    password: !secret backup_ap_password

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: !secret api_password

ota:
  password: !secret ota_password
  
# TODO: Figure out how to get the status_led to turn off when the lights are off, right now this LED stays on continuously

status_led:
  pin:
    number: GPIO02
    inverted: true   ### changed to true
    

binary_sensor:
  - platform: gpio
    name: "Guest Room Switch Button"
    pin:
      number: GPIO00
      mode: INPUT_PULLUP
      inverted: True
    on_press:
      - switch.toggle: relay

switch:
  - platform: gpio
    name: "Guest Room Switch Relay"
    id: relay
    pin: GPIO14

###### begin insert
    on_turn_on:
      - light.turn_on: led
    on_turn_off:
      - light.turn_off: led

output:
  # Relay state led
  - platform: esp8266_pwm
    id: state_led
    pin:
      number: GPIO16
      inverted: true

light:
  # Relay state light
  - platform: monochromatic
    output: state_led
    id: led


###### insert end

sensor:
  - platform: wifi_signal
    name: "Guest Room Switch WiFi signal"
    update_interval: 60s

  - platform: uptime
    name: "Guest Room Switch uptime"
    
text_sensor:
  - platform: version
    name: "Guest Room Switch ESPHome version"
1 Like

Amazing, thank you @S_E_B , that did the trick !

Final Template:

esphome:
  name: bathroom_switch
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Bathroom Switch Fallback Hotspot"
    password: !secret backup_ap_password

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: !secret api_password

ota:
  password: !secret ota_password
  
status_led:
  pin:
    number: GPIO02
    inverted: true

binary_sensor:
  - platform: gpio
    name: "Bathroom Switch Button"
    pin:
      number: GPIO00
      mode: INPUT_PULLUP
      inverted: True
    on_press:
      - switch.toggle: relay

switch:
  - platform: gpio
    name: "Bathroom Switch Relay"
    id: relay
    pin: GPIO14
    on_turn_on:
      - light.turn_on: led
    on_turn_off:
      - light.turn_off: led

output:
  # Relay state led
  - platform: esp8266_pwm
    id: state_led
    pin:
      number: GPIO16
      inverted: true

light:
  # Relay state light
  - platform: monochromatic
    output: state_led
    id: led

sensor:
  - platform: wifi_signal
    name: "Bathroom Switch WiFi signal"
    update_interval: 60s

  - platform: uptime
    name: "Bathroom Switch uptime"
    
text_sensor:
  - platform: version
    name: "Bathroom Switch ESPHome version"

Nice to hear :slight_smile: