Reset interval on button press

Tags: #<Tag:0x00007fc41b43cc68>

Hi everyone,

I’ve started using ESPHome because I wanted a mini homemade monitoring screen for my server rack.
I currently have a nodeMCU with DHT22 sensor and SSD1306 OLED display showing me time, DHT sensor data, netdata (like CPU temps and uptime) from my server, …
This is all working and the display has multiple pages with information that automatically cycle (using interval) every 3 seconds. I also added a button in case I manually want to go through the display pages and not wait for the interval.
There’s one thing I can’t figure out tho: Currently, when I manually go to the next page, the interval is still running meaning sometimes the page just immediately moves to the next one because the interval is done. Expected and normal behavior but annoying. :slight_smile:
What I would like is to remain on that selected page for 15 or more seconds and then continue with the automatic cycling every 3 seconds. A delay in the ‘then’ clause of the binary_sensor did not work, which I already expected. How would I handle this?

Relevant yaml:

  - platform: gpio
    name: "Next page button"
      number: D8
      inverted: true
      - delayed_on: 10ms
        - server_rack_display
        # adding delay here does not work
  - interval: 3s
    id: displaypageinterval
      - server_rack_display
      - component.update: server_rack_display

I’ve been looking for an action to disable the interval temporarily but don’t think it exists. I’d love to just be able to do this when button is pressed:

  - interval.disable: displaypageinterval  #this action does not exist
  - server_rack_display
  - delay: 15s
  - interval.enable: displaypageinterval #this action does not exist

Thanks in advance for any advice!

You could use a global variable (Automations and Templates — ESPHome) as bool with a name like displaypageintervalEnabled.

You can then set the variable with globals.set and add a condition to the interval based on the variable.