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

Energy support, NLE support #503

Merged
merged 99 commits into from
Aug 18, 2024
Merged

Conversation

tmenguy
Copy link
Contributor

@tmenguy tmenguy commented Jul 24, 2024

Use of the getmeasure API to compute energy (with power adjustment), support for multiple homes selection

Summary by Sourcery

This pull request introduces energy computation using the getmeasure API with power adjustment and supports multiple home selections. It includes significant refactoring of energy-related classes and mixins, enhances historical data processing, and improves error handling. New tests have been added to ensure the robustness of these features.

  • New Features:
    • Added support for computing energy using the getmeasure API with power adjustment.
    • Introduced support for multiple home selections.
  • Enhancements:
    • Refactored energy-related mixins and classes to improve modularity and clarity.
    • Updated measure types and added legacy support for older energy measure types.
    • Enhanced historical data retrieval and processing for energy measurements.
    • Improved error handling and logging for energy data collection.
  • Tests:
    • Added tests for historical data retrieval for single and multiple homes.
    • Included tests for handling disconnected main bridges.

cgtobi and others added 30 commits January 13, 2024 22:00
* Update BNCS

* feat: add centralized ventilation controller NLLF

---------

Signed-off-by: Tobias Sauerwein <cgtobi@gmail.com>
…, introduces a sum energy and an helper to be used in homeassistant primarily
Copy link

sourcery-ai bot commented Jul 24, 2024

Reviewer's Guide by Sourcery

This pull request introduces support for energy computation using the getmeasure API with power adjustment and adds support for multiple home selections. The changes include significant modifications to the energy and history data handling, as well as updates to the module classes to support these new features.

File-Level Changes

Files Changes
src/pyatmo/modules/module.py
src/pyatmo/modules/base_class.py
src/pyatmo/modules/legrand.py
Refactored module classes to support new energy and history data handling, including the introduction of new mixins and methods.
tests/test_energy.py
tests/test_home.py
tests/conftest.py
tests/common.py
Updated and added tests to align with the new energy data structure and multi-home support.
src/pyatmo/account.py
src/pyatmo/home.py
Enhanced account and home classes to support multiple homes and improved error handling.
src/pyatmo/auth.py
src/pyatmo/exceptions.py
Added new exception classes and implemented error handling for API throttling and home reachability.
fixtures/getmeasure_sum_energy_buy_from_grid,sum_energy_buy_from_grid$0,sum_energy_buy_from_grid$1,sum_energy_buy_from_grid$2_12_34_56_00_00_a1_4c_da.json
fixtures/getmeasure_sum_energy_buy_from_grid,sum_energy_buy_from_grid$0,sum_energy_buy_from_grid$1,sum_energy_buy_from_grid$2_98_76_54_32_10_00_00_69.json
fixtures/home_multi_status_error_disconnected.json
Added new fixtures for testing energy measure types and multi-home support.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @tmenguy - I've reviewed your changes and found some issues that need to be addressed.

Blocking issues:

  • Check for potential duplicate room IDs. (link)
Here's what I looked at during the review
  • 🔴 General issues: 1 blocking issue, 27 other issues
  • 🟢 Security: all looks good
  • 🟡 Testing: 5 issues found
  • 🟡 Complexity: 2 issues found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

src/pyatmo/modules/module.py Show resolved Hide resolved
src/pyatmo/modules/module.py Outdated Show resolved Hide resolved
src/pyatmo/modules/module.py Outdated Show resolved Hide resolved
src/pyatmo/modules/module.py Outdated Show resolved Hide resolved
src/pyatmo/modules/module.py Outdated Show resolved Hide resolved
fixtures/homesdata_multi.json Show resolved Hide resolved
fixtures/homesdata_multi.json Show resolved Hide resolved
fixtures/homesdata_multi.json Show resolved Hide resolved
tests/test_energy.py Show resolved Hide resolved
tests/test_energy.py Show resolved Hide resolved
src/pyatmo/account.py Outdated Show resolved Hide resolved
src/pyatmo/account.py Outdated Show resolved Hide resolved
src/pyatmo/account.py Show resolved Hide resolved
src/pyatmo/account.py Outdated Show resolved Hide resolved
src/pyatmo/home.py Outdated Show resolved Hide resolved
src/pyatmo/modules/base_class.py Outdated Show resolved Hide resolved
src/pyatmo/modules/base_class.py Show resolved Hide resolved
self.sum_energy_elec_peak = 0
self.sum_energy_elec_off_peak = 0

def compute_riemann_sum(self, power_data, conservative: bool = False):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can this be broken down into smaller functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hum, which ones , there is not a lot of statements in those not sure the Riemann one could be broken below this in meaningful and independent pieces.
Can you point me to th one you fill is too long?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Well, maybe let's extract that riemann function into a separate helper class as well.

power_data = self.get_history_data(
"power", from_ts=from_ts, to_ts=to_ts
)
if isinstance(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is deeply nested and thus hard to read and test.

src/pyatmo/modules/module.py Show resolved Hide resolved
@tmenguy tmenguy requested a review from cgtobi August 17, 2024 20:33
src/pyatmo/home.py Outdated Show resolved Hide resolved
src/pyatmo/modules/base_class.py Outdated Show resolved Hide resolved
src/pyatmo/modules/module.py Outdated Show resolved Hide resolved
cgtobi
cgtobi previously approved these changes Aug 18, 2024
@cgtobi cgtobi merged commit 4de6835 into jabesq-org:development Aug 18, 2024
4 checks passed
@tmenguy
Copy link
Contributor Author

tmenguy commented Aug 18, 2024

great! we made it :) thx for the reviews and time on it

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