Hi,
I am new to Home assistant, wanted to convert my smart plug to ESPHome plug but I didn’t find any “premade” configuration for it.
Here the amazon link if you want to buy them :
It’s based on a ESP8266-S3 ( which is the one made for slotted PCB I believe ).
After reading this page :
I have tweaked it to add the ESP blue led and the proper red led integration.
Enjoy
#Configuration for EFUN SH3331W Smart Plug
substitutions:
plug_name: esun_plug
# Higher value gives lower watt readout
current_res: "0.00221"
# Lower value gives lower voltage readout
voltage_div: "940"
esphome:
name: ${plug_name}
platform: ESP8266
board: esp01_1m
wifi:
ssid: "SSID"
password: "PASS"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esun Plug Fallback Hotspot"
password: "1J01nevV4P5p"
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
password: "PASS"
ota:
password: "PASS"
time:
- platform: homeassistant
id: homeassistant_time
binary_sensor:
- platform: gpio
pin:
number: GPIO13
inverted: True
name: "${plug_name}_button"
on_press:
then:
- switch.toggle: "${plug_name}_Relay"
- switch.toggle: "${plug_name}_LED_Blue"
switch:
- platform: gpio
name: "${plug_name}_Relay"
id: "${plug_name}_Relay"
pin: GPIO15
restore_mode: ALWAYS_ON
- platform: gpio
name: "${plug_name}_LED_Blue"
id: "${plug_name}_LED_Blue"
pin: GPIO2
inverted: True
restore_mode: ALWAYS_ON
- platform: gpio
name: "${plug_name}_ESP_LED"
pin: GPIO4
inverted: True
restore_mode: ALWAYS_ON
- platform: gpio
name: "${plug_name}_LED_Red"
pin: GPIO0
inverted: True
restore_mode: ALWAYS_OFF
sensor:
- platform: hlw8012
sel_pin:
number: GPIO12
inverted: True
cf_pin: GPIO05
cf1_pin: GPIO14
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: 10s
- 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