Environment Canada
The Environment Canada integrationIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more] provides meteorological data for Canadian locations from Environment and Climate Change Canada.
Configuration
To add the Environment Canada service to your Home Assistant instance, use this My button:
Manual configuration steps
If the above My button doesn’t work, you can also perform the following steps manually:
-
Browse to your Home Assistant instance.
-
In the bottom right corner, select the
Add Integration button. -
From the list, select Environment Canada.
-
Follow the instructions on screen to complete the setup.
Location selection
Choose your weather location using either:
- Station selector: Select a station location from a dropdown of all Environment Canada weather stations.
- Coordinates: Provide latitude and longitude to automatically find the nearest station (defaults to your Home Assistant location).
Entities
The integration will create the entities listed below.
Weather
- Current conditions, daily forecast, and hourly forecast
Radar map (Camera)
- Loop of radar imagery from the last 3 hours.
- This entity is disabled by default and can be enabled in the entry’s settings dialog.
- Radar display settings can be customized through the integration options. See Radar camera options below.
Sensors
Conditions and forecasts
- Current condition
- Forecast summary
- Icon code of current condition
- Barometric pressure
- Pressure tendency
- Humidity
- Visibility
- UV index
- Air quality health index (AQHI)
Temperature
- Temperature
- Forecast high temperature
- Forecast low temperature
- Dewpoint
- Wind chill (only at temperatures below 0ºC)
- Humidex (only at temperatures above 19ºC)
Wind
- Wind speed
- Wind gust
- Wind direction
- Wind bearing
Precipitation
- Probability of precipitation
Alerts
- Warnings
- Watches
- Advisories
- Statements
- Endings
The alert sensors use the number of current alerts as their state, with an attribute containing the title of each alert.
Radar camera options
You can customize the radar display settings. The following settings are available:
- Radar type: The radar layer to display: Rain, Snow, or Precipitation type (a composite layer showing the type of precipitation). The default is Precipitation type.
- Show legend: Whether to show the color legend on the radar image (default: off).
- Show timestamp: Whether to show the timestamp on the radar image (default: on).
- Radar opacity: Opacity of the radar overlay, from 0 to 100 (default: 65).
- Map radius: Radius of the radar map in kilometers, from 10 to 2,000 km (default: 200 km).
Configuring radar camera display
To configure the radar camera display:
- Go to Settings > Devices & services.
- Select the Environment Canada integration.
- Select Configure (the cogwheel icon).
- Change the options you want.
- Select Submit.
Changing these settings reloads the integration, so the new radar settings take effect immediately. The radar camera entity is briefly unavailable during the reload.
Solving problems
The Environment Canada service is very stable and provides high-quality data. Here are some steps that you can take before opening a problem report or posting on the forum.
Service interruptions
Although infrequent, there have been some outages and instabilities of the Environment Canada service. If you see error messages in your logs similar to the one below, it is very unlikely to be a problem with this integration and is likely a problem with the Environment Canada service.
2022-10-05 12:25:08.619 ERROR (MainThread) [homeassistant.components.environment_canada] Timeout fetching environment_canada weather data
The first course of action should be to check if there are known problems with the service. Look for recent messages on the Environment Canada mailing list (example message). The next course of action is to post on the forum. The answers are usually already known by someone.
Sensor unavailable or unknown
Not all weather stations provide a complete set of weather/sensor data. The data that is retrieved by this integration can be found here. Browsing the XML data for your station will help you to understand what data is (un)available.
Template sensors
The configuration snippets below add template sensors. See the weather integration for additional examples.
Replace NAME with the weather entity used in your configuration.
Feels Like
A sensor that takes into account the humidex or wind chill for what the temperature feels like.
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 %}
Additional Forecast Data
The configuration snippet below adds a template sensor containing the current forecast information as attributes and the text summary of the forecast for the current day.
- 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') }}"
Alerts
To get the alerts in a sensor with all the alert data, use the following, replacing CONFIG_ENTRY_ID with an actual config_entry_id. Note, this updates the sensor every minute, adjust to your needs. The Environment Canada integration updates forecast data, which includes alerts, every 5 minutes.
- trigger:
- platform: time_pattern
minutes: "/1"
- platform: homeassistant
event: start
- platform: event
event_type: event_template_reloaded
actions:
- action: environment_canada.get_alerts
data:
config_entry_id: "CONFIG_ENTRY_ID"
response_variable: alerts
sensor:
- name: "Medicine Hat Alert Data"
unique_id: "CONFIG_ENTRY_ID"
state: "{{ alerts.values() | map('length') | sum }}"
attributes:
alerts: "{{ alerts }}"
List of actions
The Environment Canada integrationIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more] provides the following actions. Each link below opens a dedicated page with examples, parameters, and a step-by-step UI walkthrough.
-
Get alerts (
environment_canada.get_alerts) Retrieves the active weather alerts for an Environment Canada location. -
Get forecasts (
environment_canada.get_forecasts) Retrieves the raw daily and hourly forecast data from Environment Canada. -
Set radar type (
environment_canada.set_radar_type) Sets the type of radar imagery shown by an Environment Canada radar camera.
For an overview of every action across all integrations, see the actions reference.