cmroche / OctoPrint-HomeAssistant

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

All Time Measurements Not working after latest update #107

Closed sushibagel closed 1 year ago

sushibagel commented 1 year ago

image

I've tried restarting Home Assistant but for some reason after the latest update none of the Time Measurements seem to update in Home Assistant.

mreditor97 commented 1 year ago

Sorry, I am just in the middle of a patch for this.

sushibagel commented 1 year ago

Sorry, I am just in the middle of a patch for this.

No need to apologize, I appreciate your work and just didn't see an report of it yet.

mreditor97 commented 1 year ago

I added it, however I found a additional warning within Home Assistant, so just improving those before resubmitting the pull. I'll tag it here once it is done. Thanks :)

mreditor97 commented 1 year ago

The fix is ready and waiting now. It is fully working as expected on my end. It would be great if you could confirm it works as expected on your end too by installing it, you can do it from my fork: https://github.com/mreditor97/octoprint-homeassistant/archive/patch/print-time.zip

sushibagel commented 1 year ago

The fix is ready and waiting now. It is fully working as expected on my end. It would be great if you could confirm it works as expected on your end too by installing it, you can do it from my fork: https://github.com/mreditor97/octoprint-homeassistant/archive/patch/print-time.zip

Seems to be working. Print time is still showing "Unavailable" but it may be due to the fact that I had just started the print. I'll update if it doesn't populate.

Edit: Print time did eventually populate as well. Thank you!

image

sushibagel commented 1 year ago

The fix is ready and waiting now. It is fully working as expected on my end. It would be great if you could confirm it works as expected on your end too by installing it, you can do it from my fork: https://github.com/mreditor97/octoprint-homeassistant/archive/patch/print-time.zip

I just realized that print times with notifications now seem to be showing wrong (in seconds maybe?).

Screenshot_20230706-093059

Here is the relevant code from the notification.

image

mreditor97 commented 1 year ago

Unfortunately the time is provided in seconds now, as that is required for Home Assistant so that it can be put into a graph.

You should be able to sort this by adding timedelta into the template of your notification: It should look something like this: {{ timedelta(seconds=states('sensor.octoprint_print_time_left')|int(default=0)) }}

This will do the conversion from seconds to a readable time for you. The same will be required of the sensor.octoprint_print_time as well.

sushibagel commented 1 year ago

Unfortunately the time is provided in seconds now, as that is required for Home Assistant so that it can be put into a graph.

You should be able to sort this by adding timedelta into the template of your notification: It should look something like this: {{ timedelta(seconds=states('sensor.octoprint_print_time_left')|int(default=0)) }}

This will do the conversion from seconds to a readable time for you. The same will be required of the sensor.octoprint_print_time as well.

Makes sense. Thanks for the quick reply.

mreditor97 commented 1 year ago

As a potential remedy to this, I could make it send the old timing method through as a attribute of the Print Time Left sensor? Would that be a good possible solution?

sushibagel commented 1 year ago

As a potential remedy to this, I could make it send the old timing method through as a attribute of the Print Time Left sensor? Would that be a good possible solution?

I don't know that it's really necessary. Your solution worked. You may just want to add it to the documentation.

Screenshot_20230706-135551

mreditor97 commented 1 year ago

I believe you should be able to prettify it too, but I'll look into that.

I will add some documentation when I get chance. Glad it works for you!

rozhkovets commented 1 year ago

HomeAssistant Discovery (3.6.5) clean install Home Assistant 2023.7.1

All time measurements stiil not working log HA https://pastebin.com/0Q57zrYA

mreditor97 commented 1 year ago

@rozhkovets The patch I have made is waiting to be pushed into the live version - this fixes the error you are getting.

https://github.com/mreditor97/octoprint-homeassistant/archive/patch/print-time.zip

Can you try to install it manually, at the link provided above and let me know if that works for you?

rozhkovets commented 1 year ago

@mreditor97, its works, thanks

but, I noticed a strange thing, print time was unavailable and was updated after ending G29, at the same time other time measurements were updated immediately after i start of printing

mreditor97 commented 1 year ago

Yes, I have the same thing on my end.

I believe this is due to Octoprint not pushing the current print time until after the initial movement commands have been sent (I believe).

I will look into it to see whether there is a potential remedy to this.