Support for Environment Canada platforms

Now that the Environment Canada components have been merged, please use this thread for related posts, such as:

  • Issues and troubleshooting
  • Feature requests
  • Anything else you need

And if you’ve come up with any interesting uses, please post those too!

4 Likes

I’ve made a few improvements in 0.97, some of which are breaking changes:

Overall

  • numpy only required for camera platform

Sensor

  • Breaking Changes
    • monitored_conditions configuration parameter removed
    • name configuration parameter removed
    • Entity names made consistent, like sensor.temperature.
  • New sensors
    • forecast - Title and summary of next forecast; should be useful for TTS
    • uv_index - Next forecasted UV level (thanks, @jm66!)
    • precipitation_yesterday - Total precipitation yesterday
  • Entity labels and text values now available in French using language parameter
  • Sensors no longer hidden if no data present; configure visibility with Lovelace instead
  • Entities added to the entity registry
  • Improved processing of alerts
  • Refresh period configurable with scan_interval parameter, defaults to 10 minutes

Weather

  • Next hourly forecast used to populate missing temperature and condition values

The documentation at https://www.home-assistant.io/components/environment_canada has been updated to reflect the changes.

Thanks everyone for your feedback so far. Let me know if you have any questions or run into any problems.

2 Likes

Perhaps a stupid request, if the component supports having multiple, could you post an example config for multiple cities and radars? I want to do detected default local station and maybe where my relatives live or something like that.

Sure, I’ve been doing exactly that to test the English and French versions side by side. Here’s one for my local (Ottawa) and Brandon, MB (the sensors didn’t fit in the screen capture):

weather:
  - platform: environment_canada
  - platform: environment_canada
    latitude: 50
    longitude: -100

camera:
  - platform: environment_canada
  - platform: environment_canada
    latitude: 50
    longitude: -100

sensor:
  - platform: environment_canada
  - platform: environment_canada
    latitude: 50
    longitude: -100

1 Like

Hi, i tried running this component that is integrated in the 0.95.4 Home Assistant with a freshly updated python to 3.7.3 I am not sure if it is because python was updated or another problem, but I tried and could not get it up and running. Here is my error log.

Wed Jul 17 2019 23:05:34 GMT-0300 (Atlantic Daylight Time)
Error while setting up platform environment_canada
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 126, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 416, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/environment_canada/camera.py", line 43, in setup_platform
    from env_canada import ECRadar
  File "/srv/homeassistant/lib/python3.7/site-packages/env_canada/__init__.py", line 1, in <module>
    from .env_canada import *
  File "/srv/homeassistant/lib/python3.7/site-packages/env_canada/env_canada.py", line 3, in <module>
    from PIL import Image
  File "/srv/homeassistant/lib/python3.7/site-packages/PIL/Image.py", line 93, in <module>
    from . import _imaging as core
ImportError: libopenjp2.so.7: cannot open shared object file: No such file or directory

Here is my config:

weather:
  - platform: environment_canada
    latitude: xx.xxxx
    longitude: xx.xxxx
    station: NB/s0000654
sensor:
  - platform: environment_canada
    station: NB/s0000654
    monitored_conditions:
      - temperature
      - dewpoint
      - wind_chill
      - humidex
      - pressure
      - condition
      - wind_speed
      - wind_gust
      - wind_dir
      - pop
      - warnings
      - watches
      - advisories
      - statements

Any guesses?

Thanks!

This a problem with numpy. In the latest version (which didn’t make it into 0.96) I’ve isolated this requirement to the camera platform, but I still need to dig into it more. It seems to only affect Debian / Raspbian / Hassbian.

Please try running this and restarting:
pip install numpy==1.16.4 --force-reinstall --ignore-installed --no-binary :all:

Thanks for the quick reply.

I tried installing numpy within and outside Home Assistant and I still have the same error. I also tried to disable the camera platform (I forgot to add it to my previous post of the config) and still could not load. I still have the same error…

Been loving this integration for my home. I have set up automatons to alert me when warnings are posted, which has been working well. I apologize if this has been addressed, but is it possible for me to increase the refresh rate on the warnings, faster than the 10 minutes for the other sensors?

@biochemguy Thanks, I’ll keep looking into it.

@stevenjev Yup, I switched all of the sensors to 1 minute for the next release, hopefully in 0.97.

2 Likes

If I am the only one that has this problem, I might try to do a fresh install of hassbian and see if it helps… My system has been acting weird lately.

@biochemguy No, quite a few people have reported the same issue. I still haven’t been able to replicate it as I don’t have a Raspberry Pi to test on, but it seems that on Raspbian / Hassbian you need to install these dependencies:

sudo apt-get install libatlas-base-dev libopenjp2-7

Let me know if that solves it for you and I’ll add it to the documentation.

Yes, this did work for me. The component is now working. I think it is a great idea to add it to the documentation.

Thanks a lot!

Does EnviroCan have terms of use? I’m wondering if a 1-minute polling period might be too aggressive.

I’m not sure. It’s not using any kind of API though, it’s mostly just reading the XML files that they host. It’s one of the most popular websites in Canada, so I don’t think they’ll notice.

1 Like

I’ll add my vote to setting the default update interval back to 10 min, and allowing the user to lower it as needed. While it could be cool to get the bad weather notifications within 60 sec of Env Canada posting them, is getting them within 10 mins that bad?

1 min polling by every user of this integration will definitely be visible to them as it is does not look like organic traffic. The last thing we need is for the admins on the Env Canada side to blacklist the Home Assistant user agent or worse, ask you to take down the integration.

@davidbb Sounds good, I’ve opened PRs to make the interval configurable with a default of 10 minutes.

This component is fantastic!

I’ve been working on setting up automation for warnings, advisories, watches. Curious how the ‘hidden’ attribute is toggled?

Would it be appropriate to use in an automation condition so that it only fires when there actually something to look at (ie the alert/warning/advisory is populated)?

If not, what’s the cleanest way to do this?

Current progress:

"Outside, it will be {{ states('sensor.condition') }} with a current temperature of {{ states('sensor.temperature') }} degrees. 
The forecast for today is a high of {{ states('sensor.high_temperature') }} degrees and a low of {{ states('sensor.low_temperature') }} degrees. 
{% if state_attr('sensor.warnings', 'hidden')!='true' %} There is a {{ states('sensor.warnings') }} in effect. {% endif %}

 {% if state_attr('sensor.advisories', 'hidden')!=true %} There is a {{ states(' sensor.advisories') }} in effect. {% endif %}

{% if state_attr('sensor.ended', 'hidden')!=true %} The {{ states('sensor.ended') }}  {% endif %}

I’m looking to do something similar with alerts. I’d love to have HA announce with TTS on my Sonos when an alert comes up!

Achievable with an automation.

There was a bit of this at the very end of the earlier thread:

I’ve also added the basic TTS script that I wrote to the documentation for the next release.

As of right now the hidden attribute is toggled based on whether there’s a value for the state or not. However, as of the next release it won’t be using the hidden attribute; entities can be hidden or shown using Lovelace instead (admittedly, I’m not sure how to do this myself).

On the automation side, you could try something like this:

automation:
  trigger:
    platform: state
    entity_id: sensor.warnings, sensor.watches
  action:
    service: script.turn_on
    entity_id: script.alert_tts