{{ states('sensor.ender_3_pro_time_remaining') | int | timestamp_custom('%H:%M:%S', 0) }}
produces the same output as
{% set etime = states.sensor.ender_3_pro_time_remaining.state | int %}
{% set seconds = etime % 60 %}
{% set minutes = ((etime % 3600) / 60) | int %}
{% set hours = ((etime % 86400) / 3600) | int %}
{% set days = (etime / 86400) | int %}
{%- if days > 0 -%}
{%- if days == 1 -%}
1 day
{%- else -%}
{{ days }} days
{%- endif -%}
{{ ', ' }}
{%- endif -%}
{% set seconds = states('sensor.octoprint_time_remaining') | int %}
{% set minutes = ((seconds % 3600) / 60) | int %}
{% set hours = ((seconds % 86400) / 3600) | int %}
{% set days = (seconds / 86400) | int %}
{%- if days -%}{{days}} day{{'s, ' if days > 1 else ', '}}{%- endif -%}
{%- if hours -%}{{hours}} hour{{'s, ' if hours > 1 else ', '}}{%- endif -%}
{%- if seconds > 59 -%}{{minutes}} minute{{'s' if minutes > 1}}{%- endif -%}
{%- if seconds < 60 and seconds > 0 -%}< 1 minute{%- endif -%}
Added seconds support which shows ā< 1 minuteā under a minute and nothing when the timer hits 0. before it was showing ā0 minuteā below a minute and when the printer was offline
By the way, there is a standard function to convert timestamps into human-friendly relative time strings:
{% set etime = states.sensor.ender_3_pro_time_remaining.state | int %}
{% set now = now() %}
{% set aware_dt = now.fromtimestamp(etime, now.tzinfo) %}
{{ relative_time(aware_dt) }}
Iām very nooby here, but where are all the above snippits meant to go? Iāve yet to see a complete example start to finish of how to insert this into the configuration.yaml to convert seconds to minutes and hours.
Like does it go within āoctoprintā ? does it stand alone as itās own sensor and somehow modify the time displayed by the time remaining and time elapsed sensors created by octoprint? Iām really confused by this. Iāve pasted in your examples from above in various places in the config.yaml file and nothing changes.