-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathdmaker.fan.1c.yaml
184 lines (168 loc) · 4.11 KB
/
dmaker.fan.1c.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
# https://home.miot-spec.com/spec/dmaker.fan.1c
external_components:
source: github://dhewg/esphome-miot@main
esphome:
name: standing-fan
friendly_name: Smart Standing Fan 2 Lite
comment: Xiaomi Mi Smart Standing Fan 2 Lite (dmaker.fan.1c)
project:
name: "dhewg.esphome-miot"
version: "dmaker.fan.p18"
esp8266:
board: esp_wroom_02
logger:
level: DEBUG
# Important: Disable UART1 logging to avoid hardware errors on main UART0
baud_rate: 0
api:
encryption:
key: !secret api_encryption_key
reboot_timeout: 0s
services:
- service: mcu_command
variables:
command: string
then:
- lambda: 'id(miot_main).queue_command(command);'
ota:
- platform: esphome
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
password: !secret wifi_ap_password
captive_portal:
uart:
tx_pin: GPIO15
rx_pin: GPIO13
baud_rate: 115200
miot:
id: miot_main
switch:
- platform: "miot"
id: "on"
miot_siid: 2
miot_piid: 1
name: "Power"
icon: "mdi:power"
on_turn_off:
- lambda: |-
if(id(template_fan).state == true) {
auto call = id(template_fan).turn_off();
call.perform();
}
on_turn_on:
- lambda: |-
if(id(template_fan).state == false) {
auto call = id(template_fan).turn_on();
call.perform();
}
- platform: "miot"
id: "horizontal_swing"
miot_siid: 2
miot_piid: 3
name: "Oscillation"
icon: "mdi:arrow-oscillating"
on_turn_off:
- lambda: |-
if (id(template_fan).oscillating == true) {
auto call = id(template_fan).make_call();
call.set_oscillating(false);
call.set_preset_mode(id(mode).state.c_str());
call.perform();
}
on_turn_on:
- lambda: |-
if (id(template_fan).oscillating == false) {
auto call = id(template_fan).make_call();
call.set_oscillating(true);
call.set_preset_mode(id(mode).state.c_str());
call.perform();
}
- platform: "miot"
miot_siid: 2
miot_piid: 12
name: "Indicator Lights"
icon: "mdi:lightbulb"
entity_category: config
- platform: "miot"
miot_siid: 2
miot_piid: 11
name: "Notification Sounds"
icon: "mdi:volume-high"
entity_category: config
- platform: "miot"
miot_siid: 3
miot_piid: 1
name: "Child Lock"
icon: "mdi:lock"
entity_category: config
select:
- platform: "miot"
id: "mode"
miot_siid: 2
miot_piid: 7
name: "Mode"
icon: "mdi:leaf"
options:
0: "Direct Breeze"
1: "Sleep Mode"
on_value:
- lambda: |-
if(id(template_fan).preset_mode != x) {
auto call = id(template_fan).make_call();
call.set_preset_mode(x.c_str());
call.perform();
}
number:
- platform: "miot"
miot_siid: 2
miot_piid: 2
name: "Fan Level"
icon: "mdi:fan-chevron-up"
min_value: 1
max_value: 3
step: 1
- platform: "miot"
miot_siid: 2
miot_piid: 10
name: "Off Delay"
icon: "mdi:clock-outline"
unit_of_measurement: "min"
device_class: duration
min_value: 0
max_value: 480
step: 1
button:
- platform: "miot"
miot_siid: 2
miot_aiid: 1
name: "Toggle Power"
icon: "mdi:power-cycle"
fan:
- platform: "template"
id: template_fan
name: None
has_oscillating: true
speed_count: 100
preset_modes:
- "Direct Breeze"
- "Sleep Mode"
restore_mode: NO_RESTORE
on_turn_on:
- lambda: if (id(on).state == false) id(on).turn_on();
on_turn_off:
- lambda: if (id(on).state == true) id(on).turn_off();
on_oscillating_set:
- lambda: |-
if (id(horizontal_swing).state != x) {
if (x == true) {
id(horizontal_swing).turn_on();
} else {
id(horizontal_swing).turn_off();
}
}
auto call = id(template_fan).make_call();
call.set_preset_mode(id(mode).state.c_str());
call.perform();