Rudd-O / homeassistant-meteoswiss

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

Add precipitation and wind forecast #12

Closed badewanne1234 closed 10 months ago

badewanne1234 commented 1 year ago

It would be very useful to have precipitation and wind forecast too. The data is provided on the Meteo Swiss Website for the location, however I'm not sure if the data is also exposed so that this integration could grab it?

This is the forecast for tomorrow provided by meteoswiss:

- datetime: '2023-03-15'
  condition: partlycloudy
  temperature: 7
  templow: 1

And this is an example of open-meteo forecast for tomorrow for the same location (+wind and precipitation):

- datetime: '2023-03-15'
  condition: rainy
  wind_bearing: 209
  temperature: 6.5
  templow: -0.2
  wind_speed: 12.6
  precipitation: 6.9

And this from met.no integration for the same location for tomorrow (+wind and precipitation):

- condition: partlycloudy
  datetime: '2023-03-15T11:00:00+00:00'
  wind_bearing: 277.1
  temperature: 4.3
  templow: -0.3
  wind_speed: 17.6
  precipitation: 8.2
nicolap75 commented 1 year ago

I am also interested in this data and unfortunately at the moment I am getting it from other components.

scachemaille commented 1 year ago

the precipitation seems to be included in the json received by the meteoswiss client used by the integration for the forcast.

Rudd-O commented 10 months ago

I need help identifying the data in the JSON, and how to integrate it into the integration. I'm entirely unsure how to do this, and I would appreciate the community's help with this. Thank you!

scachemaille commented 10 months ago

I don't really have the time to rebase my branche on your master. you can have a look at this commit

data_out[ATTR_FORECAST_NATIVE_PRECIPITATION] = float(
                forecast["precipitation"],
 )

The result in home assistant image

scachemaille commented 10 months ago

I saw that in recent home-assistant they reworked a lot the forcast and I'm not aware what changed. and when maybe with how meteoswiss works will be deprecated or not working anymore

badewanne1234 commented 10 months ago

I was looking for the receiving JSON-Data URL for a station to see whats reported (not the 10min sensors...) I assume Wind would also be forecasted and if we are lucky, even precipitation-probability... Can someone post an example url? I undestand there are the stations that one can lookup on the website and look for each attribute of the station, but I wonder what is really reported via JSON.

Rudd-O commented 10 months ago

Precipitation is done in latest master, but wind speed does not show so it cannot be done. (Sample below with fake PLZ.)

If someone finds a different data source, please let me know and I'll reopen the ticket.

[user@projects hamsclientfork]$ curl 'https://app-prod-ws.meteoswiss-app.ch/v1/forecast?plz=600100&graph=false&warning=true' | jq .
{
  "plz": 600100,
  "currentWeather": {
    "time": 1700149200000,
    "icon": 14,
    "iconV2": 14,
    "temperature": 8.7
  },
  "regionForecast": [
    {
      "dayDate": "2023-11-16",
      "iconDay": 6,
      "iconDayV2": 6,
      "temperatureMax": 10,
      "temperatureMin": 5,
      "precipitation": 6.7
    },
    {
      "dayDate": "2023-11-17",
      "iconDay": 17,
      "iconDayV2": 17,
      "temperatureMax": 9,
      "temperatureMin": 4,
      "precipitation": 4.3
    },
    {
      "dayDate": "2023-11-18",
      "iconDay": 3,
      "iconDayV2": 3,
      "temperatureMax": 8,
      "temperatureMin": 3,
      "precipitation": 0.2
    },
    {
      "dayDate": "2023-11-19",
      "iconDay": 17,
      "iconDayV2": 17,
      "temperatureMax": 12,
      "temperatureMin": 6,
      "precipitation": 3.4
    },
    {
      "dayDate": "2023-11-20",
      "iconDay": 5,
      "iconDayV2": 5,
      "temperatureMax": 12,
      "temperatureMin": 6,
      "precipitation": 2.7
    },
    {
      "dayDate": "2023-11-21",
      "iconDay": 5,
      "iconDayV2": 5,
      "temperatureMax": 9,
      "temperatureMin": 5,
      "precipitation": 3.1
    }
  ],
  "graph": null,
  "warningsOverview": [
    {
      "warnType": 0,
      "warnLevel": 3
    }
  ]
}