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

Replace Solarlog unmaintained library #117484

Open
wants to merge 23 commits into
base: dev
Choose a base branch
from

Conversation

dontinelli
Copy link
Contributor

@dontinelli dontinelli commented May 15, 2024

Breaking change

Proposed change

This PR changes to a new library for gathering the data from the Solar-Log device. Background is that the old library is not maintained anymore. With the new library, new data points can be accessed (such as self-consumption, specific data per inverter). This PR only covers the change in library and the new config entry ("extended_data) - including the migration flow - and the updated tests, any additional data will be added with subsequent PR.

Path to new libary: https://github.com/dontinelli/solarlog_cli

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request: #32868

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@home-assistant
Copy link

Hey there @Ernst79, mind taking a look at this pull request as it has been labeled with an integration (solarlog) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of solarlog can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign solarlog Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@epenet epenet changed the title Solarlog update library Replace Solarlog unmaintained library May 15, 2024
@dontinelli dontinelli marked this pull request as ready for review May 21, 2024 05:53
@dontinelli dontinelli requested a review from Ernst79 as a code owner May 21, 2024 05:53
@dontinelli
Copy link
Contributor Author

@coderabbitai review

Copy link

coderabbitai bot commented May 23, 2024

Actions Performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

coderabbitai bot commented May 23, 2024

Walkthrough

The updates focus on the solarlog component in Home Assistant, transitioning from sunwatcher to solarlog_cli. This includes changes in code ownership, logging, migration handling, and exception management. The config_flow and coordinator modules were refactored to use SolarLogConnector, while tests and requirements were updated to reflect these changes. Additionally, new strings and error messages were introduced, and sensor key names were modified for clarity.

Changes

Files Change Summary
CODEOWNERS Added @dontinelli as a co-owner for the solarlog component alongside @Ernst79.
homeassistant/components/solarlog/__init__.py Added logging with _LOGGER and a migration function async_migrate_entry for config entries.
homeassistant/components/solarlog/config_flow.py Refactored to use SolarLogConnector, updated exception handling, and modified user input processing.
homeassistant/components/solarlog/coordinator.py Refactored to use SolarLogConnector, improved error handling, and updated data update process.
homeassistant/components/solarlog/manifest.json Updated code owners, removed loggers entry, and changed requirement to solarlog_cli==0.1.5.
homeassistant/components/solarlog/sensor.py Renamed sensor key from time to last_updated and updated data retrieval in native_value.
homeassistant/components/solarlog/strings.json Added new string for extended data retrieval and updated error handling messages.
requirements_all.txt, requirements_test_all.txt Replaced sunwatcher with solarlog_cli for the solarlog component.
tests/components/solarlog/conftest.py Introduced test helpers and fixtures for mocking SolarLog API connections and setup functions.
tests/components/solarlog/test_config_flow.py Updated test functions, included new parameters, and enhanced exception handling.
tests/components/solarlog/test_init.py Added tests to ensure successful migration of entry data.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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

homeassistant/components/solarlog/sensor.py Show resolved Hide resolved
Copy link
Contributor

@Ernst79 Ernst79 left a comment

Choose a reason for hiding this comment

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

LGTM. As discussed on discord, I can’t test it, as my Solarlog device has died.

@frenck frenck added the smash Indicator this PR is close to finish for merging or closing label May 27, 2024
homeassistant/components/solarlog/config_flow.py Outdated Show resolved Hide resolved
homeassistant/components/solarlog/config_flow.py Outdated Show resolved Hide resolved
homeassistant/components/solarlog/sensor.py Show resolved Hide resolved
@home-assistant home-assistant bot marked this pull request as draft May 27, 2024 13:56
@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@frenck frenck removed the smash Indicator this PR is close to finish for merging or closing label May 27, 2024
@dontinelli dontinelli requested a review from edenhaus May 27, 2024 16:19
@dontinelli dontinelli marked this pull request as ready for review May 29, 2024 05:27
@dontinelli dontinelli requested a review from edenhaus May 29, 2024 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants