Skip to content

Instantly share code, notes, and snippets.

@webbson
Last active October 25, 2020 17:50
Show Gist options
  • Save webbson/937cc9cf014f67eea75afb328d223b0f to your computer and use it in GitHub Desktop.
Save webbson/937cc9cf014f67eea75afb328d223b0f to your computer and use it in GitHub Desktop.
esphome config gosund sp111 as switch
# Just change name here
substitutions:
plug: "Kitchen window"
plug_internal: kitchen_window
voltage_divider: "771"
current_resistor: "0.0012"
esphome:
name: ${plug_internal}
platform: ESP8266
board: esp8285
wifi:
ssid: !secret wifiname
password: !secret wifipass
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "${plug} Fallback Hotspot"
password: "3XtYLy5n2pgc"
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
web_server:
port: 80
sensor:
# Power sensor
- platform: hlw8012
voltage_divider: 771
# current_resistor: 0.001
current_resistor: 0.0012
sel_pin:
number: GPIO12
inverted: true
cf_pin: GPIO05
cf1_pin: GPIO04
change_mode_every: 3
update_interval: 5s
# Current sensor
current:
name: "${plug} current"
unit_of_measurement: A
accuracy_decimals: 3
# Voltage sensor
voltage:
name: "${plug} voltage"
unit_of_measurement: V
accuracy_decimals: 1
# Power sensor
power:
id: power
name: "${plug} power"
unit_of_measurement: W
accuracy_decimals: 0
filters:
- multiply: 0.5
binary_sensor:
# Binary sensor for the button press
- platform: gpio
name: "${plug} button"
pin:
number: GPIO13
inverted: true
on_press:
- switch.toggle: relay
switch:
# Switch to toggle the relay
- platform: gpio
id: relay
name: "${plug} relay"
pin: GPIO15
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: GPIO2
inverted: true
light:
# Relay state light
- platform: monochromatic
output: state_led
id: led
# Uses the red LED as a ESPhome status indicator
status_led:
pin:
number: GPIO0
inverted: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment