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!

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.