core: OpenWeatherMap Integration Fails to Add Both OneCall Daily and OneCall Hourly for Same Lat/Long
The problem
The UI Integration Configuration wizard will not add Hourly or Daily data from OpenWeatherMap One-Call Integrations once the other time slice has been added for a given lat/long.
Both Hourly and Daily OneCall calls add Current Conditions making it problematic to hack the wizard to include both Hourly and Daily by a slight change to lat/long.
Both Hourly and Daily, plus one set of Current Weather data from Openweathermap are needed.
The DarkSky API expiration fast approaches in March and HA needs a robust alternative.
What version of Home Assistant Core has the issue?
2023.1.7
What was the last working version of Home Assistant Core?
None
What type of installation are you running?
Home Assistant Container
Integration causing the issue
OpenWeatherMap
Link to integration documentation on our website
https://www.home-assistant.io/integrations/openweathermap/
Diagnostics information
Add OneCall Daily
with a valid key for a given Lat/Long, Then try to add OneCall Hourly
for the same Lat/Long. It will fail noting a duplicate Lat/Long.
Then again add OneCall Hourly
with a nominally different Lat/Long. it will add successfully, but a complete second set of Current Conditions will be added to HA with duplicate names having an appended “_2” suffix.
The integration should allow acquiring Daily, Hourly, and at least Alerts, if not Minutely, in one Configuration for a given Lat/Long and Key.
THANKS, I wish I was a Python programmer. I’d work on this.
Example YAML snippet
The Integration is set up from the front end so I have no control over how it functions.
However, it is quite straightforward to get daily, hourly, and Alerts data from Openweathermap. Here is a REST call, but then one will need to build a quasy-integration with a lot of manually created template sensors from the REST report to get weather data suitable for the Front End tools.
The REST call that can acquire both Daily and Hourly, and one set of Current Conditions data:
sensor:
- platform: rest
name: openweather_report
json_attributes:
- current
- daily
- hourly
- alerts
value_template: "{{ value_json['current']['dt'] | timestamp_custom('%Y-%m-%d %H:%M', true) }}"
resource: https://api.openweathermap.org/data/3.0/onecall?lat=<myLat>&lon=<myLon>&exclude=minutely&appid=<myAppID>&units=imperial&lang=en
scan_interval: 3600
Anything in the logs that might be useful for us?
Sorry, no.
Additional information
DarkSky will be unsupported next month in March. Please help us migrate to another platform.
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 16 (1 by maintainers)
atm i am using 2 instances of the integration (2nd has long / lat offset by
.00000000000001
this allows me add the 2nd, but now we have weather service it would be nice to be able to just 1 integration for both Hourly and Daily.You can create a new instance with different lat\lon, change just a fraction of a value. It’s probably will be few kms/meters away from original place, but I don’t think forecast will be dramatically different.
This repository holds the yaml files and shell script I use to create the weather data sensors and to acquire the ONE_CALL_BY_CALL data using Openweathermap’s API. https://github.com/kaijk/openweathermap/tree/main
The same API Key should work in multiple calls. Just make sure the total calls between them do not exceed the daily free call limit. You should not get a 404 using the link (with your KEY and your lat/long. I get a JSON returned. You have something wrong in the https call
Note that the REST Call creates just an
openweather_report
entity. That entity has attributes from the JSON return. I can post the template sensor script I use to create the entities for each weather item. But it will have to be later. Here is a sample: I have a script that builds this for multiple attributes and icons for 12 hours.I hope that the integration will be modified to allow selecting BOTH daily and hourly one-call calls, and then provide just one set of current data.
If you have an Openweather “one-call” subscription, you can get current conditions, and daily, and hourly forecasts for free if you stay below a call-frequency threshold (See Scan_Interval below).
However, the problem is that the HA integration does not support getting both one-call daily, and one-call hourly for the same LAT/LON.
As an example, Add one-call daily, and then add one-call hourly with a slightly different LAT/LON. It works. But, BOTH provide Current data so you now have both sensor.* and sensor.*_2 (e.g., two sets of current conditions) for every current condition. That is the second part of the problem I raise in this issue.
As a workaround, I call Openweather’s API using the following REST command, and I have built my own large collection of template sensors for Current, Daily, and Hourly weather data.