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

I’ve submitted my first major pull request, and I’d really appreciate it if more experienced contributors could spare a few minutes to review it.

It’s new code to leverage leverage Environment Canada weather data, and includes weather, sensor, and camera platforms, along with a simple component to pull them all together.
https://github.com/home-assistant/home-assistant/pull/15353
Thanks in advance!

How is the progress for this component going? Looking forward to its release.

It’s all running fine locally, but to be honest I’m a bit stuck on getting it merged into the project. A large part of this is my lack of familiarity with Git, but there’s also been a bit of back and forth about whether there should be a component or not. Thanks for your interest, and I’ll try to move it forward.

Thanks for the reply.

The core team has been quite busy with their October bug and tidy blitz. I sure hope they can give you some priority now at least for some kind of Alpha release…

I would be pleased to try it here and provide feedback. I run Hassio on a Pi3+ and pretty much push it to its limits. Could be a good test for the component’s tolerance to problems. I’m not sure that I’d give the camera component much priority but the individual sensors and weather aggregate would both get a real-world workout here.

You’ve done very well with a fairly steep learning curve from what I can gather of the GH chronology. Keep up the great work!

For the radar component i use the following and it works quite well with lovelace as well.

Camera:

  • platform: generic

still_image_url: https://radblast.wunderground.com/cgi-bin/radar/WUNIDS_map?station=XFT&brand=wui&num=6&delay=15&type=C0R&frame=0&scale=1.000&noclutter=0&showstorms=0&mapx=400&mapy=240&centerx=400&centery=240&transx=0&transy=0&showlabels=1&severe=0&rainsnow=0&lightning=Hide&smooth=0&rand=25651581&lat=0&lon=0&label=you

name: “Ottawa radar”

Hi Michael,

What’s happening with your component?
Can we download and install it separately while the Home Assistant team approves it?

I really want the environnement canada data as it is the only one I trust.

Best regards,

Sure, I’d love some feedback. Here’s what it looks like on my system (in Ottawa):

31

EDIT: See the updated post below

Here are the configs that I’m using as well:

configuration.yaml

weather:
  - platform: environment_canada

camera:
  - platform: environment_canada

sensor:
  - platform: environment_canada
    monitored_conditions:
      - temperature
      - wind_chill
      - humidex
      - humidity
      - condition
      - wind_speed
      - wind_gust
      - wind_dir
      - high_temp
      - low_temp
      - pop
      - warning

weblink:
  entities:
    - name: Weather Alerts
      url: https://weather.gc.ca/warnings/report_e.html?on41     <---Change to your location
      icon: mdi:weather-lightning-rainy

groups.yaml

  weather:
    view: yes
    icon: mdi:weather-partlycloudy
    entities:
      - sensor.ec_warning
      - sensor.ec_humidex
      - sensor.ec_wind_chill
      - sensor.ec_high_temperature
      - sensor.ec_low_temperature
      - sensor.ec_chance_of_precip
      - group.weather_alerts
      - weather.ottawa_kanata_orleans   <---Change to your location
      - camera.franktown_radar          <---Change to your location

  weather_alerts:
    name: ' '
    entities:
      - weblink.weather_alerts

customize.yaml

    sensor.ec_high_temperature:
      friendly_name: Next High
    sensor.ec_low_temperature:
      friendly_name: Overnight Low
    sensor.ec_humidex:
      friendly_name: Humidex
    sensor.ec_wind_chill:
      friendly_name: Wind Chill
    sensor.ec_chance_of_precip:
      friendly_name: Chance of Precip.
    sensor.ec_warning:
      friendly_name: Warning

Hi Michael,

Thank you very much it is working very well.

I had some problems making the camera work at first but the log files & Google helped.

For those with problem with the camera, you need to install some package.

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

I’ll keep you updated if something happens.

Best regards,

1 Like

Awesome, I’m glad you like it. Let me know if you come across any other issues.

When I try to set up Environment Canada weather i get the following errors:

