@Matt_Barnes wrote:
Hello.
I was hoping to use the uptime sensor but show the result in days hours and minutes.
This just gives unknown but I do not know enough about it to know why (code copied from on here from another use case)
- platform: uptime name: "HA Uptime" unit_of_measurement: minutes - platform: template sensors: uptime_days: value_template: >- {% set value = states('sensor.uptime') %} {% set last_updated = as_timestamp(strptime(value, "%Y-%m-%d %H:%M:%S")) %} {% set seconds = now().timestamp()-last_updated %} {% set hours = seconds / 3600 %} {% if seconds / ( 60 * 60 ) > 1 %} {{ seconds // ( 60 * 60 ) }} hours ago {% else %} {{ seconds // 60 }} minutes ago {% endif %}
Posts: 11
Participants: 5