ETA template

I would like to know when my 3D printer will be ready. So I have a OctoPrint value in seconds, which I want to add up to the actual time to get the ETA. But the following is not working:

 octoprint_time_ready:
    friendly_name: 'ETA'
    value_template: >-
      {%- set date = as_timestamp(now()) + states.sensor.octoprint_time_remaining.state -%}
      {{ date|timestamp_local }}

Anyone who can help me?

You’re adding a string (sensor.octoprint_time_remaining’s state) to a number (the timestamp.) Presuming the state is a string representation of a number of seconds, you need to change it to a number. Also, specifying the state that way can confuse the template parser so that it can’t find the entity_id. You can solve both problems like this:

  octoprint_time_ready:
    friendly_name: 'ETA'
    value_template: >-
      {%- set date = as_timestamp(now()) + states('sensor.octoprint_time_remaining')|float -%}
      {{ date|timestamp_local }}
1 Like

Thanks! I will try this tonight. I am pretty new to this, so still learning. Guess I will lookup the difference between int and float now :slight_smile: