From 2255ce5eca6aa594af96f48d3c4cdded8fb793a5 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Wed, 20 Nov 2024 18:38:13 +0100 Subject: [PATCH] yamllint --- .../nspanel_esphome_addon_climate_base.yaml | 53 ++++++++++++------- ...nspanel_esphome_core_hw_display_light.yaml | 6 ++- .../nspanel_esphome_core_hw_temperature.yaml | 16 ++++-- .../nspanel_esphome_core_page_buttons.yaml | 10 ++-- .../nspanel_esphome_core_page_climate.yaml | 12 ++--- 5 files changed, 62 insertions(+), 35 deletions(-) diff --git a/esphome/nspanel_esphome_addon_climate_base.yaml b/esphome/nspanel_esphome_addon_climate_base.yaml index 506dfc19e..e945c10ed 100644 --- a/esphome/nspanel_esphome_addon_climate_base.yaml +++ b/esphome/nspanel_esphome_addon_climate_base.yaml @@ -41,7 +41,8 @@ climate: min_temperature: ${temp_min} ${temp_units} max_temperature: ${temp_max} ${temp_units} temperature_step: - target_temperature: 0.5 # This is hard coded for now as ESPHome isn't supporting a substitution here. In contact with support. + # This is hard coded for now as ESPHome isn't supporting a substitution here. In contact with support. + target_temperature: 0.5 current_temperature: 0.1 idle_action: - switch.turn_off: relay_${heater_relay} @@ -145,7 +146,9 @@ script: #error "Invalid settings for add-on Climate. More than one option selected: Cool + Dual." #elif defined(NSPANEL_HA_BLUEPRINT_ADDON_CLIMATE_HEAT) && defined(NSPANEL_HA_BLUEPRINT_ADDON_CLIMATE_DUAL) #error "Invalid settings for add-on Climate. More than one option selected: Heat + Dual." - #elif !defined(NSPANEL_HA_BLUEPRINT_ADDON_CLIMATE_COOL) && !defined(NSPANEL_HA_BLUEPRINT_ADDON_CLIMATE_HEAT) && !defined(NSPANEL_HA_BLUEPRINT_ADDON_CLIMATE_DUAL) + #elif !defined(NSPANEL_HA_BLUEPRINT_ADDON_CLIMATE_COOL) && \ + !defined(NSPANEL_HA_BLUEPRINT_ADDON_CLIMATE_HEAT) && \ + !defined(NSPANEL_HA_BLUEPRINT_ADDON_CLIMATE_DUAL) #error "Invalid settings for add-on Climate. No option selected between Cool, Heat or Dual." #endif const uint cooler_relay = ${cooler_relay}; @@ -230,34 +233,42 @@ script: true // embedded_climate ); - update_climate_icon->execute(get_icon("climate", "target_icon"), int(thermostat_embedded->action), int(thermostat_embedded->mode)); + update_climate_icon->execute(get_icon("climate", "target_icon"), + int(thermostat_embedded->action), + int(thermostat_embedded->mode)); set_component_visibility->execute("climate", "button01", false); #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); + 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); + 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); + 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); + 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); + 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); + 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); @@ -265,14 +276,18 @@ script: set_component_font_color->execute("climate", "button01", 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); + set_component_font_color->execute("climate", "button07", + thermostat_embedded->mode == climate::CLIMATE_MODE_OFF ? + 10597 : 35921); } - id: !extend page_home then: - lambda: |- if (id(is_embedded_thermostat)) - update_climate_icon->execute(get_icon("home", "chip_climate"), int(thermostat_embedded->action), int(thermostat_embedded->mode)); + update_climate_icon->execute(get_icon("home", "chip_climate"), + int(thermostat_embedded->action), + int(thermostat_embedded->mode)); - id: !extend set_climate then: @@ -308,10 +323,10 @@ script: - lambda: |- std::string icon; int16_t icon_color = -1; - 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 + switch (action) { case 0: //CLIMATE_ACTION_OFF icon_color = 35921; // grey (off) - 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 + switch (mode) { case 0: //CLIMATE_MODE_OFF icon = "\uFFFF"; // (E424) Don't show icon when off break; diff --git a/esphome/nspanel_esphome_core_hw_display_light.yaml b/esphome/nspanel_esphome_core_hw_display_light.yaml index 0d2cd5b06..9adc50c3f 100644 --- a/esphome/nspanel_esphome_core_hw_display_light.yaml +++ b/esphome/nspanel_esphome_core_hw_display_light.yaml @@ -70,7 +70,11 @@ script: - if: condition: - lambda: |- - return (brightness != int(round(display_light->current_values.is_on() ? (display_light->current_values.get_brightness() * 100.0f) : 0.0))); + return (brightness != int( + round(display_light->current_values.is_on() ? + (display_light->current_values.get_brightness() * 100.0f) + : 0.0)) + ); then: - if: condition: diff --git a/esphome/nspanel_esphome_core_hw_temperature.yaml b/esphome/nspanel_esphome_core_hw_temperature.yaml index a57011e43..3d5930f25 100644 --- a/esphome/nspanel_esphome_core_hw_temperature.yaml +++ b/esphome/nspanel_esphome_core_hw_temperature.yaml @@ -23,7 +23,10 @@ esphome: then: - lambda: |- std::string temp_units = "${temp_units}"; - id(temperature_is_celsius) = not (temp_units == "°F" || temp_units == "F" || temp_units == "°f" || temp_units == "f"); + id(temperature_is_celsius) = not (temp_units == "°F" || + temp_units == "F" || + temp_units == "°f" || + temp_units == "f"); globals: ##### Is embedded sensor used for indoor temperature? ##### @@ -75,12 +78,17 @@ script: static std::string last_indr_temp; if (id(embedded_indoor_temp) or !wifi_component->is_connected() or !api_server->is_connected()) { const std::string temp_units = "${temp_units}"; - const bool temp_unit_fahrenheit = (temp_units == "°F" || temp_units == "F" || temp_units == "°f" || temp_units == "f"); + const bool temp_unit_fahrenheit = (temp_units == "°F" || + temp_units == "F" || + temp_units == "°f" || + temp_units == "f"); char buffer[15]; // Buffer for formatted temperature string if (temp_unit_fahrenheit) { - snprintf(buffer, sizeof(buffer), "%.0f${temp_units}", (id(temp_nspanel).state * 9.0 / 5.0) + 32); // Fahrenheit with no decimal + snprintf(buffer, sizeof(buffer), "%.0f${temp_units}", + (id(temp_nspanel).state * 9.0 / 5.0) + 32); // Fahrenheit with no decimal } else { - snprintf(buffer, sizeof(buffer), "%.1f${temp_units}", id(temp_nspanel).state); // Celsius with one decimal + snprintf(buffer, sizeof(buffer), "%.1f${temp_units}", + id(temp_nspanel).state); // Celsius with one decimal } std::string new_indr_temp = adjustDecimalSeparator(buffer, id(mui_decimal_separator)); if (new_indr_temp != last_indr_temp) { diff --git a/esphome/nspanel_esphome_core_page_buttons.yaml b/esphome/nspanel_esphome_core_page_buttons.yaml index ab488ae61..97d02159b 100644 --- a/esphome/nspanel_esphome_core_page_buttons.yaml +++ b/esphome/nspanel_esphome_core_page_buttons.yaml @@ -19,14 +19,15 @@ substitutions: api: id: !extend api_server actions: - # Dynamically configures button properties on a specified page, enhancing UI interactivity by allowing updates to button appearance and behavior based on given parameters. - - action: button # yamllint disable-line rule:indentation + # Dynamically configures button properties on a specified page, + # enhancing UI interactivity by allowing updates to button appearance and behavior based on given parameters. + - action: button variables: id: int # Button index (0 to 32) page: string # Identifier of the page where the button is located. component: string # Unique identifier for the button. state: bool # Determines the button's state, influencing background and other visual aspects. - icon: string # Icon codepoint from HASwitchPlate Material Design Icons. Example: "\uE6E8" for mdi:lightbulb-on-outline. + icon: string # Codepoint from HASwitchPlate Material Design Icons. "\uE6E8" for mdi:lightbulb-on-outline. icon_color: int[] # RGB color array for the icon. icon_font: int # Nextion font identifier for the icon, default is 8. bri: string # Brightness level or other dynamic info to be displayed close to the icon. @@ -149,7 +150,8 @@ script: then: - lambda: |- set_component_text->execute(page.c_str(), (component + "bri").c_str(), - (strcmp(buttonpage_buttons[index].bri, "0") == 0) ? " " : buttonpage_buttons[index].bri); + (strcmp(buttonpage_buttons[index].bri, "0") == 0) ? + " " : buttonpage_buttons[index].bri); - id: page_buttonpage_button_renderer_icon mode: parallel diff --git a/esphome/nspanel_esphome_core_page_climate.yaml b/esphome/nspanel_esphome_core_page_climate.yaml index 1d890359e..6aaf67452 100644 --- a/esphome/nspanel_esphome_core_page_climate.yaml +++ b/esphome/nspanel_esphome_core_page_climate.yaml @@ -19,19 +19,17 @@ api: # Dynamically updates the climate page with the latest climate control settings and status. - action: page_climate variables: - # yamllint disable rule:line-length current_temp: float # Current temperature reading. - supported_features: int # Bitmask indicating the supported features of the climate device, such as temperature control (1) and fan mode (4). + supported_features: int # Bitmask indicating the supported features of the climate device. target_temp: float # Desired target temperature setting. target_temp_high: float # Upper limit of the target temperature range for devices supporting ranges. target_temp_low: float # Lower limit of the target temperature range. - temp_step: int # Temperature adjustment step size, indicating the granularity of changes (multiplied by 10 for precision). - total_steps: int # Total adjustment steps available, derived from the device's temperature range and step size. - temp_offset: int # Calibration offset applied to the temperature reading (multiplied by 10 for precision). - climate_icon: string # Icon codepoint representing the current climate status, chosen from HASwitchPlate Material Design Icons. + temp_step: int # Temperature adjustment step size (multiplied by 10 for precision). + total_steps: int # Total adjustment steps available, derived from the temperature range and step size. + temp_offset: int # Calibration offset applied to the temperature (multiplied by 10 for precision). + climate_icon: string # Codepoint representing climate status, from HASwitchPlate Material Design Icons. embedded_climate: bool # Indicates if climate control is integrated into the interface. entity: string # Entity ID of the climate device, allowing for direct control and status updates. - # yamllint enable rule:line-length then: - script.stop: set_climate - if: