Can anyone advise me on how to use the weather integration? I’m trying to set up a simple automation that will speak a simple local weather forecast but, as often with HA, I’m lost. Because the documentation doesn’t include any "how to"s, I’ve managed to add the integration and start to create the automation but am then clueless on how to output the forecast.
When setting up the integration I entered the API key from OpenWeatherMap The documentation says “There is currently support for the following device types within Home Assistant: * Sensor * Weather” but I saw only sensor, the device I don’t want.
I don’t understand what “device” or “area” mean in this context. Is this the device to output the forecast or a sensor that will read the temperature, humidity etc (which I don’t have)? In the context of weather forecasting I would expect area to be my geographical area, but HA is only asking me to enter an area within my house and I can’t see where or how to specify which geographical area forecast is wanted. Presumably I need to add some fields from the forecast structure that OpenWeatherMap returns, but can only see a list of conditions and no way to get a summary, or any other examples of how to use them.
When deleting the integration and adding it again I see the following at the point where I would expect to have to specify the weather device - why does HA ask only for an area?
From the docs: “Devices are a logical grouping for one or more entities.” A device may represent a physical device which can have one or more sensors or it may just be a collection of entities provided by a single integration without a physical object.
HA only asks for an area because there are no other user-configurable inputs, everything else is handled by the integration based on the latitude and longitude you already provided. You do not need to assign an Area, it is optional.
By calling the weather.get_forecast service in the Developer tools > Service tool you can get a YAML representation of the response data. You will need to use Templates to parse and output the desired information.
alias: Weather
description: ""
trigger:
- platform: conversation
command:
- What's the weather forecast
- What's the weather
condition: []
action:
- service: weather.get_forecast
data:
type: daily
target:
entity_id: weather.openweathermap
response_variable: w
- service: tts.speak
data:
cache: true
media_player_entity_id: media_player.all
message: |-
{% set next = w.forecast[0] %}
The forecast for today is
{{ next.temperature}} degrees and {{ next.condition }} with a
{{ next.precipitation_probability }} percent chance of precipitation.
mode: single
For anyone setting up custom sentences and intent scripts
custom_sentences/en/
language: en
intents:
CustomGetWeather:
data:
- sentences:
- "(what is | what's | whats) {ord_day} local weather"
- "(what is | what's | whats) the local weather"
- "(what is | what's | whats) the local weather {ord_day}"
- "{ord_day} weather report"
lists:
ord_day:
values:
- "today's"
- "todays"
- "tomorrow's"
- "tomorrows"
configuration.yaml
intent_script:
CustomGetWeather:
action:
- service: weather.get_forecast
data:
type: daily
target:
entity_id: weather.openweathermap
response_variable: w
- stop: ""
response_variable: w
speech:
text: |
{% set day = 1 if (ord_day is search('tomorrow') or now().hour > 21) else 0 %}
{% set next = action_response.forecast[day] %}
The forecast for {{ 'tomorrow' if day else 'today'}} is high of
{{ next.temperature}} degrees and {{ next.condition }} with a
{{ next.precipitation_probability }} percent chance of precipitation.