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 c9486dc commit 4171728
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 34 deletions.
3 changes: 2 additions & 1 deletion esphome/nspanel_esphome_addon_ble_tracker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ script:
- lambda: |-
// Check if this is installed with Arduino
#ifdef USE_ARDUINO
#error "Invalid settings for add-on BLE Tracker. Arduino framework is not supported when using Bluetooth in this project."
#error "Invalid settings for add-on BLE Tracker. \
Arduino framework is not supported when using Bluetooth in this project."
#endif
ESP_LOGCONFIG("${project_tag}", "Add-on BLE Tracker");
Expand Down
7 changes: 3 additions & 4 deletions esphome/nspanel_esphome_addon_bluetooth_proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ bluetooth_proxy:
packages:
ble_base_package: !include nspanel_esphome_addon_ble_tracker.yaml

script:
- script:

Check failure on line 22 in esphome/nspanel_esphome_addon_bluetooth_proxy.yaml

View workflow job for this annotation

GitHub Actions / Code scan (YAML)

22:1 syntax error: expected <block end>, but found '-' (syntax)
- id: !extend dump_config
then:
- lambda: |-
// Check if this is installed with Arduino
#ifdef USE_ARDUINO
# yamllint disable rule:line-length
#error "Invalid settings for add-on Bluetooth Proxy. Arduino framework is not supported when using Bluetooth in this project."
# yamllint enable rule:line-length
#error "Invalid settings for add-on Bluetooth Proxy. \
Arduino framework is not supported when using Bluetooth in this project."
#endif
ESP_LOGCONFIG("${project_tag}", "Add-on Bluetooth Proxy:");
ESP_LOGCONFIG("${project_tag}", " Mode: %s", ble_proxy->has_active() ? "Active" : "Passive");
Expand Down
4 changes: 3 additions & 1 deletion esphome/nspanel_esphome_core_hw_buzzer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ substitutions:
tone_boot: "two short:d=4,o=5,b=100:16e6,16e6"
tone_touch_press: "Touch:d=16,o=5,b=180:g"
tone_touch_release: "Release:d=32,o=5,b=180:g,g"
tone_volume_change: '' # Ex.: "scale_up:d=32,o=5,b=100:c,c#,d#,e,f#,g#,a#,b"
# Ex.
# tone_volume_change: "scale_up:d=32,o=5,b=100:c,c#,d#,e,f#,g#,a#,b"
tone_volume_change: ""

api:
id: !extend api_server
Expand Down
53 changes: 34 additions & 19 deletions esphome/nspanel_esphome_core_hw_display.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ api:
actions:
# Sends custom commands directly to the display for dynamic interactions and updates.
- action: command
# Command string to be sent.
# Refer to the Nextion Instruction Set for supported commands: https://nextion.tech/instruction-set/
variables:
cmd: string # Command string to be sent. Refer to the Nextion Instruction Set for supported commands: https://nextion.tech/instruction-set/
cmd: string
then:
- lambda: |-
send_command->execute(cmd.c_str());
Expand All @@ -24,7 +26,7 @@ api:
- action: component_color
variables:
page: string # Page name
component: string # Identifier of the component to change color. Ensure this matches the component's ID in your display layout.
component: string # Identifier of the component to change color.
color: int[] # New color for the component, specified as an RGB array (e.g., [255, 0, 0] for red).
then:
- lambda: |-
Expand All @@ -50,7 +52,7 @@ api:
variables:
page: string # Page where the component is located
component: string # Identifier of the component to update. Must match the component's ID in the display layout.
val: int # New integer value to set for the component. Adjust based on the data type you're displaying.
val: int # New integer value to set for the component.
then:
- script.execute:
id: set_component_value
Expand All @@ -62,7 +64,7 @@ api:
- action: component_visibility
variables:
page: string # Page where the component is located
component: string # Identifier of the component to be hidden/shown. Ensure this matches the component's ID in your display layout.
component: string # Identifier of the component to be hidden/shown.
show: bool # Set to true to show the component, or false to hide it.
then:
- script.execute:
Expand All @@ -74,7 +76,7 @@ api:
# Displays detailed information for a specific entity.
- action: entity_details_show
variables:
entity_id: string # The ID of the entity for which details are shown. Supports "embedded_climate" for built-in climate control.
entity_id: string # The ID of the entity for which details are shown ("embedded_climate" for built-in climate).
back_page: string # Specifies the page to return to. Accepts "home" or "buttonpage01" to "buttonpage04".
then:
- lambda: |-
Expand Down Expand Up @@ -139,7 +141,7 @@ api:
variables:
page: string # Page name
component: string # Identifier of the entity. See "Screen components" for entity IDs.
icon: string # Icon codepoint (e.g., "/uE6E8" for mdi:thermometer) from HASwitchPlate Material Design Icons.
icon: string # Codepoint (e.g., "/uE6E8" for mdi:thermometer) from HASwitchPlate Material Design Icons.
icon_color: int[] # RGB color array for the icon (e.g., [255, 0, 0] for red).
name: string # Display name for the entity (e.g., "Temperature").
value: string # Actual value to display (e.g., "75°F").
Expand All @@ -150,16 +152,14 @@ api:
if (not icon.empty())
set_component_text->execute(page.c_str(), (component + "_icon").c_str(), icon.c_str());
if (icon_color.size() == 3)
set_component_font_color->execute(page.c_str(), (component + "_icon").c_str(),
(((icon_color[0] & 0xF8) << 8) | ((icon_color[1] & 0xFC) << 3) | (icon_color[2] >> 3)));
set_component_font_color->execute(page.c_str(), (component + "_icon").c_str(), rgb565(icon_color));
if (not name.empty())
set_component_text->execute(page.c_str(), (component + "_label").c_str(), name.c_str());
if (not value.empty())
set_component_text->execute(page.c_str(), component.c_str(),
adjustDecimalSeparator(value, id(mui_decimal_separator)).c_str());
if (value_color.size() == 3)
set_component_font_color->execute(page.c_str(), component.c_str(),
(((value_color[0] & 0xF8) << 8) | ((value_color[1] & 0xFC) << 3) | (value_color[2] >> 3)));
set_component_font_color->execute(page.c_str(), component.c_str(), rgb565(value_color));
}
binary_sensor:
Expand Down Expand Up @@ -398,7 +398,8 @@ script:
else
{
while (endPos > startPos && text_to_display[endPos] != ' ') { endPos--; }
if (endPos == startPos) endPos = startPos + (line_length_limit * id(mui_bytes_per_char)); // Handle case of long word
if (endPos == startPos)
endPos = startPos + (line_length_limit * id(mui_bytes_per_char)); // Handle case of long word
}
wrappedText += text_to_display.substr(startPos, endPos-startPos);
if (endPos < text_to_display.length())
Expand Down Expand Up @@ -735,14 +736,16 @@ script:
- lambda: return (tf_uart->get_baud_rate() != baud_rate);
then:
- lambda: |-
ESP_LOGI("script.set_baud_rate", "Baud rate changing from %" PRIu32 " to %" PRIu32 " bps", tf_uart->get_baud_rate(), baud_rate);
ESP_LOGI("script.set_baud_rate", "Baud rate changing from %" PRIu32 " to %" PRIu32 " bps",
tf_uart->get_baud_rate(), baud_rate);
ESP_LOGD("script.set_baud_rate", "Flush UART");
- wait_until:
condition:
- lambda: return (tf_uart->available() < 1);
timeout: 5s
- lambda: |-
ESP_LOGD("script.set_baud_rate", "Sending instruction '%s=%" PRIu32 "' to Nextion", definitive ? "bauds" : "baud", baud_rate);
ESP_LOGD("script.set_baud_rate", "Sending instruction '%s=%" PRIu32 "' to Nextion",
definitive ? "bauds" : "baud", baud_rate);
disp1->send_command_printf("%s=%" PRIu32, definitive ? "bauds" : "baud", baud_rate);
ESP_LOGD("script.set_baud_rate", "Flush UART");
- wait_until:
Expand Down Expand Up @@ -782,7 +785,9 @@ script:
timeout: 2s
- delay: !lambda return nextion_queue_delay_factor->state*id(nextion_queue);
- lambda: |-
disp1->set_component_font(current_page->state == page ? component.c_str() : (page + "." + component).c_str(), font);
disp1->set_component_font(current_page->state == page ?
component.c_str() :
(page + "." + component).c_str(), font);
nextion_queue_del->execute();
- id: set_component_font_color
Expand All @@ -802,7 +807,9 @@ script:
- delay: !lambda return nextion_queue_delay_factor->state*id(nextion_queue);
- lambda: |-
if (page == "home" or page == current_page->state)
disp1->set_component_font_color(current_page->state == page ? component.c_str() : (page + "." + component).c_str(), color);
disp1->set_component_font_color(current_page->state == page ?
component.c_str() :
(page + "." + component).c_str(), color);
nextion_queue_del->execute();
- id: set_component_picc
Expand All @@ -822,7 +829,9 @@ script:
- delay: !lambda return nextion_queue_delay_factor->state*id(nextion_queue);
- lambda: |-
if (page == "home" or page == current_page->state)
disp1->set_component_picc(current_page->state == page ? component.c_str() : (page + "." + component).c_str(), picc);
disp1->set_component_picc(current_page->state == page ?
component.c_str() :
(page + "." + component).c_str(), picc);
nextion_queue_del->execute();
- id: set_component_foreground_color
Expand Down Expand Up @@ -851,7 +860,9 @@ script:
- delay: !lambda return nextion_queue_delay_factor->state*id(nextion_queue);
- lambda: |-
if (page == "home" or page == current_page->state)
disp1->set_component_pic(current_page->state == page ? component.c_str() : (page + "." + component).c_str(), pic);
disp1->set_component_pic(current_page->state == page ?
component.c_str() :
(page + "." + component).c_str(), pic);
nextion_queue_del->execute();
- id: set_component_text
Expand All @@ -871,7 +882,9 @@ script:
- delay: !lambda return nextion_queue_delay_factor->state*id(nextion_queue);
- lambda: |-
if (page == "home" or page == current_page->state)
disp1->set_component_text(current_page->state == page ? component.c_str() : (page + "." + component).c_str(), text.c_str());
disp1->set_component_text(current_page->state == page ?
component.c_str() :
(page + "." + component).c_str(), text.c_str());
nextion_queue_del->execute();
- id: set_component_value
Expand All @@ -891,7 +904,9 @@ script:
- delay: !lambda return nextion_queue_delay_factor->state*id(nextion_queue);
- lambda: |-
if (page == "home" or page == current_page->state)
disp1->set_component_value(current_page->state == page ? component.c_str() : (page + "." + component).c_str(), val);
disp1->set_component_value(current_page->state == page ?
component.c_str() :
(page + "." + component).c_str(), val);
nextion_queue_del->execute();
- id: set_component_visibility
Expand Down
26 changes: 17 additions & 9 deletions esphome/nspanel_esphome_core_page_media_player.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ api:
- action: page_media_player
variables:
entity: string # Entity ID of the media player, used for state updates and control.
state: string # Current playback state of the media player (e.g., "playing", "paused", "stopped").
state: string # Current state of the media player (e.g., "playing", "paused", "stopped").
is_volume_muted: bool # Indicates if the media volume is currently muted.
friendly_name: string # Display name of the media player, shown as the page title.
volume_level: int # Current volume level, typically expressed as a percentage.
Expand All @@ -54,14 +54,16 @@ api:
media_duration: float # Total duration of the current media in seconds.
media_position: float # Current playback position in the media in seconds.
media_position_delta: float # Time elapsed since the last media position update in seconds.
supported_features: int # Bitmask indicating the media player's supported features (e.g., play, pause, volume control).
supported_features: int # Bitmask indicating thesupported features (e.g., play, pause, volume control).
then:
- lambda: |-
if (id(current_page_id) == ${PAGE_ID_MEDIA_PLAYER}) {
detailed_entity->publish_state(entity);
set_component_text->execute("${PAGE_NAME_MEDIA_PLAYER}", "page_label", friendly_name.c_str());
display_wrapped_text->execute("${PAGE_NAME_MEDIA_PLAYER}", "track", media_title.c_str(), id(display_mode) == 2 ? 16 : 27);
display_wrapped_text->execute("${PAGE_NAME_MEDIA_PLAYER}", "artist", media_artist.c_str(), id(display_mode) == 2 ? 26 : 40);
display_wrapped_text->execute("${PAGE_NAME_MEDIA_PLAYER}", "track", media_title.c_str(),
id(display_mode) == 2 ? 16 : 27);
display_wrapped_text->execute("${PAGE_NAME_MEDIA_PLAYER}", "artist", media_artist.c_str(),
id(display_mode) == 2 ? 26 : 40);
// on/off button
const bool bt_on_off_visible = (supported_features & ${MEDIA_PLAYER_FEATURE_TURN_ON})
Expand All @@ -75,7 +77,8 @@ api:
or (supported_features & ${MEDIA_PLAYER_FEATURE_PLAY});
set_component_visibility->execute("${PAGE_NAME_MEDIA_PLAYER}", "bt_play_pause", bt_play_pause_visible);
if (bt_on_off_visible)
set_component_text->execute("${PAGE_NAME_MEDIA_PLAYER}", "bt_play_pause", (state != "playing" and state != "off") ?
set_component_text->execute("${PAGE_NAME_MEDIA_PLAYER}", "bt_play_pause",
(state != "playing" and state != "off") ?
"${MDI_ICON_PLAY}" : "${MDI_ICON_PAUSE}");
// bt_prev button - PREVIOUS_TRACK
Expand All @@ -98,7 +101,9 @@ api:
set_component_visibility->execute("${PAGE_NAME_MEDIA_PLAYER}", "bt_mute", bt_mute_visible);
if (bt_mute_visible)
set_component_text->execute("${PAGE_NAME_MEDIA_PLAYER}", "bt_mute",
is_volume_muted ? "${MDI_ICON_VOLUME_VARIANT_OFF}" : "${MDI_ICON_VOLUME_LOW}");
is_volume_muted ?
"${MDI_ICON_VOLUME_VARIANT_OFF}" :
"${MDI_ICON_VOLUME_LOW}");
// Volume +/- buttons
const bool bt_vol_updown_visible = (supported_features & ${MEDIA_PLAYER_FEATURE_VOLUME_SET})
Expand Down Expand Up @@ -192,12 +197,15 @@ script:
const std::string key = json["key"];
if (key == "volume_mute") {
const std::string value = json["value"];
ha_call_action->execute("media_player.volume_mute", "is_volume_muted", value.c_str(), detailed_entity->state.c_str());
ha_call_action->execute("media_player.volume_mute", "is_volume_muted",
value.c_str(), detailed_entity->state.c_str());
} else if (key == "volume_set") {
const float value_float = json["value"].as<float>();
ha_call_action->execute("media_player.volume_set", "volume_level", to_string(value_float / 100.0f), detailed_entity->state.c_str());
ha_call_action->execute("media_player.volume_set", "volume_level",
to_string(value_float / 100.0f), detailed_entity->state.c_str());
} else if (!key.empty())
ha_call_action->execute((std::string("media_player.") + key.c_str()), "", "", detailed_entity->state.c_str());
ha_call_action->execute((std::string("media_player.") + key.c_str()),
"", "", detailed_entity->state.c_str());
}
- id: !extend page_changed
Expand Down

0 comments on commit 4171728

Please sign in to comment.