diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 232a91c..d117dcb 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -238,11 +238,22 @@ reaffirming our commitment to providing a seamless and stable user experience. ### Button Bars Visibility Enhancement and Configuration Change - **Criticality:** Breaking Change (with Enhancement) - **Affected Components:** Blueprint -- **Description:** The visibility of button bars, indicating the status of entities linked to hardware buttons, has been updated to be visible across all pages by default, including the screensaver. +- **Description:** The visibility of button bars, indicating the status of entities linked to hardware buttons, +has been updated to be visible across all pages by default, including the screensaver. This enhancement improves the accessibility of crucial status information. Users who previously customized the visibility settings for button bars will need to review and adjust their configurations to align with the new default behavior. This change enables users to selectively exclude button bars from specific pages if desired, providing greater flexibility and control over the interface's appearance. +### Service `hw_button_state` Update +- **Criticality:** Breaking Change (with Enhancement) +- **Affected Components:** Blueprint and ESPHome +- **Description:** The method for controlling the state of hardware buttons has been refined with the introduction of a `button_mask` parameter. +This update simplifies the process of simultaneously updating the visual state of multiple hardware buttons, +enhancing user interaction by providing a more intuitive interface for managing button states. +Users can now specify the buttons they wish to control using a single `button_mask` parameter, +offering a streamlined approach for activating or deactivating the on-screen indication bars of the hardware buttons. +This change fosters a more flexible and efficient user experience in configuring the visual feedback for button states. + ### Celsius Display Issue for Embedded Temperature Sensor Resolved (#1834) - **Criticality:** Medium - **Affected Components:** ESPHome diff --git a/docs/api.md b/docs/api.md index e0a60f2..4ad5808 100644 --- a/docs/api.md +++ b/docs/api.md @@ -254,26 +254,27 @@ data: > This setup provides a direct and user-friendly way to access and return from detailed entity information, enhancing the interface's usability. ### Hardware Button State Indication Service: `hw_button_state` -Updates the on-screen indication bars for the hardware buttons, reflecting the current state of the entities they control. +This service dynamically updates the on-screen indication bars for the hardware buttons, reflecting the current state of the entities they control. +It's designed to provide immediate visual feedback, enhancing the user interface by showing the active/inactive state of the left and right hardware button indicators on the panel. -**Usage:** -This service updates the visual state (on/off) of the left and right hardware button indicators on the panel. -It's used to provide visual feedback corresponding to the state of the entities controlled by these hardware buttons. +**Usage:** +Utilize this service to modify the visual state (on/off) of hardware button indicators on the panel, corresponding to the state of entities controlled by these buttons. +This allows for visual feedback that matches the operational state of the buttons. -**Parameters:** -- `left` (bool): The state to set for the left button's indication bar. -- `right` (bool): The state to set for the right button's indication bar. +**Parameters:** +- `button_mask` (int): A bitwise identifier for buttons. Use `1` for the left button, `2` for the right button, and `3` for both buttons. +- `state` (bool): The state to apply to the button(s) indicated by `button_mask`. True for on (active), false for off (inactive). **Home Assistant Example:** ```yaml service: esphome._hw_button_state data: - left: true # Turns the left button's indication bar on - right: false # Turns the right button's indication bar off + button_mask: 3 # Targets both the left (1) and right (2) buttons + state: true # Turns the indication bars on for both buttons ``` > [!NOTE] > Replace `` with your specific panel name as configured in Home Assistant. -> This service dynamically updates the hardware button state indications, enhancing the user interface by providing immediate visual feedback. +> This service leverages a bitmask (`button_mask`) for flexible control over multiple hardware buttons simultaneously, offering a streamlined method for updating their visual states. ### Icon Service: `icon` Updates a chip or custom button's icon, color, and visibility within Home Assistant. diff --git a/docs/version_compatibility.md b/docs/version_compatibility.md index 8b4faa8..e27c185 100644 --- a/docs/version_compatibility.md +++ b/docs/version_compatibility.md @@ -3,7 +3,8 @@ | NSPanel_HA_Blueprint
Version | Home Assistant
Min version | ESPHome
Min version | | :--: | :--: | :--: | -| v4.3 | 2024.3.0 | 2023.12.0 | +| v4.3.1 | 2024.3.0 | 2024.3.0 | +| v4.3.0 | 2024.3.0 | 2023.12.0 | | v4.2.2+ | 2023.12.0 | 2023.12.0 | | v4.2.1
v4.2 | 2023.9.0 | 2023.12.0 | | v4.1 | 2023.9.0 | 2023.5.0 | diff --git a/esphome/nspanel_esphome_core.yaml b/esphome/nspanel_esphome_core.yaml index ea3c433..52a3cbd 100644 --- a/esphome/nspanel_esphome_core.yaml +++ b/esphome/nspanel_esphome_core.yaml @@ -279,13 +279,16 @@ api: # Hardware Button State Indication Service - service: hw_button_state variables: - left: bool # State for the left button indication bar - right: bool # State for the right button indication bar + button_mask: int # Bitwise value for buttons: 1 for "left button", 2 for "right button", 3 for both buttons + state: bool # State for the button(s) indication: true for active, false for inactive then: - lambda: |- // Updates the visual state indication for hardware buttons - update_bitwise_setting(id(buttons_settings), left, ButtonSettings::ButtonLeft_State); - update_bitwise_setting(id(buttons_settings), right, ButtonSettings::ButtonRight_State); + // Use bitwise AND to check specific bits + if (button_mask & 1) // Checks if the least significant bit is set (left button) + update_bitwise_setting(id(buttons_settings), state, ButtonSettings::ButtonLeft_State); + if (button_mask & 2) // Checks if the second least significant bit is set (right button) + update_bitwise_setting(id(buttons_settings), state, ButtonSettings::ButtonRight_State); // Refreshes the indication bars on the display refresh_hardware_buttons_bars->execute(); diff --git a/nspanel_blueprint.yaml b/nspanel_blueprint.yaml index 1fcadae..7e2dfc3 100644 --- a/nspanel_blueprint.yaml +++ b/nspanel_blueprint.yaml @@ -7598,13 +7598,33 @@ action: embedded_climate_friendly_name: '{{ climate_friendly_name if climate_friendly_name else "" }}' embedded_indoor_temperature: '{{ embedded_indoor_temperature }}' continue_on_error: true - - &update_hw_button_state - service: 'esphome.{{ nspanel_name }}_hw_button_state' - data: - left: '{{ hardware.buttons.left.entity_is_valid and states(hardware.buttons.left.entity) | default("unavailable") in enum.states.on }}' - right: '{{ hardware.buttons.right.entity_is_valid and states(hardware.buttons.right.entity) | default("unavailable") in enum.states.on }}' - continue_on_error: true + # Update Hardware buttons bars states + - if: '{{ true }}' + then: + - variables: + hw_btn_left_state: '{{ hardware.buttons.left.entity_is_valid and states(hardware.buttons.left.entity) | default("unavailable") in enum.states.on }}' + hw_btn_right_state: '{{ hardware.buttons.right.entity_is_valid and states(hardware.buttons.right.entity) | default("unavailable") in enum.states.on }}' + - if: '{{ hw_btn_left_state == hw_btn_right_state }}' + then: # Save one service call if both buttons have the same state + - service: 'esphome.{{ nspanel_name }}_hw_button_state' + data: + button_mask: 3 # Both buttons + state: '{{ hw_btn_left_state }}' + continue_on_error: true + else: # Send individual calls if the buttons have different states + - service: 'esphome.{{ nspanel_name }}_hw_button_state' + data: + button_mask: 1 # Left button + state: '{{ hw_btn_left_state }}' + continue_on_error: true + - service: 'esphome.{{ nspanel_name }}_hw_button_state' + data: + button_mask: 2 # Right button + state: '{{ hw_btn_right_state }}' + continue_on_error: true + + # Global settings - variables: entitypages_value_alignment: !input entitypages_value_alignment - service: 'esphome.{{ nspanel_name }}_init_global' @@ -10267,7 +10287,13 @@ action: - right_button_state sequence: - *variables_hardware - - *update_hw_button_state + - variables: + button_name: '{{ "left" if trigger.id == "left_button_state" else "right" }}' + - service: 'esphome.{{ nspanel_name }}_hw_button_state' + data: + button_mask: '{{ 1 if trigger.id == "left_button_state" else 2 }}' + state: '{{ hardware.buttons[button_name].entity_is_valid and states(hardware.buttons[button_name].entity) | default("unavailable") in enum.states.on }}' + continue_on_error: true ##### OUTDOOR TEMP - entity ##### - alias: Outdoor temp - Entity