-
Notifications
You must be signed in to change notification settings - Fork 0
/
powmr-wifi-dongle.yaml
200 lines (186 loc) · 5.04 KB
/
powmr-wifi-dongle.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
substitutions:
device_name: "powmr-wifi-dongle"
uart_tx_pin: GPIO7
uart_rx_pin: GPIO21
friendly_name: "POWMR WiFi dongle 32"
esphome:
name: "powmr-wifi-dongle"
friendly_name: "powmr-wifi-dongle"
output:
- platform: gpio
id: pwr_led
pin:
number: GPIO20
inverted: true
- platform: gpio
id: comm_led
pin: GPIO8
- platform: gpio
id: net_led
pin: GPIO9
light:
# SRV
- platform: status_led
id: srv_led
pin:
number: GPIO10
inverted: true
packages:
devicecommon: !include .device_common.yaml
esp32:
board: seeed_xiao_esp32c3
framework:
type: arduino
globals:
- id: last_updated
type: ulong
initial_value: 'millis()'
- id: error_ms
type: ulong
initial_value: '3000'
wifi:
on_connect:
- output.turn_on: net_led
on_disconnect:
- output.turn_off: net_led
output_power: 8.5dB
logger:
level: WARN
uart:
- id: powmr_uart
tx_pin: ${uart_tx_pin}
rx_pin: ${uart_rx_pin}
baud_rate: 2400
pipsolar:
- id: powmr_inverter
uart_id: powmr_uart
binary_sensor:
- platform: pipsolar
pipsolar_id: powmr_inverter
backlight_on:
id: powmr_backlight_on
name: Powmr backlight on
switch_on:
id: powmr_switch_on
name: Powmr switch on
warnings_present:
id: powmr_warnings_present
name: Powmr warnings present
faults_present:
id: powmr_faults_present
name: Powmr faults present
fault_bus_over:
id: powmr_bus_overvoltage_fault
name: Powmr bus overvoltage fault
fault_inverter_voltage_too_high:
id: powmr_inverter_overvoltage_fault
name: Powmr inverter overvoltage fault
warning_battery_voltage_high:
id: powmr_batt_overvoltage_warning
name: Powmr battery overvoltage warning
- platform: template
id: powmr_grid_available
name: Powmr grid available
sensor:
- platform: pipsolar
pipsolar_id: powmr_inverter
grid_voltage:
id: powmr_grid_voltage
name: Powmr grid voltage
on_value:
- lambda: |-
id(last_updated) = millis();
grid_rating_current:
id: powmr_grid_rating_current
name: Powmr grid rating current
grid_rating_voltage:
id: powmr_grid_rating_voltage
name: Powmr grid rating voltage
battery_voltage:
id: powmr_battery_voltage
name: Powmr battery voltage
battery_charging_current:
id: powmr_battery_charging_current
name: Powmr battery charging current
battery_discharge_current:
id: powmr_battery_discharging_current
name: Powmr battery discharging current
ac_output_apparent_power:
id: powmr_ac_output_apparent_power
name: Powmr AC output apparent power
ac_output_active_power:
id: powmr_ac_output_active_power
name: Powmr AC output active power
inverter_heat_sink_temperature:
id: powmr_inverter_twmperature
name: Powmr inverter temperature
- platform: template
id: powmr_battery_charging_power
name: "Powmr battery charging power"
internal: true
unit_of_measurement: "W"
device_class: power
state_class: measurement
accuracy_decimals: 2
update_interval: 20s
lambda: |-
return id(powmr_battery_charging_current).state
* id(powmr_battery_voltage).state;
- platform: template
id: powmr_battery_discharging_power
name: "Powmr battery discharging power"
internal: true
unit_of_measurement: "W"
device_class: power
state_class: measurement
accuracy_decimals: 2
update_interval: 20s
lambda: |-
return id(powmr_battery_discharging_current).state
* id(powmr_battery_voltage).state;
- platform: total_daily_energy
id: powmr_daily_energy_in
name: 'Powmr total daily energy in'
power_id: powmr_battery_charging_power
unit_of_measurement: 'kWh'
state_class: total_increasing
device_class: energy
accuracy_decimals: 3
filters:
- multiply: 0.001
- platform: total_daily_energy
id: powmr_daily_energy_out
name: 'Powmr total daily energy out'
power_id: powmr_battery_discharging_power
unit_of_measurement: 'kWh'
state_class: total_increasing
device_class: energy
accuracy_decimals: 3
filters:
- multiply: 0.001
text_sensor:
- platform: pipsolar
pipsolar_id: powmr_inverter
device_mode:
id: powmr_device_mode
name: Powmr device mode
on_value:
lambda: |-
bool is_grid_available = x[0] != 'B';
id(powmr_grid_available).publish_state(is_grid_available);
interval:
- interval: 1s
then:
- lambda: |-
ulong now = millis();
ulong valid_update_timeout = id(powmr_inverter).get_update_interval() +
id(error_ms);
ulong last_valid_update = id(last_updated) +
valid_update_timeout;
if (last_valid_update < now) {
ESP_LOGW("pipsolar", "No readings received within %d seconds",
(ulong)(valid_update_timeout / 1000));
id(comm_led)->turn_off();
return;
}
id(comm_led)->turn_on();