-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathyeelight_light_ceila.yaml
222 lines (204 loc) · 5.61 KB
/
yeelight_light_ceila.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
substitutions:
name: yeelight-light-ceila
warm_max_power: "0.75"
cold_max_power: "0.7"
cwww_gamma_correction: "1.6"
nl_gamma_correction: "1.6"
# Xiaomi YLYK01YL remote control settings - you must provide your own MAC address
xiaomi_ylyk01yl_mac_address: "00:00:00:00:00:00"
adjust_brightness_step: "0.1"
adjust_brightness_min: "0.1"
adjust_brightness_max: "1.0"
esphome:
name: ${name}
min_version: 2024.10.0
external_components:
- source: github://syssi/esphome-yeelight-ceiling-light
esp32:
board: esp32doit-devkit-v1
flash_size: 4MB
framework:
type: esp-idf
sdkconfig_options:
CONFIG_FREERTOS_UNICORE: y
# Please uncomment these parameters if fast booting is important to you
# CONFIG_BOOTLOADER_SKIP_VALIDATE_ON_POWER_ON: y
# CONFIG_BOOTLOADER_LOG_LEVEL_NONE: y
# CONFIG_LOG_DEFAULT_LEVEL_NONE: y
advanced:
ignore_efuse_mac_crc: true
ignore_efuse_custom_mac: true
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ota:
platform: esphome
logger:
level: DEBUG
# baud_rate: 0
api:
sensor:
- platform: adc
pin: GPIO36
name: "${name} power supply"
attenuation: 12db
disabled_by_default: true
output:
- platform: ledc
pin: GPIO19
id: output_warm
power_supply: power
max_power: ${warm_max_power}
zero_means_zero: true
- platform: ledc
pin: GPIO21
id: output_cold
power_supply: power
max_power: ${cold_max_power}
zero_means_zero: true
- platform: ledc
pin: GPIO23
id: output_nightlight
power_supply: power
zero_means_zero: true
power_supply:
- id: power
pin: GPIO22
enable_time: 0s
keep_on_time: 10s
light:
- platform: cwww
name: "${name} ceiling light"
id: ceiling_light
cold_white: output_cold
warm_white: output_warm
cold_white_color_temperature: 6500 K
warm_white_color_temperature: 2700 K
constant_brightness: true
gamma_correct: 1.6
on_turn_on:
then:
- light.turn_off: night_light
- script.execute: auto_off_timer
restore_mode: RESTORE_AND_ON
- platform: monochromatic
name: "${name} night light"
id: night_light
output: output_nightlight
gamma_correct: 1.6
on_turn_on:
then:
- light.turn_off: ceiling_light
- script.execute: auto_off_timer
button:
- platform: template
id: toggle
on_press:
- if:
condition:
and:
- light.is_off: ceiling_light
- light.is_off: night_light
then:
- light.turn_on: ceiling_light
else:
- light.turn_off: ceiling_light
- light.turn_off: night_light
number:
- platform: template
id: auto_off
name: "${name} auto off"
initial_value: 0 # Zero means disabled
min_value: 0
max_value: 1440 # 24h
icon: mdi:timer
unit_of_measurement: min
step: 5
restore_value: true
optimistic: true
script:
- id: auto_off_timer
mode: restart
then:
- if:
condition:
- number.in_range:
id: auto_off
above: 0
then:
- logger.log: "Auto-off timer started"
- delay: !lambda |
return id(auto_off).state * 60000;
- logger.log: "Auto-off timer expired"
- light.turn_off: ceiling_light
- light.turn_off: night_light
- id: adjust_light_brightness
parameters:
step: float
then:
- lambda: !lambda |
const float b_min = ${adjust_brightness_min};
const float b_max = ${adjust_brightness_max};
esphome::light::LightState* l = nullptr;
if (id(ceiling_light).remote_values.is_on())
l = ceiling_light;
else if (id(night_light).remote_values.is_on())
l = night_light;
if (l != nullptr) {
float b = l->remote_values.get_brightness() + step;
b = (b > b_max) ? b_max : (b < b_min) ? b_min : b;
auto call = l->make_call();
call.set_brightness(b);
call.perform();
}
# Remote YLYK01YL config, remove all below if you don't plan to use it
esp32_ble_tracker:
setup_priority: -900 # This is important, otherwise single-core ESP won't boot
scan_parameters:
active: false
xiaomi_ble:
xiaomi_ylyk01yl:
mac_address: "${xiaomi_ylyk01yl_mac_address}"
on_press:
- keycode: 0 # on
then:
- logger.log: "BLE Remote press: ON"
- light.turn_on: ceiling_light
- keycode: 1 # off
then:
- logger.log: "BLE Remote press: OFF"
- light.turn_off: ceiling_light
- light.turn_off: night_light
- keycode: 2 # sun
then:
- logger.log: "BLE Remote press: SUN"
- light.turn_on: ceiling_light
- keycode: 4 # M
then:
- logger.log: "BLE Remote press: M"
- light.turn_on: night_light
- keycode: 3 # plus
then:
- logger.log: "BLE Remote press: PLUS"
- script.execute:
id: adjust_light_brightness
step: ${adjust_brightness_step}
- keycode: 5 # minus
then:
- logger.log: "BLE Remote press: MINUS"
- script.execute:
id: adjust_light_brightness
step: -${adjust_brightness_step}
on_long_press:
- keycode: 3 # plus
then:
- logger.log: "BLE Remote long-press: PLUS"
- script.execute:
id: adjust_light_brightness
step: 1
- keycode: 5 # minus
then:
- logger.log: "BLE Remote long-press: MINUS"
- script.execute:
id: adjust_light_brightness
step: -1