-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstealth_wood_display.yaml
157 lines (139 loc) · 3.32 KB
/
stealth_wood_display.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
#original version by nikolai on wiki.vspace.one
#modified by H3
esphome:
name: ledmatrixdisplay
platform: ESP8266
board: nodemcuv2
on_boot:
priority: 1000
then:
- component.update: mtx_disp
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 10.0.8.17
subnet: 255.255.252.0
gateway: 10.0.8.1
dns1: 10.0.8.1
dns2: 1.1.1.1
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Ledmatrixdisplay"
password: "iw3jEjew493VBmk5"
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
services:
- service: show_message
variables:
txt: string
duration: int
then:
- lambda: |-
//duration
if (id(disp_duration)>0) id(disp_duration) = duration;
else id(disp_duration) = 300;
//txt
char* txt_ptr = id(disp_txt);
const size_t dest_size = sizeof(id(disp_txt))-4;
strncpy(txt_ptr, txt.c_str(), dest_size);
txt_ptr = id(disp_txt);
strcat(txt_ptr, " . ");
- logger.log:
format: "New text to display for %d seconds: %s"
args: [ 'id(disp_duration)', 'id(disp_txt)' ]
- component.update: mtx_disp
- script.execute: clear_disp_timeout
mqtt:
broker: mqtt.int.vspace.one
ota:
platform: esphome
on_begin:
then:
- lambda: |-
char* txt_ptr = id(disp_txt);
strcpy(txt_ptr, "OTA...");
- component.update: mtx_disp
# on_progress:
# then:
# - lambda:
# id(mtx_disp).printf(0, -4, id(OpenMine_17_font), "OTA %03.1f%%", x);
# on_end:
# then:
# - lambda:
# id(mtx_disp).print(0, -4, id(OpenMine_17_font), "OTA done :)");
# on_error:
# then:
# - lambda:
# id(mtx_disp).print(0, -4, id(OpenMine_17_font), "OTA ERROR X_X");
globals:
- id: disp_txt
type: char[1024]
restore_value: False
initial_value: |-
{'v','s','p','a','c','e','.','o','n','e',0}
- id: disp_duration
type: int32_t
restore_value: False
initial_value: "300"
status_led:
pin:
number: D5
inverted: True
script:
- id: clear_disp_timeout
mode: restart
then:
- delay: !lambda "return uint32_t(id(disp_duration)) * 1000;"
- lambda: |-
char* txt_ptr = id(disp_txt);
strcpy(txt_ptr, "vspace.one");
- component.update: mtx_disp
spi:
clk_pin: D0
mosi_pin: D2
time:
- platform: homeassistant
id: ha_time
display:
- platform: max7219digit
id: mtx_disp
cs_pin: D1
num_chips: 8
intensity: 15
scroll_speed: 50ms
scroll_delay: 250ms
update_interval: never
lambda: |-
const char* txt_ptr = id(disp_txt);
it.clear();
it.print(0, -4, id(OpenMine_17_font), txt_ptr);
font:
- file: "OpenMine.ttf"
id: OpenMine_17_font
size: 17
sensor:
# Lightsensor Behind Wood
- platform: bh1750
id: light_behind_wood
name: "Light Behind Wood"
address: 0x5C
update_interval: 60s
# Lightsensor Room
- platform: bh1750
id: light_room
name: "Light Room"
address: 0x23
update_interval: 60s
on_value:
lambda: |-
if (x > 0) id(mtx_disp).intensity(std::clamp( x*3 ,float(1),float(15)));
else id(mtx_disp).intensity(15);
i2c:
sda: D3
scl: D4
scan: True
id: bus_a