I have a beginner question on the migration path for conditions in automations using the weather forecast data.
The setting:
To automate my window blinds I use the weather forecast (cloudy, sunny, …) and the forecast temperature as a condition when running automations. All automations where created via UI and therefore the attributes for the weather entities could be selected in German.
That all worked fine, but if I understand the documentation of the 2023.9 update correctly, this will stop working with the weather.get_forecast service in the future.
I’m not sure that I fully understand on how to migrate to the new service approach.
Then I used the state of this sensor in the conditions in my automations.
But …
Do I have to create a seperated template (trigger) sensor for each value I want to extract (like temperature or another forecast)?
Is there a way to do this via UI or is YAML the only way?
And as the template sensors are not translated in the UI, the state value is only available in English (‘sunny’ instead of ‘sonnig’) - which means I have to translate all conditions manually hoping to have the correct translation?
This seems a quite complicated process to use weather data in automations, is there an easier way to set this up?
It stores the entire result of weather.get_forecast in a forecast attribute. Afterwards, you can access whatever you want from the forecast attribute’s value.
Thank you, the sensor is displaying all the forecast data :-).
But when I try to use the state of the sensor in an automation I cannot see any attributes and the available states are only ‘unknown’ or ‘not available’. (If I check the state of the sensor manually, I can see all the data.)
Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.
I do not know why I get this error message when HA starts:
TemplateError('UndefinedError: 'daily' is undefined') while processing template 'Template<template=({{ daily.forecast }}) renders=4>' for attribute 'forecast' in entity 'sensor.weather_forecast_daily'
20:13:51 – (ERROR) Template
Template variable error: 'daily' is undefined when rendering '{{ daily.forecast }}'
20:13:51 – (ERROR) helpers/template.py - message first occurred at 20:13:51 and shows up 2 times
Error while processing template: Template<template=({{ daily.forecast }}) renders=2>
20:13:51 – (ERROR) helpers/template.py
Hi, I use this template too and I don’t have this error. But with the new version of the weather.get_forecasts service (with an s) it no longer works because there is a header that is added to the result. Does anyone know how to solve this problem?
The new service call lets you get the forecast from multiple weather entities. The response_variable’s structure is slightly different so you have to specify which entity’s forecast you want (even if you only asked for the forecast from one weather entity).
The deprecation caused me a bit of grief too. I was using it, among other things, to identify “bad weather” in 24h forecast and store that in template “safety” binary sensors, which I would then use to notify me. But since you can’t use forecast attribute in templates anymore (post-deprecation)…
I devised a new method. State/attribute changes on weather entity will run get_forecasts, identify the same as before, and notify me if needed; no more template sensors, everything’s in one automation. Be sure to change the timedelta in the last_triggered condition to whatever you want, if you reuse this automation.
Does anyone know what the best practice is here to round the temperature values?
As we can’t use forecast attribute in templates anymore from March.
Thank you!