Last active
November 7, 2019 16:10
-
-
Save brianhanifin/290cd6c63134e54d638a936b527d6ffd to your computer and use it in GitHub Desktop.
See https://github.com/brianhanifin/esphome-config for current configuration + more.
This file contains 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
# Sonoff S31 Power Monitoring Plug | |
# | |
substitutions: | |
devicename: sonoff_s31_01 | |
upper_devicename: Sonoff S31 01 | |
esphome: | |
name: ${devicename} | |
platform: ESP8266 | |
board: esp01_1m | |
# Turn on the LED on boot | |
on_boot: | |
priority: -10 | |
then: | |
- light.turn_off: ${devicename}_green_led | |
wifi: | |
ssid: !secret wifi_ssid | |
password: !secret wifi_pass | |
# Disable logging over USB | |
logger: | |
baud_rate: 0 | |
# Configuration for power monitor | |
uart: | |
rx_pin: RX | |
baud_rate: 4800 | |
# Enable Home Assistant API | |
api: | |
ota: | |
safe_mode: True | |
binary_sensor: | |
- platform: status | |
name: ${upper_devicename} Status | |
id: ${devicename}_status | |
# - platform: gpio | |
# pin: | |
# number: GPIO0 | |
# mode: INPUT_PULLUP | |
# inverted: True | |
# name: ${upper_devicename} Button | |
# id: ${devicename}_button | |
# on_press: | |
# - switch.toggle: relay | |
# filters: | |
# - delayed_on: 10ms | |
light: | |
# Expose the "light" to Home Assistant | |
- platform: monochromatic | |
name: ${upper_devicename} Green LED | |
id: ${devicename}_green_led | |
internal: true # hide from Home Assistant | |
output: green_led | |
output: | |
# Register the green LED as a dimmable output | |
- platform: esp8266_pwm | |
id: green_led | |
pin: | |
number: GPIO13 | |
inverted: True | |
sensor: | |
- platform: wifi_signal | |
name: ${devicename}_wifi_signal | |
update_interval: 30s | |
- platform: uptime | |
name: ${devicename}_uptime | |
- platform: cse7766 | |
current: | |
name: ${upper_devicename} Current | |
voltage: | |
name: ${upper_devicename} Voltage | |
power: | |
name: ${upper_devicename} Power | |
switch: | |
- platform: gpio | |
name: ${upper_devicename} | |
id: relay | |
internal: true # hide from Home Assistant | |
pin: GPIO12 | |
restore_mode: ALWAYS_ON | |
text_sensor: | |
- platform: version | |
name: ${devicename}_esphome_version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I use this plug as a power monitor ONLY. I have chosen to leave the code as is, but I am confident that making the two changes I mention below will give you the standard full functionality.
Line #93 restore_mode: ALWAYS_ON ensures the relay is turned on when started (remark this line out if this is not desired). And the disabled code starting at line #43 disables the physical button (restore these lines if you want the physical button to work).
Bonus: if you want the green LED to turn on at startup, change line #16 to - light.turn_on: ${devicename}_green_led.