home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
70.11k stars 29.17k forks source link

Environment Canada weather day labels are wrong at after midnight #118622

Open anthonydiiorio opened 1 month ago

anthonydiiorio commented 1 month ago

The problem

At night when Environment Canada shows the weather for "tonight" with the day temperature blank, the data is in the right places in the dashboard, exactly the same as Environment Canada, but the day labels are incorrect. Everything is shifted by 1 day. Monday shows the Sunday forecast, Tuesday shows the Monday forecast, etc.

chrome_969_bFblOj0dCw

chrome_970_T9IgVrzz0W

What version of Home Assistant Core has the issue?

2024.5.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Environment Canada

Link to integration documentation on our website

https://www.home-assistant.io/integrations/environment_canada/

Diagnostics information

No response

Example YAML snippet

show_current: true
show_forecast: true
type: weather-forecast
entity: weather.montreal
forecast_type: daily

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 month ago

Hey there @gwww, @michaeldavie, mind taking a look at this issue as it has been labeled with an integration (environment_canada) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `environment_canada` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign environment_canada` Removes the current integration label and assignees on the issue, 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 issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


environment_canada documentation environment_canada source (message by IssueLinks)

anthonydiiorio commented 1 month ago

For reference it goes back to normal during the day.

chrome_973_xMqYHerQl7

6of6 commented 1 month ago

I'm not an expert, but I "think" this is similar to a problem I had when setting up a custom Environment Canada display/dashboard. I created a "helper" to store the "previous" UTCSunset so that my weather display would properly show "day/night" values.

I suspect an integration could account for every time zone but; even Environment Canada weather reports a global timestamp that doesn't actually match any timezone in Canada.

It was a while ago, I could be wrong. I hope this helps.

6.

michaeldavie commented 1 month ago

Thanks for flagging.

@gwww can you think of a way to correct for this? I suppose we could drop the overnight low forecast after midnight, but that seems less than ideal. I also noticed that the parent weather integration now supports twice_daily as a forecast type, which is aligned with the data ECCC provides.

gwww commented 1 month ago

I will ponder this one, but for now trying to get blocking calls out of the integrations I support. And then I'm poking at the edges of the Environment Canada memory leak that people are talking about.

gwww commented 2 weeks ago

It is 8:30 pm on Sunday July 7. What I see appears correct. Is it still broken for you? I'm running 2024.7.1. Maybe I'm not reproducing this correctly or maybe something changed in HA Core or UI?

Screenshot 2024-07-07 at 20 28 07 Screenshot 2024-07-07 at 20 29 35
michaeldavie commented 2 weeks ago

I think the problem only occurs after midnight, with the "tonight" forecast showing up as the next day, and all of the other days also being ahead by one.

gwww commented 2 weeks ago

Ahhh. If that is the case my thought is to just drop that one entry.

"Twice daily" is something that could also be considered although I'm unsure if it would help with this issue.

anthonydiiorio commented 2 weeks ago

Yup, can confirm still broken after midnight. Tuesday in HA is showing the Monday forecast, etc.

image

gwww commented 2 weeks ago

So the answer I can think of is to drop the overnight low after midnight, as you suggest. Something such as between midnight and 6am if the first entry in the EC forecast is a "tonight" ("low") then drop it.

I'm gathering the EC weather as XML in files once an hour for the next 24 hours just to see what the pattern is for when singular for tonight starts and when it ends. Once I see the pattern and confirm the timing I'll figure out a patch.

I further reflected on the twice daily and it does not seem appropriate - at least by my understanding of it. Twice daily would imply that twice a day there is a high/low reading. What we have is one high and one low for the day.

MatthewFlamm commented 2 weeks ago

Twice daily means that you use the high temp during day and low temp for night. This is how the NWS data is also provided. But you should only do this, in my opinion, if you also have all the other data like condition, wind, etc.

gwww commented 2 weeks ago

@michaeldavie I two possible fixes to try.

Keep the previous day's night forecast but set it's timestamp to be the previous day. Also make sure the other days' have their timestamp set correctly and not skip a day. I'll try this first and see how it looks on the dashboard. I'm unsure what having forecast info from a previous day will do on the frontend.

The second approach is to just delete the night forecast when it's for the previous day. This is the fallback if the first approach does not work.

I hope to code the first approach today and test it out overnight.