Skip to content

Commit

Permalink
yamllint
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardtfn committed Nov 20, 2024
1 parent 3585df1 commit 2255ce5
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 35 deletions.
53 changes: 34 additions & 19 deletions esphome/nspanel_esphome_addon_climate_base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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};
Expand Down Expand Up @@ -230,49 +233,61 @@ 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",

Check failure on line 269 in esphome/nspanel_esphome_addon_climate_base.yaml

View workflow job for this annotation

GitHub Actions / Code scan (YAML)

269:69 [trailing-spaces] trailing spaces
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", "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:
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion esphome/nspanel_esphome_core_hw_display_light.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 12 additions & 4 deletions esphome/nspanel_esphome_core_hw_temperature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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? #####
Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 6 additions & 4 deletions esphome/nspanel_esphome_core_page_buttons.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
12 changes: 5 additions & 7 deletions esphome/nspanel_esphome_core_page_climate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 2255ce5

Please sign in to comment.