Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add battery-state binary_sensors, translate battery-low message to a state-change #604

Merged
merged 50 commits into from
Aug 13, 2024

Conversation

bouwew
Copy link
Contributor

@bouwew bouwew commented Aug 12, 2024

Summary by CodeRabbit

  • New Features

    • Introduced binary_sensors to track battery state for multiple devices, enhancing monitoring capabilities.
    • Updated item counts across various configurations to reflect the increased number of devices managed.
    • Enhanced device management functionality with integrated low battery detection.
  • Bug Fixes

    • Addressed potential inaccuracies in device battery monitoring with newly implemented checks.
  • Tests

    • Expanded test suite for improved coverage of device interactions, ensuring reliability with the latest changes.
  • Documentation

    • Added XML notifications for low battery status, enhancing user awareness of device health.
  • Changelog

    • Updated to reflect new version v1.1.0 and introduced battery state notifications for battery-powered devices.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b88d1ac and da05526.

Files selected for processing (1)
  • plugwise/data.py (2 hunks)

plugwise/data.py Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between da05526 and 9486b6a.

Files selected for processing (6)
  • fixtures/adam_plus_anna_new/all_data.json (4 hunks)
  • fixtures/m_adam_cooling/all_data.json (4 hunks)
  • fixtures/m_adam_heating/all_data.json (4 hunks)
  • plugwise/data.py (2 hunks)
  • tests/data/adam/adam_plus_anna_new.json (2 hunks)
  • userdata/adam_plus_anna_new/core.domain_objects.xml (2 hunks)
Files skipped from review as they are similar to previous changes (5)
  • fixtures/adam_plus_anna_new/all_data.json
  • fixtures/m_adam_cooling/all_data.json
  • fixtures/m_adam_heating/all_data.json
  • tests/data/adam/adam_plus_anna_new.json
  • userdata/adam_plus_anna_new/core.domain_objects.xml
Additional comments not posted (1)
plugwise/data.py (1)

57-73: Verify the integration and logic for low battery detection.

The addition of low battery detection logic in _update_gw_devices appears correct. Ensure that the _detect_low_batteries method is functioning as expected and that the conditions for updating binary_sensors are met correctly.

Verification successful

Integration and logic for low battery detection are correctly implemented.

The _detect_low_batteries method is properly integrated into _update_gw_devices, and its output is used correctly to update the battery state in binary_sensors. The logic for detecting low battery conditions appears sound.

  • _detect_low_batteries is defined and used correctly.
  • The method's output is utilized to update the mac_list, which is then used to update the battery state.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration and logic for low battery detection in `_update_gw_devices`.

# Test: Check for the usage of `_detect_low_batteries` and ensure its output is handled correctly.
rg --type python '_detect_low_batteries' -A 5

Length of output: 76


Script:

#!/bin/bash
# Description: Verify the integration and logic for low battery detection in `_update_gw_devices`.

# Test: Check for the usage of `_detect_low_batteries` and ensure its output is handled correctly.
rg --type py '_detect_low_batteries' -A 5

Length of output: 744

plugwise/data.py Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9486b6a and f2276fc.

Files selected for processing (1)
  • plugwise/data.py (2 hunks)
Additional comments not posted (2)
plugwise/data.py (2)

57-74: Acknowledge implemented improvements and suggest further refactoring.

The integration of low battery detection logic in _update_gw_devices is well-structured. Previous suggestions regarding readability and performance have been addressed. Consider further refactoring to enhance clarity by extracting the inline condition into a separate method or variable, as previously suggested.


79-95: Acknowledge implemented improvements and suggest further optimization.

The _detect_low_batteries method is well-implemented, with previous suggestions for error handling and performance optimization addressed. Consider compiling the regular expression pattern outside the method if it is used frequently elsewhere to further enhance performance.

Copy link

@bouwew bouwew marked this pull request as ready for review August 13, 2024 18:29
@bouwew bouwew requested a review from a team as a code owner August 13, 2024 18:29
@bouwew
Copy link
Contributor Author

bouwew commented Aug 13, 2024

Let's release to v1.1.0a0 for testing purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants