· 3 years ago · Sep 14, 2022, 08:10 PM
1esphome:
2 name: sonoff-dual-r3
3
4esp32:
5 board: esp32dev
6 framework:
7 type: arduino
8
9# Enable logging
10logger:
11
12# Enable Home Assistant API
13api:
14 encryption:
15 key: !secret api_key
16
17ota:
18 password: !secret ota_password
19
20wifi:
21 ssid: !secret wifi_ssid
22 password: !secret wifi_password
23
24 # Enable fallback hotspot (captive portal) in case wifi connection fails
25 ap:
26 ssid: "Sonoff-Dual-R3"
27 password: !secret fallback_password
28
29captive_portal:
30
31binary_sensor:
32 - platform: gpio # GPIO0 Button
33 id: sw0
34 pin:
35 number: 0
36 mode:
37 input: true
38 pullup: true
39 inverted: true
40 name: "Config Button"
41 - platform: gpio # GPIO32 SW Input #1 (inverted)
42 id: sw1
43 pin:
44 number: 32
45 mode:
46 input: true
47 pullup: true
48 inverted: true
49 name: "Switch 1"
50 on_press:
51 then:
52 - switch.toggle: rl1
53 - platform: gpio # GPIO33 SW Input #2 (inverted)
54 id: sw2
55 pin:
56 number: 33
57 mode:
58 input: true
59 pullup: true
60 inverted: true
61 name: "Switch 2"
62 on_press:
63 then:
64 - switch.toggle: rl2
65
66switch:
67 - platform: gpio # GPIO27 Relay #1
68 id: rl1
69 pin: 27
70 name: "Relay 1"
71 - platform: gpio # GPIO14 Relay #2
72 id: rl2
73 pin: 14
74 name: "Relay 1"
75
76light:
77 - platform: status_led # GPIO13 Blue LED (inverted)
78 id: led
79 name: "Blue Led"
80 pin: 13
81
82uart:
83 tx_pin: 25 # GPIO25 UART TX pin (for power sensor)
84 rx_pin: 26 # GPIO26 UART RX pin (for power sensor)
85 baud_rate: 4800
86 parity: NONE
87 stop_bits: 2
88
89sensor:
90 - platform: bl0939
91 update_interval: 30s
92 voltage:
93 name: 'Voltage'
94 current_1:
95 name: 'Current 1'
96 current_2:
97 name: 'Current 2'
98 active_power_1:
99 name: 'Power 1'
100 active_power_2:
101 name: 'Power 2'
102 energy_1:
103 name: 'Energy 1'
104 energy_2:
105 name: 'Energy 2'
106 energy_total:
107 name: 'Energy Total'
108