-
Notifications
You must be signed in to change notification settings - Fork 2
/
sonoff-s31.yaml
executable file
·104 lines (88 loc) · 2.4 KB
/
sonoff-s31.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Required substitutions:
# device_name
# device_comment
# https://tasmota.github.io/docs/devices/Sonoff-S31/
# https://templates.blakadder.com/sonoff_S31.html
# https://www.esphome-devices.com/devices/Sonoff-S31
# Button: GPIO0, Inverted
# CSE7766 Tx: GPIO1
# CSE7766 Rx: GPIO3
# Relay: GPIO12 (Connected to Red LED)
# Blue LED: GPIO13
# https://esphome.io/components/esphome.html
esphome:
name: ${device_name}
comment: ${device_comment}
# https://esphome.io/components/esp8266
esp8266:
board: esp01_1m
# https://esphome.io/components/logger.html
logger:
# Disable UART logging, it is used for the CSE7766
baud_rate: 0
# https://esphome.io/components/uart.html
uart:
rx_pin: RX
baud_rate: 4800
# https://esphome.io/guides/configuration-types.html#packages
packages:
# UART is in use, do not log over UART
api: !include api.yaml
basic: !include basic.yaml
debug: !include debug.yaml
ota: !include ota.yaml
time: !include time.yaml
wifi: !include wifi.yaml
# https://esphome.io/components/binary_sensor/index.html
binary_sensor:
# https://esphome.io/components/binary_sensor/gpio.html
- platform: gpio
name: ${device_name}_button
device_class: power
# https://esphome.io/guides/configuration-types.html#config-pin-schema
pin:
number: GPIO0
inverted: true
mode: INPUT_PULLUP
# Toggle relay state on button press
on_press:
- switch.toggle: relay
# https://esphome.io/components/switch/index.html
switch:
# https://esphome.io/components/switch/gpio.html
- platform: gpio
name: ${device_name}_relay
id: relay
pin: GPIO12
# Off on power-on
restore_mode: ALWAYS_OFF
# https://esphome.io/components/status_led.html
status_led:
pin:
number: GPIO13
# https://esphome.io/components/uart
uart:
rx_pin: RX
baud_rate: 4800
# https://esphome.io/components/sensor/index.html
sensor:
# https://esphome.io/components/sensor/cse7766.html
- platform: cse7766
update_interval: 15s
current:
name: ${device_name}_current
filters:
- throttle_average: 60s
voltage:
name: ${device_name}_voltage
filters:
- throttle_average: 60s
power:
id: wattage
name: ${device_name}_power
filters:
- throttle_average: 60s
# https://esphome.io/components/sensor/total_daily_energy.html
- platform: total_daily_energy
name: ${device_name}_total_daily_energy
power_id: wattage