diff --git a/esphome/nspanel_esphome_addon_climate_base.yaml b/esphome/nspanel_esphome_addon_climate_base.yaml index ad55ec8bd..fb21ab5db 100644 --- a/esphome/nspanel_esphome_addon_climate_base.yaml +++ b/esphome/nspanel_esphome_addon_climate_base.yaml @@ -26,12 +26,6 @@ substitutions: heat_deadband: "0.5" # Temperature delta before engaging heat heat_overrun: "0.5" # Temperature delta before disengaging heat - ##### DO NOT CHANGE THIS ##### - addon_climate_cool: "false" - addon_climate_heat: "false" - addon_climate_dual: "false" - ############################## - esphome: platformio_options: build_flags: @@ -59,18 +53,39 @@ climate: - script.execute: page_climate - script.execute: page_home +display: + - id: !extend disp1 + on_touch: + then: + - lambda: |- + if ( + page_id == 1 // Page Home + and id(is_climate) + and ( + component_id == 4 // indr_temp + or component_id == 27 // indr_temp_icon + ) + ) { + detailed_entity->publish_state((id(is_embedded_thermostat)) ? "embedded_climate" : ""); + set_component_value->execute("climate", "embedded", id(is_embedded_thermostat) ? 1 : 0); + } + globals: - ##### Is embedded thermostat visible on climate page? ##### - - id: is_addon_climate_visible + - id: is_addon_climate_visible # Is embedded thermostat visible on climate page? type: bool restore_value: false initial_value: 'false' - ##### Embeded climate friendly name ##### - - id: addon_climate_friendly_name + + - id: addon_climate_friendly_name # Embeded climate friendly name type: std::string restore_value: false initial_value: '"${name} Thermostat"' + - id: is_embedded_thermostat # Is embedded thermostat set as main climate entity? + type: bool + restore_value: true + initial_value: 'false' + logger: logs: climate: INFO @@ -182,33 +197,57 @@ script: } float total_steps = (temp_max-temp_offset)/temp_step; set_climate->execute ( - temp_current, // current_temp - 0, // supported_features - ((${addon_climate_dual}) ? -999 : temp_target), // target_temp - ((${addon_climate_dual}) ? temp_target_high : -999), // target_temp_high - ((${addon_climate_dual}) ? temp_target_low : -999), // target_temp_low - int(round(temp_step*10)), // temp_step - int(round(total_steps)), // total_steps - int(round(temp_offset*10)), // temp_offset - "", // climate_icon - true // embedded_climate + temp_current, // current_temp + 0, // supported_features + #if defined(NSPANEL_HA_BLUEPRINT_ADDON_CLIMATE_DUAL) + -999, // target_temp + temp_target_high, // target_temp_high + temp_target_low, // target_temp_low + #else + temp_target, // target_temp + -999, // target_temp_high + -999, // target_temp_low + #endif + int(round(temp_step*10)), // temp_step + int(round(total_steps)), // total_steps + int(round(temp_offset*10)), // temp_offset + "", // climate_icon + true // embedded_climate ); update_climate_icon->execute("climate", "target_icon", int(thermostat_embedded->action), int(thermostat_embedded->mode)); set_component_visibility->execute("climate", "button01", false); - set_component_visibility->execute("climate", "button02", ${addon_climate_dual}); - set_component_visibility->execute("climate", "button03", ${addon_climate_dual} or ${addon_climate_heat}); // Heat - set_component_visibility->execute("climate", "button04", ${addon_climate_dual} or ${addon_climate_cool}); // Cool + #if defined(NSPANEL_HA_BLUEPRINT_ADDON_CLIMATE_DUAL) + set_component_visibility->execute("climate", "button02", true); + set_component_font_color->execute("climate", "button02", thermostat_embedded->mode == climate::CLIMATE_MODE_HEAT_COOL ? + 65535 : 48631); + #else + set_component_visibility->execute("climate", "button02", false); + set_component_font_color->execute("climate", "button02", thermostat_embedded->mode == climate::CLIMATE_MODE_HEAT_COOL ? + 65535 : 6339); + #endif + #if defined(NSPANEL_HA_BLUEPRINT_ADDON_CLIMATE_DUAL) or defined(NSPANEL_HA_BLUEPRINT_ADDON_CLIMATE_HEAT) + set_component_visibility->execute("climate", "button03", true); // Heat + set_component_font_color->execute("climate", "button03", thermostat_embedded->mode == climate::CLIMATE_MODE_HEAT ? + 64164 : 48631); + #else + set_component_visibility->execute("climate", "button03", false); // Heat + set_component_font_color->execute("climate", "button03", thermostat_embedded->mode == climate::CLIMATE_MODE_HEAT ? + 64164 : 6339); + #endif + #if defined(NSPANEL_HA_BLUEPRINT_ADDON_CLIMATE_DUAL) or defined(NSPANEL_HA_BLUEPRINT_ADDON_CLIMATE_COOL) + set_component_visibility->execute("climate", "button04", true); // Cool + set_component_font_color->execute("climate", "button04", thermostat_embedded->mode == climate::CLIMATE_MODE_COOL ? + 1055 : 48631); + #else + set_component_visibility->execute("climate", "button04", false); // Cool + set_component_font_color->execute("climate", "button04", thermostat_embedded->mode == climate::CLIMATE_MODE_COOL ? + 1055 : 6339); + #endif set_component_visibility->execute("climate", "button05", false); set_component_visibility->execute("climate", "button06", false); set_component_visibility->execute("climate", "button07", true); // Off set_component_font_color->execute("climate", "button01", 6339); - set_component_font_color->execute("climate", "button02", thermostat_embedded->mode == climate::CLIMATE_MODE_HEAT_COOL ? 65535 : - (${addon_climate_dual} ? 48631 : 6339)); - set_component_font_color->execute("climate", "button03", thermostat_embedded->mode == climate::CLIMATE_MODE_HEAT ? 64164 : - ((${addon_climate_dual} or ${addon_climate_heat}) ? 48631 : 6339)); - set_component_font_color->execute("climate", "button04", thermostat_embedded->mode == climate::CLIMATE_MODE_COOL ? 1055 : - ((${addon_climate_dual} or ${addon_climate_cool}) ? 48631 : 6339)); set_component_font_color->execute("climate", "button05", 6339); set_component_font_color->execute("climate", "button06", 6339); set_component_font_color->execute("climate", "button07", thermostat_embedded->mode == climate::CLIMATE_MODE_OFF ? 10597 : 35921); diff --git a/esphome/nspanel_esphome_addon_climate_cool.yaml b/esphome/nspanel_esphome_addon_climate_cool.yaml index 20e17e96e..cfaf2cd7b 100644 --- a/esphome/nspanel_esphome_addon_climate_cool.yaml +++ b/esphome/nspanel_esphome_addon_climate_cool.yaml @@ -11,10 +11,6 @@ substitutions: ### Local thermostat defaults ### temp_min: "15" - ##### DO NOT CHANGE THIS ##### - addon_climate_cool: "true" - ############################## - esphome: platformio_options: build_flags: diff --git a/esphome/nspanel_esphome_addon_climate_dual.yaml b/esphome/nspanel_esphome_addon_climate_dual.yaml index 2e37eb3e9..8951475e2 100644 --- a/esphome/nspanel_esphome_addon_climate_dual.yaml +++ b/esphome/nspanel_esphome_addon_climate_dual.yaml @@ -7,11 +7,6 @@ ##### ATTENTION: This will add climate elements to the core system and requires the core part. ##### ##################################################################################################### --- -substitutions: - ##### DO NOT CHANGE THIS ##### - addon_climate_dual: "true" - ############################## - esphome: platformio_options: build_flags: diff --git a/esphome/nspanel_esphome_addon_climate_heat.yaml b/esphome/nspanel_esphome_addon_climate_heat.yaml index 35b985544..8900ea6cc 100644 --- a/esphome/nspanel_esphome_addon_climate_heat.yaml +++ b/esphome/nspanel_esphome_addon_climate_heat.yaml @@ -11,10 +11,6 @@ substitutions: ### Local thermostat defaults ### temp_max: "25" - ##### DO NOT CHANGE THIS ##### - addon_climate_heat: "true" - ############################## - esphome: platformio_options: build_flags: diff --git a/esphome/nspanel_esphome_addon_upload_tft.yaml b/esphome/nspanel_esphome_addon_upload_tft.yaml index f432d31c6..d3bf37b64 100644 --- a/esphome/nspanel_esphome_addon_upload_tft.yaml +++ b/esphome/nspanel_esphome_addon_upload_tft.yaml @@ -160,48 +160,27 @@ script: - delay: 2s - logger.log: Starting TFT upload - lambda: |- + ESP_LOGI("script.nextion_upload", "Starting TFT upload"); id(tft_upload_result) = disp1->upload_tft(baud_rate, !disp1->is_setup()); - ESP_LOGD("script.nextion_upload", "TFT upload: %s", YESNO(id(tft_upload_result))); + ESP_LOGI("script.nextion_upload", "TFT upload: %s", YESNO(id(tft_upload_result))); - id: open_upload_dialog mode: restart then: - - logger.log: Showing upload dialog page - - script.execute: - id: goto_page - page: confirm + - lambda: |- + ESP_LOGD("script.open_upload_dialog", "Showing upload dialog page"); + goto_page->execute("confirm"); - wait_until: condition: - text_sensor.state: id: current_page state: confirm timeout: 2s - - if: - condition: - - text_sensor.state: - id: current_page - state: confirm - then: - - script.execute: - id: set_component_visibility - page: confirm - component: bclose - show: false - - script.execute: - id: set_component_visibility - page: confirm - component: bt_accept - show: false - - script.execute: - id: set_component_visibility - page: confirm - component: bt_clear - show: false - - script.execute: - id: set_component_text - page: confirm - component: title - text: Upload TFT + - lambda: |- + set_component_visibility->execute("confirm", "bclose", false); + set_component_visibility->execute("confirm", "bt_accept", false); + set_component_visibility->execute("confirm", "bt_clear", false); + set_component_text->execute("confirm", "title", "Upload TFT"); - id: report_upload_progress mode: restart @@ -209,26 +188,23 @@ script: message: string then: - lambda: |- - ESP_LOGD("script.report_upload_progress", message.c_str()); + ESP_LOGI("script.report_upload_progress", message.c_str()); + disp1->set_backlight_brightness(1); - if: condition: - lambda: return id(tft_is_valid); then: - - if: + - lambda: |- + if (current_page->state != "confirm") + open_upload_dialog->execute(); + - wait_until: condition: - - not: - - text_sensor.state: - id: current_page - state: confirm - then: - - script.execute: open_upload_dialog - - script.execute: - id: display_wrapped_text - page: confirm - component: body - text_to_display: !lambda return message.c_str(); - line_length_limit: 18 - - lambda: disp1->set_backlight_brightness(1); + - text_sensor.state: + id: current_page + state: confirm + timeout: 2s + - lambda: |- + display_wrapped_text->execute("confirm", "body", message.c_str(), 18); - id: select_tft_file_model mode: restart diff --git a/esphome/nspanel_esphome_core_base.yaml b/esphome/nspanel_esphome_core_base.yaml index d77d7926b..9187cf2ba 100644 --- a/esphome/nspanel_esphome_core_base.yaml +++ b/esphome/nspanel_esphome_core_base.yaml @@ -96,13 +96,6 @@ external_components: - nspanel_ha_blueprint refresh: 30s -globals: - ##### Add-on Climate ##### - - id: is_embedded_thermostat # Is embedded thermostat set as main climate entity? - type: bool - restore_value: true - initial_value: 'false' - logger: id: logger_std baud_rate: 0 @@ -274,14 +267,11 @@ script: component: string val: bool then: - - if: - condition: - - lambda: return component == "is_embedded_thermostat"; - then: - - script.execute: - id: boot_progress - step: ${BOOT_STEP_BASE} - step_name: Base + - lambda: |- + if (component == "is_embedded_thermostat") { + id(is_embedded_thermostat) = val; + boot_progress->execute(${BOOT_STEP_BASE}, "Base"); + } - id: set_var_int mode: queued diff --git a/esphome/nspanel_esphome_core_hw_buttons.yaml b/esphome/nspanel_esphome_core_hw_buttons.yaml index be8cf4be6..0f234ea9c 100644 --- a/esphome/nspanel_esphome_core_hw_buttons.yaml +++ b/esphome/nspanel_esphome_core_hw_buttons.yaml @@ -24,57 +24,35 @@ binary_sensor: pin: number: 14 inverted: true - on_press: &hardware_button_on_press + on_press: then: - - if: - condition: - - switch.is_on: hw_button_wakeup - then: - - if: - condition: - - text_sensor.state: - id: current_page - state: screensaver - then: - - script.execute: - id: goto_page - page: !lambda return wakeup_page_name->state.c_str(); - - script.execute: timer_dim - - script.execute: timer_sleep + - lambda: |- + ESP_LOGI("binary_sensor.left_button.on_press", "Left button - Pressed"); + - &hardware_button_on_press + lambda: |- + if (hw_button_wakeup->state) { + if (current_page->state == "screensaver") + goto_page->execute(wakeup_page_name->state.c_str()); + timer_dim->execute(); + timer_sleep->execute(); + } on_multi_click: - timing: &long_click-timing - ON for at least 0.8s invalid_cooldown: ${invalid_cooldown} then: - - logger.log: Left button - Long click - - script.execute: - id: ha_button - page: !lambda return current_page->state.c_str(); - component: hw_bt_left - command: long_click + - lambda: |- + ESP_LOGI("binary_sensor.left_button.on_multi_click", "Left button - Long click"); + ha_button->execute(current_page->state.c_str(), "hw_bt_left", "long_click"); - timing: &short_click-timing - ON for at most 0.8s invalid_cooldown: ${invalid_cooldown} then: - - logger.log: Left button - Short click - - if: - condition: - or: - - lambda: return id(relay1_local); - - and: - - lambda: return id(relay1_fallback); - - or: - - not: - - api.connected: - - not: - - wifi.connected: - then: - - switch.toggle: relay_1 - - script.execute: - id: ha_button - page: !lambda return current_page->state.c_str(); - component: hw_bt_left - command: short_click + - lambda: |- + ESP_LOGI("binary_sensor.left_button.on_multi_click", "Left button - Short click"); + if (id(relay1_local) or (id(relay1_fallback) and (!api_server->is_connected() or !wifi_component->is_connected()))) + relay_1->toggle(); + ha_button->execute(current_page->state.c_str(), "hw_bt_left", "short_click"); ##### RIGHT BUTTON BELOW DISPLAY TO TOGGLE RELAY ##### - name: Right Button @@ -83,39 +61,26 @@ binary_sensor: pin: number: 27 inverted: true - on_press: *hardware_button_on_press + on_press: + then: + - lambda: |- + ESP_LOGI("binary_sensor.right_button.on_press", "Right button - Pressed"); + - *hardware_button_on_press on_multi_click: - timing: *long_click-timing invalid_cooldown: ${invalid_cooldown} then: - - logger.log: Right button - Long click - - script.execute: - id: ha_button - page: !lambda return current_page->state.c_str(); - component: hw_bt_right - command: long_click + - lambda: |- + ESP_LOGI("binary_sensor.right_button.on_multi_click", "Right button - Long click"); + ha_button->execute(current_page->state.c_str(), "hw_bt_right", "long_click"); - timing: *short_click-timing invalid_cooldown: ${invalid_cooldown} then: - - logger.log: Right button - Short click - - if: - condition: - or: - - lambda: return id(relay2_local); - - and: - - lambda: return id(relay2_fallback); - - or: - - not: - - api.connected: - - not: - - wifi.connected: - then: - - switch.toggle: relay_2 - - script.execute: - id: ha_button - page: !lambda return current_page->state.c_str(); - component: hw_bt_right - command: short_click + - lambda: |- + ESP_LOGI("binary_sensor.right_button.on_multi_click", "Right button - Short click"); + if (id(relay2_local) or (id(relay2_fallback) and (!api_server->is_connected() or !wifi_component->is_connected()))) + relay_2->toggle(); + ha_button->execute(current_page->state.c_str(), "hw_bt_right", "short_click"); globals: - id: button_left_enabled diff --git a/esphome/nspanel_esphome_core_hw_buzzer.yaml b/esphome/nspanel_esphome_core_hw_buzzer.yaml index 2d2ac3d0b..00809b538 100644 --- a/esphome/nspanel_esphome_core_hw_buzzer.yaml +++ b/esphome/nspanel_esphome_core_hw_buzzer.yaml @@ -13,7 +13,6 @@ --- substitutions: BOOT_STEP_HW_BUZZER: '1UL << 4' - tone_touch_enable: 'true' tone_touch_press: "Touch:d=16,o=5,b=180:g" tone_touch_release: "Release:d=32,o=5,b=180:g,g" @@ -31,17 +30,9 @@ display: - id: !extend disp1 on_touch: then: - - if: - condition: - - lambda: return (${tone_touch_enable}); - then: - - if: - condition: - - lambda: return touch_event; - then: - - rtttl.play: ${tone_touch_press} - else: - - rtttl.play: ${tone_touch_release} + - lambda: |- + if (buzzer_touch_feedback->state) + buzzer->play(touch_event ? "${tone_touch_press}" : "${tone_touch_release}"); output: # Buzzer output @@ -72,13 +63,19 @@ script: - id: !extend page_boot then: - - if: - condition: - - switch.is_on: notification_sound - then: - - script.execute: - id: boot_log - category: Boot - log_message: Play boot sound - - rtttl.play: "two short:d=4,o=5,b=100:16e6,16e6" + - lambda: |- + if (notification_sound->state) { + boot_log->execute("Boot", "Play boot sound"); + buzzer->play("two short:d=4,o=5,b=100:16e6,16e6"); + } + +switch: + - id: buzzer_touch_feedback + name: Touch screen feedback sound + platform: template + entity_category: config + optimistic: true + restore_mode: RESTORE_DEFAULT_OFF + internal: false + icon: mdi:volume-high ... diff --git a/esphome/nspanel_esphome_core_page_climate.yaml b/esphome/nspanel_esphome_core_page_climate.yaml index e8e7d4af2..53155fba8 100644 --- a/esphome/nspanel_esphome_core_page_climate.yaml +++ b/esphome/nspanel_esphome_core_page_climate.yaml @@ -58,17 +58,14 @@ display: on_touch: then: - lambda: |- - if ( + if ( page_id == 1 // Page Home and id(is_climate) - and - ( - component_id == 4 // indr_temp - or component_id == 27 // indr_temp_icon - ) + and ( + component_id == 4 // indr_temp + or component_id == 27 // indr_temp_icon + ) ) { - detailed_entity->publish_state((id(is_embedded_thermostat)) ? "embedded_climate" : ""); - set_component_value->execute("climate", "embedded", id(is_embedded_thermostat) ? 1 : 0); goto_page->execute("climate"); } diff --git a/esphome/nspanel_esphome_core_page_confirm.yaml b/esphome/nspanel_esphome_core_page_confirm.yaml index 002d88791..466797147 100644 --- a/esphome/nspanel_esphome_core_page_confirm.yaml +++ b/esphome/nspanel_esphome_core_page_confirm.yaml @@ -28,7 +28,8 @@ script: - id: !extend page_changed then: - lambda: |- - if (current_page->state == "confirm") page_confirm->execute(); + if (current_page->state == "confirm") + page_confirm->execute(); - id: page_confirm mode: restart diff --git a/esphome/nspanel_esphome_core_page_notification.yaml b/esphome/nspanel_esphome_core_page_notification.yaml index 6b46416f3..a184587e7 100644 --- a/esphome/nspanel_esphome_core_page_notification.yaml +++ b/esphome/nspanel_esphome_core_page_notification.yaml @@ -145,8 +145,7 @@ script: - script.stop: page_notification switch: - ##### Notification unread ##### - - name: Notification unread + - name: Notification unread # Notification unread platform: template id: notification_unread entity_category: config @@ -173,8 +172,7 @@ switch: component: notification_unread action: turn_off - ##### Notification sound ##### - - name: Notification sound + - name: Notification sound # Notification sound platform: template id: notification_sound entity_category: config