Gosund up111 constantly unavailable please help

Hi guys,

I wanted to get into esphome in hope to run local smart plugs. I found a suitable plug as per this thread Flashable UK smart plugs

I flashed it and everything seemed great yet I’m being plagued by constant disconnections
I’ve checked my wifi (ORBI) and everything is fine, the wifi signal is steady around -71db

I can’t seem to find the cause as the intervals are random.

when I run the esphome logs in the add-on everything looks okay and it works fine, yet randomly it will appear unavailable in HA

below is the yml file I uploaded

esphome:
  name: laptop_charger
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: "--------"
  password: "---------------"
  manual_ip:
    static_ip: xx.x.x.xx
    gateway: xx.x.x.x
    subnet: xxx.xxx.xxx.x

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Laptop Charger Fallback Hotspot"
    password: "------------------"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

time:
  - platform: homeassistant

substitutions:
# Unique ID for Sensors.
  switch_id: "laptop_plug"

binary_sensor:
  # Push Button
  - platform: gpio
    id: ${switch_id}_in_switch1
    internal: true
    pin: GPIO3
    name: " Switch 1"
    filters:
      - invert:
    on_click:
      min_length: 50ms
      max_length: 350ms
      then:
        - switch.toggle: ${switch_id}_out_relay1
  # Template Sensor - Tracks Relay, Switches LED to Match (Internal Only)
  - platform: template
    name: "${switch_id} Template 1"
    id: ${switch_id}_template1
    internal: true
    lambda: |-
      if (id(${switch_id}_out_relay1).state) {
        return true;
      } else {
        return false;
      }
    on_state:
      - if:
          condition:
            - binary_sensor.is_on: ${switch_id}_template1
          then:
            - switch.turn_on: ${switch_id}_out_led
            - switch.turn_off: ${switch_id}_out_led_red
      - if:
          condition:
            - binary_sensor.is_off: ${switch_id}_template1
          then:
            - switch.turn_off: ${switch_id}_out_led  
            - switch.turn_on: ${switch_id}_out_led_red

switch:
  # Restart Switch in HA
  - platform: restart
    name: "${switch_id} Restart"
  # Relay Output
  - platform: gpio
    pin: GPIO14
    id: ${switch_id}_out_relay1
    name: "${switch_id} Relay"
  # Blue LED Output
  - platform: gpio
    pin: GPIO1
    internal: true
    id: ${switch_id}_out_led
    inverted: yes
    name: "${switch_id} Touch Status Led"  
  - platform: gpio
    id: ${switch_id}_out_led_red
    name: "${switch_id} Touch Status Led Red"
    pin: GPIO13
    inverted: True
    internal: true
    restore_mode: ALWAYS_OFF

sensor:
  - platform: hlw8012
    sel_pin:
      number: GPIO12
      inverted: True
    cf_pin: GPIO04
    cf1_pin: GPIO05
    # Calibration
    current_resistor: 0.0025 # Value of shunt resistor in ohms (higher value gives lower watt readout)
    voltage_divider: 880 # Resistance ratio of internal voltage divider resistors (lower value gives lower voltage readout)
    # Other person has:
    #current_resistor: 0.00221
    #voltage_divider: 871    
    current:
      name: "${switch_id} Current"
      unit_of_measurement: A
      id: "energy_temp_Amperage"
    voltage:
      name: "${switch_id} Voltage"
      unit_of_measurement: V
      id: "energy_temp_Voltage"
    power:
      name: "${switch_id} Power"
      unit_of_measurement: W
      id: "energy_temp_Wattage"
    change_mode_every: 8
    update_interval: 10s
  - platform: total_daily_energy
    name: "${switch_id} Total Daily Energy"
    power_id: "energy_temp_Wattage"
    filters:
        # Multiplication factor from W to kW is 0.001
        - multiply: 0.001
    unit_of_measurement: kWh
  - platform: template
    name: "${switch_id} Apparent Power"
    unit_of_measurement: VA
    lambda: return id(energy_temp_Voltage).state * id(energy_temp_Amperage).state;
  - platform: template
    name: "${switch_id} Power Factor"
    lambda: return id(energy_temp_Wattage).state / (id(energy_temp_Voltage).state * id(energy_temp_Amperage).state);

I later found the below, hoping there was something wrong with the above

# Gosund UP111

# Substitutions
substitutions:
  # Device Names
  device_name: "laptop_charger"
  friendly_name: "laptop charger"
  # Icon
  main_icon: "power-socket-uk"
  # Default Relay State
  # Aka: `restore_mode` in documentation
  # Options: `RESTORE_DEFAULT_OFF`, `RESTORE_DEFAULT_ON`, `ALWAYS_ON` & `ALWAYS_OFF`
  default_state: "RESTORE_DEFAULT_OFF"
  # Activity State Threshold
  # Threshold (number) that the device will change from `Idle` to `Active` if power is greater than or equal to
  activity_threshold: "5"

# Basic Config
esphome:
  name: "${device_name}"
  platform: ESP8266
  board: esp01_1m


wifi:
  ssid: "wifi"
  password: "passwd"
  manual_ip:
    static_ip: xx.x.x.xx
    gateway: xx.x.x.x
    subnet: xxx.xxx.xxx.0

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Laptop Charger Fallback Hotspot"
    password: "r7oNLkOmr3if"

captive_portal:

logger:
  level: VERBOSE
api:
ota:

time:
  - platform: sntp
    id: sntp_time

