I’ve integrated OctoPrint to HA, using the MQTT route.
I have the sensor sensor.octoprint_print_estimated_time which tell me the estimated total print time. I also have the binary sensor binary_sensor.octoprint_printing.
I would like to get the time of day the job are finished based on the timestamp from the moment the binary_sensor goes from off to on and use the sensor for estimated print time, in 24 hr format.
Can that be done? It is far outside my template skills…
If somebody got a solution and a recipe for me - I will be very happy!
template:
- sensor:
- unique_id: octoprint_end_time
name: Octoprint End Time
device_class: timestamp
state: >
{% set t = states('sensor.octoprint_print_estimated_time') %}
{% if t not in ['unknown', 'unavailable'] %}
{% set h, m, s = t.split(":") | map('int', 0) %}
{{ now() + timedelta(hours=h, minutes=m, seconds=s) }}
{% else %}
none
{% endif %}
@petro you’re a god damn hero! Do you eat, sleep and drink templates?
First, I realized that we needed to use the remaining time sensor, otherwise it would keep extending the time all the time. Agree? Then it became like this:
template:
- sensor:
- name: Octoprint Ferdig
unique_id: octoprint_print_time_left
device_class: timestamp
state: >
{% set t = states('sensor.octoprint_print_time_left') %}
{% if t not in ['unknown', 'unavailable'] %}
{% set h, m, s = t.split(":") | map('int', 0) %}
{{ now() + timedelta(hours=h, minutes=m, seconds=s) }}
{% else %}
none
{% endif %}
Though, not exactly as I wanted it. I want it to show the time of day (as an example, like at 22:04:34).