-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcar-lighting.yaml
297 lines (273 loc) · 7.5 KB
/
car-lighting.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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# -------------------------------------
# ---- Implemented on a D1 Mini in tesla ----
# -------------------------------------
# |---------|
# | D1 mimi |
# RST | | GPIO1 TXD0
# ADC | | GPIO3 RXD0
# GPIO16 | | GPIO5
# (Button) GPIO14 | | GPIO4
# (WS2812 LEDs) GPIO12 | | GPIO0
# (Opto) GPIO13 | | GPIO2
# GPIO15 | | GND
# 3.3V |---------| 5V
#
# 3.3v -> opto -> 1k GPIO13 -> 20k -> GND
#
#
#Pin What Normal Color Car cable Color
#--------------------------------------------
#1 Ambiant+ Green Solid
#2 Ambiant- Green Stripe
#3 Spare Orange Stripe
#4 Led Data Blue Solid Orange Solid
#5 Button Blue Stripe Blue Stripe
#6 GND Orange Solid Brown Stripe
#7 5v Brown Stripe Brown Solid
#8 12v Brown Solid Blue Solid
substitutions:
devicename: car-lighting
globals:
- id: actual_effect
type: int
restore_value: no
initial_value: '1'
- id: light_enable_override
type: bool
restore_value: no
initial_value: 'false'
esphome:
name: ${devicename}
platform: ESP8266
board: nodemcuv2
on_boot:
# priority: 650.0 #https://esphome.io/components/esphome.html
priority: 550.0
then:
- light.turn_on:
id: leds
effect: "Purple"
wifi:
power_save_mode: high # power went from 0.36W to 0.18W. Dont really need wifi anyway for this
fast_connect: true
networks:
- ssid: !secret wifi_ssid
password: !secret wifi_password
hidden: True
manual_ip:
static_ip: !secret ip_car_lighting
gateway: !secret ip_gateway
subnet: 255.255.255.0
domain: .homelan
ap: # Enable fallback hotspot (captive portal) in case wifi connection fails
ssid: "${devicename} Hotspot"
password: !secret password
captive_portal:
# Enable logging
logger:
level: WARN
# Enable Home Assistant API
api:
reboot_timeout: 0s # Dont reboot..
encryption:
key: !secret encryption_key
ota:
password: !secret password
web_server:
port: 80
auth:
username: admin
password: !secret password
light:
- platform: status_led
id: statled
pin:
number: GPIO2
inverted: true
# - platform: partition
# name: "${devicename} Lights - Middle Bar"
# id: ledmb
# segments:
# - id: leds
# from: 8
# to: 9
#
# - platform: partition
# name: "${devicename} Lights - Front Bar"
# id: ledfb
# segments:
# - id: leds
# from: 0
# to: 0
# - id: leds
# from: 4
# to: 4
#
# - platform: partition
# name: "${devicename} Lights - Front Footwell"
# id: ledff
# segments:
# - id: leds
# from: 1
# to: 3
# - id: leds
# from: 5
# to: 7
#
# - platform: partition
# name: "${devicename} Lights - Back Footwell"
# id: ledff
# segments:
# - id: leds
# from: 10
# to: 13
- platform: neopixelbus
type: GRB
variant: WS2811
pin: GPIO12
num_leds: 14
name: "${devicename} Lights"
id: leds
effects:
- random:
name: "Fast Random"
transition_length: 4s
update_interval: 5s
- random:
name: "Slow Random"
transition_length: 30s
update_interval: 30s
- random:
name: "Really Slow Random"
transition_length: 90s
update_interval: 90s
- addressable_rainbow:
width: 10
speed: 10
# - addressable_lambda:
# name: "Red"
# update_interval: 5s
# lambda:
# it.all() = ESPColor(255, 0, 0);
- lambda:
name: "Red"
update_interval: 5s
lambda: |-
auto call = id(leds).make_call();
call.set_rgb(1.0, 0.0, 0.0);
call.perform();
- lambda:
name: "Green"
update_interval: 5s
lambda: |-
auto call = id(leds).make_call();
call.set_rgb(0.0, 1.0, 0.0);
call.perform();
- lambda:
name: "Blue"
update_interval: 5s
lambda: |-
auto call = id(leds).make_call();
call.set_rgb(0.0, 0.0, 1.0);
call.perform();
- lambda:
name: "IceBlue" # https://convertingcolors.com/rgb-color-128_191_255.html?search=RGB(128,191,255)
update_interval: 5s
lambda: |-
auto call = id(leds).make_call();
call.set_rgb(0.5, 0.75, 1.0);
call.perform();
- lambda:
name: "Purple" # https://convertingcolors.com/rgb-color-128_0_128.html?search=RGB(191,0,255)
update_interval: 5s
lambda: |-
auto call = id(leds).make_call();
call.set_rgb(0.75, 0, 1);
call.perform();
sensor:
- platform: duty_cycle
id: footDuty
name: "${devicename} Footwell Duty Cycle"
pin:
number: GPIO13
inverted: false
mode: INPUT
update_interval: 2s
on_value_range: # When value passes from outside a defined range of values to inside a range
- below: 15.0
then:
- light.turn_off: leds
- above: 30.0
then:
- light.turn_on: leds
on_raw_value: # when a new value is received
if:
condition:
and:
- lambda: "return id(light_enable_override) == false;"
- light.is_on: leds
- sensor.in_range:
id: footDuty
below: 10.0
then:
- light.turn_off:
id: leds
binary_sensor:
- platform: gpio
id: sidebutton
pin:
number: GPIO14
mode: INPUT_PULLUP
#inverted: True
name: "${devicename} Effect Button"
on_multi_click:
- timing:
- ON for at most 1s
- OFF for at least 0.1s
then:
- lambda: |-
id(light_enable_override) = true;
- lambda: |-
auto call = id(leds).turn_on();
if (id(actual_effect) == 0)
call.set_effect("IceBlue");
if (id(actual_effect) == 1)
call.set_effect("Purple");
if (id(actual_effect) == 2)
call.set_effect("Red");
if (id(actual_effect) == 3)
call.set_effect("Green");
if (id(actual_effect) == 4)
call.set_effect("Blue");
if (id(actual_effect) == 5)
call.set_effect("Rainbow");
if (id(actual_effect) == 6)
call.set_effect("Slow Random");
if (id(actual_effect) < 6) //Loop count
id(actual_effect) += 1;
else
id(actual_effect) = 0;
call.perform();
- light.turn_on: statled
- delay: 300ms
- light.turn_off: statled
- timing:
- ON for at least 1.5s
- OFF for at least 0.1s
then:
- lambda: |-
id(light_enable_override) = false;
- light.turn_off: leds
- light.turn_on: statled
- delay: 200ms
- light.turn_off: statled
- delay: 200ms
- light.turn_on: statled
- delay: 200ms
- light.turn_off: statled
# - delay: 2s
# - deep_sleep.enter:
# id: deep_sleep_1
# sleep_duration: 30s
#deep_sleep:
# id: deep_sleep_1