Translate a result from state_attr

service: notify.notify
data:
  title: Previsão do tempo para amanhã
  message: >-
    {% if is_state('state_attr("weather.casa", "forecast")
    [0].condition','sunny') %}
     Ensolarado
    {% else %}
      *Erro*
    {% endif %}
     com minimas de {{
    state_attr("weather.casa", "forecast") [0].templow }}ºC e máximas de {{
    state_attr("weather.casa", "forecast") [0].temperature }}ºC

Why this doesn’t work?
And there’s another method that i can translate “sunny” to “ensolarado” as an example?
I’m trying to translate all conditions to display in a notification.
The condition that i need to translate is from the weathers info from next day.

Please post your code as text and format it with 3 `. I see a bunch of errors but I’m not going to rewrite the template. I don’t think others are willing to either.

can you help me then?

I hope there will be some folks here on the forum with knowledge that can help.

Till then, have you tried to run all or part (sometimes good idea to start with small subsets) in the template tester on the developer page of your Home Assistant system?

Yep

service: notify.notify
data:
  title: Previsão do tempo para amanhã
  message: >-
   {% if state_attr("weather.casa", "forecast")[0].condition == 'sunny' %}
     Ensolarado
    {% else %}
      *Erro*
    {% endif %}
     com minimas de {{
    state_attr("weather.casa", "forecast") [0].templow }}ºC e máximas de {{
    state_attr("weather.casa", "forecast") [0].temperature }}ºC

You can also make it easier to manage in the future if entity_id’s change by making a variable

service: notify.notify
data:
  title: Previsão do tempo para amanhã
  message: >-
   {% set forecast = state_attr("weather.casa", "forecast")[0] %}
   {% if forecast.condition == 'sunny' %}
     Ensolarado
    {% else %}
      *Erro*
    {% endif %}
     com minimas de {{ forecast.templow }}ºC e máximas de {{ forecast.temperature }}ºC
2 Likes

Yes, off course!
But in this case look:

weather.casa give me those infos:

temperature: 9
humidity: 72
pressure: 1024.9
wind_bearing: 146.6
wind_speed: 11.2
attribution: >-
  Weather forecast from met.no, delivered by the Norwegian Meteorological
  Institute.
forecast:
  - condition: sunny
    precipitation: 0
    temperature: 16.8
    templow: 5.5
    datetime: '2021-07-01T15:00:00+00:00'
    wind_bearing: 119.5
    wind_speed: 16.9
  - condition: sunny
    precipitation: 0
    temperature: 20.6
    templow: 6.1
    datetime: '2021-07-02T15:00:00+00:00'
    wind_bearing: 15.8
    wind_speed: 8.3
  - condition: partlycloudy
    precipitation: 0
    temperature: 20.6
    templow: 8.6
    datetime: '2021-07-03T15:00:00+00:00'
    wind_bearing: 221.8
    wind_speed: 6.5
  - condition: partlycloudy
    precipitation: 0
    temperature: 18.7
    templow: 9.9
    datetime: '2021-07-04T15:00:00+00:00'
    wind_bearing: 128.9
    wind_speed: 10.4
  - condition: cloudy
    precipitation: 0
    temperature: 18.7
    templow: 11
    datetime: '2021-07-05T15:00:00+00:00'
    wind_bearing: 146.9
    wind_speed: 14.4
friendly_name: Casa

With “forecast” i filter by the forecast, and with [0].condition i filter by the first line after forecast.
I tried to make this work, but codding isn’t my skills by now…

Exactly what i need! Thank you very much! <3 <3

1 Like