Skip to content

Instantly share code, notes, and snippets.

@cscashby
Forked from Bouni/sp111.yml
Last active October 20, 2022 23:22
Show Gist options
  • Save cscashby/a293f50d3a55fb51dac35d51cafd5901 to your computer and use it in GitHub Desktop.
Save cscashby/a293f50d3a55fb51dac35d51cafd5901 to your computer and use it in GitHub Desktop.
ESPHome config for Gosund UP111 powerplugs (EDIT KEYS!)
---
substitutions:
devicename: "plug-XXX"
upper_devicename: "Plug XXX"
# 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: GPIO04
cf1_pin: GPIO05
button_pin: GPIO03
relay_pin: GPIO14
red_led_pin: GPIO13
blue_led_pin: GPIO01
esphome:
name: ${devicename}
esp8266:
board: esp01_1m
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "<INSERT KEY HERE>"
ota:
password: "<INSERT KEY HERE>"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Plug-XXX Fallback Hotspot"
password: "lVhCyIMtpsJ4"
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment