supperka
(Supperka)
April 22, 2024, 10:04pm
1
Hello I create this sensor , it’s working ,but time is showed without correct time-zone , in my case is’t +2 hrs
how can I change name of days genatate by strftime(‘%A’) ?
Thank you.
sensors:
## One For Each Device
okno_emma_on2:
friendly_name: novy format
value_template: >
{%- set last_changed = states.binary_sensor.dvere_vchod_zamek_contact.last_changed %}
{% if last_changed < today_at() - timedelta(days=6) %}
týden +
{% elif last_changed < today_at() - timedelta(days=1) %}
{{ last_changed.strftime('%A v %H:%M')}}
{% elif last_changed < today_at() %}
{{ last_changed.strftime( 'Včera v %H:%M')}}
{% else %}
{{ last_changed.strftime('Dnes v %H:%M') }}
{% endif %}
123
(Taras)
April 22, 2024, 10:29pm
2
Copy-paste the following template into the Template Editor and confirm it reports the correct date, time, and timezone offset.
{{ now() }}
If it’s not correct, go to Settings → System → General and ensure Time Zone is set correctly.
You can’t. It is exclusively in English.
You will need to use a template to report the day name in your preferred language (which I believe is Czech).
Here’s an example:
{{ ['Pondělí', 'Úterý', 'Středa', 'Čtvrtek', 'Pátek', 'Sobota', 'Neděle'][now().weekday()] }}
supperka
(Supperka)
April 23, 2024, 3:34am
3
{{ now() }} result 2024-04-23 05:33:10.915962+02:00
supperka
(Supperka)
April 30, 2024, 6:44am
4
So I found the way.
{%- set last_changed = states.binary_sensor.okno_kuchyn_contact.last_changed %}
{% if last_changed < today_at() - timedelta(days=6) %}
{{ as_timestamp(states.binary_sensor.okno_kuchyn_contact.last_changed, default=0)| timestamp_custom("%d.%m v %H:%M") }}
{% elif last_changed < today_at() - timedelta(days=1) %}
{{ ['Pondělí', 'Úterý', 'Středa', 'Čtvrtek', 'Pátek', 'Sobota', 'Neděle'][now().weekday()] }} {{ last_changed | timestamp_custom('%H:%M', true)}}
{% elif last_changed < today_at() %}
{{ as_timestamp(states.binary_sensor.okno_kuchyn_contact.last_changed, default=0)|timestamp_custom('včera v %H:%M', default=0) }}
{% else %}
{{ as_timestamp(states.binary_sensor.okno_kuchyn_contact.last_changed, default=0)|timestamp_custom(' %H:%M', default=0) }}
{% endif %}
I know, this isn’t clear code but working.
123
(Taras)
May 4, 2024, 9:54pm
5
It’s the custom of this community forum to assign the Solution tag to the post that offers the Solution. That would be this post , because it explained strftime
only reports in English and provided you a template to convert to Czech.
Guideline 21 in the FAQ
1 Like