-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
zmai90.yaml
221 lines (193 loc) · 4.83 KB
/
zmai90.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
substitutions:
friendly_name: "ZMAi-90"
node_name: "zmai90"
# replace with "!secret wifi_ssid" to use value from your secrets file.
wifi_ssid: ""
# replace with "!secret wifi_password" to use value from your secrets file.
wifi_password: ""
# replace with "!secret wifi_ap_password" to use value from your secrets file.
wifi_ap_password: ""
# ZMAi-90 TuyaMCU datapoints
dp_switch: "1"
dp_total: "17"
dp_power: "19"
dp_current: "18"
dp_voltage: "20"
esphome:
name: $node_name
friendly_name: $friendly_name
project:
name: "dentra.zmai90v2"
version: "2023.6.0"
esp8266:
board: esp01_1m
restore_from_flash: true
preferences:
flash_write_interval: 30min
external_components:
- source: github://dentra/esphome-components
refresh: 0s
backup:
wifi:
ssid: $wifi_ssid
password: $wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "$friendly_name Hotspot"
password: $wifi_ap_password
fast_connect: true
captive_portal:
# Enable Home Assistant API
api:
# Make sure you can upload new firmware OTA
ota:
web_server:
time:
platform: homeassistant
id: g_time
timezone: UTC-3
# Uncomment next 4 lines if you want to force update values from Tuya MCU every 10 seconds
# on_time:
# seconds: 9,19,29,39,49,59
# then:
# - uart.write: [0x55, 0xaa, 0x00, 0x08, 0x00, 0x00, 0x07]
# Enable logging
logger:
# Make sure logging is not using the serial port
baud_rate: 0
uart:
rx_pin: RX
tx_pin: TX
baud_rate: 9600
# Register the Tuya MCU connection
tuya:
time_id: g_time
switch:
# Uncomment next 5 lines to expose main switch to HA
# - platform: "tuya"
# id: sw_power
# name: None
# switch_datapoint: $dp_switch
# icon: "mdi:power"
# Uncomment next 5 lines if you want a switch to query the device working status by forces update values from Tuya MCU
# - platform: "uart"
# id: sw_tuya_query_status
# data: [0x55, 0xaa, 0x00, 0x08, 0x00, 0x00, 0x07]
# name: "Force update"
# icon: mdi:reload
text_sensor:
- platform: "template"
id: current_tariff
name: "Current Tariff"
icon: "mdi:theme-light-dark"
entity_category: diagnostic
# Create sensors
sensor:
# total
- platform: "tuya"
id: total
name: "Total"
sensor_datapoint: $dp_total
accuracy_decimals: 3
filters:
- multiply: 0.001
unit_of_measurement: "kWh"
icon: "mdi:sigma"
device_class: "energy"
state_class: total_increasing
entity_category: diagnostic
# active power
- platform: "tuya"
id: power
name: "Active Power"
sensor_datapoint: $dp_power
accuracy_decimals: 1
filters:
- multiply: 0.1
unit_of_measurement: "W"
icon: "mdi:flash"
device_class: "power"
state_class: measurement
# current
- platform: "tuya"
id: current
name: "Current"
sensor_datapoint: $dp_current
accuracy_decimals: 3
filters:
- multiply: 0.001
unit_of_measurement: "A"
icon: "mdi:current-ac"
device_class: "current"
state_class: measurement
# voltage
- platform: "tuya"
id: voltage
name: "Voltage"
sensor_datapoint: $dp_voltage
accuracy_decimals: 1
filters:
- multiply: 0.1
unit_of_measurement: "V"
icon: "mdi:sine-wave"
device_class: "voltage"
state_class: measurement
- platform: "energy_monitoring"
id: mon
power: power
voltage: voltage
current: current
apparent_power:
name: "Apparent Power"
filters:
- throttle_average: 60s
- filter_out: nan
reactive_power:
name: "Reactive Power"
filters:
- throttle_average: 60s
- filter_out: nan
power_factor:
name: "Power Factor"
# icon: "mdi:angle-acute"
# unit_of_measurement: "%"
filters:
- throttle_average: 60s
- filter_out: nan
- platform: "energy_statistics"
id: stat
total: total
energy_today:
id: today
name: "Energy Today"
- platform: "energy_tariffs"
id: tariffs
total: total
time_offset:
name: "Time Offset"
id: time_offset
tariffs:
- name: "Peak Tariff"
id: peak
icon: "mdi:weather-sunny"
service: peak_set
- name: "Off-Peak Tariff"
id: offpeak
icon: "mdi:weather-night"
time: "23:00-07:00"
service: offpeak_set
on_tariff:
lambda: |-
if (x == id(peak))
id(current_tariff).publish_state("peak");
else if (x == id(offpeak))
id(current_tariff).publish_state("off-peak");
else // should be never happen
id(current_tariff).publish_state("unknown");
on_before_tariff:
- uart.write: [0x55, 0xaa, 0x00, 0x08, 0x00, 0x00, 0x07]
- platform: uptime
name: "Uptime"
device_class: duration
- platform: wifi_signal
name: "WiFi Signal"