Last active 1719118046

using ESPHome

Revision 76ac320721d1166b197aef06f699f74f96b421b1

esp32-clock.yaml Raw
1esp32:
2 board: esp32-c3-devkitm-1
3 variant: ESP32C3
4
5i2c:
6 sda: GPIO6
7 scl: GPIO7
8 frequency: 800kHz
9
10font:
11 - file: "gfonts://Roboto"
12 id: roboto
13 size: 12
14
15time:
16 - platform: sntp
17 id: sntp_time
18 on_time:
19 - cron: '/2 * * * * *'
20 then:
21 - if:
22 condition:
23 switch.is_on: clock_active
24 then:
25 - switch.turn_off: relay
26
27display:
28 - platform: ssd1306_i2c
29 model: "SSD1306 128x32"
30 lambda: |-
31 it.strftime(0, 0, id(roboto), "%Y-%m-%d", id(sntp_time).now());
32 it.strftime(0, 16, id(roboto), "%H:%M %a", id(sntp_time).now());
33
34switch:
35 - platform: template
36 id: clock_active
37 name: "Clock active"
38 optimistic: True
39 restore_mode: ALWAYS_ON
40 - platform: gpio
41 name: "Relay"
42 id: relay
43 pin: GPIO3
44 inverted: False
45 on_turn_off:
46 - delay: 1s
47 - switch.turn_on: relay