-
Notifications
You must be signed in to change notification settings - Fork 0
/
esp32clock.yaml
134 lines (110 loc) · 3.04 KB
/
esp32clock.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
substitutions:
device_name: esp32clock
esphome:
name: ${device_name}
esp32:
board: wemos_d1_mini32
framework:
type: arduino
globals:
id: time_sync_done
type: bool
# Enable Home Assistant API
api:
encryption:
key: !secret encryption_key
ota:
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: true
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: ${device_name}
password: !secret wifi_password
captive_portal:
binary_sensor:
- platform: homeassistant
id: clock_night_mode
entity_id: schedule.clock_night_mode
sensor:
- platform: homeassistant
id: cgdk2_temperature
entity_id: "sensor.cgdk2guest_d32d_temperature"
- platform: homeassistant
id: outside_temp
entity_id: "sensor.outside_temp"
font:
- file: "fonts/basis33.ttf"
id: digit_font
size: 16
glyphs: "0123456789 "
- file: "fonts/basis33.ttf"
id: digit_font15
size: 15
glyphs: ": ."
spi:
clk_pin: GPIO27
mosi_pin: GPIO32
time:
- platform: sntp
id: sntp_time
on_time_sync:
then:
lambda: |-
id(time_sync_done) = true;
display:
- platform: max7219digit
cs_pin: GPIO25
num_chips: 4
intensity: 0
rotate_chip: 180
reverse_enable: true
lambda: |-
if(!id(time_sync_done))
{
it.print(0, 5, id(digit_font15), ". . . . . . .");
it.invert_on_off(true);
return;
}
it.invert_on_off(false);
auto time = id(sntp_time).now();
bool is_night_mode = id(clock_night_mode).state;
static int clock_should_blink = true;
it.intensity(is_night_mode ? 0 : 5);
it.strftime(0, 5, id(digit_font), TextAlign::CENTER_LEFT, "%H", time);
if(is_night_mode || clock_should_blink)
{
it.strftime(12, 4, id(digit_font15), TextAlign::CENTER_LEFT, ":", time);
}
it.strftime(17, 5, id(digit_font), TextAlign::CENTER_LEFT, "%M", time);
clock_should_blink = !clock_should_blink;
- platform: max7219
cs_pin: GPIO4
num_chips: 5 # 5 because it is on the same SPI bus with max7219digit
intensity: 0
update_interval: 1.5s
lambda: |-
static bool temp_outside = true;
static int temp_mode_time = 0;
auto sens = temp_outside ? id(outside_temp) : id(cgdk2_temperature);
char text[7] = " --";
if(!isnan(sens->state))
{
sprintf(text, "%5.1f", sens->state);
}
it.set_intensity(id(clock_night_mode).state ? 0 : 5);
if(temp_outside)
it.printf(0, " o%2s", text); //#show outside temp
else
it.printf(0, " h%2s", text); //#show room temp
if(temp_mode_time > 2)//#switch to inside/outside sensor
{
temp_outside = !temp_outside;
temp_mode_time = 0;
}
temp_mode_time++;
external_components:
- source: github://voed/esphome@dev
components: [ max7219digit ]