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 OSO Energy integration #70365

Merged
merged 37 commits into from
Dec 8, 2023
Merged

Conversation

osohotwateriot
Copy link
Contributor

@osohotwateriot osohotwateriot commented Apr 21, 2022

Breaking change

Proposed change

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)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

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
  • The code has been formatted using Black (black --fast 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.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

ludeeus
ludeeus previously requested changes Jul 6, 2022
Copy link
Member

@ludeeus ludeeus left a comment

Choose a reason for hiding this comment

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

Here are some comments to get the review started 👍

homeassistant/components/osoenergy/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/osoenergy/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/osoenergy/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/osoenergy/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/osoenergy/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/osoenergy/config_flow.py Outdated Show resolved Hide resolved
homeassistant/components/osoenergy/manifest.json Outdated Show resolved Hide resolved
@ismarslomic
Copy link

@osohotwateriot Im planning to buy OSO Charge and this integration is very interesting. Do you plan to still work on change requests in this PR? Thanks for the effort including it in the core!

@ismarslomic
Copy link

Is this PR ready to be merged or are there any review comments left to be fixed? Im eager to get my water heater included in HA with this integration.

@osohotwateriot
Copy link
Contributor Author

All comments have been reviewed and fixed - code is pushed. @ludeeus can you verify if there is something else needed for the PR in order to proceed with the approval?

@ismarslomic
Copy link

@ludeeus any chance you will get time to review and merge this PR before the holidays kicks in?

@ismarslomic
Copy link

Any reason for not merging?

@osohotwateriot osohotwateriot marked this pull request as ready for review October 2, 2023 15:39
@home-assistant home-assistant bot requested a review from edenhaus October 2, 2023 15:39
homeassistant/components/osoenergy/services.yaml Outdated Show resolved Hide resolved
@home-assistant home-assistant bot marked this pull request as draft October 4, 2023 10:31
@osohotwateriot osohotwateriot marked this pull request as ready for review October 6, 2023 08:09
@home-assistant home-assistant bot requested a review from edenhaus October 6, 2023 08:09
@home-assistant home-assistant bot marked this pull request as draft November 22, 2023 11:15
@osohotwateriot osohotwateriot marked this pull request as ready for review December 5, 2023 13:33
Copy link
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

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

Looks good, thanks @osohotwateriot 👍

Congrats to the first PR 🎉

Changing the name of the TypeVar can be done in a follow-up PR.

Comment on lines +22 to +24
_T = TypeVar(
"_T", OSOEnergyBinarySensorData, OSOEnergySensorData, OSOEnergyWaterHeaterData
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's give this TypeVar a better name, maybe:

Suggested change
_T = TypeVar(
"_T", OSOEnergyBinarySensorData, OSOEnergySensorData, OSOEnergyWaterHeaterData
)
_OSOEnergyT = TypeVar(
"_T", OSOEnergyBinarySensorData, OSOEnergySensorData, OSOEnergyWaterHeaterData
)

return unload_ok


class OSOEnergyEntity(Entity, Generic[_T]):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
class OSOEnergyEntity(Entity, Generic[_T]):
class OSOEnergyEntity(Entity, Generic[_OSOEnergyT]):

@emontnemery emontnemery merged commit 664d241 into home-assistant:dev Dec 8, 2023
53 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Dec 9, 2023
@osohotwateriot osohotwateriot deleted the osoenergy branch January 17, 2024 07:10
Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Please address the comments in a new PR. Thanks!


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
Copy link
Member

Choose a reason for hiding this comment

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

This will error if the platform wasn't setup.

"""Handle a OSO Energy config flow."""

VERSION = 1
CONNECTION_CLASS = config_entries.CONN_CLASS_CLOUD_POLL
Copy link
Member

Choose a reason for hiding this comment

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

This is legacy. It's set in the manifest.json nowadays.

"""Re Authenticate a user."""
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
data = {CONF_API_KEY: user_input[CONF_API_KEY]}
return await self.async_step_user(data)
Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't pass the old config entry data as input to the user step. Then we'll try to authenticate again with the old data when we know it's already invalid.

}
},
"error": {
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
Copy link
Member

Choose a reason for hiding this comment

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

cannot_connect string isn't used.

"error": {
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
"unknown": "[%key:common::config_flow::error::unknown%]"
Copy link
Member

Choose a reason for hiding this comment

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

unknown string isn't used.

"title": "OSO Energy Auth",
"description": "Generate and enter a new 'Subscription Key' for your account at 'https://portal.osoenergy.no/'.",
"data": {
"api_key": "[%key:common::config_flow::data::api_key%]"
Copy link
Member

Choose a reason for hiding this comment

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

There's no form for the reauth step.

@home-assistant home-assistant unlocked this conversation Jan 29, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jan 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.