cmroche / OctoPrint-HomeAssistant

Home Assistant plugin for OctoPrint, enabling MQTT discovery of you device and sensors
110 stars 18 forks source link

sensor octoprint_print_time_left as time not as state #76

Closed phiwa99 closed 2 years ago

phiwa99 commented 2 years ago

I have a problem with the print time and print time left

The argument of the sensor is not a time that grows / falls in the sensor are defenite states with the time: image

I expected it this way: image

So far not the problem, but i want to extract the minutes e.g. till the file is finished/ or minutes untill now: till now:{{( (as_timestamp(strptime(states('sensor.octoprint_print_time'), "%H:%M:%S")))|int) }} local {{( (as_timestamp(strptime(states('sensor.octoprint_print_time'), "%H:%M:%S")))|int)|timestamp_custom('%H:%M:%S') }} hour: {{( (as_timestamp(strptime(states('sensor.octoprint_print_time'), "%H:%M:%S")))|int )|timestamp_custom('%H') }} minutes: {{( (as_timestamp(strptime(states('sensor.octoprint_print_time'), "%H:%M:%S")))|int )|timestamp_custom('%M') }}

results in template: till now:-2208992163 local 00:03:57 hour: 00 minutes: 03

in the configation,yaml this templates do not work

So finally is it possible to change the format of the argument of the sensor to get a timestamp?

phiwa99 commented 2 years ago

time left min: {{(states.sensor.octoprint_print_progress.attributes["printTimeLeft"] /60 )|int}}