From 5158fa86d348057d27b029a514d89f2148c41ae2 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Mon, 18 Sep 2023 17:25:37 +0200 Subject: [PATCH] Clean up code - Removed commented out lines - Removed temporary logs Getting prepared to release --- nspanel_blueprint.yaml | 25 --- nspanel_esphome.yaml | 276 +----------------------- nspanel_esphome_addon_climate_cool.yaml | 31 +-- nspanel_esphome_addon_climate_heat.yaml | 31 +-- 4 files changed, 13 insertions(+), 350 deletions(-) diff --git a/nspanel_blueprint.yaml b/nspanel_blueprint.yaml index 87199d6..8eee7f1 100644 --- a/nspanel_blueprint.yaml +++ b/nspanel_blueprint.yaml @@ -6495,13 +6495,11 @@ action: name: !input 'left_button_name' color_rgb: !input 'left_button_color' hold_select: !input 'left_button_hold_select' - #custom_action: !input 'left_button_hold_custom_action' right: entity: !input 'right_button_entity' name: !input 'right_button_name' color_rgb: !input 'right_button_color' hold_select: !input 'right_button_hold_select' - #custom_action: !input 'right_button_hold_custom_action' relays: relay1: icon: !input 'relay01_icon' #E3A5 @@ -6717,13 +6715,6 @@ action: - alias: Home page conditions: '{{ nspanel_event.page == page.home }}' sequence: &refresh_page_home - ##### Set entity variable ##### - #- &set_entity_variable - # service: '{{ nextion.command.text_printf }}' - # data: - # component: home.climate_entity - # message: '{{ "embedded_climate" if climate == thermostat_embedded else climate }}' - # continue_on_error: true ##### Weather Icon Home Page ##### - *delay-default @@ -9311,8 +9302,6 @@ action: conditions: - condition: trigger id: alarm_state - #- '{{ trigger.event.data.new_state.state not in ["unavailable", "unknown", "", None] }}' - #- '{{ page.current == page.alarm }}' sequence: *refresh-page_alarm ########## TRIGGER - HOME PAGE ########### @@ -9439,20 +9428,6 @@ action: data: {} 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 - ############################################################# ##### CLOSE - Action ##### ############################################################# diff --git a/nspanel_esphome.yaml b/nspanel_esphome.yaml index 267c5c1..9c0e896 100644 --- a/nspanel_esphome.yaml +++ b/nspanel_esphome.yaml @@ -212,9 +212,6 @@ api: then: - lambda: |- ESP_LOGV("service.notification_show", "Starting"); - ESP_LOGV("service.notification_show", "label: %s", label.c_str()); - ESP_LOGV("service.notification_show", "text: %s", text.c_str()); - ESP_LOGV("service.notification_show", "text length: %i", text.length()); id(disp1).send_command_printf("is_notification=1"); id(disp1).goto_page("notification"); @@ -254,13 +251,6 @@ api: back_page: string then: - lambda: |- - ESP_LOGV("api.service.open_entity_settings_page", "Starting"); - ESP_LOGV("api.service.open_entity_settings_page", "page: %s", page.c_str()); - ESP_LOGV("api.service.open_entity_settings_page", "page_label: %s", page_label.c_str()); - ESP_LOGV("api.service.open_entity_settings_page", "page_icon: %s", page_icon.c_str()); - ESP_LOGV("api.service.open_entity_settings_page", "page_icon_color: %i, %i, %i", page_icon_color[0], page_icon_color[1], page_icon_color[2] ); - ESP_LOGV("api.service.open_entity_settings_page", "entity: %s", entity.c_str()); - ESP_LOGV("api.service.open_entity_settings_page", "back_page: %s", back_page.c_str()); id(entity_id) = entity; std::string cmd_page = std::string("page ") + page.c_str(); id(disp1).send_command_printf(cmd_page.c_str()); @@ -277,7 +267,6 @@ api: id(disp1).set_component_text_printf("icon_state", "%s", page_icon.c_str()); id(set_component_color).execute("icon_state", page_icon_color, {}); } - ESP_LOGV("api.service.open_entity_settings_page", "Finished"); ##### Service to play a rtttl tones ##### # Example tones : https://codebender.cc/sketch:109888#RTTTL%20Songs.ino @@ -313,13 +302,6 @@ api: entity: string then: - lambda: |- - ESP_LOGV("api.service.set_climate", "climateslider.maxval=%i", total_steps); - ESP_LOGV("api.service.set_climate", "temp_offset=%f", temp_offset); - ESP_LOGV("api.service.set_climate", "temp_step=%f", temp_step); - ESP_LOGV("api.service.set_climate", "current_temp=%f", current_temp); - ESP_LOGV("api.service.set_climate", "target_temp=%f", target_temp); - ESP_LOGV("api.service.set_climate", "target_icon=%s", climate_icon.c_str()); - ESP_LOGV("api.service.set_climate", "embedded=%i", (embedded_climate) ? 1 : 0); if (id(current_page).state == "climate") id(entity_id) = entity; - script.execute: @@ -344,18 +326,11 @@ api: btn_icon: string btn_label: string btn_bri_txt: string - #btn_confirm: bool - #entity: string then: - lambda: |- - ESP_LOGV("service.set_button", "Starting"); - ESP_LOGV("service.set_button", "btn_id: %s", btn_id.c_str()); - ESP_LOGV("service.set_button", "btn_label: %s", btn_label.c_str()); std::string btnicon = btn_id.c_str() + std::string("icon"); std::string btntext = btn_id.c_str() + std::string("text"); std::string btnbri = btn_id.c_str() + std::string("bri"); - //std::string btnconf = btn_id.c_str() + std::string("conf"); - //std::string btnentity = btn_id.c_str() + std::string("entity"); id(disp1).send_command_printf("%spic.pic=%i", btn_id.c_str(), btn_pic); id(set_component_color).execute(btnicon.c_str(), btn_icon_font, btn_bg); id(set_component_color).execute(btntext.c_str(), btn_txt_font, btn_bg); @@ -366,9 +341,6 @@ api: id(disp1).set_component_text_printf(btnbri.c_str(), "%s", btn_bri_txt.c_str()); else id(disp1).set_component_text_printf(btnbri.c_str(), " "); - //id(disp1).set_component_value(btnconf.c_str(), (btn_confirm) ? 1 : 0); - //id(disp1).set_component_text_printf(btnentity.c_str(), "%s", entity.c_str()); - ESP_LOGV("service.set_button", "Finished"); ##### SERVICE TO WAKE UP THE DISPLAY ##### - service: wake_up @@ -395,18 +367,13 @@ api: ent_value_xcen: string then: - lambda: |- - ESP_LOGV("service.set_entity", "entity: %s", ent_id.c_str()); std::string enticon = ent_id.c_str() + std::string("_pic"); std::string entlabel = ent_id.c_str() + std::string("_label"); std::string entxcen = ent_id.c_str() + std::string(".xcen=") + ent_value_xcen.c_str(); id(disp1).set_component_text_printf(enticon.c_str(), "%s", ent_icon.c_str()); - ESP_LOGV("service.set_entity", "%s: %s", enticon.c_str(), ent_id.c_str()); if (strcmp(ent_icon.c_str(), "0") != 0) id(disp1).set_component_text_printf(enticon.c_str(), "%s", ent_icon.c_str()); id(disp1).set_component_text_printf(entlabel.c_str(), "%s", ent_label.c_str()); - ESP_LOGV("service.set_entity", "%s: %s", entlabel.c_str(), ent_label.c_str()); - //id(display_wrapped_text).execute(entlabel.c_str(), ent_label.c_str(), id(display_mode) == 2 ? 16 : 20); id(disp1).set_component_text_printf(ent_id.c_str(), "%s", ent_value.c_str()); - ESP_LOGV("service.set_entity", "%s: %s", ent_id.c_str(), ent_value.c_str()); if (strcmp(ent_value_xcen.c_str(), "0") != 0) id(disp1).send_command_printf("%s", entxcen.c_str()); ##### Service for transferring global settings from the blueprint to ESPHome ##### @@ -430,25 +397,6 @@ api: mui_please_confirm: string then: - lambda: |- - // Logs - Begin - ESP_LOGV("service.global_settings", "Starting"); - ESP_LOGD("service.global_settings", "Blueprint version: %s", blueprint_version.c_str()); - ESP_LOGV("service.global_settings", "relay1_local_control: %i", (relay1_local_control) ? 1 : 0); - ESP_LOGV("service.global_settings", "relay1_icon: %s", relay1_icon.c_str()); - ESP_LOGV("service.global_settings", "relay1_icon_color: %i", relay1_icon_color); - ESP_LOGV("service.global_settings", "relay1_fallback: %i", (relay1_fallback) ? 1 : 0); - ESP_LOGV("service.global_settings", "relay2_local_control: %i", (relay2_local_control) ? 1 : 0); - ESP_LOGV("service.global_settings", "relay2_icon: %s", relay2_icon.c_str()); - ESP_LOGV("service.global_settings", "relay2_icon_color: %i", relay2_icon_color); - ESP_LOGV("service.global_settings", "relay2_fallback: %i", (relay2_fallback) ? 1 : 0); - ESP_LOGV("service.global_settings", "date_color: %i", date_color); - ESP_LOGV("service.global_settings", "time_format: %s", time_format.c_str()); - ESP_LOGV("service.global_settings", "time_color: %i", time_color); - ESP_LOGV("service.global_settings", "embedded_climate: %i", (embedded_climate) ? 1 : 0); - ESP_LOGV("service.global_settings", "embedded_indoor_temperature: %i", (embedded_indoor_temperature) ? 1 : 0); - ESP_LOGV("service.global_settings", "temperature_unit_is_fahrenheit: %i", (temperature_unit_is_fahrenheit) ? 1 : 0); - ESP_LOGV("service.global_settings", "mui_please_confirm: %s", mui_please_confirm.c_str()); - // Blueprint version id(version_blueprint) = blueprint_version; id(check_versions).execute(); @@ -479,18 +427,15 @@ api: id(display_embedded_temp).execute(); // Confirm page - ESP_LOGV("service.global_settings", "Confirm page - Start"); id(display_wrapped_text).execute("confirm.title", mui_please_confirm.c_str(), 15); // Refresh colors of global components - ESP_LOGV("service.global_settings", "Refresh colors of global components"); id(disp1).set_component_font_color("home.date", id(home_date_color)); id(disp1).set_component_font_color("home.time", id(home_time_color)); id(disp1).set_component_font_color("home.icon_top_01", id(home_relay1_icon_color)); id(disp1).set_component_font_color("home.icon_top_02", id(home_relay2_icon_color)); // Update home page - ESP_LOGV("service.global_settings", "Update home page"); id(update_page_home).execute(); - if: @@ -500,9 +445,7 @@ api: state: 'boot' then: - lambda: |- - ESP_LOGV("service.global_settings", "Boot page is visible"); id(disp1).set_component_text_printf("boot.bluep_version", "%s", blueprint_version.c_str()); - ESP_LOGV("service.global_settings", "Wait a bit"); - wait_until: condition: - not: @@ -520,7 +463,6 @@ api: condition: switch.is_on: notification_sound then: - - lambda: ESP_LOGV("service.global_settings", "Play boot sound"); - rtttl.play: rtttl: 'two short:d=4,o=5,b=100:16e6,16e6' - lambda: |- @@ -528,8 +470,6 @@ api: id(disp1).goto_page(id(wakeup_page_name).state.c_str()); id(timer_reset_all).execute(id(wakeup_page_name).state.c_str()); - - lambda: ESP_LOGV("service.global_settings", "Finished"); - #### Service to populate the page Home ##### - service: page_home variables: @@ -545,17 +485,7 @@ api: alarm_state: string then: - lambda: |- - // Logs - Begin - ESP_LOGV("service.page_home_settings", "Starting"); - ESP_LOGV("service.page_home_settings", "notification_icon: %s", notification_icon.c_str()); - ESP_LOGV("service.page_home_settings", "qrcode: %i", (qrcode) ? 1 : 0); - ESP_LOGV("service.page_home_settings", "qrcode_icon: %s", qrcode_icon.c_str()); - ESP_LOGV("service.page_home_settings", "entities_pages: %i", (entities_pages) ? 1 : 0); - ESP_LOGV("service.page_home_settings", "entities_pages_icon: %s", entities_pages_icon.c_str()); - ESP_LOGV("service.page_home_settings", "alarm_state: %s", alarm_state.c_str()); - // Notification button - ESP_LOGV("service.page_home_settings", "Notification button - Start"); id(disp1).send_command_printf("is_notification=%i", (id(notification_text).state.empty() and id(notification_label).state.empty()) ? 0 : 1); id(disp1).set_component_text_printf("home.bt_notific", "%s", notification_icon.c_str()); id(set_component_color).execute("home.bt_notific", id(notification_unread).state ? notification_icon_color_unread : notification_icon_color_normal, {}); @@ -563,25 +493,19 @@ api: id(home_notify_icon_color_unread) = notification_icon_color_unread; // QRCode button - ESP_LOGV("service.page_home_settings", "QRcode button - Start"); id(disp1).send_command_printf("is_qrcode=%i", (qrcode) ? 1 : 0); id(disp1).set_component_text_printf("home.bt_qrcode", "%s", qrcode_icon.c_str()); id(set_component_color).execute("home.bt_qrcode", qrcode_icon_color, {}); // Entities pages button - ESP_LOGV("service.page_home_settings", "Entities pages button - Start"); id(disp1).send_command_printf("is_entities=%i", (entities_pages) ? 1 : 0); id(disp1).set_component_text_printf("home.bt_entities", "%s", entities_pages_icon.c_str()); id(set_component_color).execute("home.bt_entities", entities_pages_icon_color, {}); // Alarm button - ESP_LOGV("service.page_home_settings", "Alarm button - Start"); id(disp1).send_command_printf("is_alarm=%i", (alarm_state=="" or alarm_state.empty()) ? 0 : 1); id(update_alarm_icon).execute("home.bt_alarm", alarm_state.c_str()); - // Logs - End - ESP_LOGV("service.page_home_settings", "Finished"); - #### Service to populate the page Settings ##### - service: page_settings variables: @@ -592,14 +516,7 @@ api: dim: string then: - 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", "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()); 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); @@ -616,24 +533,13 @@ api: mui_alarm: string[] #std::vector #std::map then: - lambda: |- - // Logs - Begin - ESP_LOGV("service.alarm_settings", "Starting"); - ESP_LOGV("service.alarm_settings", "page_title: %s", page_title.c_str()); - ESP_LOGV("service.alarm_settings", "state: %s", state.c_str()); - ESP_LOGV("service.alarm_settings", "supported_features: %i", supported_features); - ESP_LOGV("service.alarm_settings", "code_format: %s", code_format.c_str()); - ESP_LOGV("service.alarm_settings", "code_arm_required: %i", (code_arm_required) ? 1 : 0); - ESP_LOGV("service.alarm_settings", "entity: %s", entity.c_str()); - // set alarm icon on home page - ESP_LOGV("service.alarm_settings", "Updating home page icon"); id(disp1).send_command_printf("is_alarm=%i", (state=="" or state.empty()) ? 0 : 1); id(update_alarm_icon).execute("home.bt_alarm", state.c_str()); // Is page Alarm visible? if (id(current_page).state=="alarm") { // Update alarm page - ESP_LOGV("service.alarm_settings", "Updating alarm page"); id(entity_id) = entity; // Alarm page - Header @@ -715,9 +621,6 @@ api: } } - // Logs - End - ESP_LOGV("service.alarm_settings", "Finished"); - #### Service to populate the media player page ##### - service: media_player variables: @@ -734,45 +637,12 @@ api: supported_features: int then: - lambda: |- - ESP_LOGV("service.media_player", "Starting"); if (id(current_page).state == "media_player") { - //id(disp1).set_component_text_printf("entity", "%s", entity.c_str()); id(entity_id) = entity; id(disp1).set_component_text_printf("page_label", "%s", friendly_name.c_str()); id(display_wrapped_text).execute("track", media_title.c_str(), id(display_mode) == 2 ? 16 : 27); id(display_wrapped_text).execute("artist", media_artist.c_str(), id(display_mode) == 2 ? 26 : 40); - // states: - // OFF: Entity is turned off and is not accepting commands until turned on. - // ON: Entity is turned on, but no details on its state is currently known. - // IDLE: Entity is turned on and accepting commands, but currently not playing any media. Possibly at some idle home screen. - // PLAYING: Entity is currently playing media. - // PAUSED: Entity has an active media and is currently paused - // STANDBY: Entity is in a low power state, accepting commands. - // BUFFERING: Entity is preparing to start playback of some media - // feature: - // PAUSE: 1 - // SEEK: 2 - // VOLUME_SET: 4 - // VOLUME_MUTE: 8 - // PREVIOUS_TRACK: 16 - // NEXT_TRACK: 32 - // reserved: 64 - // TURN_ON: 128 - // TURN_OFF: 256 - // PLAY_MEDIA: 512 - // VOLUME_STEP: 1024 - // SELECT_SOURCE: 2048 - // STOP: 4096 - // CLEAR_PLAYLIST: 8192 - // PLAY: 16384 - // SHUFFLE_SET: 32768 - // SELECT_SOUND_MODE: 65536 - // BROWSE_MEDIA: 131072 - // REPEAT_SET: 262144 - // GROUPING: 524288 - // MEDIA_ANNOUNCE: 1048576 - // MEDIA_ENQUEUE: 2097152 // on/off button if (supported_features & 128 and state == "off") //TURN_ON @@ -989,12 +859,10 @@ globals: - id: home_notify_icon_color_normal type: std::vector restore_value: false - #initial_value: '52857' - id: home_notify_icon_color_unread type: std::vector restore_value: false - #initial_value: '63488' ##### Versions ##### - id: version_blueprint @@ -1107,16 +975,6 @@ binary_sensor: on_click: - 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 - ##### global variable to keep track on whether the Nextion display is ready or not. ## Delays initial info from HA to the display ##### - name: ${device_name} Nextion display @@ -1265,11 +1123,6 @@ text_sensor: #component_name: currentpage internal: false disabled_by_default: false - #filters: - # - lambda: |- - # x = x.c_str(); - # x.shrink_to_fit(); - # return x; on_value: then: - lambda: |- @@ -1456,24 +1309,16 @@ text_sensor: on_value: then: - lambda: |- - ESP_LOGV("text_sensor.localevent", "Starting"); DynamicJsonDocument doc(1024); deserializeJson(doc, x); std::string page = doc["page"]; - ESP_LOGV("text_sensor.localevent", "page: %s", page.c_str()); std::string event = doc["event"]; - ESP_LOGV("text_sensor.localevent", "event: %s", event.c_str()); if (not (event == "pagechanged" and (page == "screensaver" or page == "home"))) id(timer_reset_all).execute(page.c_str()); std::string component = doc["component"]; - ESP_LOGV("text_sensor.localevent", "component: %s", component.c_str()); std::string key = doc["key"]; - ESP_LOGV("text_sensor.localevent", "key: %s", key.c_str()); std::string value = doc["value"]; - ESP_LOGV("text_sensor.localevent", "value: %s", value.c_str()); std::string entity = id(entity_id); //doc["entity"]; - ESP_LOGV("text_sensor.localevent", "entity: %s", entity.c_str()); int embedded = doc["embedded"]; - ESP_LOGV("text_sensor.localevent", "embedded: %i", embedded); std::string service = ""; // send event to Home Assistant @@ -1536,11 +1381,11 @@ text_sensor: } else if (page=="boot") { - // Detect display mode - Need review + // Detect display mode if (doc.containsKey("display_mode")) { std::string display_mode_str = doc["display_mode"]; - ESP_LOGV("text_sensor.localevent", "display_mode: %s", display_mode_str.c_str()); + ESP_LOGD("text_sensor.localevent", "display_mode: %s", display_mode_str.c_str()); float display_mode_float = stof(display_mode_str); if (display_mode_float > 0) id(display_mode) = int(display_mode_float); } @@ -1556,7 +1401,6 @@ text_sensor: // Detect timeout if (event=="timeout") { - ESP_LOGV("text_sensor.localevent", "Trigger boot timeout event"); ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", { {"type", "boot"}, @@ -1564,10 +1408,7 @@ text_sensor: {"value", value} }); if (stof(value) >= 5) - { - ESP_LOGV("text_sensor.localevent", "Jump to wakeup page: %s", id(wakeup_page_name).state.c_str()); - id(disp1).goto_page(id(wakeup_page_name).state.c_str()); - } + id(disp1).goto_page(id(wakeup_page_name).state.c_str()); } } else if (page == "climate") id(service_call_climate).execute(entity.c_str(), key.c_str(), value.c_str(), (embedded==1)); @@ -1601,8 +1442,6 @@ text_sensor: else if (not key.empty()) id(ha_call_service).execute((std::string("media_player.") + key.c_str()), "", "", entity.c_str()); } - ESP_LOGV("text_sensor.localevent", "Finished"); - ##### START - SWITCH CONFIGURATION ##### switch: @@ -1668,29 +1507,6 @@ switch: restore_mode: ALWAYS_ON 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); - ##### Relay Local control ##### - name: ${device_name} Relay 1 Local platform: template @@ -1856,7 +1672,6 @@ display: on_setup: then: - lambda: |- - ESP_LOGV("display.disp1", "Starting"); id(disp1).goto_page("boot"); id(disp1).set_component_text_printf("boot.esph_version", "%s", "${version}"); // ### esphome-version ### id(disp1).show_component("bt_reboot"); @@ -1904,7 +1719,7 @@ script: page: string then: - lambda: |- - ESP_LOGD("script.timer_reset_all", "Resetting timers"); + ESP_LOGV("script.timer_reset_all", "Reset timers"); id(timer_page).execute(page.c_str(), int(id(timeout_page).state)); id(timer_dim).execute(page.c_str(), int(id(timeout_dim).state)); id(timer_sleep).execute(page.c_str(), int(id(timeout_sleep).state)); @@ -1916,7 +1731,7 @@ script: timeout: int then: - lambda: |- - ESP_LOGD("script.timer_page", "Reset timer: %is", timeout); + ESP_LOGV("script.timer_page", "Reset timer: %is", timeout); - if: condition: - lambda: |- @@ -1937,7 +1752,7 @@ script: timeout: int then: - lambda: |- - ESP_LOGD("script.timer_dim", "Reset timer: %is", timeout); + ESP_LOGV("script.timer_dim", "Reset timer: %is", timeout); id(display_current_brightness).update(); if (id(is_dim_brightness)) { @@ -1970,8 +1785,7 @@ script: timeout: int then: - lambda: |- - ESP_LOGD("script.timer_sleep", "Reset timer: %is", timeout); - //if (id(current_page).state == "screensaver" and page == "screensaver") id(disp1).goto_page(id(wakeup_page_name).state.c_str()); + ESP_LOGV("script.timer_sleep", "Reset timer: %is", timeout); - if: condition: - lambda: !lambda return (timeout >= 1); @@ -1996,7 +1810,6 @@ script: climate_icon: string embedded_climate: bool then: - - lambda: ESP_LOGV("script.set_climate", "Starting"); - if: condition: - text_sensor.state: # Is climate page visible? @@ -2004,13 +1817,6 @@ script: state: 'climate' then: - lambda: |- - ESP_LOGV("script.set_climate", "climateslider.maxval=%i", total_steps); - ESP_LOGV("script.set_climate", "temp_offset=%i", temp_offset); - ESP_LOGV("script.set_climate", "temp_step=%i", temp_step); - ESP_LOGV("script.set_climate", "current_temp=%f", current_temp); - ESP_LOGV("script.set_climate", "target_temp=%f", target_temp); - ESP_LOGV("script.set_climate", "target_icon=%s", climate_icon.c_str()); - ESP_LOGV("script.set_climate", "embedded=%i", (embedded_climate) ? 1 : 0); id(addon_climate_set_climate).execute(embedded_climate); id(disp1).send_command_printf("climateslider.maxval=%i", total_steps); id(disp1).set_component_value("temp_offset", temp_offset); @@ -2021,7 +1827,6 @@ script: if (target_temp > -999) { float slider_val = round(((10*target_temp) - temp_offset) / temp_step); - ESP_LOGV("script.set_climate", "climateslider=%f", slider_val); id(disp1).set_component_value("climateslider", slider_val); id(disp1).set_component_text_printf("target_temp", "%.1f°", target_temp); id(disp1).set_component_text_printf("target_icon", "%s", climate_icon.c_str()); @@ -2040,13 +1845,11 @@ script: id(disp1).hide_component("increase_temp"); } id(disp1).set_component_value("embedded", (embedded_climate) ? 1 : 0); - - lambda: ESP_LOGV("script.set_climate", "Finished"); - id: refresh_datetime mode: restart then: - lambda: |- - ESP_LOGV("script.refresh_datetime", "Starting"); std::string time_format_str = id(mui_time_format); if (time_format_str.find("%p") != std::string::npos) { @@ -2072,13 +1875,11 @@ script: } std::string time_text = id(time_provider).now().strftime(time_format_str); id(disp1).set_component_text_printf("home.time", "%s", time_text.c_str()); - ESP_LOGV("script.refresh_datetime", "Finished"); - id: refresh_relays mode: restart then: - lambda: |- - ESP_LOGV("script.refresh_relays", "Starting"); // Chips - Relays if (id(relay_1).state) id(disp1).set_component_text_printf("home.icon_top_01", "%s", id(home_relay1_icon).c_str()); else id(disp1).set_component_text_printf("icon_top_01", "\uFFFF"); @@ -2087,12 +1888,10 @@ script: // Hardware buttons - Fallback mode if (id(relay_1).state and id(relay1_local).state) id(disp1).send_command_printf("home.left_bt_pic.val=%i", (id(relay_1).state) ? 1 : 0); if (id(relay_2).state and id(relay2_local).state) id(disp1).send_command_printf("home.right_bt_pic.val=%i", (id(relay_2).state) ? 1 : 0); - ESP_LOGV("script.refresh_relays", "Finished"); - id: refresh_wifi_icon mode: restart then: - - lambda: ESP_LOGV("script.refresh_wifi_icon", "Starting"); - if: condition: - binary_sensor.is_on: nextion_init @@ -2117,12 +1916,10 @@ script: - lambda: id(disp1).send_command_printf("api=0"); - lambda: id(disp1).set_component_text_printf("home.wifi_icon", "%s", "\uE5A9"); - lambda: id(disp1).set_component_font_color("home.wifi_icon", 63488); - - lambda: ESP_LOGV("script.refresh_wifi_icon", "Finished"); - id: update_page_home mode: restart then: - - lambda: ESP_LOGV("script.update_page_home", "Starting"); - if: condition: - text_sensor.state: # Is home page visible? @@ -2132,14 +1929,11 @@ script: - script.execute: refresh_relays - script.execute: refresh_wifi_icon - lambda: |- - ESP_LOGV("script.update_page_home", "is_notification=%i", (id(notification_text).state.empty() and id(notification_label).state.empty()) ? 0 : 1); id(disp1).send_command_printf("is_notification=%i", (id(notification_text).state.empty() and id(notification_label).state.empty()) ? 0 : 1); id(set_component_color).execute("home.bt_notific", id(notification_unread).state ? id(home_notify_icon_color_unread) : id(home_notify_icon_color_normal), {}); - script.execute: refresh_datetime - script.execute: addon_climate_update_page_home - - lambda: ESP_LOGV("script.update_page_home", "Finished"); - - id: service_call_alarm_control_panel mode: restart parameters: @@ -2149,11 +1943,6 @@ script: pin: string then: - lambda: |- - ESP_LOGV("service_call_alarm_control_panel", "ESPHome remote service call"); - ESP_LOGV("service_call_alarm_control_panel", "entity=%s", entity.c_str()); - ESP_LOGV("service_call_alarm_control_panel", "key=%s", key.c_str()); - ESP_LOGV("service_call_alarm_control_panel", "code_format=%s", code_format.c_str()); - ESP_LOGV("service_call_alarm_control_panel", "pin=%s", entity.c_str()); std::string service = ""; if (key=="home") service = "alarm_control_panel.alarm_arm_home"; else if (key=="away") service = "alarm_control_panel.alarm_arm_away"; @@ -2161,10 +1950,8 @@ script: else if (key=="vacation") service = "alarm_control_panel.alarm_arm_vacation"; else if (key=="bypass") service = "alarm_control_panel.alarm_arm_custom_bypass"; else if (key=="disarm") service = "alarm_control_panel.alarm_disarm"; - ESP_LOGV("service_call_alarm_control_panel", "service=%s", service.c_str()); if (service != "" and not service.empty()) { - ESP_LOGV("service_call_alarm_control_panel", "ESPHome remote service call"); HomeassistantServiceResponse resp; HomeassistantServiceMap resp_kv; resp.service = service.c_str(); @@ -2226,10 +2013,6 @@ script: command: string then: - lambda: |- - ESP_LOGV("script.ha_button", "Starting"); - 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(page.c_str()); auto ha_event = new esphome::api::CustomAPIDevice(); ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", @@ -2239,7 +2022,6 @@ script: {"component", component}, {"command", command} }); - ESP_LOGV("script.ha_button", "Finished"); - id: update_alarm_icon mode: restart @@ -2248,26 +2030,8 @@ script: state: string then: - lambda: |- - ESP_LOGV("script.update_alarm_icon", "Starting"); std::string alarm_icon = "\uEECC"; //mdi:shield-alert-outline int alarm_color = 65535; - // Standard colors: - // blue: '1055' # rgb(0, 128, 248) - // grey_dark: '10597' # rgb(40, 44, 40) - // grey_light: '33808' # rgb(128, 128, 128) - // grey_super_light: '52857' # rgb(200, 204, 200) - // grey_white: '59164' # rgb(225, 225, 225) - // red: '63488' # rgb(248, 0, 0) - // white: '65535' # rgb(255, 255, 255) - // yellow: '65472' # rgb(248, 248, 0) - // #### Colors from HA Style: - // green: '19818' # rgb(76, 175, 80) - // orange: '64704' # rgb(255, 152, 0) - // cyan: '1530' # rgb(0, 188, 212) - // deep-orange: '64164' # rgb(255, 87, 34) - // amber: '65024' # rgb(255, 193, 7) - // "off": '35921' #8a8a8a - // disabled: '48631' # rgb(189, 189, 189) if (state == "disarmed") { alarm_icon = "\uE99B"; //mdi:shield-off-outline @@ -2315,7 +2079,6 @@ script: } id(disp1).set_component_text_printf(component.c_str(), alarm_icon.c_str()); id(disp1).set_component_font_color(component.c_str(), alarm_color); - ESP_LOGV("script.update_alarm_icon", "Finished"); - id: update_climate_icon mode: restart @@ -2325,80 +2088,62 @@ script: mode: int then: - lambda: |- - ESP_LOGV("script.update_climate_icon", "Starting"); - ESP_LOGV("script.update_climate_icon", "component: %s", component.c_str()); - ESP_LOGV("script.update_climate_icon", "action: %i", action); - ESP_LOGV("script.update_climate_icon", "mode: %i", mode); switch (action) // CLIMATE_ACTION_OFF = 0, CLIMATE_ACTION_COOLING = 2, CLIMATE_ACTION_HEATING = 3, CLIMATE_ACTION_IDLE = 4, CLIMATE_ACTION_DRYING = 5, CLIMATE_ACTION_FAN = 6 { case 0: //CLIMATE_ACTION_OFF - ESP_LOGV("script.update_climate_icon", "Climate 'action' is off. Using 'mode' instead"); switch (mode) // CLIMATE_MODE_OFF = 0, CLIMATE_MODE_HEAT_COOL = 1, CLIMATE_MODE_COOL = 2, CLIMATE_MODE_HEAT = 3, CLIMATE_MODE_FAN_ONLY = 4, CLIMATE_MODE_DRY = 5, CLIMATE_MODE_AUTO = 6 { case 0: //CLIMATE_MODE_OFF - ESP_LOGV("script.update_climate_icon", "Icon: none"); id(disp1).set_component_text_printf(component.c_str(), "%s", "\uFFFF"); // (E424) Don't show icon when off id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off) break; case 1: //CLIMATE_MODE_HEAT_COOL - ESP_LOGV("script.update_climate_icon", "Icon: autorenew"); id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE069"); // mdi:autorenew id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off) break; case 2: //CLIMATE_MODE_COOL - ESP_LOGV("script.update_climate_icon", "Icon: snowflake"); id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE716"); // mdi:snowflake id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off) break; case 3: //CLIMATE_MODE_HEAT - ESP_LOGV("script.update_climate_icon", "Icon: fire"); id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE237"); // mdi:fire id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off) break; case 4: //CLIMATE_MODE_FAN_ONLY - ESP_LOGV("script.update_climate_icon", "Icon: fan"); id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE20F"); // mdi:fan id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off) break; case 5: //CLIMATE_MODE_DRY - ESP_LOGV("script.update_climate_icon", "Icon: water-percent"); id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE58D"); // mdi:water-percent id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off) break; case 6: //CLIMATE_MODE_AUTO - ESP_LOGV("script.update_climate_icon", "Icon: calendar-sync"); id(disp1).set_component_text_printf(component.c_str(), "%s", "\uEE8D"); // mdi:calendar-sync id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off) break; } break; case 2: //CLIMATE_ACTION_COOLING - ESP_LOGV("script.update_climate_icon", "Icon: snowflake"); id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE716"); // mdi:snowflake id(disp1).set_component_font_color(component.c_str(), 1055); // blue break; case 3: //CLIMATE_ACTION_HEATING - ESP_LOGV("script.update_climate_icon", "Icon: fire"); id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE237"); // mdi:fire id(disp1).set_component_font_color(component.c_str(), 64164); // deep-orange break; case 4: //CLIMATE_ACTION_IDLE - ESP_LOGV("script.update_climate_icon", "Icon: thermometer"); id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE50E"); // mdi:thermometer id(disp1).set_component_font_color(component.c_str(), 35921); // grey (off) break; case 5: //CLIMATE_ACTION_DRYING - ESP_LOGV("script.update_climate_icon", "Icon: water-percent"); id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE58D"); // mdi:water-percent id(disp1).set_component_font_color(component.c_str(), 64704); // orange break; case 6: //CLIMATE_ACTION_FAN - ESP_LOGV("script.update_climate_icon", "Icon: fan"); id(disp1).set_component_text_printf(component.c_str(), "%s", "\uE20F"); // mdi:fan id(disp1).set_component_font_color(component.c_str(), 1530); // cyan break; } - ESP_LOGV("script.update_climate_icon", "Finished"); - id: set_component_color mode: queued @@ -2408,8 +2153,6 @@ script: background: int[] then: - lambda: |- - ESP_LOGV("script.set_component_color", "Starting"); - ESP_LOGV("script.set_component_color", "Component: %s", component.c_str()); int fg565 = -1; int bg565 = -1; @@ -2423,8 +2166,6 @@ script: else if (background.size() == 1) bg565 = background[0]; if (bg565 >= 0) id(disp1).set_component_background_color(component.c_str(), bg565); - ESP_LOGV("script.set_component_color", "Finished"); - - id: display_wrapped_text mode: queued parameters: @@ -2454,7 +2195,6 @@ script: startPos = endPos + 1; // Skip the space while (text[startPos] == ' ' and startPos < text.length()) { startPos++; } } - ESP_LOGV("script.display_wrapped_text", "text (new): %s", wrappedText.c_str()); id(disp1).set_component_text_printf(component.c_str(), "%s", wrappedText.c_str()); - id: display_embedded_temp @@ -2506,7 +2246,6 @@ script: 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; @@ -2518,7 +2257,6 @@ script: 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 ############################################################ diff --git a/nspanel_esphome_addon_climate_cool.yaml b/nspanel_esphome_addon_climate_cool.yaml index 085da7f..710479b 100644 --- a/nspanel_esphome_addon_climate_cool.yaml +++ b/nspanel_esphome_addon_climate_cool.yaml @@ -71,52 +71,33 @@ script: mode: restart then: - lambda: |- - ESP_LOGV("script.addon_climate_update_page_home", "Starting"); // Update home.climate_entity variable - ESP_LOGV("script.addon_climate_update_page_home", "Update home.climate_entity variable: %s", (id(is_embedded_thermostat)) ? "embedded_climate" : ""); id(entity_id) = (id(is_embedded_thermostat)) ? "embedded_climate" : ""; id(disp1).set_component_value("climate.embedded", (id(is_embedded_thermostat)) ? 1 : 0); // Update chips if (id(is_embedded_thermostat)) - { - ESP_LOGV("script.addon_climate_update_page_home", "Update chips"); - id(update_climate_icon).execute("home.icon_top_03", int(id(thermostat_embedded).action), int(id(thermostat_embedded).mode)); - } - ESP_LOGV("script.addon_climate_update_page_home", "Finished"); + id(update_climate_icon).execute("home.icon_top_03", int(id(thermostat_embedded).action), int(id(thermostat_embedded).mode)); - id: !extend addon_climate_service_call then: - lambda: |- - ESP_LOGV("script.addon_climate_service_call", "Starting"); id(is_addon_climate_visible) = true; id(disp1).set_component_value("climate.embedded", 1); auto call = id(thermostat_embedded).make_call(); if (key == "set_temperature") - { - call.set_target_temperature(stof(value) / 10); - } + call.set_target_temperature(stof(value) / 10); else if (key == "hvac_mode") - { - call.set_mode(value); - } + call.set_mode(value); call.perform(); - ESP_LOGV("script.addon_climate_service_call", "Finished"); - id: !extend addon_climate_set_climate then: - lambda: |- - ESP_LOGV("script.addon_climate_set_climate", "Starting"); - ESP_LOGV("script.addon_climate_set_climate", "embedded_climate: %i", (embedded_climate) ? 1 : 0); id(is_addon_climate_visible) = embedded_climate; - ESP_LOGV("script.addon_climate_set_climate", "Finished"); - id: !extend addon_climate_update_page_climate then: - lambda: |- - ESP_LOGV("script.addon_climate_update_page_climate", "Starting"); - ESP_LOGV("script.addon_climate_update_page_climate", "nextion_init: %i", (id(nextion_init)) ? 1 : 0); - ESP_LOGV("script.addon_climate_update_page_climate", "current_page: %s", id(current_page).state.c_str()); - ESP_LOGV("script.addon_climate_update_page_climate", "is_addon_climate_visible: %i", (id(is_addon_climate_visible)) ? 1 : 0); if (id(current_page).state == "climate" and id(is_addon_climate_visible)) { id(disp1).set_component_text_printf("page_label", id(addon_climate_friendly_name).c_str()); @@ -136,11 +117,9 @@ script: ); // Update target temp icon - ESP_LOGV("script.addon_climate_update_page_climate", "thermostat_embedded.action=%i", int(id(thermostat_embedded).action)); id(update_climate_icon).execute("climate.target_icon", int(id(thermostat_embedded).action), int(id(thermostat_embedded).mode)); // Update buttons bar - ESP_LOGV("script.addon_climate_update_page_climate", "Updating buttons bar"); // Hide not supported hotspots id(disp1).hide_component("button01"); id(disp1).hide_component("button02"); @@ -158,15 +137,11 @@ script: id(disp1).set_component_font_color("climate.button06_icon", 6339); id(disp1).set_component_font_color("climate.button07_icon", (id(thermostat_embedded).mode==climate::CLIMATE_MODE_OFF) ? 10597 : 35921); } - ESP_LOGV("script.addon_climate_update_page_climate", "Finished"); - id: !extend addon_climate_set_climate_friendly_name then: - lambda: |- - ESP_LOGV("script.addon_climate_set_climate_friendly_name", "Starting"); - ESP_LOGV("script.addon_climate_set_climate_friendly_name", "friendly_name: %s", friendly_name.c_str()); id(addon_climate_friendly_name) = friendly_name; - ESP_LOGV("script.addon_climate_set_climate_friendly_name", "Finished"); switch: ##### PHYSICAL SWITCH 0 (Dummy) - Used when relay is not set ##### diff --git a/nspanel_esphome_addon_climate_heat.yaml b/nspanel_esphome_addon_climate_heat.yaml index 8e8ec71..bfa5a59 100644 --- a/nspanel_esphome_addon_climate_heat.yaml +++ b/nspanel_esphome_addon_climate_heat.yaml @@ -71,52 +71,33 @@ script: mode: restart then: - lambda: |- - ESP_LOGV("script.addon_climate_update_page_home", "Starting"); // Update home.climate_entity variable - ESP_LOGV("script.addon_climate_update_page_home", "Update home.climate_entity variable: %s", (id(is_embedded_thermostat)) ? "embedded_climate" : ""); id(entity_id) = (id(is_embedded_thermostat)) ? "embedded_climate" : ""; id(disp1).set_component_value("climate.embedded", (id(is_embedded_thermostat)) ? 1 : 0); // Update chips if (id(is_embedded_thermostat)) - { - ESP_LOGV("script.addon_climate_update_page_home", "Update chips"); - id(update_climate_icon).execute("home.icon_top_03", int(id(thermostat_embedded).action), int(id(thermostat_embedded).mode)); - } - ESP_LOGV("script.addon_climate_update_page_home", "Finished"); + id(update_climate_icon).execute("home.icon_top_03", int(id(thermostat_embedded).action), int(id(thermostat_embedded).mode)); - id: !extend addon_climate_service_call then: - lambda: |- - ESP_LOGV("script.addon_climate_service_call", "Starting"); id(is_addon_climate_visible) = true; id(disp1).set_component_value("climate.embedded", 1); auto call = id(thermostat_embedded).make_call(); if (key == "set_temperature") - { - call.set_target_temperature(stof(value) / 10); - } + call.set_target_temperature(stof(value) / 10); else if (key == "hvac_mode") - { - call.set_mode(value); - } + call.set_mode(value); call.perform(); - ESP_LOGV("script.addon_climate_service_call", "Finished"); - id: !extend addon_climate_set_climate then: - lambda: |- - ESP_LOGV("script.addon_climate_set_climate", "Starting"); - ESP_LOGV("script.addon_climate_set_climate", "embedded_climate: %i", (embedded_climate) ? 1 : 0); id(is_addon_climate_visible) = embedded_climate; - ESP_LOGV("script.addon_climate_set_climate", "Finished"); - id: !extend addon_climate_update_page_climate then: - lambda: |- - ESP_LOGV("script.addon_climate_update_page_climate", "Starting"); - ESP_LOGV("script.addon_climate_update_page_climate", "nextion_init: %i", (id(nextion_init)) ? 1 : 0); - ESP_LOGV("script.addon_climate_update_page_climate", "current_page: %s", id(current_page).state.c_str()); - ESP_LOGV("script.addon_climate_update_page_climate", "is_addon_climate_visible: %i", (id(is_addon_climate_visible)) ? 1 : 0); if (id(current_page).state == "climate" and id(is_addon_climate_visible)) { id(disp1).set_component_text_printf("page_label", id(addon_climate_friendly_name).c_str()); @@ -136,11 +117,9 @@ script: ); // Update target temp icon - ESP_LOGV("script.addon_climate_update_page_climate", "thermostat_embedded.action=%i", int(id(thermostat_embedded).action)); id(update_climate_icon).execute("climate.target_icon", int(id(thermostat_embedded).action), int(id(thermostat_embedded).mode)); // Update buttons bar - ESP_LOGV("script.addon_climate_update_page_climate", "Updating buttons bar"); // Hide not supported hotspots id(disp1).hide_component("button01"); id(disp1).hide_component("button02"); @@ -158,15 +137,11 @@ script: id(disp1).set_component_font_color("climate.button06_icon", 6339); id(disp1).set_component_font_color("climate.button07_icon", (id(thermostat_embedded).mode==climate::CLIMATE_MODE_OFF) ? 10597 : 35921); } - ESP_LOGV("script.addon_climate_update_page_climate", "Finished"); - id: !extend addon_climate_set_climate_friendly_name then: - lambda: |- - ESP_LOGV("script.addon_climate_set_climate_friendly_name", "Starting"); - ESP_LOGV("script.addon_climate_set_climate_friendly_name", "friendly_name: %s", friendly_name.c_str()); id(addon_climate_friendly_name) = friendly_name; - ESP_LOGV("script.addon_climate_set_climate_friendly_name", "Finished"); switch: ##### PHYSICAL SWITCH 0 (Dummy) - Used when relay is not set #####