Rudd-O / homeassistant-meteoswiss

:sun_behind_rain_cloud: :switzerland: Meteo Swiss Integration for Home Assistant (forked from websylv)
90 stars 11 forks source link

Hourly forecast misses the condition #55

Open badewanne1234 opened 2 months ago

badewanne1234 commented 2 months ago

The hourly forecast introduction is great but it misses the current condition, it provides temp high, temp low and precipitation, but it misses the condition.

- datetime: '2024-08-25T09:00:00Z'
  temperature: 15.3
  templow: 14.1
  precipitation: 2.7

In contrast, the met.no forecast provides that plus additional attributes

- condition: rainy
  datetime: '2024-08-25T09:00:00+00:00'
  wind_bearing: 338.9
  cloud_coverage: 100
  temperature: 16.4
  wind_speed: 5.8
  precipitation: 0.7
  humidity: 98

Whilst wind_bearing, cloud_coverage and humidity are probably not offered by Meteo Schweiz, I would highly assume the current condition attribute itself would be offered by the API?

Rudd-O commented 2 months ago

The API does not send the condition, very sorry.

             'regionHourlyForecast': [{'precipitationMax': 0.0,
                                        'precipitationMean': 0.0,
                                        'precipitationMin': 0.0,
                                        'temperatureMax': 22.0,
                                        'temperatureMean': 22.0,
                                        'temperatureMin': 22.0,
                                        'time': datetime.datetime(2024, 9, 7, 22, 0, tzinfo=datetime.timezone.utc)},
                                       {'precipitationMax': 0.0,
                                        'precipitationMean': 0.0,
                                        'precipitationMin': 0.0,
                                        'temperatureMax': 21.2,
                                        'temperatureMean': 21.2,
                                        'temperatureMin': 21.2,
                                        'time': datetime.datetime(2024, 9, 7, 23, 0, tzinfo=datetime.timezone.utc)},
                                       {'precipitationMax': 0.0,
                                        'precipitationMean': 0.0,
                                        'precipitationMin': 0.0,
                                        'temperatureMax': 20.5,
                                        'temperatureMean': 20.5,
                                        'temperatureMin': 20.5,
                                        'time': datetime.datetime(2024, 9, 8, 0, 0, tzinfo=datetime.timezone.utc)},
                                       {'precipitationMax': 0.0,
                                        'precipitationMean': 0.0,
                                        'precipitationMin': 0.0,
                                        'temperatureMax': 20.6,
                                        'temperatureMean': 20.6,
                                        'temperatureMin': 20.6,

We use API URL 'https://app-prod-ws.meteoswiss-app.ch/v1/forecast?plz=671000&graph_startLowResolution=true&warning=true' for obtaining the hourly forecast.

If you can find another API URL , please reopen with the necessary info.

Rudd-O commented 2 months ago

We have found a different URL that provides the condition and the precipitation probability (for every three hours under precipitationProbability3h) as well as the condition (for every three hours under weatherIcon3h and weatherIcon3hV2):

https://app-prod-ws.meteoswiss-app.ch/v1/plzDetail?plz=390000

Sample data attached:

plzDetail.json

This is now a viable new feature that can be implemented. PRs against hamsclientfork and this integration welcome, because it's going to take me a few weeks to get this done myself.