diff --git a/nspanel_esphome.yaml b/nspanel_esphome.yaml index da6313d..a6920cd 100644 --- a/nspanel_esphome.yaml +++ b/nspanel_esphome.yaml @@ -565,6 +565,8 @@ text_sensor: - globals.set: id: lastclick_general_global value: !lambda return x; + - lambda: |- + id(page_timer)->execute(int(id(page_timeout).state)); ##### last click lightsettings page, the main action variable - push to HA ##### - platform: nextion @@ -586,6 +588,8 @@ text_sensor: - globals.set: id: lastclick_lightsettings_global value: !lambda return x; + - lambda: |- + id(page_timer)->execute(int(id(page_timeout).state)); ##### last click coversettings page, the main action variable - push to HA ##### - platform: nextion @@ -607,6 +611,8 @@ text_sensor: - globals.set: id: lastclick_coversettings_global value: !lambda return x; + - lambda: |- + id(page_timer)->execute(int(id(page_timeout).state)); ##### last click climate page, the main action variable - push to HA ##### - platform: nextion @@ -628,6 +634,8 @@ text_sensor: - globals.set: id: lastclick_climatesettings_global value: !lambda return x; + - lambda: |- + id(page_timer)->execute(int(id(page_timeout).state)); ##### currentpage sensor, the main action variable - push to HA ##### - platform: nextion @@ -649,6 +657,8 @@ text_sensor: - globals.set: id: currentpage_global value: !lambda return x; + - lambda: |- + id(page_timer)->execute(int(id(page_timeout).state)); ##### START - SWITCH CONFIGURATION ##### @@ -824,6 +834,17 @@ number: id: temperature_correction_global value: !lambda 'return x;' +##### page-timeout ##### + - platform: template + name: ${device_name} Page Timeout + id: page_timeout + entity_category: config + min_value: 0 + max_value: 60 + initial_value: 10 + step: 1 + restore_value: true + optimistic: true ##### START - DISPLAY START CONFIGURATION ##### display: @@ -855,3 +876,21 @@ display: - switch.template.publish: id: nextion_init state: on + +### Script for page_timer +script: + - id: page_timer + mode: restart + parameters: + delay: int + then: + - lambda: ESP_LOGD("nspanel", "start page-timer delay %i", int(id(page_timeout).state)); + - delay: !lambda return delay *1000; + - lambda: |- + if (id(disp1_currentpage).state == "home" or id(disp1_currentpage).state == "boot" or int(id(page_timeout).state) == 0) { + ESP_LOGD("nspanel", "no page-jump"); + } else { + ESP_LOGD("nspanel", "timer->home"); + id(disp1).send_command_printf("page 0"); + } +