-
Notifications
You must be signed in to change notification settings - Fork 0
/
heltec32-lights.yml
190 lines (170 loc) · 4.04 KB
/
heltec32-lights.yml
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
# heltec docs
# https://resource.heltec.cn/download/WiFi_Kit_32/WiFi%20Kit32.pdf
# heltec source code
# https://github.com/HelTecAutomation/Heltec_ESP32
substitutions:
node_name: heltec32-lights
device_verbose_name: "Heltec light controller"
ip_suffix: "119"
ap_password: "y0ltlm7Rryim"
board_type: heltec_wifi_kit_32
packages:
wifi: !include common/wifi.yml
device_base: !include common/device_base.yml
# https://esphome.io/index.html#
esphome:
includes:
- custom/glow
# - esp32-custom/src/display
# unique to this device
api:
# password: "19995aac489e7eab0577feae9a5f4a8d"
encryption:
key: "YUuNOPdh1y1F2XZKiL6LsPwo3QNIHRFi7hzUrxXNizo="
globals:
- id: grid_on
type: bool
restore_value: yes
initial_value: 'false'
# https://esphome.io/components/light/index.html
light:
- platform: partition
name: "LED Grid"
id: 'grid0'
segments:
- id: strip0
from: 0
to: 8
- id: strip1
from: 0
to: 8
- id: strip2
from: 0
to: 8
- id: strip3
from: 0
to: 8
on_turn_on:
then:
- lambda: |-
id(grid_on) = true;
on_turn_off:
then:
- lambda: |-
id(grid_on) = false;
effects: !include custom/grid_effects.yml
- platform: fastled_clockless
name: "LED Grid Section 1"
id: strip0
chipset: NEOPIXEL
num_leds: 9
pin: GPIO13
- platform: fastled_clockless
name: "LED Grid Section 2"
id: strip1
chipset: NEOPIXEL
num_leds: 9
pin: GPIO14
- platform: fastled_clockless
name: "LED Grid Section 3"
id: strip2
chipset: NEOPIXEL
num_leds: 9
pin: GPIO12
- platform: fastled_clockless
name: "LED Grid Section 4"
id: strip3
chipset: NEOPIXEL
num_leds: 9
pin: GPIO27
# https://esphome.io/components/i2c.html
i2c:
# Built-in display
- id: bus_a
sda: GPIO04
scl: GPIO15
scan: true
frequency: 800kHz
# https://esphome.io/components/switch/index.html
switch:
- platform: template
id: led_switch
name: "LED ON/OFF Switch"
optimistic: true
on_turn_on:
then:
- light.turn_on: grid0
on_turn_off:
then:
- light.turn_off: grid0
# https://esphome.io/components/binary_sensor/index.html
binary_sensor:
- platform: gpio
name: "LED ON/OFF"
pin:
number: GPIO35
mode:
input: true
on_press:
then:
- switch.toggle: led_switch
# https://esphome.io/components/sensor/index.html
sensor:
- platform: rotary_encoder
name: "LED Brightness"
id: 'rotary1'
pin_a:
number: GPIO33
inverted: true
mode:
input: true
pin_b:
number: GPIO32
inverted: true
mode:
input: true
pullup: true
min_value: 0
max_value: 100
unit_of_measurement: "%"
publish_initial_value: true
on_value:
then:
- light.turn_on:
id: grid0
brightness: !lambda |-
// output value must be in range 0 - 1.0
return id(rotary1).state / 100.0;
- platform: wifi_signal
id: wifi_signal_1
name: "WiFi Signal"
update_interval: 60s
# https://esphome.io/components/display/index.html?highlight=font#fonts
font:
# gfonts://family[@weight]
- file: "gfonts://Lato"
id: lato
size: 14
# https://esphome.io/components/display/index.html
display:
- platform: ssd1306_i2c
i2c_id: bus_a
model: "SSD1306 128x64"
id: blue_display
reset_pin: GPIO16
address: 0x3C
lambda: |-
const char* on_off = (id(grid_on)) ? "ON" : "OFF";
it.printf(0, 0, id(lato), "WIFI signal: %.2f", id(wifi_signal_1).state);
it.printf(0, 16, id(lato), "%s", on_off);
it.printf(0, 32, id(lato), "Brightness: %.2f", id(rotary1).state);
# # https://esphome.io/components/sensor/ultrasonic.html?highlight=hc+sr04
# - platform: ultrasonic
# trigger_pin: GPIO18
# echo_pin: GPIO23
# id: ultra_1
# name: "Ultrasonic Sensor"
# # defaults
# update_interval: 60s
# timeout: 2m
# pulse_time: 10us