Meteorological data for Canadian locations from Environment and Climate Change Canada.
This custom component provides the same functionality as the built-in environment_canada integration, plus features from pending pull requests that have not yet been merged into Home Assistant core.
Features beyond the built-in integration:
- Precip Type radar layer — shows precipitation type classification in addition to rain and snow layers (from core PR #161602)
- Richer alert data — a single
alertssensor replaces the five separate category sensors; each alert exposes title, colour, area, text, status, confidence, impact, and more (from core PR #164481) - Configurable radar camera — radar type, legend, timestamp, opacity, and map radius are all adjustable from the integration's Configure dialog
- Click the button above, or open HACS in your Home Assistant instance, go to Integrations, click ⋮ → Custom repositories, and add
michaeldavie/environment_canada_hacsas an Integration. - Search for Environment Canada and install it.
- Restart Home Assistant.
- Copy the
custom_components/environment_canadadirectory into your<config>/custom_components/directory. - Restart Home Assistant.
After installation, add the integration via Settings → Devices & Services → Add Integration → Environment Canada.
Choose your weather location using either:
- Station selector — select a station from a dropdown of all Environment Canada weather stations.
- Coordinates — provide latitude and longitude to automatically use the nearest station (defaults to your Home Assistant location).
This custom component uses the same domain (environment_canada) and will replace the built-in integration. Before installing:
- Go to Settings → Devices & Services and remove the existing Environment Canada integration.
- Install this custom component and restart Home Assistant.
- Re-add the integration via Add Integration.
Note: Your entity IDs will be the same after re-adding, so most automations and dashboards will continue working. The one exception is the alert sensors — see below.
The five separate alert category sensors have been replaced by a single combined sensor.<name>_alerts entity. If you have automations or dashboard cards that reference the old entity IDs, update them as follows:
| Old entity | Replacement |
|---|---|
sensor.<name>_advisories |
sensor.<name>_alerts filtered by type == 'advisory' |
sensor.<name>_warnings |
sensor.<name>_alerts filtered by type == 'warning' |
sensor.<name>_watches |
sensor.<name>_alerts filtered by type == 'watch' |
sensor.<name>_statements |
sensor.<name>_alerts filtered by type == 'statement' |
sensor.<name>_endings |
sensor.<name>_alerts filtered by type == 'ending' |
To replicate an old per-category count (e.g. warnings), use a template:
{{ state_attr('sensor.NAME_alerts', 'alerts')
| selectattr('type', 'eq', 'warning')
| list | count }}Current conditions, daily forecast, and hourly forecast.
A loop of radar imagery from the last 3 hours. This entity is disabled by default — enable it from the entity's settings dialog.
The camera is configurable via Settings → Devices & Services → Environment Canada → Configure:
| Option | Default | Description |
|---|---|---|
| Radar type | Precipitation type | Rain, Snow, or Precipitation type |
| Show legend | On | Toggle the colour legend overlay |
| Show timestamp | On | Toggle the timestamp overlay |
| Radar opacity | 65 | Opacity of the radar layer (0–100) |
| Map radius | 200 km | Radius of the radar map |
Changes take effect immediately after saving (the integration reloads automatically).
The radar type can also be changed at runtime without a reload using the environment_canada.set_radar_type action (see Actions below).
- Current condition
- Forecast summary
- Icon code
- Barometric pressure
- Pressure tendency
- Humidity
- Visibility
- UV index
- Air quality health index (AQHI)
- Temperature
- Forecast high temperature
- Forecast low temperature
- Dewpoint
- Wind chill (only below 0 °C)
- Humidex (only above 19 °C)
- Wind speed
- Wind gust
- Wind direction
- Wind bearing
- Probability of precipitation
-
Alerts — total count of active alerts across all categories. The
alertsattribute contains a list of all active alerts. Each alert may include:Field Description titleAlert name issuedPublication datetime colorRisk colour level (e.g. yellow,red)expiryExpiration datetime urlLink to the full alert text textFull alert text (WFS source only) areaGeographic area name (WFS source only) statusAlert status, e.g. active(WFS source only)confidenceConfidence level (WFS source only) impactImpact description (WFS source only) alert_codeAlert code (WFS source only) typeAlert type: advisory,warning,watch,statement, orendingWFS-only fields are omitted when the integration falls back to XML parsing.
Although infrequent, there have been some outages of the Environment Canada service. If you see errors similar to the one below, check the Environment Canada mailing list for known issues before opening a report.
2022-10-05 12:25:08 ERROR Timeout fetching environment_canada weather data
Not all stations provide a complete set of data. Browse the raw XML for your station to see what data is available.
Replace NAME with the name of your weather or sensor entity.
template:
- sensor:
- name: "Feels Like"
device_class: temperature
unit_of_measurement: "°C"
state: >
{% if not is_state('sensor.NAME_humidex', 'unknown') %}
{{ states('sensor.NAME_humidex') }}
{% elif not is_state('sensor.NAME_wind_chill', 'unknown') %}
{{ states('sensor.NAME_wind_chill') }}
{% else %}
{{ states('sensor.NAME_temperature') | round(0) }}
{% endif %}template:
- trigger:
- platform: time_pattern
hours: "/4"
- platform: homeassistant
event: start
- platform: event
event_type: event_template_reloaded
actions:
- action: environment_canada.get_forecasts
target:
entity_id: weather.NAME
response_variable: forecasts
sensor:
- name: Weather Forecast Daily
unique_id: weather_forecast_daily
state: "{{ states('weather.NAME') }}"
attributes:
daily: "{{ forecasts['weather.NAME']['daily_forecast'] }}"
hourly: "{{ forecasts['weather.NAME']['hourly_forecast'] }}"
summary: "{{ forecasts['weather.NAME']['daily_forecast'][0]['text_summary'] }}"
temperature_unit: "{{ state_attr('weather.NAME', 'temperature_unit') }}"{{ state_attr('sensor.NAME_alerts', 'alerts')
| selectattr('type', 'eq', 'warning')
| list | count }}{{ state_attr('sensor.NAME_alerts', 'alerts')
| map(attribute='title')
| list | join(', ') }}Returns the raw Environment Canada forecast data (both daily_forecast and hourly_forecast).
| Parameter | Description |
|---|---|
entity_id |
The weather entity to get the forecast for |
Sets the radar layer for the camera entity.
| Parameter | Description |
|---|---|
entity_id |
The camera entity to update |
radar_type |
One of Auto, Rain, Snow, or Precip Type |
Auto selects Rain from April through October and Snow from November through March.