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

Basically for the conditional card you’d have something like this:

  • type: conditional
    - entity: sensor.ec_warning

As you can see the sensor had not just a Wind Warning but also a Special Weather Statement, on Sunday there were 3 warnings for my area.

I think having 3 sensors might be the best way to handle this. Something like Statement, Watch, and Warning sensors. The question is do you just have these sensors be binary either on or off? Then let the user do what they will from there? or do you have the warning in the sensor similar to how it is now but broken out by the 3 categories?

Personally I like the idea of the sensors being just on or off but that being said I don’t see why I couldn’t create binary sensors have them trigger if one of the 3 is active to achieve my end goal.

Not sure how it would be done but maybe setting the sensors up to allow end users to have the alerts broadcasted on TTS. I don’t know if that means having the alert data in the sensor or something more complicated. Just trying to future think uses for this great tool.

Now if only Environment and Climate Change Canada had an api.

Haven’t tried this component yet, but for EC warnings I’m creating persistent notifications. A few times a day I scrape the EC XML using node red and create a persistent notification from that. Then with Lovelace I use a conditional card and markdown to display the persistent notification if it exists. Ultimately I think Lovelace could use a “list” card that’ll list persistent notifications or other stuff.

Could you invert your condition to say: state_not: “unknown” (or whatever the sensor says when there are no warnings in effect)? That should trigger it for your 3 categories.

Have the new version running now. Will report back if anything looks strange. Thanks again.

@davidbb thanks for that tip. That is a great short term fix. Ideally I’d love to have the conditional card coloured Grey, Yellow, Red based on whether it’s a Statement, Watch, or Warning.
Now I just need to wait for a weather alert to be sure it’s working :slight_smile:

FWIW, based on my experience of having created an Environment Canada weather driver in 2009 (and I’ve been using it ever since), whatever strategy is chosen to represent EnviroCan’s alerts (Statement, Watch, Warning, Ended) be advised that multiple alerts can be in effect for the same region.

For my purposes, I dispensed with Statements and focused on reporting Watch, Warning, and Ended. Other than announcing the alerts (via the home’s PA system), they’re also used to set the thermostat’s background color as yet another means of grabbing our attention (Watch=yellow, Warning=red, Ended=green).

Hi @michaeldavie just an idea that I don’t know if it’s possible or not, but could the radar image have some of the city names added?

This may be possible. It looks like the env_canada library pulls the base radar gif from Environment Canada, and this gif does not include any additional data. What Environment Canada does on their site is overlay several other gifs (one for each of roads, town names, road numbers, etc). I don’t think this is possible in Python directly without including an external dependency, but @michaeldavie may know more.

Okay, another fairly big update:

  • I’ve made a few changes to the radar component. It will now switch between the regular and the fallback COMP images as required on every update, and will also handle missing frames.

  • I’ve broken out the categories of alerts into separate sensors as suggested by @rlongfield. Multiple alerts of the same type are still concatenated together.

  • Your configuration may need to be updated:

    • warning is no longer valid as a monitored_condition
    • New sensors for alerts are:
      • warnings
      • watches
      • advisories
      • statements
      • endings

The component files have been updated on Dropbox and Github. The env_canada library has also been updated to 0.0.6, and this will need to be installed as well.

Thanks again to everyone for all of your help, and keep the bug reports and suggestions coming!

I’m already leveraging imageio to build the animated GIFs, and I imagine that it could do the overlays as well. I just found where they’ve been hiding the overlays (, so I’ll look into this next.

Quick question. Do I need to apply the 0.0.4 update and then the 0.0.6 update?
Also to apply the update for Docker I’ll need to run:

docker exec [container name] pip install env_canada==0.0.6 --target /config/deps/lib/python3.6/site-packages --upgrade

Thanks for your great work!

You do not need to apply 0.0.4 before updating to 0.0.6.

Thanks @michaeldavie. Running the latest version of env_canada and the custom component. Looks like fails if there are no alerts in the EC data on startup:

Traceback (most recent call last):
File "/usr/local/lib/python3.5/site-packages/homeassistant/helpers/", line 128, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File "/usr/local/lib/python3.5/asyncio/", line 406, in wait_for
return fut.result()
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 103, in setup_platform
for sensor_type in config[CONF_MONITORED_CONDITIONS]])
File "/root/.homeassistant/custom_components/environment_canada/", line 103, in <listcomp>
for sensor_type in config[CONF_MONITORED_CONDITIONS]])
File "/root/.homeassistant/custom_components/environment_canada/", line 116, in __init__
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 146, in update
AttributeError: 'ECData' object has no attribute 'alerts'

My config:

  • platform: environment_canada
    • wind_chill
    • pop
    • warnings
    • watches
    • advisories
    • statements
    • endings

That’s odd. The alerts dictionary is created when the ECData object is created, so I’m not sure how it could be absent. Maybe try removing all versions of env_canada and installing just 0.0.6?

Not sure why but a restart of Home Assistant allowed the custom component to load correctly. Now seeing the new sensors. Perhaps some cache somewhere… Thanks!

1 Like

I got the overlays working, and added roads and cities. env_canada has been bumped to 0.0.7, and the files have been updated on Github and Dropbox.

For some reason I had to restart my Home Assistant a couple times for the upgrade to take as well.


The overlay looks good! Working well for me with the McGill radar. Tested on HA 0.89.0. :+1:

@michaeldavie given the testing and feedback you have received here, I suggest rebasing your PR onto 0.89.0 and asking for a review one more time. You mentioned lack of familiarity with Git a few months back but it looks like you have it under control now :slight_smile: if you need help feel free to DM me.

I tried this to update to .7

docker exec home-assistant pip install env_canada==0.0.7 --target /config/deps/lib/python3.6/site-packages --upgrade

I don’t think it worked as I am not seeing the new sensors:

  • warnings
  • watches
  • advisories
  • statements
  • endings

or the overlays on the radar map, but I am not sure how to check to see what version I am running.

Appreciate the work on this and help too :slight_smile:

@davidbb Thanks! I was thinking the same thing. Everything seems to be running smoothly now (thanks to all of the feedback!), so I think I’ll push all three components into the same PR.

@rlongfield That should have upgraded the env_canada library, but you need to make sure that the custom_component files are in sync as well. They each have a line like the following, and the version numbers need to match: REQUIREMENTS = ['env_canada==0.0.7']. You also need to restart your container after updating everything.

The latest files are at the Dropbox and Github links above. Let me know if you have any trouble.

@michaeldavie so I forgot to update the files and restart the container…
I’ll do that soonish THANKS!