cmroche / OctoPrint-HomeAssistant

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

Patch for Print Time #108

Closed mreditor97 closed 1 year ago

mreditor97 commented 1 year ago

This fixes problem #107, caused by the previous patch.

I have done some work to allow the Approximate Total Print Time, Print Time, and Print Time Left sensors to be displayed within graphs within the Home Assistant interface. I have changed Approximate Completion Time to use the built in Timestamp function within Home Assistant so it will now automatically display how long it left on your print once it has been started.

All of the time sensors now check to ensure that there is a valid value before changing from unavailable state. This means that if you do not have a print selected within Octoprint, the updated sensors will display unavailable.

Once a print has been selected within Octoprint, the Approximate Total Print Time will become available and will display the expected time for the print to complete.

Only once the print has started, will the Approximate Completion Time and Print Time Left become available with there actual values. Print Time is updated once the printer has actually started making progress through the print.

I hope this is a improvement for you all! Enjoy!

The suggestion for using graphs was in Feature Request #97 I also did a little bit of tiding up of any unused imports

noy1122 commented 1 year ago

how can I use it? what I need to do for working? Thanks

mreditor97 commented 1 year ago

You can use test the patch here: https://github.com/mreditor97/octoprint-homeassistant/archive/patch/print-time.zip

Hopefully this helps. Let me know how you get on!

noy1122 commented 1 year ago

yeah, its working, thanks king!

mill1000 commented 1 year ago

Commands to install via pip

pip uninstall octoprint-homeassistant
pip install git+https://github.com/mreditor97/octoprint-homeassistant.git@patch/print-time
bharvey88 commented 1 year ago

Commands to install via pip

pip uninstall octoprint-homeassistant
pip install git+https://github.com/mreditor97/octoprint-homeassistant.git@patch/print-time

Would you be willing to fork this and add https://github.com/cmroche/OctoPrint-HomeAssistant/pull/113 this breaking-change fix? Otherwise people on your fork will still have no joy come tomorrow at 2pm when the beta becomes the new stable.

mreditor97 commented 1 year ago

@bharvey88 Yes, of course. I will add the fix for 2023.8 for when the beta comes available so we can have a working instance.

All my upcoming patches can be found here - https://github.com/mreditor97/octoprint-homeassistant/archive/master.zip

halfluck commented 1 year ago

I applied the above update but I still get the errors in HA "MQTT entity name starts with the device name in your config" is there something else I need to change on my end?

Cheers

mreditor97 commented 1 year ago

@halfluck Did you update the plugin before updating Home Assistant? I found that the warning messages haven't come to light again since a restart of Home Assistant?

Let me know if this still occurs for you when you update to the latest version of my master branch of my fork?

halfluck commented 1 year ago

@mreditor97 Thanks for the quick reply, Yes I rebooted HA and OctoPrint after applying the update from your master branch, This is my HA log after a fresh reboot

https://www.dropbox.com/scl/fi/y9zy6n1c4j8dejcex6iij/ha_log.txt?rlkey=xl57zi9yjppjsk2lal6qqs0br&dl=0

mreditor97 commented 1 year ago

@halfluck I'll look into why this happening when I get back from my holiday in a few days time.

cmroche commented 1 year ago

@mreditor97 @halfluck I do not think this is related to the change here. Looks like the MQTT integration at some point wanted the entity NOT to start with the device name, as far as I remember I think it always has with this plugin. It's a warning in any case..

cmroche commented 1 year ago

@mreditor97 Thanks for the contribution, looks good on my end.