-
-
Notifications
You must be signed in to change notification settings - Fork 29.5k
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 nws coordinator listeners #115836
Add nws coordinator listeners #115836
Conversation
Hey there @MatthewFlamm, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
I have also been investigating this. I feel like the refresh machinery should be subscribed to inside the weather integration code, not here. We have an Edit: see #115857 |
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.
The tests need to be updated because the hourly forecast will now be updated the same number of times of the twice daily (at least in most tests).
@@ -141,6 +141,8 @@ def __init__( | |||
latitude = entry_data[CONF_LATITUDE] | |||
longitude = entry_data[CONF_LONGITUDE] | |||
self.coordinator_forecast_legacy = nws_data.coordinator_forecast | |||
self.coordinator_forecast_twice_daily = nws_data.coordinator_forecast |
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 don't need these, they are already available as self.forecast_coordinators["twice_daily"]
and similar the hourly.
@@ -160,6 +162,16 @@ async def async_added_to_hass(self) -> None: | |||
self._handle_legacy_forecast_coordinator_update | |||
) | |||
) | |||
self.async_on_remove( | |||
self.coordinator_forecast_twice_daily.async_add_listener( |
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.
Same comment as above, use the built in attribute for the forecast coordinators.
And several more places below.
#115857 will take some time to mature, so this PR should move forward to make immediate fixes. Clean up of the code is happening inside the other PR. |
@MatthewFlamm I'll work on the changes and test. In the meantime, should I remove the legacy forecast? Or still keep it in there for now? |
If you remove |
@MatthewFlamm I'm having trouble understanding what exactly is failing on the unsuccessful test, if you get a chance to review it. |
I wonder if it is a bug or race condition in core. The failure clearly shows that Looking at this again, I think you could try removing |
I am not sure if this diagnosis is correct, but for the line 395 in the test, after the fast forward:
Given the current
So the NWS isn't being added to the list of entities to call the service on, and there are no other entities in the list, hence So what's the intended behavior when we call |
@MatthewFlamm in case you had an opinions about the above. Thanks |
Hmmmm, IMO any fix we put in here for the testing will be brittle as we will be testing for edge cases in the weather integration handling, rather than nws functionality. I will go back to proposing the fixes in #115857, which adds in the listeners in |
Yea ok. I think really what hass needs it not only an unavailable state but
a stale state.
…On Mon, Apr 29, 2024, 13:24 MatthewFlamm ***@***.***> wrote:
Hmmmm, IMO any fix we put in here for the testing will be brittle as we
will be testing for edge cases in the weather integration handling, rather
than nws functionality. I will go back to proposing the fixes in #115857
<#115857>, which adds in the
listeners in async_added_to_hass, but also removes the forecast
coordinators from the available check. I *think* if you do this here, you
will get the same catch-22 I run into with #115857
<#115857>. I am soon going to
test a new version of pynws that will lessen the need for custom
availability handling in the nws integration. I'm hoping this simplifies
this maintenance headache going forward.
—
Reply to this email directly, view it on GitHub
<#115836 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABWCYT4UGQTC65OOYC3NFJ3Y72F7PAVCNFSM6AAAAABGORCTV6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBTGM4DAMBXGI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Proposed change
This registers the coordinator updates for twice_daily and hourly forecasts in NWS, which should prevent stale data mentioned in the issues below.
This also updates the
available
check to account for these coordinators (using the exact same algorithm, which I'm going to take as correct for the time being).Finally, added
async_request_refresh()
calls to these coordinators in theasync_update()
function.I believe these changes should solve these issues (and maybe many other dupes): #115769, #111146, #115433
Type of change
Additional information
Checklist
ruff format 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
.To help with the load of incoming pull requests: