How to display more pages on 20x4 LCD

Hello
Can someone help me please :grinning:

This code worked fine.
But i want to switch the pages with a gpio button/switch but i dont know why.
I tryd many things but nothing worked. My las try was:

globals:
   - id: current_page_num
     type: int
     restore_value: no
     initial_value: '1'

display:
  - platform: lcd_pcf8574
    dimensions: 20x4
    address: 0x27
    id: my_display
    update_interval: 10s
    lambda: |-
      if (id(current_page_num) == 1) {
          it.strftime("It is %H:%M on %d.%m.%Y", id(my_time).now());
      }
      if (id(current_page_num) == 2) {
          it.printf(0, 0, "%s", id(IP).state.c_str()); 
          it.printf(0, 1, "%s", id(ssid).state.c_str());
          it.printf(10, 1, "%.0f dBm", id(wlan_signal).state);
          it.printf(0, 3, "%s", id(uptime_human).state.c_str());
      }
   if (id(current_page_num) == 3) {
          it.printf(0, 0, "%.0f Watt", id(Watt).state);
          it.printf(0, 1, "%.0f Ampere", id(Ambere).state);
          it.printf(0, 2, "%.0f Volt", id(Volt).state);
          it.printf(0, 3, "%.0f kWh", id(kWhTotal).state);

button:
  - platform: gpio
    pin: D5
    name: Button
    id: Button
    on_press:
      - lambda: |-
          current_page_num += 1;
          if (current_page_num > 3) {
          current_page_num = 1;
          }
          return (id(current_page_num).state)

TNX in advance

hi, this is my code to change page with one key

display:
  - platform: lcd_pcf8574
    dimensions: 20x4
    address: 0x27
    id: my_display
    lambda: |-
      int number_of_pages = 4;
      if (id(current_page_num) == 1) {
      it.printf(0, 0, "%0.0f", id(rawString).state);  
      it.strftime(0, 3, "%H:%M %d.%m.%Y", id(my_time).now());
      it.printf(19, 3, "1"); 
      }
      if (id(current_page_num) == 2) {
      it.printf(0, 0, "line 1"); 
      it.printf(0, 1, "line 2");
      it.printf(0, 2, "line 3");
      it.printf(0, 3, "line 4");
      it.printf(19, 3, "2");
      }
      if (id(current_page_num) == 3) {
      it.print(0, 0, "Watt");
      it.print(0, 1, "Ampere");
      it.print(0, 2, "Volt");
      it.print(0, 3, "kWh");
      it.printf(19, 3, "3");
      }


time:
  - platform: homeassistant
    id: my_time     

binary_sensor: 
  - platform: gpio
    pin:
      number: 4
      mode:
        input: true
        pullup: true
    name: Button
    id: Button
    on_press:
      then:
        - delay: 100ms
        - script.execute: pagina
              

script:
  - id: pagina
    then:
      - lambda: |-
            id(current_page_num) += 1;
              if (id(current_page_num) > 3) {
                id(current_page_num) = 1;
              }