diff --git a/ReleaseNotes.md b/ReleaseNotes.md
new file mode 100644
index 0000000..de2c064
--- /dev/null
+++ b/ReleaseNotes.md
@@ -0,0 +1,217 @@
+# v4.0 - Alarm and Media player pages, Climate add-ons and a more robust panel
+
+## Support this project
+
+### As always, we would like to thank everyone who donated to this project and remind you that every donation helps to support this project - so if you haven't made a donation yet, now would be a good time ;)
+
+[](https://www.paypal.com/donate/?hosted_button_id=S974SWQMB8PB2)
+
+
+## General
+
+Big news: v4.0 has finally landed! Here’s the scoop:
+🚨 We've added an Alarm control panel – safety first, right?
+🎵 The Media Player control is here for all our tunes and binge-watching needs.
+🌬️ Dial in your comfort with the new Fan speed and Embedded climate control settings.
+Plus, we've beefed up the panel's resilience to those annoying network or server glitches.
+
+Give it a spin and let us know your thoughts. Thanks for being on this journey with us!
+
+
+## Updating
+Since in this update lots of input to the blueprint changed, we highly recommend you review your settings and make sure all fields have the correct selection. We did our best to support your legacy settings and avoid breaking your system, but please double check your settings if you see something not working as expected.
+
+### Files that need to be reloaded:
+1. nspanel_blueprint.yaml - v4.0
+2. nspanel_eu.tft or nspanel_us.tft - v4.0
+3. nspanel_esphome.yaml - v4.0
+
+### Instructions
+ _You can find the update procedures following here:_
+- [(EN) How To - All important thing you should know - Update](https://github.com/Blackymas/NSPanel_HA_Blueprint/wiki/(EN)-HowTo---All-important-thing-you-should-know#2-update-blueprint)
+- [(DE) How To - Alle wichtigen Dinge die man wissen sollte - Update](https://github.com/Blackymas/NSPanel_HA_Blueprint/wiki/(DE)-HowTo---Alle-wichtigen-Dinge-die-man-wissen-sollte#2-update-blueprint)
+
+### Enable "Current page" sensor
+If have used v3.3 or earlier, and then updated to v3.4, there's a chance the entity `sensor.xxxxx_current_page` was disabled. As this entity is used again with v4.0, please go to your panel's page (Settings > Devices and Services > ESPHome) and make sure the sensor "Current page" is enabled.
+
+
+## Breaking changes
+1. New requirements: Home Assistant and ESPHome v2023.5.0 or later.
+1. Existing users will have to select again the language for the panel, otherwise English will be used to display strings.
+1. Removed entity `sensor.xxxxx_settings_entity` and service `esphome.xxxxx_set_settings_entity`.
+1. Removed entity `sensor.xxxxx_settings_entity` related to sensor "NSPanel Event". So no more of those ugly json-like strings polluting the device's page.
The sensor "Current page" is back with the information about the page currently visible in your panel, so please update your automation if you are using the event sensor.
**Attention!! If you have disabled the entity `sensor.xxxxx_current_page` in a previous version you will be required to manually enable it back after the update.**
+1. Due to the changes on the time display engine, you might have to select your time format again in the blueprint settings.
+1. The network settings was moved to under `networks` on the `wifi` section. If you are using advanced/custom settings for Wi-Fi on ESPHome, you may have to update it in order to follow the new format.
+1. The sensor "Uptime" is deprecated. It was replaced by "API timestamp" and "Device timestamp" sensors, which makes it more readable to humans on Home Assistant interface and shows respectively the last time the API got connected (between the panel and Home Assistant) and the last time the device started. Thanks to @WZYProjects (#986 and #998) for the new sensors.
+1. Service `esphome.xxxxx_qr_code` is deprecated. It was replaced by service `qrcode` which can be used for changing the QRcode value even when the QRcode page is not visible (useful when using dynamic Wi-Fi credentials).
+1. Removed switches "Relay 1 Local Fallback" and "Relay 2 Local Fallback", together with the relay fallback inputs. Now when you assign your panel's relay to it's respective button the control will be fully local and therefore will have the same behavior as the "fallback" in previous versions.
+1. The "Hardware button long press hold delay" input was removed and the delay (800ms) is now hard coded in ESPHome.
+1. The service `esphome.xxxxx_wake_up_display` was deprecated. Please use `esphome.xxxxx_wake_up` instead.
+1. The services `esphome.xxxxx_send_command_font_color` and `esphome.xxxxx_send_command_background_color` where deprecated. Please use `esphome.xxxxx_set_component_color` instead, and you can use RGB arrays for `foreground` and `background` colors, a 1-element array with the Nextion color code or an empty array if you don't want to change that specific parameter.
+1. Old color selection (based in a text input where you typed a number) is being deprecated gradually.
The icons colors selected before the implementation of the color picker (when it was about typing a number) might fail now, so if you haven't done this yet, please select the color using the new color selector. Open the Blueprint and if the colors are shown properly, you are good, otherwise, please select a color.
+1. The panel selection based on a text box (where you manually typed the panel name).
The new device selection was introduce a few releases ago and is more reliable. The previous selections are still valid, but requires extra processing every time the automation is triggered, so it will be removed.
If you can see your device name on the blueprint settings screen, you are good, otherwise, pick your panel from the new drop down list.
+1. The entity `switch.xxxxx_confirmation_message` was removed and now the confirmation is processed directly on the Nextion display.
+1. With the new flows for dimming and sleeping, you might have to adjust the page timeout as this have a slightly different name now.
+
+
+## Overview of all changes
+1. Add-ons support
+ - Embedded thermostat (cooler or heater) (#917)
+3. Alarm control panel
+4. Support to sensor display precision from Home Assistant (#880)
+5. Filtered device list (#881)
+6. New language selector (#882)
+7. Removed json sensors (#887)
+8. Support for US model on landscape mode (#890)
+9. API status indication on the panel ([#5ff5d35](https://github.com/Blackymas/NSPanel_HA_Blueprint/commit/5ff5d35833be1a1cf9ca0f570662456058980024))
+10. Light & cover settings pages will show only the supported features (#896)
+11. New "Fan speed page" (#897)
+12. Select wake-up page (#898)
+13. Panel's local control
+14. New "Confirm" pop-up
+15. Page "Settings" now supports translations
+16. Media Player control
+17. Custom buttons on Home page
+18. New controls for dimming and sleeping time
+
+
+## Details of all changes
+
+### 1. Support to add-ons
+We are trying to make your panel more useful and more robust by changing some of the functionalities to run internally in the panel, even when the Wi-Fi network or Home Assistant are not available, however, every new functionality takes a bit from the ESP embedded in your panel and increases the complexity, and having a code capable to adapt to all the different user cases will be very complex and certainly will exceed the available memory.
+
+The first add-on available is an **[embedded thermostat](/docs/en/addon_climate.md)**, able to control it locally even when your Wi-Fi is out or Home Assistant is unavailable.
+
+Please refer to the [documentation](/docs/en/addon_climate.md) to get more details on how to enable this add-on.
+
+
+### 2. Alarm control panel
+Now you can control an Alarm Control Panel from your NSPanel, which will allow you to set the alarm mode between the standard modes supported by Home Assistant (Home, Away, Night, Vacation or Custom bypass) or disarm the alarm.
+On this first release, only the basic functionality will be available, so please share your ideas for future improvements.
+
+
+
+For more details, instructions and security considerations, please take a look at the [Alarm Control Panel docs](/docs/en/alarm.md). You may also want to join [this discussion](https://github.com/Blackymas/NSPanel_HA_Blueprint/discussions/984) about the alarm implementation and some ideas for the future releases.
+
+**Important:** At this moment, this functionality is available only for alarms without a code or alarms using a numeric code. Alarms with text code are not yet supported.
+
+
+### 3. Support to sensor display precision from Home Assistant
+Now the values shown in your panel will follow the [sensor display precision](https://www.home-assistant.io/blog/2023/03/01/release-20233/#sensor-display-precision) provided by Home Assistant.
+
+=> If you have problems with a value exceeding the available space in your panel, please reduce the number of decimals using Home Assistant [sensor display precision](https://www.home-assistant.io/blog/2023/03/01/release-20233/#sensor-display-precision).
+
+
+### 4. Filtered device list
+When selecting the NSPanel on the automation, only ESP32 devices will be shown, making easier to find your panel.
+
+
+
+### 5. New language selector
+Starts using the new language selector release with HA 2023.5.0 and based on RFC 5646, which will increase reliability and standardization of the code.
+Althougt this is not visible for users at the first view, it will enable the use of more granular language selections (like pt-BR vs pt-PT or en-US vs en-UK) if needed in the future.
+
+=> If you are an existing users, please remember to select your language again after the update, as the previous selection will be invalid.
+
+
+### 6. Removed json sensors
+The entities `sensor.xxxxx_settings_entity` and `sensor.xxxxx_nspanel_event`, previously used by ESPHome to to transfer information to the Blueprint, like the selected page, buttons pressed, the selected entity on the settings page, etc., together with the service `esphome.xxxxx_set_settings_entity`. This mechanism was a bit fragile and not very user friendly.
+With this version all that information will be transfered via calls to event `esphome.nspanel_ha_blueprint' and the service `esphome.xxxxx_open_entity_settings_page`.
+Apart of a cleaner device page, this change should be transparent for most users. If you have made automation based on the removed elements, please update it using the new service and `sensor.xxxxx_current_page`.
+
+
+### 7. Support for US model on landscape mode
+If you are using a panel model US in landscape mode, you can now use `nspanel_us_land.tft` where the bars related to the hardware buttons will be located at the right, closer to the respective buttons and fixing the offset on the touch screen when using `nspanel_eu.tft` into a US panel.
+
+=> The hardware buttons labels are hidden in this format, as Nextion cannot support rotated text.
+
+
+### 8. API status indication on the panel
+Now the Wi-Fi icon in the panel (at the right side of the time) will show one of 3 possible states:
+
+ The panel is connected to the Wi-Fi and the API is connected to Home Assistant (mdi:wifi)
+
+ The panel is connected to the Wi-Fi, but the API is not connected to Home Assistant (mdi:api-off)
+
+ The panel is **NOT** connected to the Wi-Fi (mdi:wifi-off)
+
+
+### 9. Light & cover settings pages will show only the supported features
+Now when long press a button connected to a light or a cover, the detailed light settings page will open only when the entity supports advanced control, and the detailed page will only show the controls supported by that entity.
+
+
+### 10. New "Fan speed page"
+If you have a connected fan supporting speed control, now you are able to control it's speed from your panel. Just add the new fan to one of the buttons pages or to the hardware buttons and a long press on those buttons will pop up the new "Fan speed page":
+
+
+
+### 11. Select wake-up page
+Now you can select the wake-up page on the device settings:
+
+
+This selected page will be shown after a boot (after the boot page) and with a touch in the screen when on screen saver page. After showing this wake-up page, all the previous behavior for closing the page (with a click or after a timeout) will be the same and will fall back to the "Home" page.
+
+
+### 12. Panel's local control
+We are trying to make your panel as autonomous as possible by moving some of the controls from the Blueprint to ESPHome. This will reduce the load in your network and Home Assistant, but also will make a more reliable system capable to do it's core functionality even when the network is unavailable or Home Assistant is restarting.
+With this version, the following engines have been moved to your panel (local control):
+- Time display
+- Physical relay control (when hardware left button is connected to relay 1 or right button to relay 2) - Replacing the fallback mode from previous versions.
+- Embedded thermostat (see item 1 about add-ons)
+
+
+### 13. New "Confirm" pop-up
+A new pop-up will replace the previous confirmation page, making clear the difference from notifications.
+
+
+
+### 14. Page "Settings" now supports translations
+Now you will see the Settings page in the same language selected to your panel:
+ 
+ 
+
+- Not all the languages are supported at this moment. If you want to contribute with the translations for your language(s), please visit #1002.
+
+
+### 15. Media Player control
+You can now tap into basic controls for all your connected media devices right from your panel.
+Just add a media player entity to any of the buttons pages. A long press in the button will open the media player control page:
+
+The commands are still a bit laggy, but we will look for ways to improve this in the coming versions.
+
+
+### 16. Custom buttons on Home page
+Now you can add up to 3 customize buttons to the Home page. You can select a climate, cover, fan, light or media player and an icon of your preference, which will be shown in the Home page right above the already known icons for QRcode and entities pages.
+By clicking in the icon, the detailed page will be opened with the selected entity. With that, all those icons will have a similar behavior of jumping to another page.
+
+- To keep consistency with other buttons on this page, only entities supporting advanced settings will be functional on these custom buttons.
+
+
+### 17. New controls for dimming and sleeping time
+We have changed the way your panel handles the dimming and sleeping.
+#### Sleep flow on v3.4:
+
+Apart of some hard-coded times for dimming and sleeping, this flow was inconvenient when the time-out was set to 0, as the panel never go to dimming when left in a page other than Home.
+
+Now you will have full control of the 3 actions and you will be able to play with those parameters as you want or just disabling any of the flows by setting the timeout to 0:
+#### New flows on v4.0:
+
+
+
+## Next topics we are currently working on
+See here: https://github.com/Blackymas/NSPanel_HA_Blueprint/labels/roadmap
+
+## Special thanks to:
+* @chpego
+ - Fixes on the blueprint UI (#928)
+* @WZYProjects
+ - Human readable "Last started" sensor (#986)
+ - Support with customization (#1003)
+ - Translation to Spanish (#1023)
+* @Doughboy68
+ - Tons of tests and feedback during the `dev` phase.
+
+## New Contributors
+* @chpego
+* @WZYProjects
+* @Doughboy68
\ No newline at end of file
diff --git a/nspanel_blueprint.yaml b/nspanel_blueprint.yaml
index 34bbd07..1da3e0e 100644
--- a/nspanel_blueprint.yaml
+++ b/nspanel_blueprint.yaml
@@ -6491,7 +6491,7 @@ action:
- service: '{{ nextion.command.page_settings}}'
data:
reboot: '{{ mui[language].settings.reboot }}'
- sleep_mode: '{{ mui[language].settings.sleep }}'
+ #sleep_mode: '{{ mui[language].settings.sleep }}'
brightness: '{{ mui[language].settings.brightness }}'
bright: '{{ mui[language].settings.bright }}'
dim: '{{ mui[language].settings.dim }}'
@@ -9272,18 +9272,18 @@ action:
continue_on_error: true
##### Wake-up when sleep mode is disabled #####
- - alias: Sleep mode changed
- conditions:
- - condition: trigger
- id: sleep_mode_state
- - "{{ page.current == page.screensaver }}"
- - "{{ trigger.event.data.old_state.state == 'on' }}"
- - "{{ trigger.event.data.new_state.state == 'off' }}"
- sequence:
- service: '{{ nextion.command.wake_up }}'
- data:
- reset_timer: true
- continue_on_error: true
+ #- alias: Sleep mode changed
+ # conditions:
+ # - condition: trigger
+ # id: sleep_mode_state
+ # - "{{ page.current == page.screensaver }}"
+ # - "{{ trigger.event.data.old_state.state == 'on' }}"
+ # - "{{ trigger.event.data.new_state.state == 'off' }}"
+ # sequence:
+ # service: '{{ nextion.command.wake_up }}'
+ # data:
+ # reset_timer: true
+ # continue_on_error: true
#############################################################
##### CLOSE - Action #####
diff --git a/nspanel_esphome.yaml b/nspanel_esphome.yaml
index f577a7d..fac50e5 100644
--- a/nspanel_esphome.yaml
+++ b/nspanel_esphome.yaml
@@ -217,7 +217,7 @@ api:
ESP_LOGV("service.notification_show", "text length: %i", text.length());
id(disp1).send_command_printf("is_notification=1");
- id(disp1).send_command_printf("page notification");
+ id(disp1).goto_page("notification");
id(disp1).set_component_text_printf("notification.notifi_label", "%s", label.c_str());
id(display_wrapped_text).execute("notification.notifi_text01", text.c_str(), id(display_mode) == 2 ? 23 : 32);
@@ -297,7 +297,7 @@ api:
- lambda: |-
id(disp1).set_component_text_printf("qrcode.qrcode_label", "%s", title.c_str());
id(disp1).set_component_text_printf("qrcode.qrcode_value", "%s", qrcode.c_str());
- if (show) id(disp1).send_command_printf("page qrcode");
+ if (show) id(disp1).goto_page("qrcode");
#### Service to set climate state ####
- service: set_climate
@@ -370,14 +370,10 @@ api:
reset_timer: bool
then:
- lambda: |-
- if (id(current_page).state == "home")
- {
- id(disp1).send_command_printf("home.dimtimer.en=1");
- id(disp1).send_command_printf("home.sleeptimer.en=1");
- }
- else if (id(current_page).state == "screensaver") id(disp1).send_command_printf("page %s", id(wakeup_page_name).state.c_str());
- id(disp1).send_command_printf("dim=brightness");
- if (reset_timer) id(page_timer)->execute();
+ if (id(current_page).state == "screensaver") id(disp1).goto_page(id(wakeup_page_name).state.c_str());
+ id(timer_sleep)->execute();
+ id(timer_dim)->execute();
+ if (reset_timer) id(timer_page)->execute();
#### Service to set the entities ####
- service: set_entity
@@ -510,7 +506,7 @@ api:
rtttl: 'two short:d=4,o=5,b=100:16e6,16e6'
- lambda: |-
ESP_LOGV("service.global_settings", "Jump to wake-up page: %s", id(wakeup_page_name).state.c_str());
- id(disp1).send_command_printf("page %s", id(wakeup_page_name).state.c_str());
+ id(disp1).goto_page(id(wakeup_page_name).state.c_str());
- lambda: ESP_LOGV("service.global_settings", "Finished");
@@ -570,7 +566,7 @@ api:
- service: page_settings
variables:
reboot: string
- sleep_mode: string
+ #sleep_mode: string
brightness: string
bright: string
dim: string
@@ -578,12 +574,12 @@ api:
- lambda: |-
ESP_LOGV("service.page_settings", "Starting");
ESP_LOGV("service.page_settings", "reboot: %s", reboot.c_str());
- ESP_LOGV("service.page_settings", "sleep_mode: %s", sleep_mode.c_str());
+ //ESP_LOGV("service.page_settings", "sleep_mode: %s", sleep_mode.c_str());
ESP_LOGV("service.page_settings", "brightness: %s", brightness.c_str());
ESP_LOGV("service.page_settings", "bright: %s", bright.c_str());
ESP_LOGV("service.page_settings", "dim: %s", dim.c_str());
if (not reboot.empty()) id(disp1).set_component_text_printf("settings.lbl_reboot", " %s", reboot.c_str());
- if (not sleep_mode.empty()) id(disp1).set_component_text_printf("settings.lbl_sleep", " %s", sleep_mode.c_str());
+ //if (not sleep_mode.empty()) id(disp1).set_component_text_printf("settings.lbl_sleep", " %s", sleep_mode.c_str());
id(display_wrapped_text).execute("settings.lbl_brightness", brightness.c_str(), id(display_mode) == 2 ? 25 : 10);
id(display_wrapped_text).execute("settings.lbl_bright", bright.c_str(), id(display_mode) == 2 ? 25 : 10);
id(display_wrapped_text).execute("settings.lbl_dim", dim.c_str(), id(display_mode) == 2 ? 25 : 10);
@@ -850,6 +846,12 @@ globals:
restore_value: true
initial_value: '0'
+ ##### Is dimmed #####
+ - id: is_dim_brightness
+ type: bool
+ restore_value: false
+ initial_value: 'false'
+
##### Entity Id of the entity displayed on the detailed pages
- id: entity_id
type: std::string
@@ -1032,14 +1034,14 @@ binary_sensor:
- button.press: restart_nspanel
##### Sleep mode NSPanel Button #####
- - name: ${device_name} Sleep mode
- platform: nextion
- page_id: 7
- component_id: 10
- internal: true
- on_click:
- - logger.log: "Sleep mode - Nextion toggle"
- - switch.toggle: sleep_mode
+ #- name: ${device_name} Sleep mode
+ # platform: nextion
+ # page_id: 7
+ # component_id: 10
+ # internal: true
+ # on_click:
+ # - logger.log: "Sleep mode - Nextion toggle"
+ # - switch.toggle: sleep_mode
##### global variable to keep track on whether the Nextion display is ready or not.
## Delays initial info from HA to the display #####
@@ -1072,7 +1074,7 @@ sensor:
on_value:
then:
- lambda: |-
- id(page_timer)->execute();
+ id(timer_reset_all)->execute();
##### Send current brightness info to Home Assistant
- name: ${device_name} Brightness
@@ -1228,7 +1230,6 @@ text_sensor:
then:
- lambda: |-
ESP_LOGV("text_sensor.nspanelevent", "Starting");
- id(page_timer)->execute();
DynamicJsonDocument doc(1024);
deserializeJson(doc, x);
std::string page = doc["page"];
@@ -1252,6 +1253,7 @@ text_sensor:
{
ESP_LOGV("text_sensor.nspanelevent", "New page: %s", page.c_str());
ESP_LOGV("text_sensor.nspanelevent", "Trigger HA event");
+ id(timer_page)->execute();
ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint",
{
{"type", "page_changed"},
@@ -1271,19 +1273,7 @@ text_sensor:
else if (page=="screensaver")
{
ESP_LOGV("text_sensor.nspanelevent", "Construct screensaver page");
- int wakeup_page_id = 0;
- if (id(wakeup_page_name).state == "buttonpage01") wakeup_page_id = 12;
- else if (id(wakeup_page_name).state == "buttonpage02") wakeup_page_id = 13;
- else if (id(wakeup_page_name).state == "buttonpage03") wakeup_page_id = 14;
- else if (id(wakeup_page_name).state == "buttonpage04") wakeup_page_id = 15;
- else if (id(wakeup_page_name).state == "entitypage01") wakeup_page_id = 18;
- else if (id(wakeup_page_name).state == "entitypage02") wakeup_page_id = 19;
- else if (id(wakeup_page_name).state == "entitypage03") wakeup_page_id = 20;
- else if (id(wakeup_page_name).state == "entitypage04") wakeup_page_id = 21;
- else if (id(wakeup_page_name).state == "qrcode") wakeup_page_id = 17;
- else if (id(wakeup_page_name).state == "alarm") wakeup_page_id = 23;
- ESP_LOGV("text_sensor.nspanelevent", "Wake-up page id: %i", wakeup_page_id);
- id(disp1).set_component_value("orign", wakeup_page_id);
+ id(update_page_screensaver).execute();
}
else if (page=="climate")
{
@@ -1330,7 +1320,12 @@ text_sensor:
else if (page=="buttonpage02" or page=="entitypage02") id(disp1).set_component_text_printf("page_index", "%s", "\uE765\uE764\uE765\uE765"); // 2/4
else if (page=="buttonpage03" or page=="entitypage03") id(disp1).set_component_text_printf("page_index", "%s", "\uE765\uE765\uE764\uE765"); // 3/4
else if (page=="buttonpage04" or page=="entitypage04") id(disp1).set_component_text_printf("page_index", "%s", "\uE765\uE765\uE765\uE764"); // 4/4
- else if (page=="settings") id(disp1).set_component_text_printf("bt_sleep", "%s", (id(sleep_mode).state) ? "\uEA19" : "\uEA18"); //mdi:toggle-switch-outline or mdi:toggle-switch-off-outline
+ else if (page=="settings")
+ {
+ //id(disp1).set_component_text_printf("bt_sleep", "%s", (id(sleep_mode).state) ? "\uEA19" : "\uEA18"); //mdi:toggle-switch-outline or mdi:toggle-switch-off-outline
+ id(disp1).hide_component("lbl_sleep");
+ id(disp1).hide_component("bt_sleep");
+ }
else if (page=="notification")
{
id(disp1).set_component_text_printf("notification.notifi_label", "%s", id(notification_label).state.c_str());
@@ -1366,7 +1361,6 @@ text_sensor:
then:
- lambda: |-
ESP_LOGV("text_sensor.localevent", "Starting");
- id(page_timer)->execute();
DynamicJsonDocument doc(1024);
deserializeJson(doc, x);
std::string page = doc["page"];
@@ -1390,6 +1384,7 @@ text_sensor:
if (event=="pagechanged")
{
ESP_LOGV("text_sensor.localevent", "New page: %s", page.c_str());
+ id(timer_page)->execute();
ESP_LOGV("text_sensor.localevent", "Trigger HA event");
ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint",
{
@@ -1424,7 +1419,7 @@ text_sensor:
std::string title = doc["mui"];
if (code_format=="number" and (key=="disarm" or code_arm_req=="1"))
{
- id(disp1).send_command_printf("page keyb_num");
+ id(disp1).goto_page("keyb_num");
id(disp1).set_component_value("keyb_num.page_id", 23); //Calling from Alarm page
id(disp1).set_component_text_printf("keyb_num.domain", "%s", page.c_str());
id(disp1).set_component_text_printf("keyb_num.key", "%s", key.c_str());
@@ -1466,7 +1461,7 @@ text_sensor:
if (stof(value) >= 5)
{
ESP_LOGV("text_sensor.localevent", "Jump to wakeup page: %s", id(wakeup_page_name).state.c_str());
- id(disp1).send_command_printf("page %s", id(wakeup_page_name).state.c_str());
+ id(disp1).goto_page(id(wakeup_page_name).state.c_str());
}
}
}
@@ -1491,7 +1486,7 @@ text_sensor:
id(service_call_alarm_control_panel)->execute(entity.c_str(), key.c_str(), code_format.c_str(), pin.c_str());
}
else if (base_domain == "" or base_domain.empty()) base_domain = "home";
- id(disp1).send_command_printf("page %s", base_domain.c_str());
+ id(disp1).goto_page(base_domain.c_str());
}
else if (page == "light") id(ha_call_service)->execute("light.turn_on", key.c_str(), value.c_str(), entity.c_str());
else if (page == "media_player")
@@ -1569,27 +1564,27 @@ switch:
internal: true
##### Switch Display Sleep mode #####
- - name: ${device_name} Sleep mode
- platform: template
- device_class: switch
- id: sleep_mode
- entity_category: config
- restore_mode: RESTORE_DEFAULT_OFF
- optimistic: false
- turn_on_action: &sleep_mode-turn_on
- - lambda: |-
- ESP_LOGV("switch.sleep_mode", "Turn on");
- id(disp1).send_command_printf("sleep_mode=1");
- id(disp1).set_component_value("settings.bt_sleep",1);
- id(disp1).set_component_text_printf("settings.bt_sleep", "%s", "\uEA19");
- id(sleep_mode).publish_state(true);
- turn_off_action: &sleep_mode-turn_off
- - lambda: |-
- ESP_LOGV("switch.sleep_mode", "Turn off");
- id(disp1).send_command_printf("sleep_mode=0");
- id(disp1).set_component_value("settings.bt_sleep",0);
- id(disp1).set_component_text_printf("settings.bt_sleep", "%s", "\uEA18");
- id(sleep_mode).publish_state(false);
+ #- name: ${device_name} Sleep mode
+ # platform: template
+ # device_class: switch
+ # id: sleep_mode
+ # entity_category: config
+ # restore_mode: RESTORE_DEFAULT_OFF
+ # optimistic: false
+ # turn_on_action: &sleep_mode-turn_on
+ # - lambda: |-
+ # ESP_LOGV("switch.sleep_mode", "Turn on");
+ # id(disp1).send_command_printf("sleep_mode=1");
+ # id(disp1).set_component_value("settings.bt_sleep",1);
+ # id(disp1).set_component_text_printf("settings.bt_sleep", "%s", "\uEA19");
+ # id(sleep_mode).publish_state(true);
+ # turn_off_action: &sleep_mode-turn_off
+ # - lambda: |-
+ # ESP_LOGV("switch.sleep_mode", "Turn off");
+ # id(disp1).send_command_printf("sleep_mode=0");
+ # id(disp1).set_component_value("settings.bt_sleep",0);
+ # id(disp1).set_component_text_printf("settings.bt_sleep", "%s", "\uEA18");
+ # id(sleep_mode).publish_state(false);
##### Relay Local control #####
- name: ${device_name} Relay 1 Local
@@ -1635,15 +1630,8 @@ number:
id(display_brightness_global) = int(x);
id(disp1).send_command_printf("brightness=%i", int(x));
id(disp1).send_command_printf("settings.brightslider.val=%i", int(x));
- if (id(current_page).state != "screensaver")
- {
- id(disp1).set_backlight_brightness(x/100);
- id(disp1).send_command_printf("home.dimtimer.en=1");
- }
- if (id(current_page).state == "settings")
- {
- id(disp1).set_component_text_printf("bright_text", "%i%%", int(x));
- }
+ if (id(current_page).state != "screensaver") id(disp1).set_backlight_brightness(x/100);
+ if (id(current_page).state == "settings") id(disp1).set_component_text_printf("bright_text", "%i%%", int(x));
##### SCREEN BRIGHTNESS DIMMED DOWN #####
- platform: template
@@ -1682,29 +1670,46 @@ number:
- delay: 1s
- lambda: id(temp_nspanel).publish_state(id(temp_nspanel).raw_state);
- ##### page-timeout #####
- - platform: template
- name: ${device_name} Page timeout
- id: page_timeout
+ ##### Timers settings #####
+ - name: ${device_name} Timeout Page
+ platform: template
+ id: timeout_page
entity_category: config
min_value: 0
- max_value: 60
- initial_value: 5
+ max_value: 300
+ initial_value: 15
step: 1
restore_value: true
optimistic: true
-
- ##### dimming-timeout #####
- #- platform: template
- # name: ${device_name} Dimming timeout
- # id: dimming_timeout
- # entity_category: config
- # min_value: 0
- # max_value: 60
- # initial_value: 15
- # step: 1
- # restore_value: true
- # optimistic: true
+ icon: mdi:timer
+ set_action:
+ - script.execute: timer_page
+ - name: ${device_name} Timeout Dimming
+ platform: template
+ id: timeout_dim
+ entity_category: config
+ min_value: 0
+ max_value: 300
+ initial_value: 30
+ step: 1
+ restore_value: true
+ optimistic: true
+ icon: mdi:timer
+ set_action:
+ - script.execute: timer_dim
+ - name: ${device_name} Timeout Sleep
+ platform: template
+ id: timeout_sleep
+ entity_category: config
+ min_value: 0
+ max_value: 300
+ initial_value: 60
+ step: 1
+ restore_value: true
+ optimistic: true
+ icon: mdi:timer
+ set_action:
+ - script.execute: timer_sleep
select:
- id: wakeup_page_name
@@ -1728,10 +1733,8 @@ select:
internal: false
entity_category: config
icon: mdi:page-next-outline
- #set_action:
- # - logger.log:
- # format: "Wake-up page set: %s"
- # args: ["x.c_str()"]
+ set_action:
+ - script.execute: update_page_screensaver
##### START - DISPLAY START CONFIGURATION #####
display:
@@ -1745,9 +1748,10 @@ display:
then:
- lambda: |-
ESP_LOGV("display.disp1", "Starting");
- id(disp1).send_command_printf("page 8");
+ id(disp1).goto_page("boot");
id(disp1).set_component_text_printf("boot.esph_version", "%s", "${version}"); // ### esphome-version ###
id(disp1).show_component("bt_reboot");
+ id(timer_reset_all)->execute();
- wait_until:
api.connected
- lambda: |-
@@ -1759,11 +1763,11 @@ display:
{"step", "start"}
});
- delay: 1s
- - if:
- condition:
- switch.is_off: sleep_mode
- then: *sleep_mode-turn_off
- else: *sleep_mode-turn_on
+ #- if:
+ # condition:
+ # switch.is_off: sleep_mode
+ # then: *sleep_mode-turn_off
+ # else: *sleep_mode-turn_on
- lambda: |-
// Set dimming values
id(display_brightness).publish_state(id(display_brightness_global));
@@ -1772,7 +1776,6 @@ display:
id(disp1).send_command_printf("settings.brightslider.val=%i", id(display_brightness_global));
id(disp1).send_command_printf("brightness_dim=%i", id(display_dim_brightness_global));
id(disp1).send_command_printf("settings.dimslider.val=%i", id(display_dim_brightness_global));
-
id(nextion_init).publish_state(true);
auto ha_event = new esphome::api::CustomAPIDevice();
ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint",
@@ -1782,25 +1785,87 @@ display:
});
id(home_relay1_icon) = "\uE3A5";
id(home_relay1_icon) = "\uE3A8";
+ id(timer_reset_all)->execute();
- *notification_clear
- switch.turn_off: notification_unread
- logger.log: "Nextion start - Done!"
-### Script for page_timer
+### Script for timer_reset_all
script:
- - id: page_timer
+ ###### Timers ######
+ ## Global timer reset - Triggered with a touch on the screen
+
+ - id: timer_reset_all
+ mode: restart
+ then:
+ - logger.log:
+ format: Resetting timers
+ level: VERBOSE
+ - script.execute: timer_page
+ - script.execute: timer_dim
+ - script.execute: timer_sleep
+
+ - id: timer_page # Handle the fallback to home page after a timeout
mode: restart
then:
- - lambda: ESP_LOGV("script.page_timer", "start page-timer delay %i", delay);
- - delay: !lambda return int(id(page_timeout).state *1000);
- lambda: |-
- if (id(current_page).state == "home" or id(current_page).state == "screensaver" or id(current_page).state == "boot" or int(id(page_timeout).state) == 0)
- ESP_LOGD("script.page_timer", "no page-jump");
- else
+ ESP_LOGV("script.timer_page", "Reset timer: %is", int(id(timeout_page).state));
+ - if:
+ condition:
+ - lambda: !lambda return (id(timeout_page).state >= 1);
+ then:
+ - delay: !lambda return int(id(timeout_page).state *1000);
+ - lambda: |-
+ ESP_LOGV("script.timer_page", "Timed out on page: %s", id(current_page).state.c_str());
+ if (id(current_page).state != "home" and id(current_page).state != "screensaver" and id(current_page).state != "boot" and id(timeout_page).state >= 1)
+ {
+ ESP_LOGD("script.timer_page", "Fallback to page Home");
+ id(disp1).goto_page("home");
+ }
+ - id: timer_dim # Handle the brightness dimming after a timeout DEBUG
+ mode: restart
+ then:
+ - lambda: |-
+ ESP_LOGV("script.timer_dim", "Reset timer: %is", int(id(timeout_dim).state));
+ if (id(is_dim_brightness))
{
- ESP_LOGD("script.page_timer", "timer->home");
- id(disp1).send_command_printf("page 0");
+ if (id(current_page).state != "screensaver" and id(current_page).state != "boot")
+ {
+ ESP_LOGD("script.timer_dim", "Waking up on page: %s", id(current_page).state.c_str());
+ id(disp1).send_command_printf("wakeup_timer.en=1");
+ }
+ id(is_dim_brightness) = false;
}
+ - if:
+ condition:
+ - lambda: !lambda return (id(timeout_dim).state >= 1);
+ then:
+ - delay: !lambda return int(id(timeout_dim).state *1000);
+ - lambda: |-
+ if (id(current_page).state != "screensaver" and id(current_page).state != "boot" and id(timeout_dim).state >= 1)
+ {
+ ESP_LOGD("script.timer_dim", "Dimming the display to %i%%", id(display_dim_brightness_global));
+ id(disp1).send_command_printf("dim=%i", id(display_dim_brightness_global));
+ id(is_dim_brightness) = true;
+ }
+ - id: timer_sleep # Handle the sleep (go to screensaver page) after a timeout DEBUG
+ mode: restart
+ then:
+ - lambda: |-
+ ESP_LOGV("script.timer_sleep", "Reset timer: %is", int(id(timeout_sleep).state));
+ if (id(current_page).state == "screensaver") id(disp1).goto_page(id(wakeup_page_name).state.c_str());
+ - if:
+ condition:
+ - lambda: !lambda return (id(timeout_sleep).state >= 1);
+ then:
+ - delay: !lambda return int(id(timeout_sleep).state *1000);
+ - lambda: |-
+ if (id(current_page).state != "screensaver" and id(current_page).state != "boot" and id(timeout_sleep).state >= 1)
+ {
+ ESP_LOGD("script.timer_sleep", "Going to sleep");
+ id(disp1).goto_page("screensaver");
+ id(is_dim_brightness) = true;
+ }
- id: set_climate
mode: restart
@@ -2047,6 +2112,7 @@ script:
ESP_LOGV("script.ha_button", "page: %s", page.c_str());
ESP_LOGV("script.ha_button", "component: %s", component.c_str());
ESP_LOGV("script.ha_button", "command: %s", command.c_str());
+ id(timer_reset_all)->execute();
auto ha_event = new esphome::api::CustomAPIDevice();
ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint",
{
@@ -2308,6 +2374,31 @@ script:
{"blueprint", id(version_blueprint).c_str()}
});
+ - id: update_page_screensaver
+ mode: restart
+ then:
+ - if:
+ condition:
+ text_sensor.state:
+ id: current_page
+ state: screensaver
+ then:
+ - lambda: |-
+ ESP_LOGV("script.update_page_screensaver", "Starting");
+ int wakeup_page_id = 0;
+ if (id(wakeup_page_name).state == "buttonpage01") wakeup_page_id = 12;
+ else if (id(wakeup_page_name).state == "buttonpage02") wakeup_page_id = 13;
+ else if (id(wakeup_page_name).state == "buttonpage03") wakeup_page_id = 14;
+ else if (id(wakeup_page_name).state == "buttonpage04") wakeup_page_id = 15;
+ else if (id(wakeup_page_name).state == "entitypage01") wakeup_page_id = 18;
+ else if (id(wakeup_page_name).state == "entitypage02") wakeup_page_id = 19;
+ else if (id(wakeup_page_name).state == "entitypage03") wakeup_page_id = 20;
+ else if (id(wakeup_page_name).state == "entitypage04") wakeup_page_id = 21;
+ else if (id(wakeup_page_name).state == "qrcode") wakeup_page_id = 17;
+ else if (id(wakeup_page_name).state == "alarm") wakeup_page_id = 23;
+ ESP_LOGV("script.update_page_screensaver", "Wake-up page id: %i", wakeup_page_id);
+ id(disp1).set_component_value("orign", wakeup_page_id);
+
##### ADD-ONS ############################################################
##### Add-on - Climate #####
- id: addon_climate_service_call
diff --git a/nspanel_eu.HMI b/nspanel_eu.HMI
index eead8ca..8dbae30 100644
Binary files a/nspanel_eu.HMI and b/nspanel_eu.HMI differ
diff --git a/nspanel_eu.tft b/nspanel_eu.tft
index 30f5c34..5203f68 100644
Binary files a/nspanel_eu.tft and b/nspanel_eu.tft differ
diff --git a/nspanel_eu_code/Program.s.txt b/nspanel_eu_code/Program.s.txt
index 627811f..9cb5ec8 100644
--- a/nspanel_eu_code/Program.s.txt
+++ b/nspanel_eu_code/Program.s.txt
@@ -6,7 +6,6 @@ Program.s
int p=0,q=0,t=0,f=0
int dimdelta=0
int api=0 // 0 = disconnected from HA, 1 = connected to HA
- int sleep_mode=0
int is_alarm=0,is_entities=0,is_qrcode=0,is_notification=0
int brightness=100,brightness_dim=40
int display_mode=1 // 1 = EU, 2 = US, 3 = US landscape
diff --git a/nspanel_eu_code/home.txt b/nspanel_eu_code/home.txt
index e1678e1..daefdaa 100644
--- a/nspanel_eu_code/home.txt
+++ b/nspanel_eu_code/home.txt
@@ -12,8 +12,6 @@ Page home
Events
Preinitialize Event
- dimtimer.en=1
- sleeptimer.en=1
printh 92
prints "nspanelevent",0
printh 00
@@ -44,36 +42,30 @@ Page home
prints rand,0
printh FF FF FF
-Variable (int32) disdim
- Attributes
- ID : 2
- Scope: global
- Value: 0
-
Variable (string) lastclick
Attributes
- ID : 39
+ ID : 36
Scope : local
Text :
Max. Text Size: 100
Variable (string) climate_entity
Attributes
- ID : 40
+ ID : 37
Scope : global
Text :
Max. Text Size: 100
Variable (string) click_comp
Attributes
- ID : 48
+ ID : 45
Scope : local
Text :
Max. Text Size: 8
Text time
Attributes
- ID : 5
+ ID : 3
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -83,7 +75,7 @@ Text time
Text current_temp
Attributes
- ID : 6
+ ID : 4
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -93,7 +85,7 @@ Text current_temp
Text outdoor_temp
Attributes
- ID : 7
+ ID : 5
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -103,7 +95,7 @@ Text outdoor_temp
Text date
Attributes
- ID : 8
+ ID : 6
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -113,7 +105,7 @@ Text date
Text value01_state
Attributes
- ID : 10
+ ID : 8
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -123,7 +115,7 @@ Text value01_state
Text left_bt_text
Attributes
- ID : 14
+ ID : 11
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -133,7 +125,7 @@ Text left_bt_text
Text right_bt_text
Attributes
- ID : 15
+ ID : 12
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -143,7 +135,7 @@ Text right_bt_text
Text icon_top_01
Attributes
- ID : 16
+ ID : 13
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -153,7 +145,7 @@ Text icon_top_01
Text icon_top_02
Attributes
- ID : 17
+ ID : 14
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -163,7 +155,7 @@ Text icon_top_02
Text icon_top_03
Attributes
- ID : 18
+ ID : 15
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -173,7 +165,7 @@ Text icon_top_03
Text icon_top_04
Attributes
- ID : 19
+ ID : 16
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -183,7 +175,7 @@ Text icon_top_04
Text icon_top_05
Attributes
- ID : 20
+ ID : 17
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -193,7 +185,7 @@ Text icon_top_05
Text icon_top_06
Attributes
- ID : 21
+ ID : 18
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -203,7 +195,7 @@ Text icon_top_06
Text icon_top_07
Attributes
- ID : 22
+ ID : 19
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -213,7 +205,7 @@ Text icon_top_07
Text icon_top_08
Attributes
- ID : 23
+ ID : 20
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -223,7 +215,7 @@ Text icon_top_08
Text icon_top_09
Attributes
- ID : 24
+ ID : 21
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -233,7 +225,7 @@ Text icon_top_09
Text icon_top_10
Attributes
- ID : 25
+ ID : 22
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -243,7 +235,7 @@ Text icon_top_10
Text value01_icon
Attributes
- ID : 26
+ ID : 23
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -253,7 +245,7 @@ Text value01_icon
Text value03_state
Attributes
- ID : 27
+ ID : 24
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -263,7 +255,7 @@ Text value03_state
Text value03_icon
Attributes
- ID : 28
+ ID : 25
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -273,7 +265,7 @@ Text value03_icon
Text value02_icon
Attributes
- ID : 29
+ ID : 26
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -283,7 +275,7 @@ Text value02_icon
Text value02_state
Attributes
- ID : 30
+ ID : 27
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -293,7 +285,7 @@ Text value02_state
Text wifi_icon
Attributes
- ID : 31
+ ID : 28
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -303,7 +295,7 @@ Text wifi_icon
Text indoortempicon
Attributes
- ID : 32
+ ID : 29
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -313,7 +305,7 @@ Text indoortempicon
Text bt_notific
Attributes
- ID : 33
+ ID : 30
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -330,7 +322,7 @@ Text bt_notific
Text bt_qrcode
Attributes
- ID : 34
+ ID : 31
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -344,7 +336,7 @@ Text bt_qrcode
Text bt_entities
Attributes
- ID : 35
+ ID : 32
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -361,7 +353,7 @@ Text bt_entities
Text bt_alarm
Attributes
- ID : 36
+ ID : 33
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -378,7 +370,7 @@ Text bt_alarm
Text meridiem
Attributes
- ID : 38
+ ID : 35
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -388,7 +380,7 @@ Text meridiem
Text button01
Attributes
- ID : 45
+ ID : 42
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -416,7 +408,7 @@ Text button01
Text button02
Attributes
- ID : 46
+ ID : 43
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -444,7 +436,7 @@ Text button02
Text button03
Attributes
- ID : 47
+ ID : 44
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -472,14 +464,14 @@ Text button03
Picture weather
Attributes
- ID : 9
+ ID : 7
Scope : global
Dragging : 0
Send Component ID: disabled
Dual-state Button left_bt_pic
Attributes
- ID : 42
+ ID : 39
Scope : global
Dragging : 0
Send Component ID: disabled
@@ -489,7 +481,7 @@ Dual-state Button left_bt_pic
Dual-state Button right_bt_pic
Attributes
- ID : 43
+ ID : 40
Scope : global
Dragging : 0
Send Component ID: disabled
@@ -499,7 +491,7 @@ Dual-state Button right_bt_pic
Hotspot fc_weather
Attributes
- ID : 11
+ ID : 9
Scope : global
Dragging : 0
Send Component ID: on press and release
@@ -513,7 +505,7 @@ Hotspot fc_weather
Hotspot jump_climate
Attributes
- ID : 12
+ ID : 10
Scope : local
Dragging : 0
Send Component ID: on press and release
@@ -551,7 +543,7 @@ Hotspot jump_climate
Hotspot settings_click
Attributes
- ID : 37
+ ID : 34
Scope : local
Dragging : 0
Send Component ID: disabled
@@ -563,23 +555,9 @@ Hotspot settings_click
Touch Release Event
settings_timer.en=0
-Timer dimtimer
- Attributes
- ID : 1
- Scope : global
- Period (ms): 50000
- Enabled : yes
-
- Events
- Timer Event
- if(disdim.val==0)
- {
- dims=brightness_dim // Dim down screen to val set from HA
- }
-
Timer swipestore
Attributes
- ID : 4
+ ID : 2
Scope : local
Period (ms): 50
Enabled : no
@@ -589,25 +567,9 @@ Timer swipestore
swipex=tch0
swipey=tch1
-Timer sleeptimer
- Attributes
- ID : 13
- Scope : local
- Period (ms): 65000
- Enabled : no
-
- Events
- Timer Event
- if(sleep_mode==1)
- {
- screensaver.orign.val=0
- // Go to screensaver page
- page screensaver
- }
-
Timer settings_timer
Attributes
- ID : 41
+ ID : 38
Scope : local
Period (ms): 1000
Enabled : no
@@ -618,7 +580,7 @@ Timer settings_timer
Timer wakeup_timer
Attributes
- ID : 44
+ ID : 41
Scope : local
Period (ms): 50
Enabled : yes
@@ -641,7 +603,7 @@ Timer wakeup_timer
Timer click_timer
Attributes
- ID : 49
+ ID : 46
Scope : local
Period (ms): 800
Enabled : no
@@ -659,16 +621,14 @@ Timer click_timer
TouchCap swipe
Attributes
- ID : 3
+ ID : 1
Scope: local
Value: 0
Events
Touch Press Event
swipestore.en=1 // Start swipestore timer
- dim=brightness // Set brightness to saved value (from HA)
- dimtimer.en=1 // Enable timer to calc down for dimming screen
- sleeptimer.en=1
+ wakeup_timer.en=1 // Set brightness to saved value (from HA)
Touch Release Event
swipestore.en=0
diff --git a/nspanel_eu_code/power.page b/nspanel_eu_code/power.page
new file mode 100644
index 0000000..d15ea6a
Binary files /dev/null and b/nspanel_eu_code/power.page differ
diff --git a/nspanel_eu_code/screensaver.txt b/nspanel_eu_code/screensaver.txt
index d53450d..49e829d 100644
--- a/nspanel_eu_code/screensaver.txt
+++ b/nspanel_eu_code/screensaver.txt
@@ -26,7 +26,7 @@ Page screensaver
Variable (int32) orign
Attributes
ID : 2
- Scope: global
+ Scope: local
Value: 0
TouchCap wakeup
diff --git a/nspanel_eu_code/settings.txt b/nspanel_eu_code/settings.txt
index 6c82859..f45ba51 100644
--- a/nspanel_eu_code/settings.txt
+++ b/nspanel_eu_code/settings.txt
@@ -22,6 +22,8 @@ Page settings
prints "{\"page\": \"settings\", \"component\": \"currentpage\", \"value\": \"pagechange\"}",0
printh 00
printh FF FF FF
+ vis lbl_sleep,0
+ vis bt_sleep,0
Touch Press Event
printh 91
diff --git a/nspanel_us.HMI b/nspanel_us.HMI
index 10fe45b..f80d738 100644
Binary files a/nspanel_us.HMI and b/nspanel_us.HMI differ
diff --git a/nspanel_us.tft b/nspanel_us.tft
index 0f4e694..8c28732 100644
Binary files a/nspanel_us.tft and b/nspanel_us.tft differ
diff --git a/nspanel_us_code/Program.s.txt b/nspanel_us_code/Program.s.txt
index fbee574..52a40de 100644
--- a/nspanel_us_code/Program.s.txt
+++ b/nspanel_us_code/Program.s.txt
@@ -6,7 +6,6 @@ Program.s
int p=0,q=0,t=0,f=0
int dimdelta=0
int api=0 // 0 = disconnected from HA, 1 = connected to HA
- int sleep_mode=0
int is_alarm=0,is_entities=0,is_qrcode=0,is_notification=0
int brightness=100,brightness_dim=40
int display_mode=2 // 1 = EU, 2 = US, 3 = US landscape
diff --git a/nspanel_us_code/home.txt b/nspanel_us_code/home.txt
index 293d3b4..7525195 100644
--- a/nspanel_us_code/home.txt
+++ b/nspanel_us_code/home.txt
@@ -12,8 +12,6 @@ Page home
Events
Preinitialize Event
- dimtimer.en=1
- sleeptimer.en=1
printh 92
prints "nspanelevent",0
printh 00
@@ -44,36 +42,30 @@ Page home
prints rand,0
printh FF FF FF
-Variable (int32) disdim
- Attributes
- ID : 2
- Scope: global
- Value: 0
-
Variable (string) lastclick
Attributes
- ID : 39
+ ID : 36
Scope : local
Text :
Max. Text Size: 100
Variable (string) climate_entity
Attributes
- ID : 40
+ ID : 37
Scope : global
Text :
Max. Text Size: 100
Variable (string) click_comp
Attributes
- ID : 48
+ ID : 45
Scope : local
Text :
Max. Text Size: 8
Text time
Attributes
- ID : 5
+ ID : 3
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -83,7 +75,7 @@ Text time
Text current_temp
Attributes
- ID : 6
+ ID : 4
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -93,7 +85,7 @@ Text current_temp
Text outdoor_temp
Attributes
- ID : 7
+ ID : 5
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -103,7 +95,7 @@ Text outdoor_temp
Text date
Attributes
- ID : 8
+ ID : 6
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -113,7 +105,7 @@ Text date
Text value01_state
Attributes
- ID : 10
+ ID : 8
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -123,7 +115,7 @@ Text value01_state
Text left_bt_text
Attributes
- ID : 14
+ ID : 11
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -133,7 +125,7 @@ Text left_bt_text
Text right_bt_text
Attributes
- ID : 15
+ ID : 12
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -143,7 +135,7 @@ Text right_bt_text
Text icon_top_01
Attributes
- ID : 16
+ ID : 13
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -153,7 +145,7 @@ Text icon_top_01
Text icon_top_02
Attributes
- ID : 17
+ ID : 14
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -163,7 +155,7 @@ Text icon_top_02
Text icon_top_03
Attributes
- ID : 18
+ ID : 15
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -173,7 +165,7 @@ Text icon_top_03
Text icon_top_04
Attributes
- ID : 19
+ ID : 16
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -183,7 +175,7 @@ Text icon_top_04
Text icon_top_05
Attributes
- ID : 20
+ ID : 17
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -193,7 +185,7 @@ Text icon_top_05
Text icon_top_06
Attributes
- ID : 21
+ ID : 18
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -203,7 +195,7 @@ Text icon_top_06
Text icon_top_07
Attributes
- ID : 22
+ ID : 19
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -213,7 +205,7 @@ Text icon_top_07
Text icon_top_08
Attributes
- ID : 23
+ ID : 20
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -223,7 +215,7 @@ Text icon_top_08
Text icon_top_09
Attributes
- ID : 24
+ ID : 21
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -233,7 +225,7 @@ Text icon_top_09
Text icon_top_10
Attributes
- ID : 25
+ ID : 22
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -243,7 +235,7 @@ Text icon_top_10
Text value01_icon
Attributes
- ID : 26
+ ID : 23
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -253,7 +245,7 @@ Text value01_icon
Text value03_state
Attributes
- ID : 27
+ ID : 24
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -263,7 +255,7 @@ Text value03_state
Text value03_icon
Attributes
- ID : 28
+ ID : 25
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -273,7 +265,7 @@ Text value03_icon
Text value02_icon
Attributes
- ID : 29
+ ID : 26
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -283,7 +275,7 @@ Text value02_icon
Text value02_state
Attributes
- ID : 30
+ ID : 27
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -293,7 +285,7 @@ Text value02_state
Text wifi_icon
Attributes
- ID : 31
+ ID : 28
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -303,7 +295,7 @@ Text wifi_icon
Text indoortempicon
Attributes
- ID : 32
+ ID : 29
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -313,7 +305,7 @@ Text indoortempicon
Text bt_notific
Attributes
- ID : 33
+ ID : 30
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -330,7 +322,7 @@ Text bt_notific
Text bt_qrcode
Attributes
- ID : 34
+ ID : 31
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -344,7 +336,7 @@ Text bt_qrcode
Text bt_entities
Attributes
- ID : 35
+ ID : 32
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -361,7 +353,7 @@ Text bt_entities
Text bt_alarm
Attributes
- ID : 36
+ ID : 33
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -378,7 +370,7 @@ Text bt_alarm
Text meridiem
Attributes
- ID : 38
+ ID : 35
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -388,7 +380,7 @@ Text meridiem
Text button01
Attributes
- ID : 45
+ ID : 42
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -416,7 +408,7 @@ Text button01
Text button02
Attributes
- ID : 46
+ ID : 43
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -444,7 +436,7 @@ Text button02
Text button03
Attributes
- ID : 47
+ ID : 44
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -472,14 +464,14 @@ Text button03
Picture weather
Attributes
- ID : 9
+ ID : 7
Scope : global
Dragging : 0
Send Component ID: disabled
Dual-state Button left_bt_pic
Attributes
- ID : 42
+ ID : 39
Scope : global
Dragging : 0
Send Component ID: disabled
@@ -489,7 +481,7 @@ Dual-state Button left_bt_pic
Dual-state Button right_bt_pic
Attributes
- ID : 43
+ ID : 40
Scope : global
Dragging : 0
Send Component ID: disabled
@@ -499,7 +491,7 @@ Dual-state Button right_bt_pic
Hotspot fc_weather
Attributes
- ID : 11
+ ID : 9
Scope : global
Dragging : 0
Send Component ID: on press and release
@@ -513,7 +505,7 @@ Hotspot fc_weather
Hotspot jump_climate
Attributes
- ID : 12
+ ID : 10
Scope : local
Dragging : 0
Send Component ID: on press and release
@@ -550,7 +542,7 @@ Hotspot jump_climate
Hotspot settings_click
Attributes
- ID : 37
+ ID : 34
Scope : local
Dragging : 0
Send Component ID: disabled
@@ -562,23 +554,9 @@ Hotspot settings_click
Touch Release Event
settings_timer.en=0
-Timer dimtimer
- Attributes
- ID : 1
- Scope : global
- Period (ms): 50000
- Enabled : yes
-
- Events
- Timer Event
- if(disdim.val==0)
- {
- dims=brightness_dim // Dim down screen to val set from HA
- }
-
Timer swipestore
Attributes
- ID : 4
+ ID : 2
Scope : local
Period (ms): 50
Enabled : no
@@ -588,25 +566,9 @@ Timer swipestore
swipex=tch0
swipey=tch1
-Timer sleeptimer
- Attributes
- ID : 13
- Scope : local
- Period (ms): 65000
- Enabled : no
-
- Events
- Timer Event
- if(sleep_mode==1)
- {
- screensaver.orign.val=0
- // Go to screensaver page
- page screensaver
- }
-
Timer settings_timer
Attributes
- ID : 41
+ ID : 38
Scope : local
Period (ms): 1000
Enabled : no
@@ -617,7 +579,7 @@ Timer settings_timer
Timer wakeup_timer
Attributes
- ID : 44
+ ID : 41
Scope : local
Period (ms): 50
Enabled : yes
@@ -640,7 +602,7 @@ Timer wakeup_timer
Timer click_timer
Attributes
- ID : 49
+ ID : 46
Scope : local
Period (ms): 800
Enabled : no
@@ -658,16 +620,14 @@ Timer click_timer
TouchCap swipe
Attributes
- ID : 3
+ ID : 1
Scope: local
Value: 0
Events
Touch Press Event
swipestore.en=1 // Start swipestore timer
- dim=brightness // Set brightness to saved value (from HA)
- dimtimer.en=1 // Enable timer to calc down for dimming screen
- sleeptimer.en=1
+ wakeup_timer.en=1 // Set brightness to saved value (from HA)
Touch Release Event
swipestore.en=0
diff --git a/nspanel_us_code/screensaver.txt b/nspanel_us_code/screensaver.txt
index d53450d..49e829d 100644
--- a/nspanel_us_code/screensaver.txt
+++ b/nspanel_us_code/screensaver.txt
@@ -26,7 +26,7 @@ Page screensaver
Variable (int32) orign
Attributes
ID : 2
- Scope: global
+ Scope: local
Value: 0
TouchCap wakeup
diff --git a/nspanel_us_code/settings.txt b/nspanel_us_code/settings.txt
index baa0c25..f610ccb 100644
--- a/nspanel_us_code/settings.txt
+++ b/nspanel_us_code/settings.txt
@@ -22,6 +22,8 @@ Page settings
prints "{\"page\": \"settings\", \"component\": \"currentpage\", \"value\": \"pagechange\"}",0
printh 00
printh FF FF FF
+ vis lbl_sleep,0
+ vis bt_sleep,0
Touch Press Event
printh 91
diff --git a/nspanel_us_land.HMI b/nspanel_us_land.HMI
index deef0e9..af7b4e3 100644
Binary files a/nspanel_us_land.HMI and b/nspanel_us_land.HMI differ
diff --git a/nspanel_us_land.tft b/nspanel_us_land.tft
index 42e12ab..9591140 100644
Binary files a/nspanel_us_land.tft and b/nspanel_us_land.tft differ
diff --git a/nspanel_us_land_code/Program.s.txt b/nspanel_us_land_code/Program.s.txt
index 9bed1b0..0a45324 100644
--- a/nspanel_us_land_code/Program.s.txt
+++ b/nspanel_us_land_code/Program.s.txt
@@ -6,7 +6,6 @@ Program.s
int p=0,q=0,t=0,f=0
int dimdelta=0
int api=0 // 0 = disconnected from HA, 1 = connected to HA
- int sleep_mode=0
int is_alarm=0,is_entities=0,is_qrcode=0,is_notification=0
int brightness=100,brightness_dim=40
int display_mode=3 // 1 = EU, 2 = US, 3 = US landscape
diff --git a/nspanel_us_land_code/home.txt b/nspanel_us_land_code/home.txt
index 5c45239..38ea664 100644
--- a/nspanel_us_land_code/home.txt
+++ b/nspanel_us_land_code/home.txt
@@ -12,8 +12,6 @@ Page home
Events
Preinitialize Event
- dimtimer.en=1
- sleeptimer.en=1
printh 92
prints "nspanelevent",0
printh 00
@@ -44,36 +42,30 @@ Page home
prints rand,0
printh FF FF FF
-Variable (int32) disdim
- Attributes
- ID : 2
- Scope: global
- Value: 0
-
Variable (string) lastclick
Attributes
- ID : 39
+ ID : 36
Scope : local
Text :
Max. Text Size: 100
Variable (string) climate_entity
Attributes
- ID : 40
+ ID : 37
Scope : global
Text :
Max. Text Size: 100
Variable (string) click_comp
Attributes
- ID : 48
+ ID : 45
Scope : local
Text :
Max. Text Size: 8
Text time
Attributes
- ID : 5
+ ID : 3
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -83,7 +75,7 @@ Text time
Text current_temp
Attributes
- ID : 6
+ ID : 4
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -93,7 +85,7 @@ Text current_temp
Text outdoor_temp
Attributes
- ID : 7
+ ID : 5
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -103,7 +95,7 @@ Text outdoor_temp
Text date
Attributes
- ID : 8
+ ID : 6
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -113,7 +105,7 @@ Text date
Text value01_state
Attributes
- ID : 10
+ ID : 8
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -123,7 +115,7 @@ Text value01_state
Text left_bt_text
Attributes
- ID : 14
+ ID : 11
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -133,7 +125,7 @@ Text left_bt_text
Text right_bt_text
Attributes
- ID : 15
+ ID : 12
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -143,7 +135,7 @@ Text right_bt_text
Text icon_top_01
Attributes
- ID : 16
+ ID : 13
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -153,7 +145,7 @@ Text icon_top_01
Text icon_top_02
Attributes
- ID : 17
+ ID : 14
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -163,7 +155,7 @@ Text icon_top_02
Text icon_top_03
Attributes
- ID : 18
+ ID : 15
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -173,7 +165,7 @@ Text icon_top_03
Text icon_top_04
Attributes
- ID : 19
+ ID : 16
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -183,7 +175,7 @@ Text icon_top_04
Text icon_top_05
Attributes
- ID : 20
+ ID : 17
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -193,7 +185,7 @@ Text icon_top_05
Text icon_top_06
Attributes
- ID : 21
+ ID : 18
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -203,7 +195,7 @@ Text icon_top_06
Text icon_top_07
Attributes
- ID : 22
+ ID : 19
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -213,7 +205,7 @@ Text icon_top_07
Text icon_top_08
Attributes
- ID : 23
+ ID : 20
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -223,7 +215,7 @@ Text icon_top_08
Text icon_top_09
Attributes
- ID : 24
+ ID : 21
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -233,7 +225,7 @@ Text icon_top_09
Text icon_top_10
Attributes
- ID : 25
+ ID : 22
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -243,7 +235,7 @@ Text icon_top_10
Text value01_icon
Attributes
- ID : 26
+ ID : 23
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -253,7 +245,7 @@ Text value01_icon
Text value03_state
Attributes
- ID : 27
+ ID : 24
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -263,7 +255,7 @@ Text value03_state
Text value03_icon
Attributes
- ID : 28
+ ID : 25
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -273,7 +265,7 @@ Text value03_icon
Text value02_icon
Attributes
- ID : 29
+ ID : 26
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -283,7 +275,7 @@ Text value02_icon
Text value02_state
Attributes
- ID : 30
+ ID : 27
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -293,7 +285,7 @@ Text value02_state
Text wifi_icon
Attributes
- ID : 31
+ ID : 28
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -303,7 +295,7 @@ Text wifi_icon
Text indoortempicon
Attributes
- ID : 32
+ ID : 29
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -313,7 +305,7 @@ Text indoortempicon
Text bt_notific
Attributes
- ID : 33
+ ID : 30
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -330,7 +322,7 @@ Text bt_notific
Text bt_qrcode
Attributes
- ID : 34
+ ID : 31
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -344,7 +336,7 @@ Text bt_qrcode
Text bt_entities
Attributes
- ID : 35
+ ID : 32
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -361,7 +353,7 @@ Text bt_entities
Text bt_alarm
Attributes
- ID : 36
+ ID : 33
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -378,7 +370,7 @@ Text bt_alarm
Text meridiem
Attributes
- ID : 38
+ ID : 35
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -388,7 +380,7 @@ Text meridiem
Text button01
Attributes
- ID : 45
+ ID : 42
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -416,7 +408,7 @@ Text button01
Text button02
Attributes
- ID : 46
+ ID : 43
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -444,7 +436,7 @@ Text button02
Text button03
Attributes
- ID : 47
+ ID : 44
Scope : global
Dragging : 0
Send Component ID : disabled
@@ -472,14 +464,14 @@ Text button03
Picture weather
Attributes
- ID : 9
+ ID : 7
Scope : global
Dragging : 0
Send Component ID: disabled
Dual-state Button left_bt_pic
Attributes
- ID : 42
+ ID : 39
Scope : global
Dragging : 0
Send Component ID: disabled
@@ -489,7 +481,7 @@ Dual-state Button left_bt_pic
Dual-state Button right_bt_pic
Attributes
- ID : 43
+ ID : 40
Scope : global
Dragging : 0
Send Component ID: disabled
@@ -499,7 +491,7 @@ Dual-state Button right_bt_pic
Hotspot fc_weather
Attributes
- ID : 11
+ ID : 9
Scope : global
Dragging : 0
Send Component ID: on press and release
@@ -513,7 +505,7 @@ Hotspot fc_weather
Hotspot jump_climate
Attributes
- ID : 12
+ ID : 10
Scope : local
Dragging : 0
Send Component ID: on press and release
@@ -551,7 +543,7 @@ Hotspot jump_climate
Hotspot settings_click
Attributes
- ID : 37
+ ID : 34
Scope : local
Dragging : 0
Send Component ID: disabled
@@ -563,23 +555,9 @@ Hotspot settings_click
Touch Release Event
settings_timer.en=0
-Timer dimtimer
- Attributes
- ID : 1
- Scope : global
- Period (ms): 50000
- Enabled : yes
-
- Events
- Timer Event
- if(disdim.val==0)
- {
- dims=brightness_dim // Dim down screen to val set from HA
- }
-
Timer swipestore
Attributes
- ID : 4
+ ID : 2
Scope : local
Period (ms): 50
Enabled : no
@@ -589,25 +567,9 @@ Timer swipestore
swipex=tch0
swipey=tch1
-Timer sleeptimer
- Attributes
- ID : 13
- Scope : local
- Period (ms): 65000
- Enabled : no
-
- Events
- Timer Event
- if(sleep_mode==1)
- {
- screensaver.orign.val=0
- // Go to screensaver page
- page screensaver
- }
-
Timer settings_timer
Attributes
- ID : 41
+ ID : 38
Scope : local
Period (ms): 1000
Enabled : no
@@ -618,7 +580,7 @@ Timer settings_timer
Timer wakeup_timer
Attributes
- ID : 44
+ ID : 41
Scope : local
Period (ms): 50
Enabled : yes
@@ -641,7 +603,7 @@ Timer wakeup_timer
Timer click_timer
Attributes
- ID : 49
+ ID : 46
Scope : local
Period (ms): 800
Enabled : no
@@ -659,16 +621,14 @@ Timer click_timer
TouchCap swipe
Attributes
- ID : 3
+ ID : 1
Scope: local
Value: 0
Events
Touch Press Event
swipestore.en=1 // Start swipestore timer
- dim=brightness // Set brightness to saved value (from HA)
- dimtimer.en=1 // Enable timer to calc down for dimming screen
- sleeptimer.en=1
+ wakeup_timer.en=1 // Set brightness to saved value (from HA)
Touch Release Event
swipestore.en=0
diff --git a/nspanel_us_land_code/screensaver.txt b/nspanel_us_land_code/screensaver.txt
index d53450d..49e829d 100644
--- a/nspanel_us_land_code/screensaver.txt
+++ b/nspanel_us_land_code/screensaver.txt
@@ -26,7 +26,7 @@ Page screensaver
Variable (int32) orign
Attributes
ID : 2
- Scope: global
+ Scope: local
Value: 0
TouchCap wakeup
diff --git a/nspanel_us_land_code/settings.txt b/nspanel_us_land_code/settings.txt
index b7b3241..42ef3f2 100644
--- a/nspanel_us_land_code/settings.txt
+++ b/nspanel_us_land_code/settings.txt
@@ -22,6 +22,8 @@ Page settings
prints "{\"page\": \"settings\", \"component\": \"currentpage\", \"value\": \"pagechange\"}",0
printh 00
printh FF FF FF
+ vis lbl_sleep,0
+ vis bt_sleep,0
Touch Press Event
printh 91