Platform not found: weather.environment_canada 
Platform not found: camera.environment_canada 
Platform not found: sensor.environment_canada

When checking my configuration.

i’m located in BC, so it’s not because I don’t live in Canada

Sorry, I could have been more clear about that. The components haven’t been merged in yet, so you need load them as custom components, or in the case of the sensor, sideload it.

The required files can be downloaded from the Dropbox link above, then the files need to be placed in the following folders:

Sensor: components/sensor
Weather: custom_components/weather
Camera: custom_components/camera

I hope that helps, but let me know if you have any more trouble.

I have not installed it yet but how does one specify the polling frequency?

I found this line in environment_canada.py:

from homeassistant.components.sensor.environment_canada import (
    ECData, get_station, validate_station,
    CONF_STATION, CONF_ATTRIBUTION, MIN_TIME_BETWEEN_UPDATES)

Should I put a min_times_between_updates parameter in the config file? Are the units minutes or seconds?

The time between updates is not currently configurable in the config file, though I should probably make it that way. In the meantime, you can set it for both the sensor and weather components at line 40 of sesnor/environment_canada.py, and for the camera at line 36 of its file. Both lines currently read:

MIN_TIME_BETWEEN_UPDATES = datetime.timedelta(minutes=10)

I’ve set it to 10 minutes as the (hard-coded) default as this seems to be the frequency of updates from Environment Canada.

I just found this and it’s something that I really want to implement.

I’m getting the 3 Platform not found messages

I am running my Home Assistant in docker.
I placed the camera and weather in my custom_components folder which is inside the config folder.
So my path for these two are ~/home-assistant/config/custom_components/camera and ~/home-assistant/config/custom_components/weather

For the sensor platform I placed that inside the ~/home-assistant/dep folder.
I don’t know if that is right as all my other sensors are located inside the docker container but I can’t for the life of me paste or copy file contents into the envirment_canada.py file I created (I deleted the empty file before creating the one in /dep)

Any ideas?

I’m running it in Docker too. I have my custom_components folder in the config root, with the camera and weather sub-folders underneath and the appropriate environment_canada.py file in each. The sensor file is also in the config root (but could be anywhere) and is mapped in as a core component.

Here’s how I’m mapping things in as part of my docker run command:

    -v ~/home-assistant:/config \
    -v ~/home-assistant/ec_sensor.py:/usr/src/app/homeassistant/components/sensor/environment_canada.py \

I hope that helps, but let me know if you’re still stuck.

I have this in my docker run aswell. I assumed this created the config folder in ~/home-assistant instead of it being in /usr/src/app/homeassistant/config, it looks like my assumption was correct :slight_smile:

For this one, is it basically saying the the file ec_sensor.py located in ~/home-assistant/ will appear (map) to be environment_canada.py and be found in /usr/src/app/homeassistant/components/sensor/?
I’m a bit confused though on this one, you mentioned this file was in the config root. Is that the ~/home-assistant/ folder or the ~/home-assistant/config folder?

On the host, my config folder is located at ~/home-assistant. In the container, this is mapped to /config, i.e. it’s right off the root of the container file system. This folder is where the custom_components subfolder should be, and there isn’t a config subfolder below this.

It doesn’t matter where the sensor file is on the host (or what it’s called), but it needs to be mapped into /usr/src/app/homeassistant/components/sensor/environment_canada.py in the container, because the weather component relies on it being there.

I realize that this is a bit clunky, and I have a plan of how to address it, but haven’t been able to yet. Let me know if you’re still stuck.

Sorry I’m about 90% there on fully understanding this and it’s driving me in circles,

So you have ~/home-assistant/custom_components?

As long as it works I don’t mind the clunky :slight_smile: I just want to get it working…

That’s right, I have
~/home-assistant/custom_components/weather/environment_canada.py

So I used portainer and added the bind for the volume:

/home/bert/hassio/ec_sensor.py to /components/sensor/environment_canada.py

So in HA I now have a Weather Alerts card but I am also getting:

Entity not found: camera.franktown_radar
No state available for weather.weather