-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstairs.yaml
163 lines (144 loc) · 4 KB
/
stairs.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
# Контроллер подсветки ступенек лестницы
# Железо:
# Контроллер WT32-ETH01
# 74AHCT125N (хуже 74HCT125N)
# APA102
#
#
#
esphome:
name: stairs
platform: ESP32
board: esp-wrover-kit
ethernet:
type: LAN8720
mdc_pin: GPIO23
mdio_pin: GPIO18
clk_mode: GPIO0_IN
phy_addr: 1
power_pin: GPIO16
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
web_server:
port: 80
globals:
- id: gStepFirstLed
type: int[19]
restore_value: no
initial_value: '{ 0, 60, 120, 180, 240, 300, 360, 420, 480, 540, 600, 660, 720, 780, 840, 900, 960, 1020, 1080 }'
- id: gStepLastLed
type: int[19]
restore_value: no
initial_value: '{ 59, 119, 179, 239, 299, 359, 419, 479, 539, 599, 659, 719, 779, 839, 899, 959, 1019, 1079, 1139 }'
light:
- platform: fastled_spi
chipset: APA102
data_pin: GPIO17
clock_pin: GPIO5
rgb_order: BGR
num_leds: 1140
name: "StairLight"
id: staircase
data_rate: 200kHz #длинные ленты не работают на большой частоте!
effects:
- addressable_lambda:
name: "Steps down to up"
update_interval: 400ms
lambda: |-
static uint16_t stepsCount = 0;
static uint16_t i = 0;
static uint16_t run = 0;
if (initial_run)
{
//Определяем количество ступеней
stepsCount = sizeof(id(gStepFirstLed)) / sizeof(id(gStepFirstLed)[0]);
i = 0;
run = 0;
it.all() = Color::BLACK; //гасим ленту
return;
}
/* final run */
if (run == 2)
{
auto call = id(staircase).turn_off();
call.perform();
return;
}
if (i < stepsCount && run < 2)
{
if (run == 0)
{
it.range(id(gStepFirstLed)[i], id(gStepLastLed)[i]) = current_color;
}
else
{
it.range(id(gStepFirstLed)[i], id(gStepLastLed)[i]) = Color::BLACK;
}
i += 1;
if (i == stepsCount)
{
i = 0;
run += 1;
}
}
- addressable_lambda:
name: "Steps up to down"
update_interval: 400ms
lambda: |-
static uint16_t stepsCount = 0;
static uint16_t i = 0;
static uint16_t run = 0;
if (initial_run)
{
stepsCount = sizeof(id(gStepFirstLed)) / sizeof(id(gStepFirstLed)[0]);
i = stepsCount;
run = 0;
it.all() = Color::BLACK;
return;
}
/* final run */
if (run == 2)
{
auto call = id(staircase).turn_off();
call.perform();
return;
}
if (i > 0 && run < 2)
{
if (run == 0)
{
it.range(id(gStepFirstLed)[i-1], id(gStepLastLed)[i-1]) = current_color;
}
else
{
it.range(id(gStepFirstLed)[i-1], id(gStepLastLed)[i-1]) = Color::BLACK;
}
i -= 1;
if (i == 0)
{
i = stepsCount;
run += 1;
}
}
switch:
- platform: template
name: "down2up"
turn_on_action:
- light.turn_on:
id: staircase
#brightness: 100%
effect: "Steps down to up"
turn_off_action:
- light.turn_off: staircase
- platform: template
name: "up2down"
turn_on_action:
- light.turn_on:
id: staircase
#brightness: 100%
effect: "Steps up to down"
turn_off_action:
- light.turn_off: staircase