After consulting the documentation and examples of templates and several attempts I have not succeeded.
First I changed the name of a file from WaningGibbous.jpg to GibosaMenguante.jpg. So, in the card appears the name in Spanish, but, disappears the icon.
Then I tried with my template and the name is still in English.
Check config is valid and, apparently, the template is fine
But this error appears in the log:
Log Details (WARNING)
Tue Jun 25 2019 09:59:05 GMT+0200 (hora de verano de Europa central)
Your configuration contains extra keys that the platform does not support.
Please remove [sensor]. (See /config/configuration.yaml, line 137).
Offending data: {“platform”: “template”, “sensors”: “”, “sensor”: {“moon_phases”: {“fiendly_name”: “Luna”, “entity_id”: “sensor.moon”, “value_template”: “{% set phases = { ‘new_moon’:‘Luna nueva’, ‘waxing_crescent’:‘Luna creciente’, ‘first_quarter’:‘Cuarto creciente’, ‘waxing_gibbous’:‘Gibosa creciente’, ‘full_moon’:‘Luna llena’, ‘waning_gibbous’:‘Gibosa menguante’, ‘last_quarter’:‘Cuarto menguante’, ‘waning_crescent’:‘Lluna menguante’} %} {% set phase = states(‘sensor.moon’) %} {{ phases[phase] if phase in phases.keys() else ‘fase lunar desconocida’ }}\n”}}}
This is the templates section of my configuration file:
#################################################################
# Comienza TEMPLATES
#################################################################
###### Fases de la Luna ##########################
# Iconos de Fases de la luna
- platform: template
sensors:
moon_phases:
entity_id: sensor.moon
friendly_name: 'Luna'
value_template: >
{{ states('sensor.moon').title().replace('_',' ') }}
entity_picture_template: >
{% set state = states('sensor.moon').title().replace('_','') %}
{{ '/local/luna/{}.jpg'.format(state) }}
# Nombres de las Fases de la Luna en castellano ###################
sensor:
moon_phases:
fiendly_name: Luna
entity_id: sensor.moon
value_template: >
{% set phases = { 'new_moon':'Luna nueva', 'waxing_crescent':'Luna creciente', 'first_quarter':'Cuarto creciente', 'waxing_gibbous':'Gibosa creciente', 'full_moon':'Luna llena', 'waning_gibbous':'Gibosa menguante', 'last_quarter':'Cuarto menguante', 'waning_crescent':'Lluna menguante'} %}
{% set phase = states('sensor.moon') %}
{{ phases[phase] if phase in phases.keys() else 'fase lunar desconocida' }}
###################################################################
# Finaliza TEMPLATES
###################################################################
I have come to the conclusion, I do not know if it is correct, that, instead of two templates, only one template is needed, which serves for both things, icons and names. Unfortunately, my lack of knowledge of programming languages and my difficulties with English, make me unable to find the right syntax for the template.
Again, abusing your patience and generosity, I am forced to ask for your help. Thank you.