@@ -29,6 +29,7 @@ substitutions:
2929 cool_overrun : ${1 if TEMP_UNIT_IS_FAHRENHEIT else 0.5} # Temperature delta before disengaging cooling
3030 heat_deadband : ${1 if TEMP_UNIT_IS_FAHRENHEIT else 0.5} # Temperature delta before engaging heat
3131 heat_overrun : ${1 if TEMP_UNIT_IS_FAHRENHEIT else 0.5} # Temperature delta before disengaging heat
32+ climate_chip_visibility_default : " 0" # CLIMATE_CHIP_ACTIVE_ONLY
3233 TAG_ADDON_CLIMATE : nspanel.addon.climate
3334
3435esphome :
@@ -67,6 +68,12 @@ climate:
6768 ESP_LOGV("${TAG_ADDON_CLIMATE}", "Update page 'home'");
6869 page_home->execute();
6970
71+ globals :
72+ - id : climate_chip_visibility
73+ type : uint8_t
74+ restore_value : true
75+ initial_value : ' ${climate_chip_visibility_default}'
76+
7077switch :
7178 # #### PHYSICAL SWITCH 0 (Dummy) - Used when relay is not set #####
7279 - name : Relay 0 (dummy)
@@ -80,13 +87,29 @@ script:
8087 - id : !extend action_component_text
8188 then :
8289 - lambda : |-
83- if (page == "mem") {
84- if (component == "addon_climate_friendly_name") {
85- ESP_LOGV("${TAG_ADDON_CLIMATE}", "Set addon_climate_friendly_name:");
86- ESP_LOGV("${TAG_ADDON_CLIMATE}", " from: %s", addon_climate_friendly_name.c_str());
87- ESP_LOGV("${TAG_ADDON_CLIMATE}", " to: %s", txt.c_str());
88- addon_climate_friendly_name = txt;
90+ if (page != "mem") return;
91+ if (component == "addon_climate_friendly_name") {
92+ ESP_LOGV("${TAG_ADDON_CLIMATE}", "Set addon_climate_friendly_name:");
93+ ESP_LOGV("${TAG_ADDON_CLIMATE}", " from: %s", addon_climate_friendly_name.c_str());
94+ ESP_LOGV("${TAG_ADDON_CLIMATE}", " to: %s", txt.c_str());
95+ addon_climate_friendly_name = txt;
96+ return;
97+ }
98+
99+ - id : !extend action_component_val
100+ then :
101+ - lambda : |-
102+ if (page != "mem") return;
103+ if (component == "climate_chip_visibility") {
104+ const bool valid = (val >= static_cast<int>(nspanel_easy::CLIMATE_CHIP_ACTIVE_ONLY) &&
105+ val <= static_cast<int>(nspanel_easy::CLIMATE_CHIP_NEVER));
106+ id(climate_chip_visibility) = valid
107+ ? static_cast<uint8_t>(val)
108+ : static_cast<uint8_t>(nspanel_easy::CLIMATE_CHIP_ACTIVE_ONLY);
109+ if (!valid) {
110+ ESP_LOGW("${TAG_ADDON_CLIMATE}", "Invalid climate_chip_visibility: %d. Falling back to ACTIVE_ONLY", val);
89111 }
112+ ESP_LOGD("${TAG_ADDON_CLIMATE}", "climate_chip_visibility set to %" PRIu8, id(climate_chip_visibility));
90113 }
91114
92115 - id : !extend change_climate_state
@@ -373,22 +396,46 @@ script:
373396 ESP_LOGV("${TAG_ADDON_CLIMATE}", " component: %s", component.c_str());
374397 ESP_LOGV("${TAG_ADDON_CLIMATE}", " action: %d", action);
375398 ESP_LOGV("${TAG_ADDON_CLIMATE}", " mode: %d", mode);
399+ ESP_LOGV("${TAG_ADDON_CLIMATE}", " visibility: %" PRIu8, id(climate_chip_visibility));
400+
401+ // Determine visibility based on user preference and current climate state
402+ const auto visibility = static_cast<nspanel_easy::ClimateChipVisibility>(id(climate_chip_visibility));
403+ const bool is_active = (action == nspanel_easy::CLIMATE_ACTION_COOLING ||
404+ action == nspanel_easy::CLIMATE_ACTION_HEATING ||
405+ action == nspanel_easy::CLIMATE_ACTION_DRYING ||
406+ action == nspanel_easy::CLIMATE_ACTION_FAN);
407+
408+ bool visible = false;
409+ if (visibility == nspanel_easy::CLIMATE_CHIP_NEVER) {
410+ visible = false; // Never show
411+ } else if (visibility == nspanel_easy::CLIMATE_CHIP_ALWAYS) {
412+ visible = true; // Always show
413+ } else {
414+ visible = is_active; // Active only (default)
415+ }
416+
417+ ESP_LOGV("${TAG_ADDON_CLIMATE}", " visible: %s", YESNO(visible));
376418
377419 const char* icon = Icons::NONE;
378420 uint16_t color = Colors::BLACK;
379421
380- if (action == nspanel_easy::CLIMATE_ACTION_OFF) {
381- // Handle OFF action with different modes
382- if (mode <= nspanel_easy::CLIMATE_MODE_AUTO) {
383- icon = climate_off_mode_icons[mode].icon;
384- color = climate_off_mode_icons[mode].color;
422+ if (visible) {
423+ if (action == nspanel_easy::CLIMATE_ACTION_OFF) {
424+ // Handle OFF action — only reached when visibility != NEVER
425+ if (mode <= nspanel_easy::CLIMATE_MODE_AUTO) {
426+ icon = climate_off_mode_icons[mode].icon;
427+ color = climate_off_mode_icons[mode].color;
428+ }
429+ } else if (is_active) {
430+ // Handle actively running states (heating/cooling/drying/fan)
431+ icon = climate_action_icons[action].icon;
432+ color = climate_action_icons[action].color;
433+ } else if (action == nspanel_easy::CLIMATE_ACTION_IDLE) {
434+ // Handle idle — only reached when visibility == ALWAYS
435+ icon = climate_action_icons[nspanel_easy::CLIMATE_ACTION_IDLE].icon;
436+ color = climate_action_icons[nspanel_easy::CLIMATE_ACTION_IDLE].color;
385437 }
386- } else if (action >= nspanel_easy::CLIMATE_ACTION_COOLING
387- && action <= nspanel_easy::CLIMATE_ACTION_FAN) {
388- // Handle active action states
389- icon = climate_action_icons[action].icon;
390- color = climate_action_icons[action].color;
391- }
438+ } // #endif visible — icon/color remain NONE/BLACK when hidden
392439
393440 // Extract component information using helper function
394441 const NextionComponent comp = extractNextionComponent(component, page_names[current_page_id]);
0 commit comments