Hi.
were is my time and date sensor entities?
cant find them.
just Finnish my new HA installation on RP 3B and
there no time/date sensor.
do i need to write something in Configuratin.yaml?
Thanks
Refael
Hi.
were is my time and date sensor entities?
cant find them.
just Finnish my new HA installation on RP 3B and
there no time/date sensor.
do i need to write something in Configuratin.yaml?
Thanks
Refael
Check if you have enabled the time_date platform in your configuration.yaml, also see this link: https://www.home-assistant.io/components/sensor.time_date/
Hi.
once again Thanks for the replay. you right. now itâs working.
Thanks .
Refael
I have mine enabled in yaml but only the first two work in the template editor, the rest return âunknownâ.
ie
{{states(âsensor.dateâ)}} returns 2020-01-17
{{states(âsensor.timeâ)}} returns 11:29
{{states(âsensor.time_dateâ)}} returns unknown
Is there a way to have the time display in 12 hour not 24
no there is not a way, unless⌠you are a programmerâŚ
Wow, what a surprise. Why is not this activated by default? And on top of that⌠why is not said on all the references that you need this to be manually activated? It was really unexpected
What are you trying to do? Chances are, you donât even need this sensor. You can do everything without it, automations, scripts, timing, etc. The only reason youâd want to add this is for display in the UI.
{% set t = states('sensor.time') %}
And I think being able to display text and dates is common enough
that still doesnât explain what you are trying to do. You donât need the sensor for that.
{% set t = now().strftime('%H:%M') %}
Will get you the same thing. But if youâre trying to compare times in a template, thereâs much easier ways now.
The way the time and date is displayed is governed by the language chosen for each userâs Profile.
For example, if I select this:
it will display time with AM/PM:
but if I choose this:
it displays it in 24h time:
However, thatâs just for display purposes. The values of date/time-based sensors remain in ISO format.
ON mi specific example, I just wanted something that updates every second to keep a visual element up to date.
And the thing that lead me to this post was putting the current time on an external display.
Is this API then deprecated?
Nothing updates every second in HA unless you make an automation that does that (or you have a hardware sensor that does that). Templates are throttled to updates based on the input sensor or now() updates once per minute.
No, thereâs just easier ways to do it now in templates.
This would be a template sensor that would update once per second.
template:
- trigger:
- platform: time_pattern
seconds: "/1"
sensor:
- name: time
state: "{{ now().strftime('%H:%M:%S') }}"
Once per minute was good enough to my usecase, sorry for the confusion.
Thanks for the template in any case
Why âadessoâ is wrong?
{{states('sensor.date')}}
{% set oggi = as_timestamp(states("sensor.date")) | timestamp_custom('%d/%m/%Y') %}
{{ oggi }}
<-------------------------->
{{states('sensor.time')}}
{% set adesso = as_timestamp(states('sensor.time')) | timestamp_custom('%H:%M') %}
{{ adesso }}
Because as_timestamp doesnât convert a partial time string into a timestamp.
Excuse my ignoranceâŚ
If timestamp = date+time
See example here
and
as_timestamp doesnât convert a partial time string into a timestamp.
why
as_timestamp convert a partial data string into a timestamp?
(see âoggiâ in my screenshot)
Thanks for your attention.
It can only read partial timestamps left to right, and it has to start with the date.
Instead of asking this very narrow viewed question, how about you explain your end goal with the template. There have been many improvements to templates and dates over the past year.