Akriss
(kris)
December 15, 2022, 5:18pm
64
HA does not like that as well.
Error loading /config/configuration.yaml: mapping values are not allowed here in "/config/configuration.yaml", line 199, column 20
Line 199 is state: state: {{ states('sensor.moon_phase') }}
Oh well. Thank you however.
Akriss
(kris)
December 15, 2022, 5:46pm
65
I got it. It’s double quotes, not singles.( /smack’s head )
template:
- sensor:
unique_id: my_moon_jpg
name: 'My_Moon'
state: "{{ states('sensor.moon_phase') }}"
picture: /local/moon_phases/{{states('sensor.moon_phase') }}.png
1 Like
yep, see YAML Style Guide | Home Assistant Developer Docs
remember outside and inside quotes need to be different. It’s fairly easy once you see what it’s about.
way easier is using multi-line notation with >
, and forget about those quotes.
state: >
{{ states('sensor.moon') }}
same for the other template. all templates really
again: see my suggestion in the link you have
UgoCo
December 20, 2022, 9:26pm
67
here I am, sorry mario I misunderstood.
so, i used the template that you showed me but i’m not getting in lovelance, here is the screen of the moon sensor, i have only one.
UgoCo
December 20, 2022, 11:09pm
68
I get this response from the model
Kars
(Kars de Jong)
December 21, 2022, 6:07am
69
You’re changing the name
of the sensor, I don’t think that will work, since that will also change its entity_id
. The name
should probably be something like “Moon phase”. Your entity will then be named sensor.moon_phase
.
UgoCo
December 21, 2022, 11:42am
70
I’m not understanding anything anymore, I found this sensor in the overview tab
I took the id and put it in lovelace
- type: 'tile'
name: Luna
entity: sensor.asgrouwe_maan_unknown_2
show_state: true
the result
and only if i click on the tab i see the png image, how can i see the image instead of the eye?
Kars
(Kars de Jong)
December 21, 2022, 12:57pm
71
Like I said, don’t set the name like this. The entity id will change with every state change of the moon.
As for the tile
card, I think you need to set show_entity_picture: true
instead.
UgoCo
December 21, 2022, 2:25pm
73
do i need to change this name?
Kars
(Kars de Jong)
December 21, 2022, 2:30pm
74
Yes. The ID
is derived from the name
of a template sensor. It’s extremely inconvenient if that changes based on the state of an entity…
That name looks more like something you could put in the state
of your template sensor.
UgoCo
December 21, 2022, 2:39pm
75
I also renamed the sensor to " sensor.fase_lunare" and added it to lovelance, it seems to work. last question, perhaps stupid… but to translate the phases of the moon into another language, just go to the template and replace the translated items?
alexamend
(Alexander Amend)
December 21, 2022, 2:45pm
76
UgoCo
dose you mean like this “translate to german”
sensor:
- platform: template
sensors:
mond:
entity_id: sensor.mond
friendly_name: 'Mond'
value_template: >
{% if is_state('sensor.moon_phase', 'new_moon') %}
Neumond
{% elif is_state('sensor.moon_phase', 'waxing_crescent') %}
Zuhnemender Sichelmond
{% elif is_state('sensor.moon_phase', 'first_quarter') %}
Zunehmender Halbmond
{% elif is_state('sensor.moon_phase', 'waxing_gibbous') %}
Zuhnemender Dreiviertelmond
{% elif is_state('sensor.moon_phase', 'full_moon') %}
Vollmond
{% elif is_state('sensor.moon_phase', 'waning_gibbous') %}
Abnehmender Deiviertelmond
{% elif is_state('sensor.moon_phase', 'last_quarter') %}
Abnehmender Halbmond
{% elif is_state('sensor.moon_phase', 'waning_crescent') %}
Abnehmender Sichelmond
{% endif %}
entity_picture_template: /local/moon_phases/{{ states("sensor.moon_phase") }}.png
Kars
(Kars de Jong)
December 21, 2022, 2:47pm
77
Yes, except this is an old style template sensor. So please don’t post variations of this anymore…
alexamend
(Alexander Amend)
December 21, 2022, 2:51pm
78
Kars,
I’m sorry about this, could you correct it to current version “sorry I don’t know how to do” or point me how to do
Kars
(Kars de Jong)
December 21, 2022, 3:08pm
79
Something like this, I guess. This should generate a sensor with entity id sensor.mond
:
template:
- sensor:
- name: 'Mond'
unique_id: my_moon
state: >
{% if is_state('sensor.moon_phase', 'new_moon') %}
Neumond
{% elif is_state('sensor.moon_phase', 'waxing_crescent') %}
Zuhnemender Sichelmond
{% elif is_state('sensor.moon_phase', 'first_quarter') %}
Zunehmender Halbmond
{% elif is_state('sensor.moon_phase', 'waxing_gibbous') %}
Zuhnemender Dreiviertelmond
{% elif is_state('sensor.moon_phase', 'full_moon') %}
Vollmond
{% elif is_state('sensor.moon_phase', 'waning_gibbous') %}
Abnehmender Deiviertelmond
{% elif is_state('sensor.moon_phase', 'last_quarter') %}
Abnehmender Halbmond
{% elif is_state('sensor.moon_phase', 'waning_crescent') %}
Abnehmender Sichelmond
{% endif %}
picture: >
{% set state = states('sensor.moon') %}
/local/MoonPhases/{{state}}.png
Or use the mapper technique from the example of @Mariusthvdb :
template:
- sensor:
- name: 'Mond'
unique_id: my_moon
state: >
{% set phase = states('sensor.moon_phase') %}
{% set mapper = {'new_moon':'Neumond',
'waxing_crescent':'zunehmender Mond',
'first_quarter':'Erstes Viertel',
'waxing_gibbous':'Halbmond',
'full_moon':'Vollmond',
'waning_gibbous':'Abnehmender Mond',
'last_quarter':'Letztes Viertel'} %}
{{mapper.get(phase,'Aschgrauer Mond')}}
({{phase|replace('_',' ')|capitalize}})
picture: >
{% set state = states('sensor.moon') %}
/local/MoonPhases/{{state}}.png
UgoCo
December 21, 2022, 3:15pm
80
I tried to translate into Italian, but I didn’t get any result, where am I wrong?
template:
- sensor:
- unique_id: moon_phases
name: >
{% set phase = states('sensor.moon') %}
{% set mapper = {'new_moon':'Luna Nuova',
'waxing_crescent':'Luna Crescente',
'first_quarter':'Primo Quarto',
'waxing_gibbous':'Gibbosa Crescente',
'full_moon':'Luna Piena',
'waning_gibbous':'Gibbosa Calante',
'last_quarter':'Ultimo Quarto'} %}
{{mapper.get(phase,'Luna Calante')}}
({{phase|replace('_',' ')|capitalize}})
state: >
{{states('sensor.moon').capitalize().replace('_',' ')}}
picture: >
{% set state = states('sensor.moon') %}
/local/MoonPhases/{{state}}.png
you templated the name, not the state
the name is correctly set to Luna Calante (Waning crescent)?
maybe this is not your template sensor, but the system moon sensor
UgoCo
December 21, 2022, 5:06pm
82
my model sensor is sensor.phase_moon, i replaced it but its not working
UgoCo
December 21, 2022, 5:07pm
83
template:
- sensor:
- unique_id: moon_phases
name: >
{% set phase = states('sensor.fase_lunare') %}
{% set mapper = {'new_moon':'Luna Nuova',
'waxing_crescent':'Luna Crescente',
'first_quarter':'Primo Quarto',
'waxing_gibbous':'Gibbosa Crescente',
'full_moon':'Luna Piena',
'waning_gibbous':'Gibbosa Calante',
'last_quarter':'Ultimo Quarto'} %}
{{mapper.get(phase,'Luna Calante')}}
({{phase|replace('_',' ')|capitalize}})
state: >
{{states('sensor.fase_lunare').capitalize().replace('_',' ')}}
picture: >
{% set state = states('sensor.fase_lunare') %}
/local/MoonPhases/{{state}}.png
UgoCo
December 21, 2022, 5:32pm
84
yes, in fact the template says crescent moon, but in fact it is waning as also indicated on this site: Fase lunare di oggi | Ciclo lunare attuale per oggi e stanotte