your second macro template (based on system_monitors since_last_boot works perfectly:
It updates nicely per minute, and the 2 sensors are beautifully in sync in the frontend.
the one based on uptime doesn’t:
see how it reports 14 minutes, while in fact it is only online for 4 minutes, (or 0.16 hours, or 0.01 day )
its update frequency per 14 minutes is killing its accuracy, which is of course silly for a sensor like this. I tried to update it with the homeassistant.update_entity service, but that is not having any effect.
EDIT: HOLD ON!!! this has some stupid testing code… I’ll update shortly
EDIT2: Updated now, correctly I think !
Actually it doesn’t. Not if the up time is less than a day!
But I think this does
{% macro phrase(value, name) %}
{%- set value = value | int %}
{%- set end = ‘s’ if value > 1 else ‘’ %}
{{- ‘{} {}{}’.format(value, name, end) if value | int > 0 else ‘’ }}
{%- endmacro %}
{% if ‘day’ in states(‘sensor.since_last_boot’) %}
{% set days = states(‘sensor.since_last_boot’).split(’ ')[0] %}
{% else %}
{% set days = 0 %}
{% endif %}
{% set minutes = states(‘sensor.since_last_boot’)[-12:-10] %}
{% set hours = states(‘sensor.since_last_boot’)[-15:-13] %}
{% set weeks = (days | int / 7) | int %}
{% set days = (days | int) - (weeks * 7) %}
As for this one… I am starting to wonder if it is worth the effort!!!
The 14 minutes update is silly and I am not sure why it was chosen to be so imprecise?
btw did you notice the sensor.since_last_boot updates every 30 secs, and not every minute?
As far as I can tell, its the only one with this update frequency. Of course the new Macro sensor does so too now.
That might be nice to know, and come in handy, if one needs an entity_id in an template without entity_id on which HA can update.
No I didn’t notice, good spot and good idea for another use of it!
Have you changed to the latest version I posted? Can I assume it shows correctly for times greater than one day?