Skip to content
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

Use current instead of current_weather query parameter #660

Open
MrEbbinghaus opened this issue Jun 26, 2024 · 2 comments
Open

Use current instead of current_weather query parameter #660

MrEbbinghaus opened this issue Jun 26, 2024 · 2 comments

Comments

@MrEbbinghaus
Copy link

MrEbbinghaus commented Jun 26, 2024

Currently, forecast objects have a current_weather field that only includes condition, temperature and wind, whereas hourly and daily include much more.

The MeteoAPI has a current parameter with a subset of the hourly attributes, which allows more granular queries. (Like temperature, precipitation, humidity, pressure, cloud cover, ...)

Why this is relevant
At the moment, the Open-Meteo Home Assistant integration provides precipitation only in the forecasts and wind information only in the entity state. This is a nuisance.

Going forward
Open Meteo has their own python SDK / implementation, unfortunately without an async implementation (yet).
https://github.com/open-meteo/sdk/tree/main/python
https://github.com/open-meteo/python-requests

So maybe this project can only provide the async interface in the future or even be archived in favour of the official implementation. (I'll just innocently mention @patrick-zippenfenig here 😉)

Note on backwards compatibility
It seems that current_weather overwrites the current parameter, so you can't just query for more and be backwards compatible. This should be solved by always querying with current=temperature_2m,is_day,weather_code,wind_speed_10m,wind_direction_10m and then mapping the variables to the old CurrentWeather model.

Compare:

current_weather=true

{
  // ...
  "current_weather_units": {
    "time": "iso8601",
    "interval": "seconds",
    "temperature": "°C",
    "windspeed": "km/h",
    "winddirection": "°",
    "is_day": "",
    "weathercode": "wmo code"
  },
  "current_weather": {
    "time": "2024-06-26T13:15",
    "interval": 900,
    "temperature": 24.9,
    "windspeed": 14.5,
    "winddirection": 199,
    "is_day": 1,
    "weathercode": 2
  }
}

current=temperature_2m,is_day,weather_code,wind_speed_10m,wind_direction_10m

{
  // ...
  "current_units": {
    "time": "iso8601",
    "interval": "seconds",
    "temperature_2m": "°C",
    "is_day": "",
    "weather_code": "wmo code",
    "wind_speed_10m": "km/h",
    "wind_direction_10m": "°"
  },
  "current": {
    "time": "2024-06-26T13:15",
    "interval": 900,
    "temperature_2m": 24.9,
    "is_day": 1,
    "weather_code": 2,
    "wind_speed_10m": 14.5,
    "wind_direction_10m": 199
  }
}
@patrick-zippenfenig
Copy link

Hi,
yes, there are now more options for current weather, but the old format is still supported for backwards compatibility.

I can also provide an async implementation based on aiohttp or httpx. The requests implementation in combination with FlatBuffers as a binary data transport format has been primarily developed for data science use cases. I am not sure how well it interfaces with HA. @MrEbbinghaus Would a simple aiohttp or httpx implementation provide any benefit in this direction?

@MrEbbinghaus
Copy link
Author

I guess @frenck should decide on that. He is the expert. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants