From 217b456e75a84db7dce98cbd6a155f20f58707b4 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Sun, 14 Jan 2024 23:09:30 +0100 Subject: [PATCH] Fix crash when internal temp sensor was not defined This was preventing the rendering of other elements on Home page until those elements gets an update on it's statuses. This change also add a input for default icon fallback colors for `on` and `off` states. Solves #1624 --- docs/error_compiling.md | 31 +++++++ nspanel_blueprint.yaml | 173 ++++++++++++++++++++++------------------ 2 files changed, 127 insertions(+), 77 deletions(-) create mode 100644 docs/error_compiling.md diff --git a/docs/error_compiling.md b/docs/error_compiling.md new file mode 100644 index 0000000..c45728d --- /dev/null +++ b/docs/error_compiling.md @@ -0,0 +1,31 @@ +# Compiling Errors Guide +It seems the issue is due to insufficient resources on your server for compiling. +Here are two suggestions: + +## Free Up Server Resources +1. Add the following to your device's YAML to reduce resource usage (this may slow down the compilation process): + + ```yaml + # Limit the amount of resources used for compiling + esphome: + compile_process_limit: 1 + ``` + + > [!TIP] + > Place this in a dedicated customization section in your YAML for easier maintenance, + similar to [this example](https://github.com/Blackymas/NSPanel_HA_Blueprint/blob/main/docs/customization.md#instructions). + +2. Restart your host system, not just Home Assistant. Use the advanced options to **Reboot system**, which also restarts add-ons and can free up memory. + +3. Temporarily stop non-essential add-ons in Home Assistant, especially resource-intensive ones like Studio Code Server. + +4. Clean up build files (on the ESPHome Dashboard, click the 3-dot meny related to your device and then "**Clean Build Files**"). + +5. Try compiling again. + +6. After completion, restart your host system to reactivate the stopped add-ons. + +## Compile Using Your Computer +1. Install ESPHome on your computer (Windows, Mac, or Linux) following this guide: [Installing ESPHome Manually](https://esphome.io/guides/installing_esphome.html). + +2. With ESPHome installed locally, you can use the ESPHome Dashboard or the [ESPHome Command Line Interface](https://esphome.io/guides/cli.html#command-line-interface) for compilation. diff --git a/nspanel_blueprint.yaml b/nspanel_blueprint.yaml index 5f02b2f..ba007a7 100644 --- a/nspanel_blueprint.yaml +++ b/nspanel_blueprint.yaml @@ -37,7 +37,7 @@ blueprint: 🎉 Roadmap can be found here: [Roadmap](https://github.com/Blackymas/NSPanel_HA_Blueprint/labels/roadmap) - â„šī¸ Version: v4.2.1 + â„šī¸ Version: v4.2.2dev source_url: https://github.com/Blackymas/NSPanel_HA_Blueprint/blob/main/nspanel_blueprint.yaml domain: automation @@ -416,7 +416,7 @@ blueprint: *HOME page* *Icon color which should be displayed* - default: [128, 128, 128] # 33808 Grey light + default: [] selector: *color_selector chip02: name: Chip 02 - ENTITY (Optional) @@ -449,7 +449,7 @@ blueprint: *HOME page* *Icon color which should be displayed* - default: [128, 128, 128] # 33808 Grey light + default: [] selector: *color_selector chip03: name: Chip 03 - ENTITY (Optional) @@ -482,7 +482,7 @@ blueprint: *HOME page* *Icon color which should be displayed* - default: [128, 128, 128] # 33808 Grey light + default: [] selector: *color_selector chip04: name: Chip 04 - ENTITY (Optional) @@ -515,7 +515,7 @@ blueprint: *HOME page* *Icon color which should be displayed* - default: [128, 128, 128] # 33808 Grey light + default: [] selector: *color_selector chip05: name: Chip 05 - ENTITY (Optional) @@ -548,7 +548,7 @@ blueprint: *HOME page* *Icon color which should be displayed* - default: [128, 128, 128] # 33808 Grey light + default: [] selector: *color_selector chip06: name: Chip 06 - ENTITY (Optional) @@ -581,7 +581,7 @@ blueprint: *HOME page* *Icon color which should be displayed* - default: [128, 128, 128] # 33808 Grey light + default: [] selector: *color_selector chip07: name: Chip 07 - ENTITY (Optional) @@ -614,7 +614,7 @@ blueprint: *HOME page* *Icon color which should be displayed* - default: [128, 128, 128] # 33808 Grey light + default: [] selector: *color_selector ## Custom buttons - Page Home ##### PLACEHOLDER ###################################################################### @@ -3759,7 +3759,7 @@ blueprint: *HOME page* *Icon color which should be displayed (default color is set)* - default: [128, 128, 128] # 33808 Grey light + default: [] selector: *color_selector ##### Relay 2 Chip ###### relay02_icon: @@ -3776,7 +3776,7 @@ blueprint: *HOME page* *Icon color which should be displayed (default color is set)* - default: [128, 128, 128] # 33808 Grey light + default: [] selector: *color_selector ##### Time label ###### time_label_color: @@ -3815,6 +3815,32 @@ blueprint: default: [64, 64, 64] selector: *color_selector + ##### Icons colors ##### + ##### PLACEHOLDER ###################################################################### + placeholder21: + name: ' ' + description: '# ✅ ICONS COLORS ✅' + default: ' ' + selector: *placeholder-selector + ##### PLACEHOLDER ###################################################################### + ##### TFT Folder ##### + icon_color_fallback_on: + name: Icon fallback color when state is "**ON**" + description: > + *General* + + *Which default color should be used for icons when the state is **ON** while a custom color is not selected and the domain does not provides a state-based color?* + default: [255, 255, 255] + selector: *color_selector + icon_color_fallback_off: + name: Icon fallback color when state is "**OFF**" + description: > + *General* + + *Which default color should be used fo icons when the state is **OFF**?* + default: [92, 92, 92] + selector: *color_selector + ##### Advanced settings ##### ##### PLACEHOLDER ###################################################################### placeholder19: @@ -3928,7 +3954,7 @@ trigger_variables: variables: ##### GENERAL ##### - blueprint_version: '4.2.1' + blueprint_version: '4.2.2dev' date_format_temp: !input 'date_format' # Avoid breaking change for existing users with legacy type format date_format: > @@ -3960,8 +3986,8 @@ variables: cyan: [0, 188, 212] deep_orange: [255, 87, 34] amber: [255, 193, 7] - "on": [255, 255, 255] - "off": [17, 34, 17] + "on": !input icon_color_fallback_on + "off": !input icon_color_fallback_off disabled: [189, 189, 189] unknown: [3, 6, 3] unavailable: [3, 6, 3] @@ -7297,19 +7323,18 @@ action: supported_features: '{{ state_attr(entity_id, "supported_features") | default(0) if entity_id_is_valid else 0 }}' icon: > {% set icon_domain = nextion.icon.domain[entity_domain] | default(all_icons.unknown) if entity_domain else all_icons.unknown %} - {% if not entity_id_is_valid %}{{ all_icons.blank }} - {% elif overlap is defined and overlap.icon is defined and overlap.icon is string and overlap.icon | length > 0 %} + {% if overlap is defined and overlap.icon is defined and overlap.icon is string and overlap.icon | length > 0 %} {{ all_icons[overlap.icon.split(":")[1]] | default(icon_domain) if overlap.icon.split(":") | count == 2 else overlap.icon }} {% elif entity_domain == "climate" %} {% set entity_hvac_action = state_attr(entity_id, "hvac_action") | default(None) %} - {% set entity_climate_action = (entity_hvac_action if entity_hvac_action not in ["unavailable", "unknown", "", None] else entity_state) %} - {% if "off" in entity_climate_action %}{{ all_icons.blank }} + {% set entity_climate_action = (entity_hvac_action if entity_hvac_action not in enum.states.unknown else entity_state) %} + {% if "off" in entity_climate_action %}{{ all_icons.thermostat }} {% elif "heating" in entity_climate_action or "heat" in entity_climate_action %}{{ all_icons["thermometer-lines"] }} {% elif "cooling" in entity_climate_action or "cool" in entity_climate_action %}{{ all_icons.snowflake }} {% elif "drying" in entity_climate_action or "dry" in entity_climate_action %}{{ all_icons["water-percent"] }} {% elif "fan" in entity_climate_action or "fan_only" in entity_climate_action %}{{ all_icons.fan }} {% elif "heat_cool" in entity_climate_action %}{{ all_icons.autorenew }} - {% elif "auto" in entity_climate_action %}{{ all_icons.blank }} + {% elif "auto" in entity_climate_action %}{{ all_icons["calendar-sync"] }} {% elif "idle" in entity_climate_action %}{{ all_icons.thermometer }} {% else %}{{ icon_domain }} {% endif %} @@ -7341,7 +7366,7 @@ action: {% endif %} {% elif entity_domain == "climate" %} {% set entity_hvac_action = state_attr(entity_id, "hvac_action") | default(None) %} - {% set entity_climate_action = (entity_hvac_action if entity_hvac_action not in ["unavailable", "unknown", "", None] else entity_state) %} + {% set entity_climate_action = (entity_hvac_action if entity_hvac_action not in enum.states.unknown else entity_state) %} {% if "off" in entity_climate_action %}{{ nextion.color.off }} {% elif "heating" in entity_climate_action or "heat" in entity_climate_action %}{{ nextion.color.deep_orange}} {% elif "cooling" in entity_climate_action or "cool" in entity_climate_action %}{{ nextion.color.blue }} @@ -7488,8 +7513,8 @@ action: if bt_notific.icon is string else all_icons["email"]) }} - notification_icon_color_normal: '{{ [ bt_notific.color_normal ] if is_number(bt_notific.color_normal) else bt_notific.color_normal }}' - notification_icon_color_unread: '{{ [ bt_notific.color_unread ] if is_number(bt_notific.color_unread) else bt_notific.color_unread }}' + notification_icon_color_normal: '{{ bt_notific.color_normal }}' + notification_icon_color_unread: '{{ bt_notific.color_unread }}' qrcode: '{{ bt_qrcode.enabled }}' qrcode_icon: > {{ @@ -7497,7 +7522,7 @@ action: if bt_qrcode.icon is string else all_icons["format-list-bulleted-square"]) }} - qrcode_icon_color: '{{ [ bt_qrcode.color_rgb ] if is_number(bt_qrcode.color_rgb) else bt_qrcode.color_rgb }}' + qrcode_icon_color: '{{ bt_qrcode.color_rgb }}' entities_pages: '{{ bt_entities.enabled }}' entities_pages_icon: > {{ @@ -7505,7 +7530,7 @@ action: if bt_entities.icon is string else all_icons["format-list-bulleted-square"]) }} - entities_pages_icon_color: '{{ [ bt_entities.color_rgb ] if is_number(bt_entities.color_rgb) else bt_entities.color_rgb }}' + entities_pages_icon_color: '{{ bt_entities.color_rgb }}' continue_on_error: true - &delay-default delay: @@ -7579,13 +7604,18 @@ action: ) }} relay1_icon_color: > - {{ + {% set temp_color = hardware.relays.relay1.icon_color_rgb - if is_number(hardware.relays.relay1.icon_color_rgb) - else - ((hardware.relays.relay1.icon_color_rgb[0] //(2**3)) *(2**11)) + - ((hardware.relays.relay1.icon_color_rgb[1] //(2**2)) *(2**5)) + - ((hardware.relays.relay1.icon_color_rgb[2] //(2**3))) + if + hardware.relays.relay1.icon_color_rgb is defined and + hardware.relays.relay1.icon_color_rgb is sequence and + hardware.relays.relay1.icon_color_rgb | count == 3 + else nextion.color.on + %} + {{ + ((temp_color[0] //(2**3)) *(2**11)) + + ((temp_color[1] //(2**2)) *(2**5)) + + ((temp_color[2] //(2**3))) }} relay1_fallback: '{{ hardware.relays.relay1.fallback }}' relay2_local_control: '{{ hardware.buttons.right.entity == relay02_entity }}' @@ -7601,13 +7631,18 @@ action: ) }} relay2_icon_color: > - {{ + {% set temp_color = hardware.relays.relay2.icon_color_rgb - if is_number(hardware.relays.relay2.icon_color_rgb) - else - ((hardware.relays.relay2.icon_color_rgb[0] //(2**3)) *(2**11)) + - ((hardware.relays.relay2.icon_color_rgb[1] //(2**2)) *(2**5)) + - ((hardware.relays.relay2.icon_color_rgb[2] //(2**3))) + if + hardware.relays.relay2.icon_color_rgb is defined and + hardware.relays.relay2.icon_color_rgb is sequence and + hardware.relays.relay2.icon_color_rgb | count == 3 + else nextion.color.on + %} + {{ + ((temp_color[0] //(2**3)) *(2**11)) + + ((temp_color[1] //(2**2)) *(2**5)) + + ((temp_color[2] //(2**3))) }} relay2_fallback: '{{ hardware.relays.relay2.fallback }}' continue_on_error: true @@ -7754,7 +7789,7 @@ action: - service: '{{ nextion.command.set_component_color }}' data: component: home.outdoor_temp - foreground: '{{ [ outdoor_temp_color_rgb ] if is_number(outdoor_temp_color_rgb) else outdoor_temp_color_rgb }}' + foreground: '{{ outdoor_temp_color_rgb }}' continue_on_error: true ### LABEL Outdoor Temp Font ### - *delay-default @@ -7774,51 +7809,35 @@ action: then: ##### NSPanel Indoor Temp ##### - variables: + temperature_sensor: > + {{ + indoor_temperature_sensor + if + (not embedded_indoor_temperature) and + indoor_temperature_sensor is string and + indoor_temperature_sensor is match "sensor." + else + nspaneltemp + }} indoor_temp: - state: > - {{ - states(indoor_temperature_sensor, rounded=true) | default("unavailable") - if - (not embedded_indoor_temperature) and - indoor_temperature_sensor is string and - indoor_temperature_sensor is match "sensor." - else - states(nspaneltemp, rounded=true) - }} - indoor_temperature_sensor_uom: '{{ state_attr(indoor_temperature_sensor, "unit_of_measurement") }}' + state: '{{ states(temperature_sensor, rounded=true) | default("unavailable") }}' + sensor_uom: '{{ state_attr(temperature_sensor, "unit_of_measurement") }}' nspaneltemp_uom: '{{ state_attr(nspaneltemp, "unit_of_measurement") }}' - units: > - {{ - indoor_temperature_sensor_uom - if - (not embedded_indoor_temperature) and - indoor_temperature_sensor is string and - indoor_temperature_sensor is match "sensor." and - indoor_temperature_sensor_uom is string and - indoor_temperature_sensor_uom | length > 0 - else - ( - nspaneltemp_uom - if - nspaneltemp_uom is string and - nspaneltemp_uom | length > 0 - else temperature_units - ) - }} + units: '{{ sensor_uom if sensor_uom is string and sensor_uom | length > 0 else temperature_units }}' icon: icon: !input 'home_indoor_temp_icon' color_rgb: !input 'home_indoor_temp_icon_color' label: color_rgb: !input 'home_indoor_temp_label_color' - - if: '{{ is_number(indoor_temp.state) or embedded_indoor_temperature }}' + - if: '{{ is_number(indoor_temp.state) }}' then: ### ICON Indoor Temp Font Color ### - *delay-default - service: '{{ nextion.command.set_component_color }}' data: component: home.indoortempicon - foreground: '{{ [ indoor_temp.icon.color_rgb ] if is_number(indoor_temp.icon.color_rgb) else indoor_temp.icon.color_rgb }}' + foreground: '{{ indoor_temp.icon.color_rgb }}' continue_on_error: true ### ICON Indoor Temp Font ### - *delay-default @@ -7842,7 +7861,7 @@ action: - service: '{{ nextion.command.set_component_color }}' data: component: home.current_temp - foreground: '{{ [ indoor_temp.label.color_rgb ] if is_number(indoor_temp.label.color_rgb) else indoor_temp.label.color_rgb }}' + foreground: '{{ indoor_temp.label.color_rgb }}' continue_on_error: true - if: '{{ not embedded_indoor_temperature }}' then: @@ -7862,14 +7881,14 @@ action: - variables: left_button_state: '{{ states(hardware.buttons.left.entity) | default("unavailable") if hardware.buttons.left.entity is string else "unavailable" }}' right_button_state: '{{ states(hardware.buttons.right.entity) | default("unavailable") if hardware.buttons.right.entity is string else "unavailable" }}' - - if: '{{ left_button_state not in ["unavailable", "unknown", "", None] }}' + - if: '{{ left_button_state not in enum.states.unknown }}' then: - *delay-default - service: '{{ nextion.command.printf }}' data: cmd: home.left_bt_pic.val={{ 1 if left_button_state in enum.states.on else 0 }} continue_on_error: true - - if: '{{ right_button_state not in ["unavailable", "unknown", "", None] }}' + - if: '{{ right_button_state not in enum.states.unknown }}' then: - *delay-default - service: '{{ nextion.command.printf }}' @@ -7963,7 +7982,7 @@ action: then: - variables: entity_hvac_action: '{{ state_attr(entity_id, "hvac_action") | default(None) }}' - entity_climate_action: '{{ (entity_hvac_action if entity_hvac_action not in ["unavailable", "unknown", "", None] else entity_state) }}' + entity_climate_action: '{{ (entity_hvac_action if entity_hvac_action not in enum.states.unknown else entity_state) }}' - if: '{{ entity_climate_action in ["off", "heating", "heat", "cooling", "cool", "dry", "drying", "fan", "fan_only", "heat_cool", "auto", "idle"] }}' then: ### ICON Font Color ### @@ -8682,7 +8701,7 @@ action: ##### COVER Battery ICON Yes / NO ##### - variables: battery_level: > - {% if state_attr(cover_entity, "battery") | default("unavailable") not in ["unavailable", "unknown", "", None] %} + {% if state_attr(cover_entity, "battery") | default("unavailable") not in enum.states.unknown %} {{ state_attr(cover_entity, "battery") | default("unavailable") }} {% elif expand(device_entities(device_id(cover_entity))) | selectattr("attributes.device_class", "defined") @@ -9010,7 +9029,7 @@ action: climate_state: '{{ states(climate_entity) | default("unavailable") if climate_entity is string else "unavailable" }}' hvac_action: '{{ state_attr(climate_entity, "hvac_action") }}' hvac_modes: '{{ state_attr(climate_entity, "hvac_modes") }}' - climate_action: '{{ hvac_action if hvac_action not in ["unavailable", "unknown", "", None] else climate_state }}' + climate_action: '{{ hvac_action if hvac_action not in enum.states.unknown else climate_state }}' climate_icon: > {% if "off" in climate_action %}{{ all_icons.blank }} {% elif "heating" in climate_action or "heat" in climate_action %}{{ all_icons["thermometer-lines"] }} @@ -10241,7 +10260,7 @@ action: - current_state_entity30 - current_state_entity31 - current_state_entity32 - - '{{ trigger.to_state.state not in ["unavailable", "unknown", "", None] }}' + - '{{ trigger.to_state.state not in enum.states.unknown }}' - condition: or conditions: - '{{ page.current in page.buttonpages }}' @@ -10366,7 +10385,7 @@ action: sequence: - *update-home_page-climate_chip - if: - - '{{ trigger.event.data.new_state.state not in ["unavailable", "unknown", "", None] }}' + - '{{ trigger.event.data.new_state.state not in enum.states.unknown }}' - '{{ page.current == page.climate }}' - '{{ trigger.event.data.entity_id == states(detailed_entity) }}' then: @@ -10482,7 +10501,7 @@ action: id: - left_button_state - right_button_state - - '{{ trigger.to_state.state not in ["unavailable", "unknown", "", None] }}' + - '{{ trigger.to_state.state not in enum.states.unknown }}' sequence: ##### SET hardware Button PIC on Home Page #### - service: '{{ nextion.command.printf }}' @@ -10515,7 +10534,7 @@ action: conditions: - condition: trigger id: weather_state_change - - '{{ page.current == page.home and trigger.event.data.new_state.state not in ["unavailable", "unknown", "", None] }}' + - '{{ page.current == page.home and trigger.event.data.new_state.state not in enum.states.unknown }}' sequence: - *refresh-page_home-outdoor_temp - *delay-default