Created
February 1, 2021 14:39
-
-
Save FireBall1725/2cf43613d29b6093c5fb89c53b12b7a0 to your computer and use it in GitHub Desktop.
ESPHome Sonoff S31
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
substitutions: | |
device_name: "sonoff_s31" | |
plug_name: "Sonoff S31 Template" | |
esphome: | |
name: ${device_name} | |
platform: ESP8266 | |
board: esp01_1m | |
esp8266_restore_from_flash: true | |
wifi: | |
ssid: !secret wifi_ssid | |
password: !secret wifi_password | |
logger: | |
baud_rate: 0 # (UART logging interferes with cse7766) | |
api: | |
ota: | |
web_server: | |
port: 80 | |
time: | |
- platform: homeassistant | |
id: homeassistant_time | |
uart: | |
rx_pin: RX | |
baud_rate: 4800 | |
binary_sensor: | |
- platform: status | |
name: "${plug_name} Status" | |
- platform: gpio | |
pin: | |
number: GPIO0 | |
mode: INPUT_PULLUP | |
inverted: True | |
name: "${plug_name} Button" | |
on_press: | |
then: | |
- switch.toggle: relay | |
- platform: template | |
name: "${plug_name} Fault" | |
lambda: |- | |
if (id(relay).state == 1) { | |
if (id(wattage).state <= 0.1) { | |
return true; | |
} else { | |
return false; | |
} | |
} else { | |
return false; | |
} | |
filters: | |
- delayed_on: 12s | |
on_press: | |
then: | |
- light.turn_on: light_led_blue | |
on_release: | |
then: | |
- light.turn_off: light_led_blue | |
switch: | |
- platform: restart | |
name: "${plug_name} Restart" | |
- platform: gpio | |
name: "${plug_name} Relay" | |
icon: mdi:power-socket-us | |
pin: GPIO12 | |
id: relay | |
output: | |
- platform: esp8266_pwm | |
pin: GPIO13 | |
inverted: True | |
id: led_blue | |
light: | |
- platform: monochromatic | |
name: "${plug_name} LED Blue" | |
output: led_blue | |
id: light_led_blue | |
sensor: | |
- platform: wifi_signal | |
name: "${plug_name} WiFi Signal" | |
update_interval: 60s | |
- platform: uptime | |
name: "${plug_name} Uptime" | |
- platform: cse7766 | |
current: | |
name: "${plug_name} Amperage" | |
unit_of_measurement: A | |
accuracy_decimals: 1 | |
voltage: | |
name: "${plug_name} Voltage" | |
unit_of_measurement: V | |
accuracy_decimals: 1 | |
power: | |
name: "${plug_name} Wattage" | |
unit_of_measurement: W | |
accuracy_decimals: 1 | |
id: "wattage" | |
update_interval: 8s | |
- platform: total_daily_energy | |
name: "${plug_name} Total Daily Energy" | |
power_id: "wattage" | |
filters: | |
# Multiplication factor from W to kW is 0.001 | |
- multiply: 0.001 | |
unit_of_measurement: kWh | |
text_sensor: | |
- platform: version | |
name: "${plug_name} ESPHome" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment