Get precipitation forecast
Use this action to retrieve the precipitation forecast series for one of your Environment Canada locations: a short-interval series covering the recent past and the next hour or so, and an hourly series covering up to the next two days. The result is intended for building your own precipitation chart, for example with a template sensor or a custom card.
This action returns its result in a response variable, which you can use in later steps of the same automation or script.
Using this action from the user interface
If you prefer building automations and scripts visually, Home Assistant walks you through this action step by step. You pick what to target, tweak a few options, and save. No YAML knowledge required.
To get the precipitation forecast from an automation or a script:
- Go to Settings > Automations & scenes.
- Open an existing automation or script, or select Create automation > Create new automation.
- If you’re setting up a new automation, add a trigger in the When section. Scripts don’t need a trigger. They run when something else calls them.
- In the Then do section, select Add action.
- From the search box, search for and select Environment Canada: Get precipitation forecast.
- Select the Environment Canada service to get the precipitation forecast for, and set any of the options you need.
- In the Response variable field, enter a name to store the data in, such as
precipitation. - Select Save.
This action does not support targets. In the UI, you are not prompted to choose an area, device, entity, or label.
Options in the UI
The Environment Canada location to get the precipitation forecast for.
Which precipitation type to report. One of auto, rain, or snow. Defaults to auto, which detects the type from radar.
How far back the short-interval series reaches, in minutes, from 0 to 180. Defaults to 60.
How far ahead the short-interval series reaches, in minutes, from 0 to 72. Defaults to 72.
Using this action in YAML
If you work directly in YAML, or you want to know exactly what Home Assistant does under the hood, this section has the technical reference. It lists the field names you use in YAML, their types, and which ones are required.
In YAML, refer to this action as environment_canada.get_precipitation_forecast. Store the result in a response variable so you can use it in later steps:
action: environment_canada.get_precipitation_forecast
data:
config_entry_id: YOUR_CONFIG_ENTRY_ID
response_variable: precipitation
This stores the precipitation forecast series for the selected location in precipitation.
Options in YAML
The Environment Canada location to get the precipitation forecast for.
Which precipitation type to report. One of auto, rain, or snow. Defaults to auto, which detects the type from radar.
How far back the short-interval series reaches, in minutes, from 0 to 180. Defaults to 60.
How far ahead the short-interval series reaches, in minutes, from 0 to 72. Defaults to 72.
Response data
The response has three keys:
-
nowcast: A short-interval precipitation rate series, combining recent observed radar with roughly the next hour of radar extrapolation. -
hourly: An hourly precipitation amount, probability, and type series, covering up to the next two days. -
metadata: Attribution and reference information for the series, such as the timestamp of the most recent radar observation.
Each nowcast entry has a timestamp field along with fields such as rate, unit, precip_type, and forecast, which is true for an extrapolated entry and false for an observed one. Each hourly entry has a timestamp field along with fields such as amount, probability, conditional_amount, expected_amount, and precip_type.
nowcast:
- timestamp: "2024-01-01T12:00:00+00:00"
rate: 1.2391
unit: mm/h
precip_type: rain
forecast: false
hourly:
- timestamp: "2024-01-01T13:00:00+00:00"
amount: 1.726
probability: 57
conditional_amount: 0.909
expected_amount: 0.518
precip_type: Rain
metadata:
attribution: Data provided by Environment Canada
timestamp: "2024-01-01T12:00:00+00:00"
Good to know
- Unlike the weather and radar camera entities in this integration, this action is not backed by a coordinator: each call queries Environment Canada directly, so the response reflects the latest available radar and model data at the time of the call.
- Repeated calls with the same location and options within a few minutes can reuse a very recent result instead of triggering a new query.
Try it yourself
Ready to test this? Open Settings > Tools > Actions, search for this action, fill in the fields, and select Perform action. You see what happens on your actual entitiesAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more] without writing a line of YAML.
More examples
Real scenarios where this action shows up in automations and scripts. Copy any example and adapt it to your setup.
You don’t need to edit YAML to use these examples. Copy a YAML snippet from this page, open the automation editor in Home Assistant, and press Ctrl+V (or Cmd+V on Mac). Home Assistant automatically converts the pasted YAML into the visual editor format, whether it’s a full automation, a single trigger, a condition, or an action.
Automation: notify about rain in the next hour
This automation checks the short-interval series every 10 minutes and, if any of the next hour’s rates are above zero, notifies you with the upcoming rates so you know rain is about to start without checking the app.
- Trigger: Time pattern (every 10 minutes)
-
Action: Get precipitation forecast
- Precipitation type: Rain
- Past minutes: 0
- Future minutes: 60
- Condition: Template
-
Action: Send a notification message
-
Target: My Device (
notify.my_device)
-
Target: My Device (
YAML example for notifying about rain in the next hour
alias: "Notify about rain in the next hour"
triggers:
- trigger: time_pattern
minutes: "/10"
actions:
- action: environment_canada.get_precipitation_forecast
data:
config_entry_id: YOUR_CONFIG_ENTRY_ID
precip_type: rain
past_minutes: 0
future_minutes: 60
response_variable: precipitation
- condition: template
value_template: >
{{ precipitation.nowcast | selectattr('rate', 'gt', 0) | list
| count > 0 }}
- action: notify.send_message
target:
entity_id: notify.my_device
data:
message: >
Rain expected in the next hour: {{ precipitation.nowcast
| map(attribute='rate') | list }}
Automation: notify about precipitation in the next 24 hours
This automation runs every evening, retrieves the hourly series, and notifies you with the total expected amount, so you can plan for the next day.
- Trigger: Time (21:00)
- Action: Get precipitation forecast
-
Action: Send a notification message
-
Target: My Device (
notify.my_device)
-
Target: My Device (
YAML example for notifying about precipitation in the next 24 hours
alias: "Notify about precipitation in the next 24 hours"
triggers:
- trigger: time
at: "21:00:00"
actions:
- action: environment_canada.get_precipitation_forecast
data:
config_entry_id: YOUR_CONFIG_ENTRY_ID
response_variable: precipitation
- action: notify.send_message
target:
entity_id: notify.my_device
data:
message: >
Expected precipitation over the next 24 hours: {{
precipitation.hourly | sum(attribute='expected_amount')
| round(1) }} mm.
Still stuck?
The Home Assistant community is quick to help: join Discord for real-time chat, post on the community forum with the action you’re calling and what you expected to happen, or share on our subreddit /r/homeassistant.
AI assistants like ChatGPT or Claude can also explain actions or suggest the right one when you describe what you want in plain language.
Related actions
Explore related actions:
-
Get alerts: Retrieves the active weather alerts for an Environment Canada location.
-
Get forecasts: Retrieves the raw daily and hourly forecast data from Environment Canada.
-
Set radar type: Sets the type of radar imagery shown by an Environment Canada radar camera.