Skip to content

Instantly share code, notes, and snippets.

@Bouni
Last active February 1, 2023 12:34
Show Gist options
  • Save Bouni/40f21d99e44df3d2cbecb575bf8b7e9b to your computer and use it in GitHub Desktop.
Save Bouni/40f21d99e44df3d2cbecb575bf8b7e9b to your computer and use it in GitHub Desktop.
ESPHome config for Gosund SP111 V1.4 powerplugs
---
substitutions:
devicename: "powerplug-1"
upper_devicename: "Powerplug 1"
# Higher value gives lower watt readout
current_res: "0.002452"
# Lower value gives lower voltage readout
voltage_div: "939"
# GPIO config
sel_pin: GPIO12
cf_pin: GPIO05
cf1_pin: GPIO14
button_pin: GPIO13
relay_pin: GPIO15
red_led_pin: GPIO00
blue_led_pin: GPIO01
esphome:
name: $devicename
platform: ESP8266
board: esp8285
# Wifi settings
wifi:
networks:
- ssid: !secret wifi_ssid_home
password: !secret wifi_password_home
- ssid: !secret wifi_ssid_work
password: !secret wifi_password_work
# Enable logging
logger:
# Enable Home Assistant API
api:
# Enable over the air updates
ota:
# Enable Web server
web_server:
port: 80
# see: https://esphome.io/components/time.html
time:
- platform: homeassistant
id: homeassistant_time
text_sensor:
- platform: version
name: "Version"
icon: mdi:cube-outline
- platform: wifi_info
ip_address:
name: ip
ssid:
name: ssid
bssid:
name: bssid
sensor:
- platform: wifi_signal
name: "Wifi Signal"
icon: mdi:wifi
- platform: uptime
name: "Uptime"
icon: mdi:clock-outline
- platform: hlw8012
sel_pin:
number: ${sel_pin}
inverted: True
cf_pin: ${cf_pin}
cf1_pin: ${cf1_pin}
current_resistor: ${current_res}
voltage_divider: ${voltage_div}
update_interval: 3s
change_mode_every: 3
current:
name: "Ampere"
unit_of_measurement: A
accuracy_decimals: 3
icon: mdi:current-ac
voltage:
name: "Volt"
unit_of_measurement: V
accuracy_decimals: 1
icon: mdi:flash-outline
power:
name: "Watt"
unit_of_measurement: W
id: "power_wattage"
icon: mdi:gauge
- platform: total_daily_energy
name: "Todays Usage"
power_id: "power_wattage"
filters:
# Multiplication factor from W to kW is 0.001
- multiply: 0.001
unit_of_measurement: kWh
icon: mdi:calendar-clock
binary_sensor:
# Binary sensor for the button press
- platform: gpio
name: button
pin:
number: ${button_pin}
inverted: true
on_press:
- switch.toggle: relay
switch:
# Switch to restart the plug
- platform: restart
name: restart
# Switch to toggle the relay
- platform: gpio
id: relay
name: switch
pin: ${relay_pin}
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: ${red_led_pin}
inverted: true
light:
# Relay state light
- platform: monochromatic
output: state_led
id: led
status_led:
# Status light
pin:
number: ${blue_led_pin}
inverted: true
@Bouni
Copy link
Author

Bouni commented Jul 13, 2021

  • Create secrets.yml and define wifi_ssid and wifi_password
  • Build firmware with esphome compile sp11.yml
  • Upload powerplug/.pioenv/powerplug/firmware.bin using OTA (gzip firmware.bin first if Tasmota 9.5 is running)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment