Kwadwo
1
First of all I am a total coding noob. I created a template sensor of an weather integration using a subentity.
- sensor:
- name: dailyconditionforecastffm
state: "{{state_attr('weather.dwd_weather_frankfurt','forecast')[0].condition}}"
That’s working. In the next step I tried to rename the states using different if-commands, but nothing worked.
So I need a little help. Thanks in advance.
tom_l
2
What are all the states the attribute value could be?
And what do you want them renamed to?
Kwadwo
3
partlycloudy, cloudy, rain, etc.
Just want to translate them
123
(Taras)
4
List the translation for each weather condition.
Kwadwo
5
leicht bewölkt, bewölkt, Regen
123
(Taras)
6
- sensor:
- name: dailyconditionforecastffm
state: >
{% set x =
{ 'partlycloudy': 'leicht bewölkt',
'cloudy': 'bewölkt',
'rain': 'regen'
} %}
{% set y = state_attr('weather.dwd_weather_frankfurt','forecast')[0].condition %}
{{ x.get(y, 'unknown') }}
2 Likes
Kwadwo
7
That worked, thanks a lot. Tried and googled it for about a week. Never stumbled acroos this set command.
1 Like