Skip to content

Commit a6546cb

Browse files
committed
Modify Blank page switch to disable all other pages (Night Mode)
1 parent 1c13891 commit a6546cb

File tree

2 files changed

+87
-20
lines changed

2 files changed

+87
-20
lines changed

packages/display_sh1106_multi_page.yaml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ display:
113113
lambda: |-
114114
it.printf(0, 0, id(open_sans_14), " ");
115115
116-
117116
on_page_change:
118117
- to: airgradient_default
119118
then:
@@ -180,6 +179,7 @@ display:
180179
- display.page.show_next: oled_display
181180
- component.update: oled_display
182181
- to: blank
182+
# Skip blank page unless it is turned on and the interval: will only display it
183183
then:
184184
- if:
185185
condition:
@@ -200,14 +200,15 @@ interval:
200200
then:
201201
switch.turn_off: display_boot_page
202202
- interval: 5s
203-
# Automatically switch to the next page every five seconds
203+
# Automatically switch to the next page every five seconds if not set to blank
204204
then:
205205
- if:
206-
# Always show boot screen if switch is enabled
207206
condition:
208-
switch.is_on: display_boot_page
207+
# If the blank page switch is on, only display the blank page, otherwise, rotate to next page
208+
switch.is_on: display_blank_page
209209
then:
210-
- display.page.show: boot
210+
- display.page.show: blank
211+
- component.update: oled_display
211212
else:
212213
# Change page on display
213214
- display.page.show_next: oled_display
@@ -286,6 +287,12 @@ switch:
286287
optimistic: True
287288
entity_category: config
288289
icon: "mdi:monitor"
290+
on_turn_on:
291+
- display.page.show: blank
292+
- component.update: oled_display
293+
on_turn_off:
294+
- display.page.show_next: oled_display
295+
- component.update: oled_display
289296

290297
number:
291298
- platform: template

packages/display_sh1106_single_page.yaml

Lines changed: 75 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ display:
2222
address: 0x3C
2323
# rotation: 180°
2424
pages:
25-
- id: summary
25+
- id: airgradient_default
2626
# https://forum.airgradient.com/t/airgradient-one-customized-mallocarray-esphome-display/1328
2727
lambda: |-
2828
if (id(display_in_f).state) {
@@ -50,29 +50,58 @@ display:
5050
it.printf(128, 0, id(open_sans_14), TextAlign::TOP_RIGHT, "%s", get_mac_address().c_str());
5151
it.printf(0, 21, id(open_sans_14), "Config Ver: $config_version");
5252
it.printf(0, 42, id(open_sans_14), "$friendly_name");
53+
- id: blank
54+
lambda: |-
55+
it.printf(0, 0, id(open_sans_14), " ");
5356
5457
on_page_change:
55-
to: boot
56-
then:
57-
- if:
58-
# Skip the boot page after initial boot
59-
condition:
60-
lambda: 'return id(device_uptime).state > 30;'
61-
then:
62-
- display.page.show_next: oled_display
63-
- component.update: oled_display
58+
- to: airgradient_default
59+
then:
60+
- if:
61+
condition:
62+
switch.is_off: display_ag_default_page
63+
then:
64+
- display.page.show_next: oled_display
65+
- component.update: oled_display
66+
- to: boot
67+
then:
68+
- if:
69+
condition:
70+
switch.is_off: display_boot_page
71+
then:
72+
- display.page.show_next: oled_display
73+
- component.update: oled_display
74+
- to: blank
75+
# Skip blank page unless it is turned on and the interval: will only display it
76+
then:
77+
- if:
78+
condition:
79+
switch.is_off: display_blank_page
80+
then:
81+
- display.page.show_next: oled_display
82+
- component.update: oled_display
6483

6584

6685
interval:
86+
- interval: 10s
87+
startup_delay: 1s
88+
# Show boot screen serial number and config version only when first starting up
89+
then:
90+
if:
91+
condition:
92+
switch.is_on: display_boot_page
93+
then:
94+
switch.turn_off: display_boot_page
6795
- interval: 5s
68-
# Automatically switch to the next page every five seconds
96+
# Automatically switch to the next page every five seconds if not set to blank
6997
then:
7098
- if:
71-
# Show boot screen for first 10 seconds with serial number and config version
7299
condition:
73-
lambda: 'return id(device_uptime).state < 10;'
100+
# If the blank page switch is on, only display the blank page, otherwise, rotate to next page
101+
switch.is_on: display_blank_page
74102
then:
75-
- display.page.show: boot
103+
- display.page.show: blank
104+
- component.update: oled_display
76105
else:
77106
# Change page on display
78107
- display.page.show_next: oled_display
@@ -82,10 +111,41 @@ interval:
82111
switch:
83112
- platform: template
84113
name: "Display Temperature in °F"
85-
icon: "mdi:thermometer"
86114
id: display_in_f
87115
restore_mode: RESTORE_DEFAULT_ON
88116
optimistic: True
117+
entity_category: config
118+
icon: "mdi:thermometer"
119+
120+
- platform: template
121+
name: "Display AirGradient Default Page"
122+
id: display_ag_default_page
123+
restore_mode: RESTORE_DEFAULT_ON
124+
optimistic: True
125+
entity_category: config
126+
icon: "mdi:monitor"
127+
128+
- platform: template
129+
name: "Display Boot Page"
130+
id: display_boot_page
131+
restore_mode: ALWAYS_ON
132+
optimistic: True
133+
entity_category: config
134+
icon: "mdi:monitor"
135+
136+
- platform: template
137+
name: "Display Blank Page"
138+
id: display_blank_page
139+
restore_mode: RESTORE_DEFAULT_OFF
140+
optimistic: True
141+
entity_category: config
142+
icon: "mdi:monitor"
143+
on_turn_on:
144+
- display.page.show: blank
145+
- component.update: oled_display
146+
on_turn_off:
147+
- display.page.show_next: oled_display
148+
- component.update: oled_display
89149

90150
number:
91151
- platform: template

0 commit comments

Comments
 (0)