Nesting Intervals and Time Ranges

I have a bit of an odd one here. I’ve included all relevant code below, but here’s the background. We have a small greenhouse in which I’ve put together an ESP8266 with two OLED 1306s and a BME380 to record temperature and humidity of the greenhouse. The issue is that the OLEDs are too bright at night and I need to turn them off. The OLEDs cycle between two pages - the current value and a graph view.

According to this thread we can’t ‘turn off’ the screens, but can create a blank page which should minimize any light coming from them.

Currently, I just have this interval for the screens:

interval:
   - interval: 5s
   then:
     - display.page.show_next: screen1
     - component.update: screen1
   - interval: 5s
   then:
     - display.page.show_next: screen2
     - component.update: screen2

This works great and as expected. So now I’m thinking I’ll add time + on_time > cron automation. What I currently have is below. page3 is the “blank page”. Pages 1 and 2 are the value and graph, respectively

time:
  - platform: homeassistant
    id: homeassistant_time
    on_time:
      - cron: '0 22 * * * *' 
        then:
          - display.page.show: s2page3
          - component.update: screen2 
          - display.page.show: s1page3
          - component.update: screen1 
      - cron: '0 6 * * * *' 
        then:
          - display.page.show: s2page1
          - component.update: screen2 
          - display.page.show: s1page2
          - component.update: screen1 

However, I can’t seem to add time or interval after the then in cron. So even if the cron works, the interval will kick back in after 30 seconds and turn the screens back on. I thought maybe I could nest crons… but nope.

My next thought is to use a lambda, but that’s my weakest skill in ESPHome, so it is still very much a work in progress.

Curious if anyone has faced a similar situation and if they have any suggestions? Thanks in advance!

Why you use cron? Just set a time for “off” and another for “on”.

on_time:
      # At 6:30am 
      - seconds: 0
        minutes: 30
        hours: 6
        then:

There are also triggers for sunset and sunrise…

Thanks! I think Cron is just preferred because I use it in NodeRed and other places, so I’m familiar, but you’re right, that would work too.

Still need to figure out how to place an interval within that on_time because right now esphome requires them to be separate.

You don’t need intervals.

Do you mind sharing a little more? Nesting the - seconds/minutes/hours didn’t work for me either. How can I set one display.component page between the overnight hours and then during daytime hours, have it cycle between the two display pages I have setup?

at 22 turn display black, from 6am to 22 display alternating every 5s.


 - seconds: 0
   minutes: 0
   hours: 22
   then:
 - seconds: 0,10,20,30,40,50
   hours: 06-21
   then:
 - seconds: 5,15,25,35,45,55
   hours: 06-21
   then: