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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add brightsky weather entity #37800
Add brightsky weather entity #37800
Conversation
28d130c
to
f1bd2ae
Compare
We no longer accept integrations, that connect with a device or service, to be configured via YAML. Please add a configuration flow to this integration, see our developers documentation for more information: https://developers.home-assistant.io/docs/config_entries_config_flow_handler Thanks already 馃憤 |
b26c97a
to
e211ffa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding review comment to correct the state of this PR.
I have this in a somewhat working state and have been using it for a couple of weeks. I have no clue if what I've done with the config flow and its test is sensible. The API currently has the limitation of only relying on data collected from stations, filled up with data from other stations, when the closest station does not offer a certain feature. This means that data like the weather condition could come from a station as much as 30km away. Another limitation is that there is no interpolation of data in relation to the distance one has to the next station. So the data has to be taken with a grain of salt. My next station is 3 km away across the city and the values measured are spot on, so there is certainly some value. |
The developer docs mention that all API specific code should be part of a third party library. It's not just about 2 HTTP GET requests, you are mapping brightsky keys to ha keys here, which is API specific code. That should be put in a separate library such that when API's change, ha only needs a dependency bump and the logic can be changed in the third party library. |
There's an official library on PyPI for brightsky now: https://pypi.org/project/brightsky/ |
I wouldn't recommend running your own brightsky instance, when there is an API that can be easily queried. @RobBie1221 Okay, rescheduling work on this for some time in october, can't get to it earlier than that. |
API specific code needs to abstracted to a package hosted on PyPi. @disrupted is pointing to an existing package which can be used. |
I might've gotten it wrong. Looks like the PyPI package is for running your own instance as @mweinelt noted. If we just want to query the official instance https://brightsky.dev/ I guess we should build a wrapper around that or ask the developer if he's planning to make this functionality available within the brightsky package. |
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
I'm working on separating API access and hass integration right now. |
Published Untested as of yet. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Squashed and rebased. |
This was fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please exclude non tested modules from coverage by including them in .coveragerc
. Only the config flow requires 100 % coverage, although more tests are appreciated.
CONFIG_SCHEMA = vol.Schema({DOMAIN: vol.Schema({})}, extra=vol.ALLOW_EXTRA) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CONFIG_SCHEMA = vol.Schema({DOMAIN: vol.Schema({})}, extra=vol.ALLOW_EXTRA) |
try: | ||
info = await validate_input(self.hass, user_input) | ||
|
||
return self.async_create_entry(title=info["title"], data=user_input) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please only wrap the line than can raise in the try... except block. Use and else:
block if needed.
vol.Required( | ||
CONF_LONGITUDE, default=self.hass.config.longitude | ||
): cv.longitude, | ||
vol.Optional(CONF_MODE, default="hourly"): vol.In(FORECAST_MODE), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this option isn't required for the connection it should be moved to an options flow instead of the main flow.
@@ -0,0 +1,11 @@ | |||
{ | |||
"domain": "brightsky", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We normally separate words with underscore.
"domain": "brightsky", | |
"domain": "bright_sky", |
"unknown": "[%key:common::config_flow::error::unknown%]" | ||
}, | ||
"abort": { | ||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This string isn't used.
return self._name | ||
|
||
@property | ||
def state(self) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't implement state
. Implement the condition
property.
return items | ||
|
||
@Throttle(UPDATE_INTERVAL) | ||
def update(self) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using our data update coordinator instead.
"homeassistant.components.brightsky.async_setup_entry", | ||
return_value=True, | ||
) as mock_setup_entry: | ||
result2 = await hass.config_entries.flow.async_configure( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to patch the library here to avoid I/O.
Sorry, I've lost interest in completing this. |
Breaking change
Proposed change
Add support for DWD weather data using the Bright Sky API.
Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.The integration reached or maintains the following Integration Quality Scale:
TODOs
Notes
It's violating the rule about requests to external services being outsourced into dedicated Python Packages. That makes little sense to me for ~60 LOC that do two HTTP GET requests and very little else.