Skip to content

Update to add MQTT(PlugIn.Helper) publish support (issue #39)#40

Closed
jcassel wants to merge 3 commits intotechman83:mainfrom
jcassel:MQTT
Closed

Update to add MQTT(PlugIn.Helper) publish support (issue #39)#40
jcassel wants to merge 3 commits intotechman83:mainfrom
jcassel:MQTT

Conversation

@jcassel
Copy link

@jcassel jcassel commented Aug 11, 2023

Update to add MQTT(PlugIn.Helper) publish support for last known weight value.

I have to be honest, I did not have a load cell to test this on. So the only value for the last known weight was "Error" but I did not change any of the functional code for the PlugIn.. I simply added the hook to the MQTT PlugIn and then setup a Publish to it if it was found. I did thoroughly test the MQTT Sections. If you think it should be sending some other value or if you think I need to add some additional checks around the value of "lastknownweight" let me know, I will make an update.

Copy link
Owner

@techman83 techman83 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one minor question! I would like to keep the format related changes in a separate commit at the very least, but preferably a separate PR. But the project really could use porting to Black, and really appreciate this contribution.

Overall looks great, I'll try and do a sanity check at some point today. If it goes well, I'll cut a release!

@techman83
Copy link
Owner

I'll need to do some further debugging, I do get it seeing that mqtt is available

2023-08-11 10:01:23,640 - octoprint.plugins.filament_scale - INFO - do send weight
2023-08-11 10:01:23,641 - octoprint.plugins.filament_scale - INFO - baseTopic:octoPrint/

and the mqtt plugin is publishing

octoPrint/mqtt connected
octoPrint/progress/printing {"location": "", "path": "", "progress": 0, "_timestamp": 1691744473}
octoPrint/progress/slicing {"slicer": "", "source_location": "", "source_path": "", "destination_location": "", "destination_path": "", "progress": 0, "_timestamp": 1691744473}

But I'm not getting any weights show up. Though just need to rule out an issue with the load cell!

@jcassel
Copy link
Author

jcassel commented Aug 11, 2023

This is what I get from a more or less default MQTT setup.
PiBench_MQTT

I ordered a loadcell and board. It might be here today.

@jcassel
Copy link
Author

jcassel commented Aug 11, 2023

I was looking at this again.. Just noted that I reused the timer t for the new MQTT method. I am making an update. I also looked harder in my shop and found a good load cell and board. I have it hooked up. Let me work this a little and I will update later today I hope.

@jcassel
Copy link
Author

jcassel commented Aug 11, 2023

OK, with the last commit, I think it is all worked out. I should not have submitted the changes without having tested it fully. Including hooking up a load cell. Lessons learned. Anyway I have connected a load cell and done a full test. Seems to be good now. Issue was mostly the Timer reuse but also had found a conversion need for the value int to str.

Hope this tests out well for you as well.

techman83 pushed a commit that referenced this pull request Aug 12, 2023
Building on @jcassel's work in #40, this publishes scale changes
to mqtt via the Octoprint-MQTT plugin.

closes #39
@techman83
Copy link
Owner

@jcassel - I combined your commits into #41 if you'd like to take a look. I noticed that it didn't show the correct weight. I originally ported the existing library from python2 -> python3, and it has a few quirks as a result.

Things I fixed/changed over in my PR

  • lastknownweight only gets updated when the web fronted is loaded, so weight wouldn't change if the UI wasn't open
  • lastknownweight is the raw value, I've implemented a python version of what happens in the frontend to get the filament weight
  • I simplified the methods a little
  • Fixed up the commit messages

If you would like to give it a once over, I'll get a release out the door!

techman83 pushed a commit that referenced this pull request Aug 12, 2023
Building on @jcassel's work in #40, this publishes scale changes
to mqtt via the Octoprint-MQTT plugin.

closes #39
@techman83 techman83 closed this Aug 12, 2023
@jcassel jcassel deleted the MQTT branch August 12, 2023 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants