home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
70.52k stars 29.45k forks source link

AirNow Integration has error "No results found for that location" #105091

Open jeffeb3 opened 8 months ago

jeffeb3 commented 8 months ago

The problem

AirNow has been giving me trouble for a little while. I removed it and am trying to re-add it.

The lat/lon fields are filled with numbers that are very very long. I'm not sure if those came from my HA location or what. There are 14 digits past the decimal place.

When I type those large numbers into the AirNow web query the boxes turn red, and the URL is built funky, so it doesn't work.

When I type smaller numbers with only 4 decimal places into the HA add integration box, I get a "No results found for that location, try changing the location or station radius". The Latitude/Longitude fields reset to the long numbers and my API key is removed.

When I use smaller numbers in the AirNow query website, I get this response:

"DateIssue","DateForecast","ReportingArea","StateCode","Latitude","Longitude","ParameterName","AQI","CategoryNumber","CategoryName","ActionDay","Discussion"
"2023-12-05","2023-12-05","Denver-Boulder","CO","39.9003","-105.042","O3","-1","1","Good","false",""
"2023-12-05","2023-12-05","Denver-Boulder","CO","39.9003","-105.042","PM2.5","-1","1","Good","false",""
"2023-12-05","2023-12-06","Denver-Boulder","CO","39.9003","-105.042","O3","-1","1","Good","false",""
"2023-12-05","2023-12-06","Denver-Boulder","CO","39.9003","-105.042","PM2.5","-1","1","Good","false",""

Maybe that is the core issue? The state of CO doesn't have any useful data right now?

What version of Home Assistant Core has the issue?

core-2023.11.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

AirNow

Link to integration documentation on our website

https://www.home-assistant.io/integrations/airnow

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 8 months ago

