Translation of a weather entity

Your sensor.meteo_saint_ciers_de_canesse only translates the state of your weather entity, whereas you need the condition of the forecast attributes translated in your automation.

This might be a useful application for a reusable template, so you can quickly and easily translate it anywhere. Create something like custom_templates/traduire.jinja with this in:

{% macro traduire(mots) -%}
{{ {'clear': 'Ciel dégagé',
    'clear-night': 'Nuit claire',
    'cloudy': 'Nuageux',
    'rainy': 'Pluie',
    'hail': 'Risque de grèle',
    'snowy': 'Neige',
    'windy': 'Venteux',
    'fog': 'Brouillard',
    'partlycloudy': 'Eclaircies',
    'pouring': 'Pluie forte',
    'lightning': 'Orages',
    'sunny': 'Ensoleillé',
    'windy-variant': 'Venteux variable',
    'exceptional': 'Exceptionnel',
    'snowy-rainy': 'Pluie verglaçante',
    'lightning-rainy': 'Pluie orageuse'}.get(mots,'error') -}}
{% endmacro -%}

Restart or call the service as described. Then in your automation:

      message: >-
        {% from 'traduire.jinja' import traduire %}
        Aujourdhui, le temps sera
        {{ traduire(state_attr('weather.saint_ciers_de_canesse','forecast')[0].condition) }}
        avec des températures minimales de
        {{state_attr('weather.saint_ciers_de_canesse','forecast')[0].templow}}°C
        et maximales de 
        {{state_attr('weather.saint_ciers_de_canesse','forecast')[0].temperature}}°C.

and your template sensor:

template:
    - sensor:
        - name: "Meteo Saint Ciers de Canesse"
          state: >
            {% from 'traduire.jinja' import traduire %}
            {{ traduire(states('weather.saint_ciers_de_canesse')) }}
3 Likes