However I want them to be displayed like this: Mon 15-02-2021 4:30PM.
To achieve this, I have consulted the example in the Home Assistant documentation (Time&Date), the Phyton standard and this forum.
This is how I modified my configuration file:
############ Se añade el sensor de Fecha y Hora ##################
- platform: time_date
display_options:
- 'date_time_iso'
###### Personalización de Fecha y Hora ##########################
- platform: template
sensors:
time_formatted:
friendly_name: Fecha y Hora
value_template: "{{ as_timestamp(states('sensor.date_time_iso')) | timestamp_custom('%a %d %m %Y, %I:%M %p') }}"
icon_template: mdi:calendar-clock
What am I doing wrong?
Thanks in advance.
Thank you very much for your response.
But, if I disable the “date_time_iso” sensor, what should I do to make it appear in the “entities card” with the title “Almanaque”?
No need to apologize, I should have been more clear in my first post.
Glad to hear the suggested template answers your question.
Please consider marking my first post with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has an accepted solution. Effectively, it marks this topic as being resolved and helps users find answers to similar questions.
After you have modified the configuration file, you have to instruct Home Assistant to reload the file. If you don’t do that it is unaware you changed anything and will continue to use the previous version.
First, execute Configuration > Server Controls > Check Configuration. Make sure it doesn’t report any errors. If it does then it means your modifications introduced an error and it must be corrected.
Second, assuming there are no errors, execute Configuration > Server Controls > Reload Template Entities.
I have discovered my error and, now, the date and time are displayed as I want.
Besides modifying my “template”, in the “card entities” it is necessary to replace “sensor.date_time_iso” by the new sensor “sensor.time_formatted”.
An inexperienced mistake.
Thank you very much for your time.
For the result to be perfect, I just need to get the name of the days of the week to be displayed in Spanish.
Somewhere I will have to add es_ES. I have consulted the Phyton documentation and I have made a test without success.
Can someone help me?
Thanks in advance.
If you use timestamp_custom it will convert %a into the day in English only. It doesn’t use the local language (at least not in Home Assistant). Wherever you are adding es_ES won’t help (as you have already discovered).
Let me know if you still want the day in Spanish and I’ll show you a different way to do it (using a slightly more sophisticated template).
Thank you very much for your offer.
If you are willing to give me your time, I would like the days of the week to appear like this:
lunes, martes, miércoles, jueves, viernes, sábado, domingo
Your template works perfectly. Now my “Almanaque” card looks like this
Thank you very much for your help to an 80 year old, inexperienced man, who uses Home Assistant to control his lights and weather station and that serves me to keep me active.
The date works as expected, but the time does not. My intent is to have 12Hour:Minute:Second AM/PM displayed. I’ve consulted the Python Date/Time formatting as per the HA Time & Date page, but I seem to be missing something.