Hey there @asymworks, mind taking a look at this issue as it has been labeled with an integration (airnow) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `airnow` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign airnow` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


airnow documentation airnow source (message by IssueLinks)

dai80027 commented 8 months ago

Also seeing the same issue. My log says:

2023-12-12 20:00:03.749 ERROR (MainThread) [homeassistant.components.airnow.coordinator] Unexpected error fetching airnow data: No data was returned Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 300, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/airnow/coordinator.py", line 53, in _async_update_data obs = await self.airnow.observations.latLong( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pyairnow/observation.py", line 44, in latLong return await self._request( ^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pyairnow/api.py", line 86, in _get raise EmptyResponseError('No data was returned') pyairnow.errors.EmptyResponseError: No data was returned 2023-12-12 20:00:03.759 DEBUG (MainThread) [homeassistant.components.airnow.coordinator] Finished fetching airnow data in 0.258 seconds (success: False)

dai80027 commented 8 months ago

Screenshot 2023-12-12 8 15 54 PM

Looks like then problem is on AirNow's end - no info available on their web site either.

dai80027 commented 8 months ago

Screenshot 2023-12-12 9 07 36 PM

dai80027 commented 8 months ago

image

All good now.

rodalpho commented 7 months ago

Same problems here, "No results found for that location, try changing the location or station radius.". Integration appears to be broken. Confirm lat/long and API key are correct and 250 mile station radius.

I also went to the AirNow page and tested those specific lat/long and station radius numbers and they work great on their webpage with my API key embedded in the URL:

https://www.airnowapi.org/aq/forecast/latLong/?format=text/csv&latitude=40.7354&longitude=-73.9842&date=2024-01-06&distance=250&API_KEY=REMOVED

Deleting and re-adding the integration didn't help.

asymworks commented 7 months ago

@rodalpho If you are able to get data directly from the AirNow page and still have this error with the HA integration, please post the AirNow response here to help debug. Feel free to sanitize data, but please keep all the keys in the response as-is.

asymworks commented 7 months ago

In general though, the upstream EPA AirNow API is flaky and will occasionally stop sending data for a particular station. There's not much the integration can do about that except report the data as unavailable and log an error, which is what some folks here are seeing. It is usually a temporary thing, though, and the data should return in HA as soon as it does from the EPA (within a polling interval anyway).

rodalpho commented 7 months ago

@asymworks I just readded the integration and hey what do you know, you're right-- it works now, after showing offline for several days. Thanks for the support anyway!

asymworks commented 7 months ago

No worries, glad it works now :)

ziptbm commented 6 months ago

So what was the fix on this?

It stopped working for me a few days ago with an error "Unexpected error fetching airnow data: No data was returned". I've since removed the integration and attempted to re-add it and I get an error indicating no results at that location. If I run the API manually via a browser with my long and lat, it returns results. Now I can't even add it back.

ziptbm commented 6 months ago

So what was the fix on this?

It stopped working for me a few days ago with an error "Unexpected error fetching airnow data: No data was returned". I've since removed the integration and attempted to re-add it and I get an error indicating no results at that location. If I run the API manually via a browser with my long and lat, it returns results. Now I can't even add it back.

and after trying again today, it accepted and is now reporting data. Weird.

danni-storm commented 6 months ago

Update to minimum TLS requirements for https://files.airnowtech.org/ connections

Beginning December 31st, 2023, connections made to https://files.airnowtech.org/ must use Transport Layer Security (TLS) 1.2 or higher. Prior to December 31st, users connecting with TLS 1.1 or lower may experience occasional connection deprecation. For the vast majority of users accessing the site via web browser or connecting via automated script, there will be no impact. However, a small amount of users may need to update scripts if connecting to https://files.airnowtech.org/ using TLS 1.1 or lower. Thank you, EPA and AirNow Data Management Center.

Is this related to this issue at all? I have had intermittent errors for the past couple of weeks but would assume API requests would already be using TLS 1.2/1.3?


(edit) It won't let me re-add the integration at all even when increasing the range to 300 miles. Data on the website loads just fine.

image
csnavely commented 6 months ago

FWIW, my experience is the same: direct query gives results, same values supplied to the integration fails to add a location, and re-adding the integration didn't make a difference.

Results with location scrubbed look like this:

"DateIssue","DateForecast","ReportingArea","StateCode","Latitude","Longitude","ParameterName","AQI","CategoryNumber","CategoryName","ActionDay","Discussion"
"2024-02-01","2024-02-01","x","y","m","n","PM2.5","29","1","Good","false",
"2024-02-01","2024-02-02","x","y","m","n","PM2.5","33","1","Good","false",
"2024-02-01","2024-02-03","x","y","m","n","PM2.5","-1","1","Good","false",
"2024-02-01","2024-02-04","x","y","m","n","PM2.5","-1","1","Good","false",
"2024-02-01","2024-02-05","x","y","m","n","PM2.5","-1","1","Good","false",
"2024-02-01","2024-02-06","x","y","m","n","PM2.5","-1","1","Good","false",

However, I was able to add a location - 50 Rockefeller Plaza :D - in NYC with my API Key, which worked fine.

Results look like this:

"DateIssue","DateForecast","ReportingArea","StateCode","Latitude","Longitude","ParameterName","AQI","CategoryNumber","CategoryName","ActionDay","Discussion"
"2024-02-01","2024-02-01","New York City Region","NY","40.8419","-73.8359","PM2.5","58","2","Moderate","false",""
"2024-02-01","2024-02-02","New York City Region","NY","40.8419","-73.8359","PM2.5","45","1","Good","false",""

The differences I notice in my station's response are

Both kinda look like data errors, but they don't seem like they should be fatal. Perhaps the integration's feeling are too sensitive?

HTH.

asymworks commented 6 months ago

@csnavely Can you please try the JSON data endpoint from AirNow with your home location and post that santized result (if you still can't install the integration)? The integration uses the JSON endpoint, not CSV, and I suspect there may be something on AirNow's side that is giving different answers.

As evidenced by this and other threads, this is often a temporary issue on EPA's side that will resolve itself later, so do please try and re-add the integration if the JSON data looks reasonable, just to confirm that it is still an issue.

csnavely commented 6 months ago

Sure @asymworks - here's the JSON response. Those -1 AQIs look a little suspect.

[
  {
    "DateIssue": "2024-02-02",
    "DateForecast": "2024-02-02",
    "ReportingArea": "x",
    "StateCode": "y",
    "Latitude": m,
    "Longitude": n,
    "ParameterName": "PM2.5",
    "AQI": 33,
    "Category": {
      "Number": 1,
      "Name": "Good"
    },
    "ActionDay": false
  },
  {
    "DateIssue": "2024-02-02",
    "DateForecast": "2024-02-03",
    "ReportingArea": "x",
    "StateCode": "y",
    "Latitude": m,
    "Longitude": n,
    "ParameterName": "PM2.5",
    "AQI": 29,
    "Category": {
      "Number": 1,
      "Name": "Good"
    },
    "ActionDay": false
  },
  {
    "DateIssue": "2024-02-02",
    "DateForecast": "2024-02-04",
    "ReportingArea": "x",
    "StateCode": "y",
    "Latitude": m,
    "Longitude": n,
    "ParameterName": "PM2.5",
    "AQI": 25,
    "Category": {
      "Number": 1,
      "Name": "Good"
    },
    "ActionDay": false
  },
  {
    "DateIssue": "2024-02-02",
    "DateForecast": "2024-02-05",
    "ReportingArea": "x",
    "StateCode": "y",
    "Latitude": m,
    "Longitude": n,
    "ParameterName": "PM2.5",
    "AQI": 33,
    "Category": {
      "Number": 1,
      "Name": "Good"
    },
    "ActionDay": false
  },
  {
    "DateIssue": "2024-02-02",
    "DateForecast": "2024-02-06",
    "ReportingArea": "x",
    "StateCode": "y",
    "Latitude": m,
    "Longitude": n,
    "ParameterName": "PM2.5",
    "AQI": -1,
    "Category": {
      "Number": 1,
      "Name": "Good"
    },
    "ActionDay": false
  },
  {
    "DateIssue": "2024-02-02",
    "DateForecast": "2024-02-07",
    "ReportingArea": "x",
    "StateCode": "y",
    "Latitude": m,
    "Longitude": n,
    "ParameterName": "PM2.5",
    "AQI": -1,
    "Category": {
      "Number": 1,
      "Name": "Good"
    },
    "ActionDay": false
  }
]
asymworks commented 6 months ago

Thanks @csnavely - that looks like the forecast data. Is that what AirNow is returning for the current observation? Sorry, I didn't notice that in the CSV data you sent before, but the integration checks the current observation data during setup - I should have been clearer on the ask.

csnavely commented 6 months ago

Yeah @asymworks evidently the response includes both current and forecast. From what I infer, the semantics are that the current readings are the response where DateIssue = DateForecast, and the forecasted readings are the response(s) where DateIssue < DateForecast...? Not sure if that behavior is new or not.

Here's a side-by-side diff of a response for my location (sanitized) and NYC; they both seem to include both current and forecast in the response. My location does have those bogus -1 AQIs and no Discussion fields (as was shown in the CSV, too) but otherwise the differences look sane.

$ diff -y me ny 
[                               [
  {                               {
    "DateIssue": "2024-02-02",                      "DateIssue": "2024-02-02",
    "DateForecast": "2024-02-02",                   "DateForecast": "2024-02-02",
    "ReportingArea": "x",                     |     "ReportingArea": "New York City Region",
    "StateCode": "y",                         |     "StateCode": "NY",
    "Latitude": m,                        |     "Latitude": 40.8419,
    "Longitude": n,                       |     "Longitude": -73.8359,
    "ParameterName": "PM2.5",                       "ParameterName": "PM2.5",
    "AQI": 33,                            |     "AQI": 55,
    "Category": {                           "Category": {
      "Number": 1,                        |       "Number": 2,
      "Name": "Good"                          |       "Name": "Moderate"
    },                                  },
    "ActionDay": false                        |     "ActionDay": false,
                                  >     "Discussion": ""
  },                                  },
  {                               {
    "DateIssue": "2024-02-02",                      "DateIssue": "2024-02-02",
    "DateForecast": "2024-02-03",                   "DateForecast": "2024-02-03",
    "ReportingArea": "x",                     |     "ReportingArea": "New York City Region",
    "StateCode": "y",                         |     "StateCode": "NY",
    "Latitude": m,                        |     "Latitude": 40.8419,
    "Longitude": n,                       |     "Longitude": -73.8359,
    "ParameterName": "PM2.5",                       "ParameterName": "PM2.5",
    "AQI": 29,                            |     "AQI": 43,
    "Category": {                           "Category": {
      "Number": 1,                            "Number": 1,
      "Name": "Good"                              "Name": "Good"
    },                                  },
    "ActionDay": false                        |     "ActionDay": false,
                                  >     "Discussion": ""
  },                                  },
  {                               {
    "DateIssue": "2024-02-02",                      "DateIssue": "2024-02-02",
    "DateForecast": "2024-02-04",                   "DateForecast": "2024-02-04",
    "ReportingArea": "x",                     |     "ReportingArea": "New York City Region",
    "StateCode": "y",                         |     "StateCode": "NY",
    "Latitude": m,                        |     "Latitude": 40.8419,
    "Longitude": n,                       |     "Longitude": -73.8359,
    "ParameterName": "PM2.5",                       "ParameterName": "PM2.5",
    "AQI": 25,                            |     "AQI": 50,
    "Category": {                           "Category": {
      "Number": 1,                            "Number": 1,
      "Name": "Good"                              "Name": "Good"
    },                                  },
    "ActionDay": false                        |     "ActionDay": false,
                                  >     "Discussion": ""
  },                                  },
  {                               {
    "DateIssue": "2024-02-02",                      "DateIssue": "2024-02-02",
    "DateForecast": "2024-02-05",                   "DateForecast": "2024-02-05",
    "ReportingArea": "x",                     |     "ReportingArea": "New York City Region",
    "StateCode": "y",                         |     "StateCode": "NY",
    "Latitude": m,                        |     "Latitude": 40.8419,
    "Longitude": n,                       |     "Longitude": -73.8359,
    "ParameterName": "PM2.5",                     <
    "AQI": 33,                            <
    "Category": {                         <
      "Number": 1,                        <
      "Name": "Good"                          <
    },                                <
    "ActionDay": false                        <
  },                                  <
  {                               <
    "DateIssue": "2024-02-02",                    <
    "DateForecast": "2024-02-06",                 <
    "ReportingArea": "x",                     <
    "StateCode": "y",                         <
    "Latitude": m,                        <
    "Longitude": n,                       <
    "ParameterName": "PM2.5",                     <
    "AQI": -1,                            <
    "Category": {                         <
      "Number": 1,                        <
      "Name": "Good"                          <
    },                                <
    "ActionDay": false                        <
  },                                  <
  {                               <
    "DateIssue": "2024-02-02",                    <
    "DateForecast": "2024-02-07",                 <
    "ReportingArea": "x",                     <
    "StateCode": "y",                         <
    "Latitude": m,                        <
    "Longitude": n,                       <
    "ParameterName": "PM2.5",                       "ParameterName": "PM2.5",
    "AQI": -1,                            |     "AQI": 48,
    "Category": {                           "Category": {
      "Number": 1,                            "Number": 1,
      "Name": "Good"                              "Name": "Good"
    },                                  },
    "ActionDay": false                        |     "ActionDay": false,
                                  >     "Discussion": ""
  }                               }
]                               ]
csnavely commented 6 months ago

Also, just checked, and the lat/lon used for NYC above adds successfully in the AirNow integration.

asymworks commented 6 months ago

That's odd... I don't see that when I plug in the NYC lat/lng. Just to confirm once more, you're using this tool, right? https://docs.airnowapi.org/CurrentObservationsByLatLon/query (or directly querying https://www.airnowapi.org/aq/observation/latLong/current/?format=application/json&latitude=40.8419&longitude=-73.8359&distance=25&API_KEY=xxxx)?

The forecast data is still throwing me. I get the following from the CurrentObservationsByLatLon tool:

[
  {
    "DateObserved": "2024-02-04",
    "HourObserved": 9,
    "LocalTimeZone": "EST",
    "ReportingArea": "New York City Region",
    "StateCode": "NY",
    "Latitude": 40.8419,
    "Longitude": -73.8359,
    "ParameterName": "O3",
    "AQI": 28,
    "Category": {
      "Number": 1,
      "Name": "Good"
    }
  },
  {
    "DateObserved": "2024-02-04",
    "HourObserved": 9,
    "LocalTimeZone": "EST",
    "ReportingArea": "New York City Region",
    "StateCode": "NY",
    "Latitude": 40.8419,
    "Longitude": -73.8359,
    "ParameterName": "PM2.5",
    "AQI": 27,
    "Category": {
      "Number": 1,
      "Name": "Good"
    }
  }
]
csnavely commented 6 months ago

Sorry, @asymworks - I was indeed hitting the Forecast endpoint and not realizing there was a separate one for Current Observation. 😒

The behavior as of this morning is that adding the NY sensor by lat/lon works, but adding a sensor at my local lat/lon produces an empty dialog box titled "AirNow" in response (not an error in a red box, like before), but doesn't add the sensor:

AirNow empty dialog box

Very mysterious!

Also, here is that side-by-side again, my location sanitized, and using

curl 'https://www.airnowapi.org/aq/observation/latLong/current/?format=application/json&latitude=m&longitude=n&date=2024-02-04&distance=150&API_KEY=x'
[                               [
  {                               {
    "DateObserved": "2024-02-04",                   "DateObserved": "2024-02-04",
    "HourObserved": 9,                        |     "HourObserved": 12,
    "LocalTimeZone": "PST",                   |     "LocalTimeZone": "EST",
    "ReportingArea": "x",                     |     "ReportingArea": "New York City Region",
    "StateCode": "y",                         |     "StateCode": "NY",
    "Latitude": m,                        |     "Latitude": 40.8419,
    "Longitude": n,                       |     "Longitude": -73.8359,
    "ParameterName": "O3",                      "ParameterName": "O3",
    "AQI": 32,                            |     "AQI": 34,
    "Category": {                           "Category": {
      "Number": 1,                            "Number": 1,
      "Name": "Good"                              "Name": "Good"
    }                                   }
  },                                  },
  {                               {
    "DateObserved": "2024-02-04",                   "DateObserved": "2024-02-04",
    "HourObserved": 9,                        |     "HourObserved": 12,
    "LocalTimeZone": "PST",                   |     "LocalTimeZone": "EST",
    "ReportingArea": "x",                     |     "ReportingArea": "New York City Region",
    "StateCode": "y",                         |     "StateCode": "NY",
    "Latitude": m,                        |     "Latitude": 40.8419,
    "Longitude": n,                       |     "Longitude": -73.8359,
    "ParameterName": "PM2.5",                       "ParameterName": "PM2.5",
    "AQI": 2,                             |     "AQI": 23,
    "Category": {                           "Category": {
      "Number": 1,                            "Number": 1,
      "Name": "Good"                              "Name": "Good"
    }                                   }
  }                               }
]                               ]
asymworks commented 6 months ago

Thanks - the empty dialog box is new, and I'm not sure why it would be doing that. Which version of HA are you running?

I plugged your JSON data into the test cases and everything passes, so I'm not sure where things are going wrong. If you're comfortable emailing me your lat/lng (email addr in my profile) I might be able to reproduce what you're seeing better.

csnavely commented 6 months ago

This was observed on 2024.1.5, OS 11.4, right before I upgraded to 2024.1.6. (I'm always very on top of the updates, usually within a week at the most.) Now, later in the day, I just sat down and tried adding the local sensor again, and it worked without a hitch. 😒

This almost feels like there is a cached artifact of some sort that prevented that particular sensor from being added. 🤷Previous to the symptom of being unable to add it, the sensor was displaying incorrectly; that was why I tried removing and re-adding it. Maybe that particular sensor was somehow persistently tainted by a problem with the feed from AirNow? Seems far-fetched, but it's the only thing I can imagine.

In any case, it's back to normal now. Thanks for the help and suggestions! Let me know if this gives you any ideas you'd like me to test out.

asymworks commented 6 months ago

Glad to hear it finally decided to work for you. I don't have any other ideas right at the moment to check out... unfortunately these errors seem to be really hard to replicate, but definitely let me know if you see any other weirdness with it.

issue-triage-workflows[bot] commented 3 months ago

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.

SergeyZa commented 3 months ago

AirNow Web query: https://www.airnowapi.org/aq/forecast/latLong/?format=application/json&latitude=37.xxxxx&longitude=-122.xxxxx&date=2024-05-07&distance=25&API_KEY=78

AirNow Web response: [{"DateIssue":"2024-05-06","DateForecast":"2024-05-07","ReportingArea":"Concord","StateCode":"CA","Latitude":37.xx,"Longitude":-122.xx,"ParameterName":"O3","AQI":39,"Category":{"Number":1,"Name":"Good"},"ActionDay":false},{"DateIssue":"2024-05-06","DateForecast":"2024-05-08","ReportingArea":"Concord","StateCode":"CA","Latitude":37.97,"Longitude":-122.03,"ParameterName":"O3","AQI":-1,"Category":{"Number":1,"Name":"Good"},"ActionDay":false},{"DateIssue":"2024-05-06","DateForecast":"2024-05-09","ReportingArea":"Concord","StateCode":"CA","Latitude":37.97,"Longitude":-122.03,"ParameterName":"O3","AQI":-1,"Category":{"Number":2,"Name":"Moderate"},"ActionDay":false},{"DateIssue":"2024-05-06","DateForecast":"2024-05-10","ReportingArea":"Concord","StateCode":"CA","Latitude":37.97,"Longitude":-122.03,"ParameterName":"O3","AQI":-1,"Category":{"Number":2,"Name":"Moderate"},"ActionDay":false},{"DateIssue":"2024-05-06","DateForecast":"2024-05-11","ReportingArea":"Concord","StateCode":"CA","Latitude":37.97,"Longitude":-122.03,"ParameterName":"O3","AQI":-1,"Category":{"Number":2,"Name":"Moderate"},"ActionDay":false}]

HA log: Logger: homeassistant.components.airnow.coordinator Source: helpers/update_coordinator.py:315 integration: AirNow (documentation, issues) First occurred: May 6, 2024 at 11:04:00 PM (57 occurrences) Last logged: 12:12:29 AM

Unexpected error fetching airnow data Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 315, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/airnow/coordinator.py", line 65, in _async_update_data obs = await self.airnow.observations.latLong( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyairnow/observation.py", line 44, in latLong return await self._request( ^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyairnow/api.py", line 86, in _get raise EmptyResponseError('No data was returned') pyairnow.errors.EmptyResponseError: No data was returned

skitchbeatz commented 1 month ago

I too am having this issue

Query https://www.airnowapi.org/aq/forecast/latLong/?format=application/json&latitude=42.xxxx&longitude=-83.xxxx&date=2024-06-30&distance=50&API_KEY=34abcxyz

Response

{ "DateIssue": "2024-06-29", "DateForecast": "2024-06-30", "ReportingArea": "Detroit", "StateCode": "MI", "Latitude": 42.xxxx, "Longitude": -83.xxxx, "ParameterName": "O3", "AQI": -1, "Category": { "Number": 1, "Name": "Good" }, "ActionDay": false, "Discussion": "FORECAST SUMMARY: ..." } ]

Home Assistant Error:

Logger: homeassistant.components.airnow.coordinator Source: helpers/update_coordinator.py:312 integration: AirNow (documentation, issues) First occurred: 10:43:27 AM (527 occurrences) Last logged: 10:26:49 PM

Unexpected error fetching airnow data Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 312, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/airnow/coordinator.py", line 65, in _async_update_data obs = await self.airnow.observations.latLong( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyairnow/observation.py", line 44, in latLong return await self._request( ^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyairnow/api.py", line 86, in _get raise EmptyResponseError('No data was returned') pyairnow.errors.EmptyResponseError: No data was returned

skitchbeatz commented 1 month ago

Not sure what changed but the query is now working inside of HA--I'm no longer getting this error, and the integration is working as expected.

csnavely commented 1 month ago

In my experience, once the current observation API endpoint returned successfully - note: not the forecast one, as you cite above and as I was originally citing mistakenly - then configuring the integration will work. That's understandable, I think. If there were to be any improvement for anyone so inclined, I guess it would be messaging on failure, a la "The location can't be added due to an invalid response from the AirNow API. This is usually due to a transient problem with AirNow. Please try again later."

Once configured it seems to tolerate the errors. You don't see readings, but it heals eventually.

rodalpho commented 1 month ago

It does break pretty frequently, yeah, and always seems to recover eventually. A notification saying the Airnow API isn't responding but we'll keep trying would be good I guess, but ultimately this isn't the home assistant integration's problem.