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 c8884bd commit 6356f34
Show file tree
Hide file tree
Showing 6 changed files with 1,335 additions and 312 deletions.
8 changes: 4 additions & 4 deletions components/nspanel_ha_blueprint/ha_to_nextion.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ namespace nspanel_ha_blueprint {
void addSubscription(const std::string &entity_id, const std::string &page,
const std::string &component, bool is_global) {
esphome::ESP_LOGD(TAG_HA_TO_NEXTION, "New subscription requested to '%s', page '%s', and component '%s'",
entity_id.c_str(), page.c_str(), component.c_str());
entity_id.c_str(), page.c_str(), component.c_str());
// Check if subscription already exists
if (findSubscription(page, component) != nullptr) {
esphome::ESP_LOGW(TAG_HA_TO_NEXTION, "Subscription for page '%s', and component '%s' already exists!",
page.c_str(), component.c_str());
page.c_str(), component.c_str());
return;
}
esphome::ESP_LOGD(TAG_HA_TO_NEXTION, "No previous subscription found");
Expand Down Expand Up @@ -155,10 +155,10 @@ namespace nspanel_ha_blueprint {
void updateNextionDisplay(EntityTarget* subscription, const std::string &state) {
// Placeholder: Replace with actual logic to send data to the Nextion display
if (subscription->is_global) {
esphome::ESP_LOGI(TAG_HA_TO_NEXTION, "Global Component: Sending update to Nextion for entity '%s' with value: %s",
esphome::ESP_LOGD(TAG_HA_TO_NEXTION, "Global Component: Sending update to Nextion for entity '%s' with value: %s",
subscription->entity_id, state.c_str());
} else {
esphome::ESP_LOGI(TAG_HA_TO_NEXTION, "Component '%s' on page '%s': Sending update to Nextion with value: %s",
esphome::ESP_LOGD(TAG_HA_TO_NEXTION, "Component '%s' on page '%s': Sending update to Nextion with value: %s",
subscription->component, subscription->page, state.c_str());
}

Expand Down
2 changes: 1 addition & 1 deletion components/nspanel_ha_blueprint/icons.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ namespace nspanel_ha_blueprint {
PageIcon* new_icon = icon_allocator.allocate(1); // Allocate memory for 1 PageIcon in PSRAM

if (!new_icon) {
esphome::ESP_LOGE(TAG_ICONS, "Failed to allocate memory for new icon.");
esphome::ESP_LOGE(TAG_ICONS, "Failed to allocate memory for new icon %s on page %s", component, page);
return nullptr; // Memory allocation failed
}

Expand Down
2 changes: 1 addition & 1 deletion esphome/nspanel_esphome_core_base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ script:
- id: dump_config
mode: restart
then:
- delay: 30s
- delay: 90s
- lambda: |-
static const char *const TAG = "${project_tag}";
// report API status
Expand Down
21 changes: 15 additions & 6 deletions esphome/nspanel_esphome_core_hw_wifi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,17 @@ script:
mode: restart
then:
- lambda: |-
static const char* TAG = "script.refresh_wifi_icon";
ESP_LOGV(TAG, "Refreshing Wi-Fi icon");
static PageIcon* wifi_icon = get_icon("home", "wifi_icon");
if (!wifi_icon or wifi_icon == nullptr)
if (!wifi_icon or wifi_icon == nullptr) {
ESP_LOGE(TAG, "No icon pointer available");
return;
if (!wifi_icon->initiated)
}
if (!wifi_icon->initiated){
ESP_LOGV(TAG, "Initializing icon");
wifi_icon->initiated = true;
}
static bool blueprint_is_connected = false;
static bool api_is_connected = false;
static bool wifi_is_connected = false;
Expand All @@ -111,6 +117,7 @@ script:
wifi_is_connected != wifi_component->is_connected() or
api_is_connected != api_server->is_connected();
if (status_has_changed) {
ESP_LOGV(TAG, "Status has changed");
blueprint_is_connected = is_boot_step_completed(${BOOT_STEP_VERSIONING});
api_is_connected = api_server->is_connected();
wifi_is_connected = wifi_component->is_connected();
Expand All @@ -136,26 +143,28 @@ script:
icon_set_icon->execute(wifi_icon);
}
if (blueprint_is_connected and api_is_connected and wifi_is_connected) {
ESP_LOGI("script.refresh_wifi_icon", "Wi-Fi icon changed to %s (\\u%04X)",
new_wifi_icon, decode_utf8(new_wifi_icon));
ESP_LOGI(TAG, "Wi-Fi icon changed to %s (\\u%04X)", new_wifi_icon, decode_utf8(new_wifi_icon));
set_variable_value->execute("api", 1);
} else {
ESP_LOGW("script.refresh_wifi_icon", "Wi-Fi icon changed to %s (\\u%04X)",
ESP_LOGW(TAG, "Wi-Fi icon changed to %s (\\u%04X)",
new_wifi_icon, decode_utf8(new_wifi_icon));
set_variable_value->execute("api", 0);
}
}
// Update Wi-Fi icon color
if (status_has_changed or (wifi_rssi_warning != (wifi_rssi->state <= -70))) {
ESP_LOGV(TAG, "RSSI changed");
wifi_rssi_warning = (wifi_rssi->state <= -70);
uint16_t new_wifi_icon_color = (blueprint_is_connected and wifi_is_connected and api_is_connected)
? (wifi_rssi_warning ? 64992 : 33808)
: 63488;
if (wifi_icon->icon_color != new_wifi_icon_color) {
wifi_icon->icon_color = new_wifi_icon_color;
if (id(current_page_id) == ${PAGE_ID_HOME})
if (id(current_page_id) == ${PAGE_ID_HOME}) {
ESP_LOGD(TAG, "Wi-Fi icon color changed to %" PRIu16, new_wifi_icon_color);
icon_set_color->execute(wifi_icon);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion esphome/nspanel_esphome_core_page_buttons.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ api:
label: string # Main text label for the button.
then:
- lambda: |-
ESP_LOGI("api.actions.button", "Received data for button %i", id);
ESP_LOGD("api.actions.button", "Received data for button %i", id);
if (id >= 1 and id <= 32) {
uint8_t index = static_cast<uint8_t>(id) - 1;
bool changed_visibility = !buttonpage_buttons[index].visible;
Expand Down
Loading

0 comments on commit 6356f34

Please sign in to comment.