#Using weather.get_forecasts in timed automation?
1 messages · Page 1 of 1 (latest)
Chat GPT is often outdated for HA, but have a look at https://community.home-assistant.io/t/how-to-migrate-from-weather-integration-approach-to-new-weather-get-forecast-service/619481/
You'll see some of what you want in practice at https://github.com/DubhAd/Home-AssistantConfig/blob/live/scripts/weather_notification_accuweather.yaml#L39-L48, though I don't care about the times
I don't manage to get this working so any help is really appreciated.
Then share what you've done
This did work previously, now it doesn't render in a notification but it also does not render in an error:
weather_notification_smhi:
alias: Weather notification SMHI
sequence:
- action: weather.get_forecasts
data:
type: hourly
target:
entity_id: weather.smhi_home
response_variable: hourly
- variables:
temp_low: "{{ hourly['weather.smhi_home'].forecast|selectattr('templow')|map(attribute='templow')|min()|default(0)|round(0) }} {{ state_attr('weather.smhi_home','temperature_unit') }}"
temp_high: "{{ hourly['weather.smhi_home'].forecast|selectattr('temperature')|map(attribute='temperature')|max()|default(0)|round(0) }} {{ state_attr('weather.smhi_home','temperature_unit') }}"
- action: notify.mobile_app_daniel_iphone
data:
message: >-
{{ temp_low }} to {{ temp_high }}. {{hourly['weather.smhi_home'].forecast }}
data:
icon: "{{ weather_icon }}"
duration: 40
repeat: 2
pushIcon: 1
Have you checked the trace?
I can’t find a trace. I’m testing by executing the action in developer tools.
Run the script and then you'll have a trace
In the UI, go to settings -> automations and scenes -> scripts.
Then find that script, select the three vertical dots to the right of it, and in the dropdown select “traces”.
After the trace window opens, look to the top right for the three vertical dots again and click them. In that dropdown, select “download trace”.
Now copy the contents of that file and share it using a code share site