Last active
March 21, 2023 09:44
-
-
Save janeczku/e0f8dfba3a1947877a80a31a69824bc6 to your computer and use it in GitHub Desktop.
Gosund SP1 + Esphome
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
substitutions: | |
devicename: gosund_sp1_01 | |
friendlyname: SP1 Socket 01 | |
sp1_current_resistor: "0.00221" | |
sp1_voltage_divider: "871" | |
############# | |
# Note: These numbers were found online | |
# BW SHP2 Current Resistor: 0.0028 | |
# BW SHP2 Voltage Devider: 960 | |
# Gosund SP1 Current Resistor: 0.00221 | |
# Gosund SP1 Voltage Devider: 871 | |
# Gosund SP1 Current Resistor ALT: 0.00103 | |
# Gosund SP1 Voltage Devider ALT: 2160 | |
############# | |
red_led_pin: GPIO13 | |
blue_led_pin: GPIO1 | |
esphome: | |
name: $devicename | |
comment: $friendlyname | |
platform: ESP8266 | |
board: esp8285 | |
# WiFi connection | |
wifi: | |
ssid: !secret wifi_ssid | |
password: !secret wifi_password | |
ap: | |
ssid: ${devicename}_fallback | |
password: !secret wifi_fallback_password | |
ap_timeout: 1min | |
captive_portal: | |
# Enable logging | |
logger: | |
# Enable Home Assistant API | |
api: | |
password: !secret esphome_api_password | |
# Enable over-the-air updates | |
ota: | |
password: !secret esphome_api_password | |
# Enable Web server | |
web_server: | |
port: 80 | |
# Sync time with Home Assistant | |
time: | |
- platform: homeassistant | |
id: homeassistant_time | |
# Text sensors with general information | |
text_sensor: | |
- platform: version | |
name: ${friendlyname} Version | |
- platform: wifi_info | |
ip_address: | |
name: ${friendlyname} IP Address | |
sensor: | |
# Uptime sensor | |
- platform: uptime | |
name: ${friendlyname} Uptime | |
# WiFi Signal sensor | |
- platform: wifi_signal | |
name: ${friendlyname} Wifi Signal | |
update_interval: 10s | |
# Power sensor | |
- platform: hlw8012 | |
sel_pin: | |
number: GPIO12 | |
inverted: true | |
cf_pin: GPIO04 | |
cf1_pin: GPIO05 | |
current_resistor: ${sp1_current_resistor} | |
voltage_divider: ${sp1_voltage_divider} | |
change_mode_every: 8 | |
update_interval: 10s | |
# Current sensor | |
current: | |
name: ${friendlyname} Energy Current | |
unit_of_measurement: A | |
accuracy_decimals: 2 | |
# Voltage sensor | |
voltage: | |
name: ${friendlyname} Energy Voltage | |
unit_of_measurement: V | |
accuracy_decimals: 1 | |
# Power sensor | |
power: | |
id: power | |
name: ${friendlyname} Energy Power | |
unit_of_measurement: W | |
accuracy_decimals: 0 | |
# Total daily energy sensor | |
- platform: total_daily_energy | |
name: ${friendlyname} Daily Energy Usage | |
power_id: power | |
filters: | |
# Multiplication factor from W to kW is 0.001 | |
- multiply: 0.001 | |
unit_of_measurement: kWh | |
# Binary sensor for the power button | |
binary_sensor: | |
- platform: gpio | |
name: ${friendlyname} Power Button | |
id: button | |
pin: | |
number: GPIO3 | |
inverted: true | |
on_press: | |
- switch.toggle: fakebutton | |
switch: | |
# Switch to restart the plug | |
- platform: restart | |
name: ${friendlyname} Restart Switch | |
# Switch to toggle the relay | |
- platform: template | |
name: ${friendlyname} Power Switch | |
optimistic: true | |
id: fakebutton | |
turn_on_action: | |
- switch.turn_on: relay | |
- light.turn_on: led | |
turn_off_action: | |
- switch.turn_off: relay | |
- light.turn_off: led | |
- platform: gpio | |
id: relay | |
pin: GPIO14 | |
output: | |
# esphome state led | |
- platform: esp8266_pwm | |
id: state_led | |
pin: | |
number: ${blue_led_pin} | |
inverted: true | |
light: | |
# Power state light | |
- platform: monochromatic | |
output: state_led | |
id: led | |
# Uses the red LED as a status indicator | |
status_led: | |
pin: | |
number: ${red_led_pin} | |
inverted: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment