forked from jaromeyer/mipurifier-esphome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mipurifier.yaml
164 lines (152 loc) · 3.87 KB
/
mipurifier.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
esphome:
name: mipurifier
comment: for Xiaomi Mi Air Purifier 3H (and similar models using the same protocol)
includes:
- mipurifier.h
# Required configuration for the weird single core ESP-WROOM-32D module
esp32:
board: esp32doit-devkit-v1
framework:
type: esp-idf
sdkconfig_options:
CONFIG_FREERTOS_UNICORE: y
advanced:
ignore_efuse_mac_crc: true
# Enable logging
logger:
# Enable Home Assistant API
api:
password: ""
# Enable OTA updates
ota:
password: ""
# Wi-Fi configuration
# EDIT CREDENTIALS OR PROVIDE YOUR OWN secrets.yaml
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Mipurifier Fallback Hotspot"
password: "PyCfsbmzuMbj"
# Initialize the serial connection to the STM32 microcontroller
uart:
id: uart_bus
tx_pin: GPIO17
rx_pin: GPIO16
baud_rate: 115200
# Initialize our custom component
custom_component:
- lambda: |-
auto mipurifier = new MiPurifier(id(uart_bus));
App.register_component(mipurifier);
return {mipurifier};
components:
- id: mipurifier
# Main switch for turning on/off the unit
switch:
- platform: template
name: "Power"
id: power_switch
icon: mdi:power
turn_on_action:
- lambda:
auto c = static_cast<MiPurifier *>(mipurifier);
c->turn_on();
turn_off_action:
- lambda:
auto c = static_cast<MiPurifier *>(mipurifier);
c->turn_off();
- platform: template
name: "Beeper"
id: beeper_switch
icon: mdi:volume-high
entity_category: config
turn_on_action:
- lambda:
auto c = static_cast<MiPurifier *>(mipurifier);
c->enable_beeper();
turn_off_action:
- lambda:
auto c = static_cast<MiPurifier *>(mipurifier);
c->disable_beeper();
- platform: template
name: "Lock"
id: lock_switch
icon: mdi:lock
entity_category: config
turn_on_action:
- lambda:
auto c = static_cast<MiPurifier *>(mipurifier);
c->lock();
turn_off_action:
- lambda:
auto c = static_cast<MiPurifier *>(mipurifier);
c->unlock();
# Select components for mode & brightness
select:
- platform: template
name: "Mode"
id: mode_select
options:
- "auto"
- "night"
- "manual"
- "low"
- "medium"
- "high"
set_action:
- lambda: |-
auto c = static_cast<MiPurifier *>(mipurifier);
c->set_mode(x);
- platform: template
name: "Display Brightness"
id: brightness_select
icon: mdi:brightness-6
entity_category: config
options:
- "off"
- "low"
- "high"
set_action:
- lambda: |-
auto c = static_cast<MiPurifier *>(mipurifier);
c->set_brightness(x);
# Number to control the speed in manual mode
number:
- platform: template
name: "Manual Speed"
id: manualspeed
icon: mdi:speedometer
min_value: 1
max_value: 15
step: 1
set_action:
- lambda: |-
auto c = static_cast<MiPurifier *>(mipurifier);
c->set_manualspeed((int)x-1);
# Expose measured environmental values, and remaining filter life
sensor:
- platform: custom
lambda: |-
auto c = static_cast<MiPurifier *>(mipurifier);
return {
c->airquality_sensor,
c->humidity_sensor,
c->temperature_sensor,
c->filterlife_sensor,
};
sensors:
- name: "Air quality (PM2.5)"
unit_of_measurement: "µg/m³"
device_class: pm25
- name: "Humidity"
unit_of_measurement: "%"
device_class: humidity
- name: "Temperature"
unit_of_measurement: "°C"
device_class: temperature
accuracy_decimals: 1
- name: "Filter remaining"
unit_of_measurement: "%"
icon: mdi:air-filter