# Device Specific Config
binary_sensor:
  # Push Button (Toggles Relay When Pressed)
  - platform: gpio
    pin:
      number: GPIO3
      mode: INPUT_PULLUP
      inverted: true
    name: "${friendly_name} Button"
    on_press:
      - switch.toggle: relay
  - platform: status
    name: "${friendly_name} Server Status"

switch:
  # Relay (As Switch)
  - platform: gpio
    name: "${friendly_name}"
    icon: "mdi:${main_icon}"
    pin: GPIO14
    id: relay
    restore_mode: "${default_state}"
    on_turn_on:
      - light.turn_on:
          id: led
          brightness: 100%
          transition_length: 0s
    on_turn_off:
      - light.turn_off:
          id: led
          transition_length: 0s

sensor:
  # WiFi Signal Sensor
  - platform: wifi_signal
    name: "${friendly_name} WiFi Status"
    update_interval: 60s
  # Power Monitoring
  - platform: hlw8012
    sel_pin:
      number: GPIO12
      inverted: true
    cf_pin: GPIO4
    cf1_pin: GPIO05
    change_mode_every: 3
    update_interval: 3s
    voltage:
      name: "${friendly_name} Voltage"
      id: voltage
      unit_of_measurement: V
      accuracy_decimals: 1
      filters:
        # Map from sensor -> measured value
        - calibrate_linear:
            - 0.0 -> 0.0
            - 602.87506 -> 229.9
            - 609.8 -> 232.8
    power:
      name: "${friendly_name} Power"
      id: power
      unit_of_measurement: W
      accuracy_decimals: 0
      filters:
        # Map from sensor -> measured value
        - calibrate_linear:
            - 0.0 -> 1.14
            - 62.06167 -> 10.93
            - 1503.27161 -> 247.6
            - 1599.81213 -> 263.7
            - 3923.67700 -> 631.4
            - 7109.50928 -> 1148.0
            - 7237.0857 -> 1193.0
            - 7426.71338 -> 1217.0
    current:
      name: "${friendly_name} Current"
      id: current
      unit_of_measurement: A
      accuracy_decimals: 3
      filters:
        # Map from sensor -> measured value
        - calibrate_linear:
            - 0.0 -> 0.013
            - 0.08208 -> 0.071
            - 1.34223 -> 1.066
            - 5.57170 -> 4.408
            - 6.69184 -> 5.259
            - 6.97187 -> 5.540
  # Total daily energy sensor
  - platform: total_daily_energy
    name: "${friendly_name} Daily Energy"
    power_id: power
    filters:
      # Multiplication factor from W to kW is 0.001
      - multiply: 0.001
    unit_of_measurement: kWh

text_sensor:
  # Device Activity State
  # e.g. shows as active if power reading above a certain threshold
  - platform: template
    name: "${friendly_name} Activity State"
    icon: "mdi:${main_icon}"
    lambda: |-
      if (id(power).state >= $activity_threshold) {
        return {"Active"};
      } else {
        return {"Idle"};
      }
    update_interval: 5s

# Relay State LED
output:
  - platform: esp8266_pwm
    id: state_led
    pin:
      number: GPIO1
      inverted: true

light:
  - platform: monochromatic
    output: state_led
    id: led

status_led:
  pin:
    number: GPIO13
    inverted: True

can someone please help I’m pulling my hair out…

Here’s a known good config that “never” disconnects for me, and does not use the power monitoring. Perhaps try this and see if it helps. The substitutions section is just to help me deploy over multiple devices — you may also need to edit the gateway and subnet.

Curious that the board in your examples is esp01_1m but esp8285 for me: wonder if that’s the issue?

substitutions:
  devicename: gosund1
  upper_devicename: Gosund1
  ip: 192.168.1.40

esphome:
  name: $devicename
  platform: ESP8266
  board: esp8285

wifi:
  ssid: "XXXXXXXXX"
  password: "XXXXXXXXXX"
  manual_ip:
    static_ip: $ip
    gateway: 192.168.1.1
    subnet: 255.255.255.0

logger:

api:
  password: "XXXXXXX"

ota:
  password: "XXXXXXX"

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO3
      inverted: True
    name: "${upper_devicename} Power Button"
    on_press:
      - switch.toggle: relay

  - platform: status
    name: "${upper_devicename} status"

switch:
  - platform: gpio
    id: led
    pin:
      number: GPIO1
      inverted: true

  - platform: gpio
    id: red_led
    pin:
      number: GPIO13
      inverted: true
    
  - platform: gpio
    name: "${upper_devicename} Plug"
    pin: GPIO14
    id: relay
    on_turn_on:
      - switch.turn_on: red_led
      - switch.turn_off: led
    on_turn_off:
      - switch.turn_off: red_led
      - switch.turn_on: led

  - platform: restart
    name: "${upper_devicename} restart"
1 Like

thank you I’ll give it a try once I take delivery of another one.
I was impatient last night and ended up bricking it trying to move over to tasmota to see if they made any difference. :grimacing:

You may not have bricked it permanently: I found one of my two was particularly stubborn at flashing and gave the impression of being bricked. Does it still physically work with the button on the side?

after being faced with not enough space when trying to update to tasmota.bin I uploaded tasmota-minimal.bin seconds before reading dont use minimal for first flash…ahhhh! I should have used the lite version.

the button flashes red and there isn’t any ssid to connect too, I didn’t check if it still powered on/off with the button.

Probably worth persevering. That’s what mine did, but repeated long-press resets and getting the timing just right recovered it, although I’d not yet flashed it at that point.

1 Like

Suggestion would be to perform a factory reset (hold the power button for 10 seconds), then see if you can reflash it.

1 Like