Use "display.page.show:" to show a specific page number based on a sensor value

I’m in need of some help regarding the “display.page.show:” command. I have some pages (page1, page2, etc.) in my yaml and now would like to use “display.page.show:” to call a specific page based on an integer value from a sensor.

example:
if the sensor value is 1, the display should show page1, if the sensor has a value of 2, it should show page2 and so on.

I’m struggling with how to implement this, or if this is even possible in the first place.

Some help would be greatly appreciated. Cheers

Hi,

Something like:

sensor:
  - platform: ...        
    id: ...
    on_value:
      then:
        - if:
            condition:
               lambda: 'return (x == 1.0);'
            then:
              - display.page.show: page1             
        - if:
            condition:
                lambda: 'return (x == 2.0);'
            then:
               - display.page.show: page2

Thank you for your reply,

yes that is as far as I got, but since it’s 20+ pages I was hoping for some kind of solution where I could combine the “page” part with the sensor value.
something like:

  • display.page.show: string (“page”+“sensor.value”).

My coding skills are very limited and I couldn’t find a solution in the docs unfortunately

1 Like

Hi,

kind of a similar problem:

    - if:
        condition:
          display.is_displaying_page:
            id: main_display
            page_id: page20
        then:
          - display.page.show: !lambda |-
                return id(page_is_showing);

Where “page_is_showing” is a global (float - just a number), that would be okay, better would be somthing like:

          - display.page.show: !lambda |-
                return id"page"(page_is_showing);

But i just got this:

Compiling /data/bltester/.pioenvs/bltester/src/main.cpp.o
/config/esphome/bltester.yaml: In lambda function:
/config/esphome/bltester.yaml:135:37: error: cannot convert ‘float’ to ‘esphome::display::DisplayPage*’ in return
return id(page_is_showing);
^

I don´t know, 3 hours in and no solution :frowning:

Any Ideas? Or Solutions?

Thx!