Closed lukewaite closed 2 years ago
environment_canada documentation environment_canada source (message by IssueLinks)
Looks like my local station appears to have no current state:
Vs the Ottawa station:
I've been running into this issue, with the exact same stacktrace, so I won't duplicate that.
When the state becomes available on the environment canada site, I've found I need to restart hass to get the integration to show up. Perhaps it needs to be changed to accept no current state on startup, instead of erroring out fully for that boot?
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.
~This has been happening to ever since upgrading from 2021.7.3 to 2021.8.6 the other day, so it is still an issue.~
~I haven't had a chance to dig into it yet but I'll try to do some debugging later. FWIW, I'm using this station: https://dd.weather.gc.ca/citypage_weather/xml/AB/s0000510_e.xml~
EDIT: I just saw there was a new point release, and after upgrading, it seems to be working again. I'm not sure if that's because there was an actual fix, or if restarting HA this time finally resolved it.
It turns out that my restart was just a fluke. I am still hitting this quite regularly.
I did a bit of digging and I think this might be caused by some rate limiting that is baked into the env_canada
library:
https://github.com/michaeldavie/env_canada/blob/v0.2.5/env_canada/ec_data.py#L244-L246
Note that there is a pretty low rate limit of 2 calls per minute, at which point the update()
method will be skipped. This isn't much of an issue after the ECData
object is initialized, but if we hit the rate limit error inside __init__()
, then none of the attributes will be populated and we would see an IndexError
like in the tracebacks above.
eg:
>>> ec_data = ECData(coordinates=coords); print(len(ec_data.hourly_forecasts))
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): dd.weather.gc.ca:443
DEBUG:urllib3.connectionpool:https://dd.weather.gc.ca:443 "GET /citypage_weather/docs/site_list_en.csv HTTP/1.1" 200 32894
DEBUG:env_canada.ec_data:station_id = AB/s0000510
DEBUG:env_canada.ec_data:in update
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): dd.weather.gc.ca:443
DEBUG:urllib3.connectionpool:https://dd.weather.gc.ca:443 "GET /citypage_weather/xml/AB/s0000510_e.xml HTTP/1.1" 200 2732
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): dd.weather.gc.ca:443
DEBUG:urllib3.connectionpool:https://dd.weather.gc.ca:443 "GET /air_quality/doc/AQHI_XML_File_List.xml HTTP/1.1" 200 6313
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): dd.weather.gc.ca:443
DEBUG:urllib3.connectionpool:https://dd.weather.gc.ca:443 "GET /air_quality/aqhi/pnr/observation/realtime/xml/AQ_OBS_IACMP_CURRENT.xml HTTP/1.1" 200 525
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): dd.weather.gc.ca:443
DEBUG:urllib3.connectionpool:https://dd.weather.gc.ca:443 "GET /air_quality/aqhi/pnr/forecast/realtime/xml/AQ_FCST_IACMP_CURRENT.xml HTTP/1.1" 200 734
24
>>> ec_data = ECData(coordinates=coords); print(len(ec_data.hourly_forecasts))
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): dd.weather.gc.ca:443
DEBUG:urllib3.connectionpool:https://dd.weather.gc.ca:443 "GET /citypage_weather/docs/site_list_en.csv HTTP/1.1" 200 32894
DEBUG:env_canada.ec_data:station_id = AB/s0000510
DEBUG:env_canada.ec_data:in update
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): dd.weather.gc.ca:443
DEBUG:urllib3.connectionpool:https://dd.weather.gc.ca:443 "GET /citypage_weather/xml/AB/s0000510_e.xml HTTP/1.1" 200 2734
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): dd.weather.gc.ca:443
DEBUG:urllib3.connectionpool:https://dd.weather.gc.ca:443 "GET /air_quality/doc/AQHI_XML_File_List.xml HTTP/1.1" 200 6313
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): dd.weather.gc.ca:443
DEBUG:urllib3.connectionpool:https://dd.weather.gc.ca:443 "GET /air_quality/aqhi/pnr/observation/realtime/xml/AQ_OBS_IACMP_CURRENT.xml HTTP/1.1" 200 525
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): dd.weather.gc.ca:443
DEBUG:urllib3.connectionpool:https://dd.weather.gc.ca:443 "GET /air_quality/aqhi/pnr/forecast/realtime/xml/AQ_FCST_IACMP_CURRENT.xml HTTP/1.1" 200 734
24
>>> ec_data = ECData(coordinates=coords); print(len(ec_data.hourly_forecasts))
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): dd.weather.gc.ca:443
DEBUG:urllib3.connectionpool:https://dd.weather.gc.ca:443 "GET /citypage_weather/docs/site_list_en.csv HTTP/1.1" 200 32894
DEBUG:env_canada.ec_data:station_id = AB/s0000510
DEBUG:env_canada.ec_data:hit rate limit: too many calls
0
Please try the custom component version of this integration, which is hosted at https://github.com/michaeldavie/hass_environment_canada. This version includes a number of fixes, but is not currently part of the main HA project as it has not been integrated into the GUI config.
If this problem persists please let me know.
I can confirm that the custom component addressed the issue with the weather component but I am now getting errors when setting up the sensor component:
Sensor component:
Logger: homeassistant.components.sensor
Source: custom_components/environment_canada/sensor.py:89
Integration: Sensor (documentation, issues)
First occurred: 10:10:52 PM (1 occurrences)
Last logged: 10:10:52 PM
Error while setting up environment_canada platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/environment_canada/sensor.py", line 89, in async_setup_platform
async_add_entities(
TypeError: 'NoneType' object is not iterable
That's odd. Can you please provide some more info on your installation and configuration?
@michaeldavie the custom integration seems to be working for me, thanks!
The only issue I've noticed so far is that it seems to be missing the air_quality_health_index
sensor that the builtin integration exposes.
@gwww Are you up for adding another sensor type? I moved the AQHI data into a separate ECAirQuality
class in the library since it's a completely different data source. However, it's unique data provided by Environment Canada so it would probably be worth including.
Will look at it.
@campbellr AQHI has been added back in:
hey @michaeldavie, was the AQHI removed?
It’s coming back. PRs are backlogged. We’re looking at seeing if that work can be accelerated.
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
Upon initial installation of the Environment Canada weather integration, the integration fails to start.
What is version of Home Assistant Core has the issue?
2021.5.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
Environment Canada
Link to integration documentation on our website
https://www.home-assistant.io/integrations/environment_canada/#weather
Example YAML snippet
Additional information
No response