Closed kaijk closed 2 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!
(message by CodeOwnersMention)
openweathermap documentation openweathermap source (message by IssueLinks)
I had the same issue yesterday.
In my case I knew that the API key was valid because I did an API call using Postman to get the data. One of the things I learned in doing that is that OpenweatherMap will reduce your Lat/Long down to four digits to the right of the decimal whereas HA goes on much longer beyond that. I sent seven digit resolution Lat/Lon values in the call, and got back this in the response (replaced the four digits to right of decimal with 'x's for privacy reasons):
BEGIN CUT AND PASTE { "lat": 36.xxxx, "lon": -94.xxxx, "timezone": "America/Chicago", "timezone_offset": -21600, "current": { "dt": 1676088215, "sunrise": 1676034596, "sunset": 1676073097, < << SNIP>>> END CUT AND PASTE
Then, once I knew the API key was valid for OneCall Daily, I tried setting up this integration and was unsuccessful a number of times. The first time the configuration dialog accepted the API Key but once the configuration was entered, it failed. Then I deleted the integration and started over. That next time it claimed my API Key was invalid which was a pile of Bidenitis because I just used it with Postman successfully. However, I had three different API Keys with OpenWeatherMap and cycled through them until on the third time, the integration dialog accepted the API Key and then that time the integration was actually able to go out and populate the sensor data.
However, now I appear to be stuck with duplicate services for this integration.
Given my experience, this Integration could use some refinement. But for me, persistence got it working and HA is now populating data from it to my Influxdb database.
Hello I am using the free version of the API and therefore get the 3h-period forecast for the next 7 days (I think). I fine that this is great for a free service, however I see that the APi call is directly ingested by the integration in a list of 3h-period datasets. These datasets are then used in the weather cards of different sorts, but with always the 3h interval.
My problem, a bit different from above, but I think of the same nature, is that I would like to be able to retrieve the data with a 3h granularity to keep the free service, but display and process it also as a 24h granularity.
As an example, I would like to know if and how much it will rain in the next 48h to trigger my garden watering or not, so I could just display and add 2 daily values instead of 16 values (picked up from the midnight one). Also the weather card would be able to show a 5 days forecast instead of a 7 x 3h forecast.
I therefore believe that there could be a configuration option in the integration whereby you could choose both the type of API call you want to make (as is now) AND the type of temporal output you want to generate from the API call: "native" (e.g. 3h period), "daily" (aggegated to 24h from midnight), or any other relevant grouping.
I know that one answer would be, "buy a licence if you want a daily forecast", but as a matter of fact, all the data is there already with the free API key, it's just a matter of aggregation, averaging, adding, etc.
It seems to me that this would be relevant to process the data in the integration, so that the data is processed and normalised there, to be later displayed in any generic lovelace weather card, or be used in templates, etc.
An important point being that the "forecast" sensors would follow the selected aggregation, i.e. 3h, or 24h, or else.
Thank you!
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.
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=<YOUR_LAT>&lon=<YOUR_LON>&exclude=minutely&appid=<YOUR_APP_ID>&units=imperial&lang=en
scan_interval: 3600 # This keeps the number of calls below the permitted One-Call Free Call threshold
Yes, your One Call API_KEY. See here: https://openweathermap.org/api/one-call-3#data
On Sun, May 14, 2023 at 5:27 AM RedNo7 @.***> wrote:
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.
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=
&lon= &exclude=minutely&appid= &units=imperial&lang=en scan_interval: 3600 # This keeps the number of calls below the permitted One-Call Free Call threshold Does YOUR_APP_ID mean "API Key"?
— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/87817#issuecomment-1546888641, or unsubscribe https://github.com/notifications/unsubscribe-auth/AL2THYSLA2PV6VP5UQDPSQ3XGDFTRANCNFSM6AAAAAAUXGU6AY . You are receiving this because you authored the thread.Message ID: @.***>
cheers. Can I use the same API key twice (I have it in use already in the openreach onecall_daily integration) and want to use it again for onecall_hourly with your sensor (I am getting a 404 when I use the link in a browser).
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.
template:
sensor:
# hourlyy Values
# Hour0 (Note H0 in OPW is last hour. Current hour is H1. So, call shift H1 to H0, etc
- name: 'Openweather Temp 0h'
state: >
{% if state_attr('sensor.openweather_report', 'hourly')[1].temp is defined %}
{{ ( state_attr('sensor.openweather_report', 'hourly')[1].temp | float(0) ) | round(1) }}
{% else %}
0
{% endif %}
attributes:
dt: "{{ state_attr('sensor.openweather_report', 'hourly')[1].dt }}"
date_time: "{{ state_attr('sensor.openweather_report', 'hourly')[1].dt | timestamp_custom('%Y-%m-%d %H:%M', true) }}"
state_class: measurement
device_class: temperature
unit_of_measurement: '°F'
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
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.
That's what led me down this path. Perturbing the Lat/Lon a bit to add both
Hourly and Daily One-Call resulted in duplicate "
If I could code up integrations I'd have taken a crack at changing the One-Call logic.
On Mon, May 15, 2023 at 10:12 AM Evgeny @.***> wrote:
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.
— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/87817#issuecomment-1548241107, or unsubscribe https://github.com/notifications/unsubscribe-auth/AL2THYQJICTJQGNGFOTYXVTXGJPXPANCNFSM6AAAAAAUXGU6AY . You are receiving this because you authored the thread.Message ID: @.***>
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.template: sensor: # hourlyy Values # Hour0 (Note H0 in OPW is last hour. Current hour is H1. So, call shift H1 to H0, etc - name: 'Openweather Temp 0h' state: > {% if state_attr('sensor.openweather_report', 'hourly')[1].temp is defined %} {{ ( state_attr('sensor.openweather_report', 'hourly')[1].temp | float(0) ) | round(1) }} {% else %} 0 {% endif %} attributes: dt: "{{ state_attr('sensor.openweather_report', 'hourly')[1].dt }}" date_time: "{{ state_attr('sensor.openweather_report', 'hourly')[1].dt | timestamp_custom('%Y-%m-%d %H:%M', true) }}" state_class: measurement device_class: temperature unit_of_measurement: '°F'
Sorry for late reply - life and all that.
This is brilliant and thanks for sharing! 👍
I have got my API to work (for some reason once_call
had stopped working and I had to resubscribe to it).
I am only using a few sensors (rain/temp today, tomorrow, day after) for irrigation so made them manually from your template above.
I'm not sure if this helps, but I modified it slightly using availability
. I also noticed that you don't need |float (0)
.
- name: 'Openweather Temp 0h'
availability: "{{ state_attr('sensor.openweather_report', 'hourly') not in [none,'unknown', 'unavailable'] }}"
state: "{{ ( state_attr('sensor.openweather_report', 'hourly')[1].temp| round(1) }}"
attributes:
dt: "{{ state_attr('sensor.openweather_report', 'hourly')[1].dt }}"
date_time: "{{ state_attr('sensor.openweather_report', 'hourly')[1].dt | timestamp_custom('%Y-%m-%d %H:%M', true) }}"
state_class: measurement
device_class: temperature
unit_of_measurement: '°F'
edit: I think your way is better than using availability
though as my way still causes a log entry on startup - I think to do with the use of none
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.
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.
Hey there @fabaff, @freekode, @nzapponi, any news on supporting both Daily and Hourly in a single instance, now that the get.forcasts supports multiple types.
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.
any updates ?
This still doesn't work. Just can't get OpenWeather to work with the onecall api. Removed added, restarted, tried mulitple keys which work fine in the browser. Nothing works. The only one that works is the normal hourly call. All the others it will just say failed.
looks like this now supported in latest release.
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.
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 addOneCall 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:
Anything in the logs that might be useful for us?
Additional information
DarkSky will be unsupported next month in March. Please help us migrate to another platform.