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
73.94k stars 30.99k forks source link

Openweathermap UV index "Unknown" #115045

Closed rcblackwell closed 2 months ago

rcblackwell commented 7 months ago

The problem

I installed the openweathermap integration a couple of days ago. Installation was completed using a paid One Call API 3.0 key. With exception of UV readings, the integration is obtaining current weather data. I've been watching the UV sensor (sensor.openweathermap_uv_index) for the last 24 hours. It's always reporting "Unknown".

If i make a call using [(https://api.openweathermap.org/data/3.0/onecall?lat={MY_LAY}&lon={MY_LON}&appid={MY_API_KEY})]. The following data is returned;

{REDACTED HEADER}
{"dt":1712428841,"sunrise":1712400953,"sunset":1712447770,"temp":283.72,"feels_like":282.22,"pressure":1018,"humidity":53,"dew_point":274.55,"uvi":4.17,"clouds":7,"visibility":10000,"wind_speed":6.49,"wind_deg":359,"wind_gust":8.17,"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01d"}]},"minutely":[{"dt":1712428860,"precipitation":0},

{BALANCE OMITTED FOR CLARITY}

I see a UVI value of 4.17 in the data. Why is the integration not displaying it?

What version of Home Assistant Core has the issue?

core-2024.4.1

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

OpenWeatherMap

Link to integration documentation on our website

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

Diagnostics information

2024-04-06 14:28:52.631 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2024-04-06 14:28:52.633 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration smart_irrigation which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2024-04-06 14:28:52.635 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration ontario_energy_board which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2024-04-06 14:28:52.636 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration localtuya which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2024-04-06 14:28:52.638 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration chime_tts which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2024-04-06 14:28:52.639 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration battery_notes which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2024-04-06 14:28:52.641 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration nodered which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2024-04-06 14:29:00.570 DEBUG (MainThread) [homeassistant.components.openweathermap.weather_update_coordinator] Finished fetching openweathermap data in 0.893 seconds (success: True) 2024-04-06 14:39:05.993 DEBUG (MainThread) [homeassistant.components.openweathermap.weather_update_coordinator] Finished fetching openweathermap data in 0.524 seconds (success: True)

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2024-04-06 14:29:00.570 DEBUG (MainThread) [homeassistant.components.openweathermap.weather_update_coordinator] Finished fetching openweathermap data in 0.893 seconds (success: True)
2024-04-06 14:39:05.993 DEBUG (MainThread) [homeassistant.components.openweathermap.weather_update_coordinator] Finished fetching openweathermap data in 0.524 seconds (success: True)

Additional information

No response

home-assistant[bot] commented 7 months ago

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

Code owner commands Code owners of `openweathermap` 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 openweathermap` 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)


openweathermap documentation openweathermap source (message by IssueLinks)

babygiraffe05 commented 7 months ago

In addition, all of the state_attr data for forecast is missing. If you attempt state_attr('weather.openweathermap','forecast')[1],['temperature'] for example, it is now returning an error. The hourly forecast state_attr data is completely missing from the state view in developer tools window.

This breaks all automations that relied on forecast data.

fabaff commented 6 months ago

Probably related to #113000

Phoenix-DH commented 6 months ago

Same here.

babygiraffe05 commented 6 months ago

Same here.

I discovered this was unrelated. You need to change the way Openweathermap pulls data. The new method is to use a service to call the forecast as required. You can use that data to create sensors that are functional within automations, helpers, etc. For me, this is a far worse solution and required a ton of reprogramming, but I was able to recover everything after many hours of labor. The information can be found here: https://www.home-assistant.io/integrations/weather/

There are two examples of the service at the bottom of that page that pull the data into a sensor via an automation, but I suggest searching for other examples of the weather.get_forecasts (note the plural forecasts) service. Note that weather.get_forecast (singular forecast) has been deprecated.

Phoenix-DH commented 6 months ago

@babygiraffe05 Is UV really also related to this new service? I am already using it to create a new sensor for weather forecast.

{{ hourly['weather.openweathermap'].forecast }}"

I thought all now providef sensors should still work.

babygiraffe05 commented 6 months ago

@babygiraffe05 Is UV really also related to this new service? I am already using it to create a new sensor for weather forecast.

{{ hourly['weather.openweathermap'].forecast }}"

I thought all now providef sensors should still work.

@Phoenix-DH I thought your comment was referencing my reply to the op, not the op post. The UV Index is not included in any forecast data, including the current hour or current day forecast, nor any of the future periods that are available by calling the weather.get_forecasts service I referenced in my comment above. UV Index is included in the current weather conditions. See the documentation here: https://www.home-assistant.io/integrations/openweathermap/

So to answer your question directly, no UV Index is not related to the new get_forecasts service.

Phoenix-DH commented 6 months ago

Yes, so just an issue with uv and openweathermap.

Levante75 commented 5 months ago

As temp solution, I added this to get the UV Index and Dew Point in my configuration.yaml: command_line:

issue-triage-workflows[bot] commented 2 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

ryanaross commented 1 month ago

Just for future reference to people, I dived into the code and found that when you setup the OpenWeatherMap integration, make sure you select a mode of 3.0 (2.5 would also work but no recommended) as the mode. The default mode is "current". But that does not use the OneCall API and therefore does not have UV Index Ref: https://github.com/freekode/pyopenweathermap/blob/6ec53ee3bbf3452aca9fe19975ad8df068c861ea/src/pyopenweathermap/client/owm_client_factory.py#L11 https://github.com/freekode/pyopenweathermap/blob/6ec53ee3bbf3452aca9fe19975ad8df068c861ea/src/pyopenweathermap/data_converter.py#L85