Reviewers needed: Environment Canada component with weather, sensor, and camera (radar) platforms

I updated my PR with all three pieces. If you’re on Github, feel free to comment with your support!

Thanks again!

This morning my logs showed 4 instances of an error like this:

Error handling message: {‘id’: 18, ‘type’: ‘camera_thumbnail’, ‘entity_id’: ‘camera.mcgill_radar’}
Traceback (most recent call last):
File “/usr/local/lib/python3.5/site-packages/homeassistant/components/websocket_api/”, line 17, in _handle_async_response
await func(hass, connection, msg)
File “/usr/local/lib/python3.5/site-packages/homeassistant/components/camera/”, line 464, in websocket_camera_thumbnail
image = await async_get_image(hass, msg[‘entity_id’])
File “/usr/local/lib/python3.5/site-packages/homeassistant/components/camera/”, line 94, in async_get_image
image = await camera.async_camera_image()
File “/usr/local/lib/python3.5/asyncio/”, line 381, in iter
yield self # This tells Task to wait for completion.
File “/usr/local/lib/python3.5/asyncio/”, line 310, in _wakeup
File “/usr/local/lib/python3.5/asyncio/”, line 294, in result
raise self._exception
File “/usr/local/lib/python3.5/concurrent/futures/”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/root/.homeassistant/custom_components/environment_canada/”, line 76, in camera_image
File “/usr/local/lib/python3.5/site-packages/homeassistant/util/”, line 224, in wrapper
result = method(*args, **kwargs)
File “/root/.homeassistant/custom_components/environment_canada/”, line 101, in update
self.image = self.radar_object.get_loop()
File “/root/.homeassistant/deps/lib/python3.5/site-packages/env_canada/”, line 257, in get_loop
frames = self.get_frames(self.LOOP_FRAMES)
File “/root/.homeassistant/deps/lib/python3.5/site-packages/env_canada/”, line 246, in get_frames
frames.append(frames[count - 1])
IndexError: list index out of range

Perhaps some corner case?

Yes, it looks like it; thanks for letting me know. That could happen if there were no images available at all, which is something I’m not handling at the moment. Are you able to tell we which station you’re using, and when the errors occurred? With that I can check the source at to see what might have been going on.

It’s the CASBV station, but my logs rotated and I have lost the exact time/date of the errors. I will post again if I notice them.

1 Like

Wow, this is a real can of worms. I wasn’t handling selecting the 5-letter stations properly, which I’ve fixed now. I also needed to update the Wikipedia article that I use to get their coordinates, as the Timmins site recently changed. The new sites also output images at a different frequency, every 6 minutes instead of every 10. To handle both cases I’ve changed the way I’m scraping the GIF files from the website. I still need to fix how I detect failovers to the composite imagery.

Thanks for bringing this up!

Hi! Hope you find yourself well Michael. I’ve been testing and see things progressing well. One item that seems to not be yet addressed is the correct selection of the weather station. In my case, [ West End Ottawa ]. I’m roughly 16km from Ottawa airport and 35km from Gatineau Airport.

Here is the problem…Sensors are values from Chelsea and the Gatineau Airport. Somehow Geo Coordinates are not making the right station value. It may also be of use for some folks to pick their own station choice. Not sure if you have the code for that or not…
Let me know your thoughts and any help would be useful to help make the testing more accurate for me.


It looks like this could be because Environment Canada only reports the station locations to 2 decimal places, so they’re a bit off. If more than one station is relatively close, you might get the wrong one.

No worries though, you can definitely override it. Just add the following to your weather and sensor configurations to get the Ottawa airport instead:

station: 'ON/s0000430'

For anyone in a similar situation, the station codes are available at

Okay, time for another update. Here are the changes, in descending order of importance:

  • env_canada has been bumped to 0.0.8
  • I’ve removed the ec_ prefix from the sensors, so you’ll need to update your groups.yaml and customize.yaml if you were referring to those.
  • I’ve improved support for the 5-letter radar stations, and changed how radar fails over to composite images.
  • I’ve reordered the overlays on the radar images, so the roads are underneath the city labels.

To update:

  • Install the updated env_canada library:
    • For Docker: docker exec [container name] pip install env_canada==0.0.8 --target /config/deps/lib/python3.6/site-packages --upgrade
    • Otherwise: pip install env_canada==0.0.8 --target [config folder]/deps/lib/python3.6/site-packages --upgrade
  • Place the files from Dropbox in a folder at [config folder]/custom_components/environment_canada/
  • Restart your Home Assistant installation

As always, thanks for your feedback!

Is anyone else having issues with this component after updating to 0.90? For me it looks like weather and sensors are working, but the camera failed to start.

2019-03-21 06:07:36 ERROR (MainThread) [] Setup of platform environment_canada is taking longer than 60 seconds. Startup will proceed without waiting any longer.

Setup of platform environment_canada is taking longer than 60 seconds. Startup will proceed without waiting any longer.

using 0.0.8.

Entity not found: camera.franktown_radar…

Camera fails to initialize.

I updated yesterday, and am running into the same problem. The camera worked fine running 0.0.7

@pg.sylvestre @cariboo can you please post your version of Home Assistant? The camera platform worked fine for me on HA 0.88 and 0.89 with env_canada 0.0.8. I believe the issue is with HA 0.90.

I’m just updated to 0.91 to see if it made a difference.

Yes, it seems like something changed in the master camera component in 0.90 that broke the radar platform, and I haven’t figured out what yet. It looks like 90.1 only changed the new stream component, so I don’t know if that will help.

I’m still looking into it; thanks for your patience.

Edit: I didn’t change anything, but when I restarted my 0.90 container to capture the logs it seems to have come up properly. Weird. If you’ve tried restarting and you’re still stuck, please let me know.

@michaeldavie I’ve restarted several times and having the same issue with the radar image not working after upgrading to 0.90.

I just restarted my development version, and the camera started working again:

Now my radar image is working this morning :thinking:

well. I changes my real cameras to use stream_source: instead of input: and not the problem with the EC radar has gone away in HA version 0.90. using env_canada 0.0.8 . Don’t understand the relationship but seems to be a conflict with 0.90. stream to chrome cast function added in HA 0.90.

Just got HA 0.90.1 and everything looks good.

PS. Used Stream Component: Confirmed Cameras and Configurations to find correct streaming settings for my cameras.

Update to say that after restarting 0.90 with env_canada 0.0.8 and no changes in configuration, the radar is working again.

1 Like


Was hoping to take your component here for a preview spin before it gets integrated.

When I run this command:

pip install env_canada==0.0.8 --target /config/deps/lib/python3.6/site-packages --upgrade

I get this error

C compiler: gcc -fno-strict-aliasing -Os -fomit-frame-pointer -g -DNDEBUG -Os -fomit-frame-pointer -g -DTHREAD_STACK_SIZE=0x100000 -fPIC

compile options: '-Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -I/usr/include/python2.7 -c'
gcc: _configtest.c
removing: _configtest.c _configtest.o
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pip-install-CDQIcq/numpy/", line 415, in <module>
  File "/tmp/pip-install-CDQIcq/numpy/", line 407, in setup_package
  File "/tmp/pip-install-CDQIcq/numpy/numpy/distutils/", line 171, in setup
    return old_setup(**new_attr)
  File "/usr/lib/python2.7/site-packages/setuptools/", line 129, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib/python2.7/distutils/", line 151, in setup
  File "/usr/lib/python2.7/distutils/", line 953, in run_commands
  File "/usr/lib/python2.7/distutils/", line 972, in run_command
  File "/tmp/pip-install-CDQIcq/numpy/numpy/distutils/command/", line 62, in run
    r = self.setuptools_run()
  File "/tmp/pip-install-CDQIcq/numpy/numpy/distutils/command/", line 36, in setuptools_run
  File "/usr/lib/python2.7/distutils/command/", line 563, in run
  File "/usr/lib/python2.7/distutils/", line 326, in run_command
  File "/usr/lib/python2.7/distutils/", line 972, in run_command
  File "/tmp/pip-install-CDQIcq/numpy/numpy/distutils/command/", line 47, in run
  File "/usr/lib/python2.7/distutils/command/", line 127, in run
  File "/usr/lib/python2.7/distutils/", line 326, in run_command
  File "/usr/lib/python2.7/distutils/", line 972, in run_command
  File "/tmp/pip-install-CDQIcq/numpy/numpy/distutils/command/", line 148, in run
  File "/tmp/pip-install-CDQIcq/numpy/numpy/distutils/command/", line 159, in build_sources
  File "/tmp/pip-install-CDQIcq/numpy/numpy/distutils/command/", line 292, in build_library_sources
    sources = self.generate_sources(sources, (lib_name, build_info))
  File "/tmp/pip-install-CDQIcq/numpy/numpy/distutils/command/", line 375, in generate_sources
    source = func(extension, build_dir)
  File "numpy/core/", line 667, in get_mathlib_info
    raise RuntimeError("Broken toolchain: cannot link a simple C program")
RuntimeError: Broken toolchain: cannot link a simple C program

Command "/usr/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-CDQIcq/numpy/';f=getattr(tokenize, 'open', open)(__file__);'\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-4i8egh/install-record.txt --single-version-externally-managed --compile --home=/tmp/pip-target-uLuuDx" failed with error code 1 in /tmp/pip-install-CDQIcq/numpy/

Any idea where I might have went wrong? Running Hassio 0.90.1 on rPi3.