Skip to content

Commit 649d38f

Browse files
authored
Merge pull request #36 from edwardtfn/v9999.99.9
Climate chip visibility control & inverted Kelvin color temperature fix
2 parents 2c8c4bc + f7f7a82 commit 649d38f

28 files changed

+140
-52
lines changed

components/nspanel_easy/addon_climate.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ namespace nspanel_easy {
5151
CLIMATE_MODE_AUTO = 6 ///< Climate device is set to automatic mode
5252
};
5353

54+
/**
55+
* @enum ClimateChipVisibility
56+
* @brief Controls when the climate chip is shown on the home screen.
57+
*
58+
* Sent by the blueprint on boot via `action_component_val` with `page: "mem"`
59+
* and stored in the `climate_chip_visibility` global.
60+
*/
61+
enum ClimateChipVisibility : uint8_t {
62+
CLIMATE_CHIP_ACTIVE_ONLY = 0, ///< Show chip only when actively heating/cooling/drying/fan
63+
CLIMATE_CHIP_ALWAYS = 1, ///< Always show chip when a climate entity is configured
64+
CLIMATE_CHIP_NEVER = 2 ///< Never show the chip, regardless of climate state
65+
};
66+
5467
// =============================================================================
5568
// Climate Icon Lookup Tables
5669
// =============================================================================

esphome/nspanel_esphome_addon_climate_base.yaml

Lines changed: 64 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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

3435
esphome:
@@ -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+
7077
switch:
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]);

esphome/nspanel_esphome_version.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ substitutions:
1111
# Value is imported from versioning/version.yaml
1212
<<: !include ../versioning/version.yaml
1313
# Minimum required versions for compatibility
14-
min_blueprint_version: 4
15-
min_tft_version: 4
14+
min_blueprint_version: 5
15+
min_tft_version: 5
1616
min_esphome_compiler_version: 2026.1.0
1717
TAG_VERSIONING: nspanel.versioning
1818

hmi/dev/nspanel_CJK_eu_code/boot.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Variable (string) version
6060
Attributes
6161
ID : 6
6262
Scope : global
63-
Text : 4
63+
Text : 5
6464
Max. Text Size: 7
6565

6666
Variable (int32) log_len

hmi/dev/nspanel_CJK_eu_code/light.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -684,8 +684,8 @@ Slider tempslider
684684
Back. Picture ID : 21
685685
Slided Back. Picture ID: 21
686686
Position : 0
687-
Upper range limit : 6535
688-
Lower range limit : 2000
687+
Upper range limit : 2000
688+
Lower range limit : 6535
689689

690690
Events
691691
Touch Release Event

hmi/dev/nspanel_CJK_us_code/boot.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Variable (string) version
6060
Attributes
6161
ID : 6
6262
Scope : global
63-
Text : 4
63+
Text : 5
6464
Max. Text Size: 7
6565

6666
Variable (int32) log_len

hmi/dev/nspanel_CJK_us_code/light.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -684,8 +684,8 @@ Slider tempslider
684684
Back. Picture ID : 21
685685
Slided Back. Picture ID: 21
686686
Position : 0
687-
Upper range limit : 6535
688-
Lower range limit : 2000
687+
Upper range limit : 2000
688+
Lower range limit : 6535
689689

690690
Events
691691
Touch Release Event

hmi/dev/nspanel_CJK_us_land_code/boot.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Variable (string) version
6060
Attributes
6161
ID : 6
6262
Scope : global
63-
Text : 4
63+
Text : 5
6464
Max. Text Size: 7
6565

6666
Variable (int32) log_len

hmi/dev/nspanel_CJK_us_land_code/light.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -684,8 +684,8 @@ Slider tempslider
684684
Back. Picture ID : 21
685685
Slided Back. Picture ID: 21
686686
Position : 0
687-
Upper range limit : 6535
688-
Lower range limit : 2000
687+
Upper range limit : 2000
688+
Lower range limit : 6535
689689

690690
Events
691691
Touch Release Event

hmi/dev/nspanel_eu_code/boot.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Variable (string) version
6060
Attributes
6161
ID : 6
6262
Scope : global
63-
Text : 4
63+
Text : 5
6464
Max. Text Size: 7
6565

6666
Variable (int32) log_len

0 commit comments

Comments
 (0)