-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathesp32-example-advanced-multiple-uarts.yaml
213 lines (194 loc) · 5.16 KB
/
esp32-example-advanced-multiple-uarts.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
substitutions:
name: smg-ii-multi
device0: "${name} 1"
device1: "${name} 2"
device_description: "Monitor and control two ISolar/EASUN SMG II inverters via RS232"
tx_pin: GPIO16
rx_pin: GPIO17
tx_pin2: GPIO32
rx_pin2: GPIO33
esphome:
name: ${name}
comment: ${device_description}
min_version: 2024.6.0
project:
name: "syssi.esphome-smg-ii"
version: 1.2.0
esp32:
board: wemos_d1_mini32
framework:
type: esp-idf
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ota:
platform: esphome
logger:
level: INFO
# If you use Home Assistant please remove this `mqtt` section and uncomment the `api` component!
# The native API has many advantages over MQTT: https://esphome.io/components/api.html#advantages-over-mqtt
mqtt:
broker: !secret mqtt_host
username: !secret mqtt_username
password: !secret mqtt_password
id: mqtt_client
# api:
uart:
- id: uart_0
baud_rate: 9600
tx_pin: ${tx_pin}
rx_pin: ${rx_pin}
- id: uart_1
baud_rate: 9600
tx_pin: ${tx_pin2}
rx_pin: ${rx_pin2}
modbus:
- id: modbus0
uart_id: uart_0
send_wait_time: 200ms
- id: modbus1
uart_id: uart_1
send_wait_time: 200ms
modbus_controller:
- id: smg0
address: 0x01
modbus_id: modbus0
command_throttle: 200ms
update_interval: 10s
- id: smg1
address: 0x01
modbus_id: modbus1
command_throttle: 200ms
update_interval: 10s
sensor:
- platform: modbus_controller
modbus_controller_id: smg0
name: "${device0} pv average voltage"
address: 219
register_type: holding
value_type: S_WORD
unit_of_measurement: "V"
device_class: voltage
state_class: measurement
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: smg0
name: "${device0} pv average current"
address: 220
register_type: holding
value_type: S_WORD
unit_of_measurement: "A"
device_class: current
state_class: measurement
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: smg1
name: "${device1} pv average voltage"
address: 219
register_type: holding
value_type: S_WORD
unit_of_measurement: "V"
device_class: voltage
state_class: measurement
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: smg1
name: "${device1} pv average current"
address: 220
register_type: holding
value_type: S_WORD
unit_of_measurement: "A"
device_class: current
state_class: measurement
accuracy_decimals: 1
filters:
- multiply: 0.1
select:
- platform: modbus_controller
modbus_controller_id: smg0
name: "${device0} output priority"
use_write_multiple: true
address: 301
value_type: U_WORD
optionsmap:
"Utility-PV-Battery (UTI)": 0
"PV-Utility-Battery (SOL)": 1
"PV-Battery-Utility (SBU)": 2
"PV-Utility-Battery (SUB)": 3
- platform: modbus_controller
modbus_controller_id: smg1
name: "${device1} output priority"
use_write_multiple: true
address: 301
value_type: U_WORD
optionsmap:
"Utility-PV-Battery (UTI)": 0
"PV-Utility-Battery (SOL)": 1
"PV-Battery-Utility (SBU)": 2
"PV-Utility-Battery (SUB)": 3
text_sensor:
- platform: modbus_controller
modbus_controller_id: smg0
name: "${device1} operation mode"
address: 201
register_type: holding
raw_encode: HEXBYTES
lambda: |-
uint16_t value = modbus_controller::word_from_hex_str(x, 0);
switch (value) {
case 0: return std::string("Power On");
case 1: return std::string("Standby");
case 2: return std::string("Mains");
case 3: return std::string("Off-Grid");
case 4: return std::string("Bypass");
case 5: return std::string("Charging");
case 6: return std::string("Fault");
}
return std::string("Unknown");
- platform: modbus_controller
modbus_controller_id: smg1
name: "${device1} operation mode"
address: 201
register_type: holding
raw_encode: HEXBYTES
lambda: |-
uint16_t value = modbus_controller::word_from_hex_str(x, 0);
switch (value) {
case 0: return std::string("Power On");
case 1: return std::string("Standby");
case 2: return std::string("Mains");
case 3: return std::string("Off-Grid");
case 4: return std::string("Bypass");
case 5: return std::string("Charging");
case 6: return std::string("Fault");
}
return std::string("Unknown");
number:
- platform: modbus_controller
modbus_controller_id: smg0
name: "${device0} battery equalization time"
use_write_multiple: true
address: 335
register_type: holding
value_type: U_WORD
min_value: 0.0
max_value: 900.0
step: 1
unit_of_measurement: "min"
- platform: modbus_controller
modbus_controller_id: smg1
name: "${device1} battery equalization time"
use_write_multiple: true
address: 335
register_type: holding
value_type: U_WORD
min_value: 0.0
max_value: 900.0
step: 1
unit_of_measurement: "min"