-
Notifications
You must be signed in to change notification settings - Fork 111
/
zhimi.humidifier.ca1.yaml
183 lines (167 loc) · 5.73 KB
/
zhimi.humidifier.ca1.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
fan humidifier:
- platform: xiaomi_miio_airpurifier
name: Humidifier
host: <IP>
token: <TOKEN>
model: zhimi.humidifier.ca1
switch:
- platform: template
switches:
humidifier_buzzer:
friendly_name: Buzzer
value_template: "{{ is_state_attr('fan.humidifier', 'buzzer', True) }}"
turn_on:
service: xiaomi_miio_airpurifier.fan_set_buzzer_on
data:
entity_id: fan.humidifier
turn_off:
service: xiaomi_miio_airpurifier.fan_set_buzzer_off
data:
entity_id: fan.humidifier
icon_template: mdi:volume-high
humidifier_lock:
friendly_name: Child lock
value_template: "{{ is_state_attr('fan.humidifier', 'child_lock', True) }}"
turn_on:
service: xiaomi_miio_airpurifier.fan_set_child_lock_on
data:
entity_id: fan.humidifier
turn_off:
service: xiaomi_miio_airpurifier.fan_set_child_lock_off
data:
entity_id: fan.humidifier
icon_template: mdi:lock-outline
humidifier_dry_mode:
friendly_name: Dry mode
value_template: "{{ is_state_attr('fan.humidifier', 'dry', True) }}"
turn_on:
service: xiaomi_miio_airpurifier.fan_set_dry_on
data:
entity_id: fan.humidifier
turn_off:
service: xiaomi_miio_airpurifier.fan_set_dry_off
data:
entity_id: fan.humidifier
icon_template: mdi:hair-dryer-outline
sensor:
- platform: template
sensors:
humidifier_water_level:
friendly_name: Water level
value_template: '{{ (states.fan.humidifier.attributes.depth / 125 * 100) | round() }}' # provides value in [0, ..., 125]
unit_of_measurement: '%'
icon_template: mdi:waves
humidifier_humidity:
friendly_name: Humidity
value_template: '{{ states.fan.humidifier.attributes.humidity }}'
unit_of_measurement: '%'
icon_template: mdi:water-percent
humidifier_temperature:
friendly_name: Temperature
value_template: '{{ states.fan.humidifier.attributes.temperature }}'
unit_of_measurement: '°C'
icon_template: mdi:thermometer
input_select:
humidifier_mode:
name: Operation mode
options:
- Auto
- Silent
- Medium
- High
humidifier_led:
name: Led mode
options:
- 'Off' # will be converted to False without quotes
- Dim
- Bright
humidifier_target_humidity:
name: Target humidity
options:
- 30
- 40
- 50
- 60
- 70
- 80
automation:
- alias: Humidifier - select operation mode by input select
trigger:
entity_id: input_select.humidifier_mode
platform: state
action:
service: fan.set_preset_mode
data_template:
entity_id: fan.humidifier
preset_mode: "{{ states('input_select.humidifier_mode') }}"
- alias: Humidifier - monitor operation mode and update input select
trigger:
platform: template
value_template: '{{ states.fan.humidifier.attributes.preset_mode }}'
action:
service: input_select.select_option
entity_id: input_select.humidifier_mode
data_template:
option: >
{{ states.fan.humidifier.attributes.preset_mode }}
- alias: Humidifier - select LED mode by input select
trigger:
entity_id: input_select.humidifier_led
platform: state
action:
service: xiaomi_miio_airpurifier.fan_set_led_brightness
data_template:
entity_id: fan.humidifier
brightness: > # accepts value in [0, 1, 2], input provides value in [Off, Dim, Bright]
{% set str_to_int =
{ 'Off':'2',
'Dim':'1',
'Bright':'0' } %}
{% set str_brightness = states('input_select.humidifier_led') %}
{% set int_brightness = str_to_int[str_brightness] if str_brightness in str_to_int %}
{{ int_brightness }}
- alias: Humidifier - monitor LED mode and update input select
trigger:
platform: template
value_template: '{{ states.fan.humidifier.attributes.led_brightness }}'
action:
service: input_select.select_option
entity_id: input_select.humidifier_led
data_template:
option: > # provides value in [0, 1, 2], input accepts value in [Off, Dim, Bright]
{% set int_to_str =
{ 2:'Off',
1:'Dim',
0:'Bright' } %}
{% set int_brightness = states.fan.humidifier.attributes.led_brightness %}
{% set str_brightness = int_to_str[int_brightness] if int_brightness in int_to_str %}
{{ str_brightness }}
- alias: Humidifier - select target humidity by input select
trigger:
platform: state
entity_id: input_select.humidifier_target_humidity
action:
service: xiaomi_miio_airpurifier.fan_set_target_humidity
data_template:
entity_id: fan.humidifier
humidity: >
{{ states('input_select.humidifier_target_humidity') }}
- alias: Humidifier - monitor target humidity and update input select
trigger:
platform: template
value_template: '{{ states.fan.humidifier.attributes.target_humidity }}'
action:
service: input_select.select_option
entity_id: input_select.humidifier_target_humidity
data_template:
option: >
{{ states.fan.humidifier.attributes.target_humidity }}
# automation humidifier_water_level_low:
# trigger:
# - platform: numeric_state
# entity_id: sensor.humidifier_water_level
# below: 30
# action:
# - service: notify.<NOTIFIER>
# data_template:
# message: "Humidifier water level low - {{ states('sensor.humidifier_water_level') }}%"