GOSUND EP2 Plug with ESPhome

I made it!

These little Smart-Sockets from gosund are really cheap and working fine.
Bad thing is: they cannot be flashed OTA with different firmware like ESPhome/Tasmota without opening and they work only with the Smart-Life app, so internet is always needed.
For flashing with ESPhome they have to be opened.
See here for how to open the gosund-plug for flashing.
to open the plug case i used a lathe wich worked fine without a damage!
Then i connected my USB-Flasher and flashed a blank esphome bin file.
So OTA was enabled.
After some trying with the gpios i got a running well ESPhome-Plug.
I then calibrateted voltage and current with a 2000W Heater and now the firmware is ready, also for you:

substitutions:
  plug_name: gosund_plug_1
  # Higher value gives lower watt readout
  current_res: "0.00221" # geeicht mit 2000W Heizlüfter
  # Lower value gives lower voltage readout
  voltage_div: "733"
  
esphome:
  name: gosund_plug_1
  platform: ESP8266
  board: esp8285

wifi:
  networks:
  - ssid: "--------"
    password: ""--------""
  - ssid: ""--------2""
    password: ""--------""
  - ssid: ""--------"3"
    password: ""--------""
  
  manual_ip:
    static_ip: 192.168.3.10
    gateway: 192.168.2.1
    subnet: 255.255.252.0
    
captive_portal:

logger:

api:
  password: ""--------""

ota:
  password: ""--------""

# Enable Web server
web_server:
  port: 80
  
time:
  - platform: homeassistant
    id: homeassistant_time


binary_sensor:
  # Binary sensor for the button press
  - platform: gpio
    name: "${plug_name}_button"
    pin:
      number: GPIO13
      inverted: true
    on_press:
      - switch.toggle: relay

switch:
  - platform: gpio
    id: relay
    name: "${plug_name}_Relay"
    restore_mode: ALWAYS_OFF
    pin: GPIO15
    on_turn_on:
      - light.turn_on: led
    on_turn_off:
      - light.turn_off: led
sensor:
  - platform: hlw8012
    sel_pin:
      number: GPIO12
      inverted: True
    cf_pin: GPIO05
    cf1_pin: GPIO04
    current_resistor: ${current_res}
    voltage_divider: ${voltage_div}
    current:
      name: "${plug_name}_Amperage"
      unit_of_measurement: A
    voltage:
      name: "${plug_name}_Voltage"
      unit_of_measurement: V
    power:
      name: "${plug_name}_Wattage"
      unit_of_measurement: W
      id: "${plug_name}_Wattage"
    change_mode_every: 8
    update_interval: 5s
  - platform: total_daily_energy
    name: "${plug_name}_Total Daily Energy"
    power_id: "${plug_name}_Wattage"
    filters:
        # Multiplication factor from W to kW is 0.001
        - multiply: 0.001
    unit_of_measurement: kWh
      
# Extra sensor to keep track of plug uptime
  - platform: uptime
    name: ${plug_name}_Uptime Sensor
    
  - platform: wifi_signal
    name: ${plug_name}_WiFi Signal
    update_interval: 60s

text_sensor:
  - platform: wifi_info
    ip_address:
      name: ${plug_name}_WiFi IP
    ssid:
      name: ${plug_name}_WiFi SSID
    
output:
  # blue LED
  - platform: esp8266_pwm
    id: state_led
    pin:
      number: GPIO02    
      inverted: true

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

# green LED
status_led:
  pin:
    number: GPIO00     
    inverted: true

i used the code from here but this code is for a different type of plug but gave me a good startpoint.
I added WiFi IP and SSID as sensor.

So now the first Gosund Plug is ready to use in a local network without using any cloud!
Have fun!

3 Likes

See Brilliant / Mirabella Genio Smart Plugs — ESPHome

Yes, good link!
But this i made is for gosund EP2 wich has different gpio’s and tuya convert doesn’t work anymore with these new plugs.

This plug was delivered to me with firmware version v1.0.4

if you send an email with the virtual ID of the plug (can be found in the GoSund app) to [email protected]
and ask them to enable v1.0.6 for you because you want to flash it with tuya convert. after that request they will do this for you.
(my plugs have been processed within the hour)

with v1.0.6 you can use Tuya Convert again.
hope this helps anyone.

4 Likes

Hi @TheFalcone are EP2 smart plugs working with esphome or tasmota?

If with esphome, can you confirm the yaml code of @mega-hz or post your version here?

How did you @mega-hz & @TheFalcone used Tuya-convert? On a raspi or the docker container?
Do you have a good Tuya-convert tutorial? I will first watch the Tuya-convert video from their GitHub site several times, hope that helps and answers all questions and necessary steps…
Thanks!

OK, I can strongly recommend this video in German. It is a great step by step video tutorial and works fine! → Tuya Convert Tasmota flashen 2022 [Gosund Nous Usmart EP2 Socket Steckdose] - YouTube

Hi derMick,

Make sure the firmware version is v1.0.6 see my previous comment here.
after its v1.0.6. i followed this tutorial Tuya Convert tutorial. one thing i struggled with was the wifi adapter. i asked around with friends & family to get a USB wifi adapter. i managed to get 2-3 devices as of which 2 unbranded ones worked. after that is was just following the tutorial.
good luck. let me know if it worked!

TheFalcone