-
Notifications
You must be signed in to change notification settings - Fork 2
/
ha-ups-makelsan.yaml
243 lines (227 loc) · 5.77 KB
/
ha-ups-makelsan.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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
substitutions:
platform: ESP8266
board: d1_mini
deviceName: ha-ups-makelsan
deviceFriendlyName: HA Makelsan UPS
esphome:
name: ha-ups-makelsan
platform: ESP8266
board: d1_mini
wifi:
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "HA Makelsan UPS Hotspot"
password: "1234"
ssid: "WiFi SSID"
password: "WiFi Password"
captive_portal:
logger:
baud_rate: 0
esphome:
includes:
- UPS-Makelsan.h
api:
password: !secret esphome_api_password
ota:
password: !secret esphome_api_password
uart:
id: uart_bus
rx_pin: RX
tx_pin: TX
baud_rate: 2400
data_bits: 8
stop_bits: 1
parity: none
globals:
- id: uart_data_queue_value
type: bool
restore_value: false
initial_value: 'true'
interval:
- interval: 1s
then:
- if:
condition:
- lambda:
'return id(uart_data_queue_value);'
then:
- uart.write:
id: uart_bus
data: [0x46, 0x0d] # F.
- globals.set:
id: uart_data_queue_value
value: 'false'
else:
- uart.write:
id: uart_bus
data: [0x51, 0x31, 0x0d] # Q1.
- globals.set:
id: uart_data_queue_value
value: 'true'
custom_component:
lambda: |-
MakelsanUPS *uart_data_ups = new MakelsanUPS(id(uart_bus));
return {uart_data_ups};
components:
- id: uart_data_ups
binary_sensor:
- platform: custom
lambda: |-
MakelsanUPS *ups_binary_sensor = (MakelsanUPS*) id(uart_data_ups);
return {
ups_binary_sensor->battery_low
,ups_binary_sensor->beeper_on
,ups_binary_sensor->eco_mode
,ups_binary_sensor->power_status
,ups_binary_sensor->shutdown_active
,ups_binary_sensor->test_in_progress
,ups_binary_sensor->ups_failed
,ups_binary_sensor->ups_type_is_standby
,ups_binary_sensor->utility_fail
};
binary_sensors:
- name: "Battery Low"
device_class: "battery"
- name: "Beeper"
icon: mdi:bell-ring
- name: "Eco Mode"
icon: mdi:leaf-circle
- name: "Power Status"
device_class: "power"
- name: "Shutdown Active"
icon: mdi:power
- name: "Test in Progress"
icon: mdi:test-tube
- name: "UPS Failed"
icon: mdi:battery-alert
- name: "UPS Type is Standby"
icon: mdi:power-standby
- name: "Utility Fail"
icon: mdi:alert
sensor:
- platform: total_daily_energy
name: Daily Energy
power_id: output_power
unit_of_measurement: 'kWh'
filters:
- multiply: 0.001
- platform: custom
lambda: |-
MakelsanUPS *ups_sensor = (MakelsanUPS*) id(uart_data_ups);
return {
ups_sensor->battery_capacity
,ups_sensor->battery_voltage
,ups_sensor->battery_voltage_current
,ups_sensor->internal_tempeture
,ups_sensor->output_current
,ups_sensor->output_power
,ups_sensor->raiting_current
,ups_sensor->raiting_voltage
,ups_sensor->voltage_frequency
,ups_sensor->voltage_input
,ups_sensor->voltage_input_fault
,ups_sensor->voltage_input_frequency
,ups_sensor->voltage_output
};
sensors:
- name: "Battery Capacity"
device_class: "battery"
unit_of_measurement: "%"
accuracy_decimals: 0
- name: "Battery Voltage"
unit_of_measurement: "V"
device_class: "voltage"
accuracy_decimals: 1
- name: "Battery Voltage Current"
unit_of_measurement: "V"
device_class: "current"
accuracy_decimals: 1
- name: "Internal Tempeture"
unit_of_measurement: "°C"
device_class: "temperature"
accuracy_decimals: 0
- name: "Output Current"
device_class: "power_factor"
unit_of_measurement: "%"
accuracy_decimals: 0
- name: "Output Power"
id: output_power
device_class: "power"
unit_of_measurement: "W"
accuracy_decimals: 0
- name: "Raiting Current"
unit_of_measurement: "V"
device_class: "current"
accuracy_decimals: 1
- name: "Raiting Voltage"
unit_of_measurement: "V"
device_class: "voltage"
accuracy_decimals: 1
- name: "Voltage Frequency"
icon: mdi:cosine-wave
unit_of_measurement: "Hz"
accuracy_decimals: 1
- name: "Voltage Input"
unit_of_measurement: "VAC"
device_class: "voltage"
accuracy_decimals: 1
- name: "Voltage Input Fault"
unit_of_measurement: "OV"
device_class: "voltage"
accuracy_decimals: 1
- name: "Voltage Input Frequency"
icon: mdi:cosine-wave
unit_of_measurement: "Hz"
accuracy_decimals: 1
- name: "Voltage Output"
unit_of_measurement: "VAC"
device_class: "voltage"
accuracy_decimals: 1
switch:
- platform: uart
name: Beeper Toggle On/Off
icon: mdi:bell-ring
data: [0x51, 0x0d] # "Q."
- platform: uart
name: Test
icon: mdi:test-tube
data: [0x54, 0x0d] # "T."
- platform: uart
name: Test - Cancel
icon: mdi:test-tube-off
data: [0x43, 0x54, 0x0d] # "CT."
- platform: uart
name: Test - For Specified Time Period(Minutes 30)
icon: mdi:test-tube
data: [0x54, 0x33, 0x30, 0x0d] # "T30."
- platform: uart
name: Test - Until Battery Low
icon: mdi:test-tube
data: [0x54, 0x4c, 0x0d] # "TL."
- platform: uart
name: Shutdown 5 Minutes Later
icon: mdi:power
data: [0x53, 0x30, 0x35, 0x0d] # "S05."
- platform: uart
name: Shutdown 5 Minutes Later and Restore 1 Minute Later
icon: mdi:power
data: [0x53, 0x30, 0x35, 0x52, 0x30, 0x31 , 0x0d] # "S05R01."
- platform: uart
name: Shutdown Cancel
icon: mdi:alert-octagon-outline
data: [0x43, 0x0d] # "S05."
text_sensor:
- platform: custom
lambda: |-
MakelsanUPS *ups_text_sensor = (MakelsanUPS*) id(uart_data_ups);
return {
ups_text_sensor->power_type
,ups_text_sensor->ups_type
};
text_sensors:
- name: "Power Type"
icon: mdi:power-socket-eu
- name: "UPS Type"
icon: mdi:car-battery
time:
- platform: homeassistant