how to translate “cloudy or rainy” to my language (danish)
{{ vejr[‘weather.home’].forecast[1].condition }}
weather.home:
forecast:
- condition: cloudy
precipitation_probability: 0
datetime: "2024-05-04T10:00:00+00:00"
wind_bearing: 68.2
temperature: 13.5
templow: 12.6
wind_gust_speed: 2
wind_speed: 0.89
precipitation: 0
humidity: 94
- condition: rainy
precipitation_probability: 79.3
datetime: "2024-05-05T10:00:00+00:00"
wind_bearing: 108.9
temperature: 15
templow: 10.2
i don’t know what i don’t know… but i’ve not seen a way. hopefully someone else will correct me if i’m mistaken.
till then, i’d do a dictionary:
{% set translated_forecasts = {'cloudy': 'overskyet', 'rainy': 'regnfuld'} %}
{{ translated_forecasts.get(vejr['weather.home'].forecast[1].condition) }}
If it’s always a specific future condition you want you could make a template sensor and use the new state_translated
function, passing the new sensor to it.
Otherwise, if you’re just displaying forecasts on the UI, it should already be according to your locale.
How are you intending to use this? In a notification?
It’s usually better to state your use case.
1 Like
Thanks, yes it is for a notification. I had hoped that I could make it with the new state_translated option. But yes, I may make a new sensor for it.
data:
title: "Vejr udsigten for imorgen:"
data: {}
message: >-
Laveste : {{ vejr['weather.home'].forecast[1].templow|float(default=0) }} °C
Højeste : {{ vejr['weather.home'].forecast[1].temperature|float(default=0)
}} °C Vind : {{
vejr['weather.home'].forecast[1].wind_speed|float(default=0)|round(1) }} m/s
Regn : {{ vejr['weather.home'].forecast[1].precipitation|float(default=0) }}
mm. {{ vejr['weather.home'].forecast[1].condition }} test
You can. Make a sensor with the raw condition value – or as many as you need. Then in the notification’s message template field pass the sensor to the function.