Esphome config to turn off ssd1306 OLED display with a trigger

The SSD1306 is an OLED display, thus you can’t control the brightness and there is no backlight you can turn off. You can only display a blank page.

You will need to do something like:

      - id: page4   
        lambda: |-   
          it.print(0, 0, id(my_font), "");

interval:
  - interval: 5s
    then:        
      - if:
          condition:
            binary_sensor.is_on: occupancy
          then:
            if: 
              condition:
                display.is_displaying_page: page1
              then:
                display.page.show: page2
              else:
                if:
                  condition:
                    display.is_displaying_page: page2
                  then:
                    display.page.show: page3
                  else:
                    display.page.show: page1
          else:
            - display.page.show: page4
      - component.update: my_display 

Messy I know and not tested…

1 Like