Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Pairing ESPHome with Home Assistant opens a multitude of opportunities to create

## Disable Display and LED based on time

Enabling the "Blank Page" switch will disable output on the display. It is not necessary to turn off any existing pages, and disabling all pages will result in the device rebooting
Enabling the "Blank Page" switch will disable output on the display. It is not necessary to turn off any existing pages.

1. In Home Assistant, navigate to Settings>Automations and scenes
2. Click "Create Automation" button, then "Create new automation"
Expand All @@ -90,9 +90,8 @@ Enabling the "Blank Page" switch will disable output on the display. It is not
2. Set to your desired time to turn off the display and/or LED
2. Then do
1. Add Action>Device>Select your AirGradient from the ESPHome Integration
2. In the Action field, select "Turn on `<Your AirGradient Name> Display Blank Page`"
1. For the base config with only the single page display package, this will set the display to show an empty page
2. If using the multi_page package, may need to add additional actions to turn off the other enabled pages
2. In the Action field, select "Turn on `<Your AirGradient Name> Display Blank Page`" (if your display package provides this switch)
1. This will set the display to show an empty page
3. Repeat action for "Turn Off `<Your AirGradient Name> LED Strip`" (If applicable)
3. Click the Save button and give it a name, such as "AirGradient Night Mode"
3. Repeat with a new Automation, with the actions reversed (Turn off Display Blank Page and turn on LED Strip), at the desired time with a name such as "AirGradient Night Mode Off"
Expand Down
43 changes: 34 additions & 9 deletions packages/display_sh1106_multi_page.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@ font:
glyphs: '!"%()+=,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz/µ³'


binary_sensor:
# True if and only if at least one non-blank page switch is on.
# Any new page switches should be added here
- platform: template
id: any_non_blank_page_enabled
internal: True
lambda: |-
return id(display_ag_default_page).state
|| id(display_boot_page).state
|| id(display_summary_pages).state
|| id(display_huge_no_units_page).state
|| id(display_air_quality_page).state
|| id(display_air_temp_page).state
|| id(display_voc_page).state
|| id(display_combo_page).state;


display:
- platform: ssd1306_i2c
# https://esphome.io/components/display/ssd1306.html
Expand Down Expand Up @@ -202,11 +219,12 @@ display:
- display.page.show_next: oled_display
- component.update: oled_display
- to: blank
# Skip blank page unless it is turned on and the interval: will only display it
then:
- if:
# Only change pages if a page switch for a non-blank page is actually enabled;
# acts as a base case to prevent recursive page change loop
condition:
switch.is_off: display_blank_page
binary_sensor.is_on: any_non_blank_page_enabled
then:
- display.page.show_next: oled_display
- component.update: oled_display
Expand All @@ -227,14 +245,14 @@ interval:
then:
- if:
condition:
# If the blank page switch is on, only display the blank page, otherwise, rotate to next page
switch.is_on: display_blank_page
and:
- switch.is_off: display_blank_page
- binary_sensor.is_on: any_non_blank_page_enabled
then:
- display.page.show: blank
- display.page.show_next: oled_display
- component.update: oled_display
else:
# Change page on display
- display.page.show_next: oled_display
- display.page.show: blank
- component.update: oled_display


Expand Down Expand Up @@ -322,8 +340,15 @@ switch:
- display.page.show: blank
- component.update: oled_display
on_turn_off:
- display.page.show_next: oled_display
- component.update: oled_display
- if:
condition:
binary_sensor.is_on: any_non_blank_page_enabled
then:
- display.page.show_next: oled_display
- component.update: oled_display
else:
- display.page.show: blank
- component.update: oled_display

number:
- platform: template
Expand Down
37 changes: 28 additions & 9 deletions packages/display_sh1106_single_page.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ font:
bpp: 2


binary_sensor:
# True if and only if at least one non-blank page switch is on.
# Any new page switches should be added here
- platform: template
id: any_non_blank_page_enabled
internal: True
lambda: |-
return id(display_ag_default_page).state
|| id(display_boot_page).state;


display:
- platform: ssd1306_i2c
# https://esphome.io/components/display/ssd1306.html
Expand Down Expand Up @@ -73,11 +84,12 @@ display:
- display.page.show_next: oled_display
- component.update: oled_display
- to: blank
# Skip blank page unless it is turned on and the interval: will only display it
then:
- if:
# Only change pages if a page switch for a non-blank page is actually enabled;
# acts as a base case to prevent recursive page change loop
condition:
switch.is_off: display_blank_page
binary_sensor.is_on: any_non_blank_page_enabled
then:
- display.page.show_next: oled_display
- component.update: oled_display
Expand All @@ -98,14 +110,14 @@ interval:
then:
- if:
condition:
# If the blank page switch is on, only display the blank page, otherwise, rotate to next page
switch.is_on: display_blank_page
and:
- switch.is_off: display_blank_page
- binary_sensor.is_on: any_non_blank_page_enabled
then:
- display.page.show: blank
- display.page.show_next: oled_display
- component.update: oled_display
else:
# Change page on display
- display.page.show_next: oled_display
- display.page.show: blank
- component.update: oled_display


Expand Down Expand Up @@ -145,8 +157,15 @@ switch:
- display.page.show: blank
- component.update: oled_display
on_turn_off:
- display.page.show_next: oled_display
- component.update: oled_display
- if:
condition:
binary_sensor.is_on: any_non_blank_page_enabled
then:
- display.page.show_next: oled_display
- component.update: oled_display
else:
- display.page.show: blank
- component.update: oled_display

number:
- platform: template
Expand Down