Skip to content

Instantly share code, notes, and snippets.

@webbson
Last active October 31, 2020 12:15
Show Gist options
  • Save webbson/b0541959b92ad60c71e7faa3fbfaea98 to your computer and use it in GitHub Desktop.
Save webbson/b0541959b92ad60c71e7faa3fbfaea98 to your computer and use it in GitHub Desktop.
esphome config gosund sp111 as light
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: $voltage_divider
current_resistor: $current_resistor
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:
- light.toggle: internal_light
output:
# Relay state led
- platform: esp8266_pwm
id: state_led
pin:
number: GPIO2
inverted: true
- platform: gpio
id: light_relay
pin: GPIO15
light:
# Relay state light
- platform: monochromatic
output: state_led
id: led
- platform: binary
name: $plug
output: light_relay
id: internal_light
on_turn_on:
- light.turn_on: led
on_turn_off:
- light.turn_off: 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