Also keep in mind that dates and times will be formatted according to your locale, if set correctly. I’m not sure if what you’re attempting here is that, or something different from what you’re used to natively.
now() and the Time & Date sensors update once a minute. I suggest you review this section of the documentation to understand why: Rate Limiting Updates
You won’t get per second updates with a template that merely computes time. Refer to the documentation to see an example of what does produce per second updates.
You can try adding the example into your Template Sensor (see below) and see if it causes it to be updated every second. I haven’t tried it myself so I can’t be certain if it works (it may get throttled to once a minute because of the presence of now()). If it doesn’t work, then I know of no other way to do it.
template:
- sensor:
- name: "Date and time test"
state: >
{% set x = states.sensor | selectattr('state', 'in', ['unavailable', 'unknown', 'none']) | list | count %}
{{ now().timestamp() | timestamp_custom('%d-%b-%Y, %I:%M:%S %p') }}
icon: "mdi:calendar-clock"
I notice another thing as well, home-assistant_v2.db file size is increasing kind of fast although I already excluded that “date & time test” sensor from the recorder, or maybe there is something else is filling up the database.
Yes, you will definitely want to exclude this Template Sensor from having its history recorded. One database entry per second will inflate your database to an unwieldy size very quickly!
FWIW, just another reason why a time-based update defaults to once a minute.