Support for Environment Canada platforms

Also, I checked the Environment Canada service itself and it seems to be returning data (if I’m looking at the correct source), for example: https://dd.weather.gc.ca/citypage_weather/xml/BC/s0000547_e.xml

So not sure where the chain is broken.

Since I mostly need the UV Index right now (though I want some other data in the future) I used the Scrape platform to get the data directly myself. Total workaround but it suffices for now. Looking forward figuring the root of the “unavailable” issue though.

(replace <provinceCode> and <site code> with the appropriate values from here: https://dd.weather.gc.ca/citypage_weather/xml/siteList.xml

  - platform: scrape
    name: environment_canada_max_uv_scraped
    resource: https://dd.weather.gc.ca/citypage_weather/xml/<province>/<site code>.xml
    select: "uv > index"

My sensors are returning unknown when there is no value, I suspect that unavailable might happen when the sensor is failed somehow. Unfortunately, I’m not sure what could cause this.

Is there a way to enable extra logging to help track down root cause? Happy to do some digging if I know where to look.

Does it happen to all of the sensor devices at once? I’ve sometimes seen failures on startup, but it seems weird to me that a sensor could drop to unavailable once it’s been setup.

All sensors at once. Tried removing it from the config, rebooting, re-adding, rebooting but they’re still all unavailable. I suppose it’s possible something else in the config is interfering but I can’t imagine what. No errors when config checked or on start-up and all other devices function as expected.

Found it. It’s this configuration section that breaks the sensors. If I have both the environment_canada platforms (I use one for hourly and one for daily weather reports) it breaks all the sensors. If I remove one or the other the sensors work.

Do I have the syntax wrong? Am I breaking a rule?

weather:
  - platform: environment_canada
    name: environment_canada_hourly
    forecast: hourly

  - platform: environment_canada
    name: environment_canada_daily  
    forecast: daily

FYI both those weather entities work as expected. I can display both hourly and daily reports on my dashboard with no issues. It’s just the sensors that break.

@michaeldavie any suggestions on how to trace down the cause? Or am I using it wrong or are two instances not supported?

Sorry, I haven’t had time to look at this. You’re not using it wrong; to me the platforms should be independent from each other so I’m not sure why having two copies of the weather one would break the sensors. I’ll try to take a look at this use case once 0.115 comes out tomorrow.

1 Like

Thanks for taking the time :slight_smile:

@bverkron Unfortunately what you have found is not the only issue.

As previously stated, I do not have multiple weather platforms, I only have one, yet I’m experiencing exactly the same issue.

As nobody has yet acknowledged this failure mode, I opened bug 39597 for those affected by this bug but without multiple weather platforms instances.

Thanks, but I think these are two separate issues:

  1. Sensors stop updating after a period of time; and
  2. Sensors cannot be setup at all if two weather components are in place.

Have I got that right?

1 Like

Seems correct to me, two separate issues.

Submitted a GitHub issue so it can be properly tracked and worked on. https://github.com/home-assistant/core/issues/40084 Let me know there if there’s any further information I can provide or testing I can do :smiley:

Did anyone develop some YAML code to be able to display an icon of the current weather conditions that correspond to sensor.icon_code ? Can you please share?

Looks like Environment Canada platform is broken in 0.115? It was working fine on 0.114.4 until I updated to 0.115.1, HA does not start unless it is commented out. error:

Platform error camera.environment_canada - Requirements for environment_canada not found: [‘env_canada==0.2.0’]

Works for me in 0.115.0 and 0.115.1, aside from the issues I reported above since 0.114.4

Thank you @bverkron

Still does not work. HA docker setup. I recreated HA container multiple times. No luck. same error. With simple weather integration I get same error:

Logger: homeassistant.util.package
Source: util/package.py:95
First occurred: 1:47:48 PM (1 occurrences)
Last logged: 1:47:48 PM

Unable to install package env_canada==0.2.0: ERROR: Command errored out with exit status 1: command: /usr/local/bin/python3 /usr/local/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-5tu5ofse/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple --find-links https://wheels.home-assistant.io/alpine-3.11/amd64/ --prefer-binary – setuptools wheel scikit-build cmake pip ‘numpy==1.11.3; python_version==’"’"‘3.5’"’"’’ ‘numpy==1.13.3; python_version==’"’"‘3.6’"’"’’ ‘numpy==1.14.5; python_version==’"’"‘3.7’"’"’’ ‘numpy==1.17.3; python_version>=’"’"‘3.8’"’"’’ cwd: None Complete output (24 lines): Keyring is skipped due to an exception: ‘PosixPath’ object has no attribute ‘read_text’ Looking in links: https://wheels.home-assistant.io/alpine-3.11/amd64/ Ignoring numpy: markers ‘python_version == “3.5”’ don’t match your environment Ignoring numpy: markers ‘python_version == “3.6”’ don’t match your environment Ignoring numpy: markers ‘python_version == “3.7”’ don’t match your environment Collecting setuptools Downloading setuptools-50.3.0-py3-none-any.whl (785 kB) Collecting wheel Downloading wheel-0.35.1-py2.py3-none-any.whl (33 kB) Collecting scikit-build Downloading scikit_build-0.11.1-py2.py3-none-any.whl (72 kB) Collecting cmake Downloading cmake-3.18.2.post1.tar.gz (28 kB) ERROR: Command errored out with exit status 1: command: /usr/local/bin/python3 -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-hil1x59n/cmake/setup.py’"’"’; file=’"’"’/tmp/pip-install-hil1x59n/cmake/setup.py’"’"’;f=getattr(tokenize, ‘"’"‘open’"’"’, open)(file);code=f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ egg_info --egg-base /tmp/pip-pip-egg-info-4d7e5wyi cwd: /tmp/pip-install-hil1x59n/cmake/ Complete output (5 lines): Traceback (most recent call last): File “”, line 1, in File “/tmp/pip-install-hil1x59n/cmake/setup.py”, line 7, in from skbuild import setup ModuleNotFoundError: No module named ‘skbuild’ ---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. ---------------------------------------- ERROR: Command errored out with exit status 1: /usr/local/bin/python3 /usr/local/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-5tu5ofse/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple --find-links https://wheels.home-assistant.io/alpine-3.11/amd64/ --prefer-binary – setuptools wheel scikit-build cmake pip ‘numpy==1.11.3; python_version==’"’"‘3.5’"’"’’ ‘numpy==1.13.3; python_version==’"’"‘3.6’"’"’’ ‘numpy==1.14.5; python_version==’"’"‘3.7’"’"’’ ‘numpy==1.17.3; python_version>=’"’"‘3.8’"’"’’ Check the logs for full command output.

Issue reported on Github https://github.com/home-assistant/core/issues/40346

Wish I was able to help :frowning: I gave up on this integration because of the problems I outlined above. Instead I just configured a couple scrape sensors to get the data I care about directly from Environment Canada. In my case I only really care about UV, air quality, and maybe temperature (not show).

Get the site code for the UV here:
https://dd.weather.gc.ca/citypage_weather/xml/siteList.xml

Get the cgndb code for the Air Quality here:
https://dd.weather.gc.ca/air_quality/doc/AQHI_XML_File_List.xml

Substitute the values in the < > in the urls below with the correct values from the above links. You may want to choose different values for name. I chose to match the names provided by the Environment Canada sensors so that if/when I switch back to that integration all my dashboard and calculations will continue to work and I don’t have to do a bunch of search and replace and break fix stuff :slight_smile:

Note that having the same names if you have the Environment Canada integration may cause conflicts. Mine got automatically renamed with _2 at the end until I cleaned up left over remnants of the Environment Canada integration by deleted entries from the /config/.storage/ files. I think just core.config_entries and core.entity_registry but I forget.

# Fallback for environment_canada issue. Can be disabled if / when environment_canada data is stable.
# https://community.home-assistant.io/t/support-for-environment-canada-platforms/126241/232
# Rest platform could work but would not allow matching the same name as the official integration sensors
  - platform: scrape
    name: uv_index # use same name as official Environment Canada integration for easy swapping back when bug fixed.
    unit_of_measurement: UV index
    resource: https://dd.weather.gc.ca/citypage_weather/xml/<province>/<site code>.xml
    select: "uv > index"
    scan_interval: 3600 # Every hour. Just a forecast and doesn't change much if at all throughout the day.
    
  - platform: scrape
    name: air_quality_health_index
    unit_of_measurement: AQHI
    resource: https://dd.weather.gc.ca/air_quality/aqhi/pyr/observation/realtime/xml/AQ_OBS_<cgndb>_CURRENT.xml
    select: "conditionAirQuality > airQualityHealthIndex"
    scan_interval: 600 # every 10 minutes  

I use the weather config for Environment Canada to get hourly and daily forecast info. That part seems stable at least.

weather:
  - platform: environment_canada
    name: environment_canada_hourly
    forecast: hourly

  - platform: environment_canada
    name: environment_canada_daily  
    forecast: daily
1 Like