Greetings,
I'm currently trying to get my project i made in a book with ESP controls to run in a plugin. The idea is, I get the height from a homed printer, move the print-head down to the last well done layer of a failed print using a piece of paper as a tool, then tell the plugin to start the print again from this exact height, it splits the GCode in python and starts the print.
It is working using my book, but i want it to run more elegantly in an Octoprint Plugin with UI.
The problem is, I don't know how to get the information from the M114 result back, and if I would get it, I have no idea how to pipe that information back to python. I have been following the custom controls wiki page that mentions using M114. I also saw some other implementations to get a button to work from the .js file, so my status is now like this:
This gives me a Button, I can press the Button, the button executes the M114 command, it gets something useful back: Recv: X:-8.00 Y:-28.00 Z:0.00 E:0.00 Count X:-320 Y:-1120 Z:0
What it doesn't do is write the Template text next to it, does anyone have any idea? And While I'm asking, How do I execute my python script with that result? I could probably call my Blueprint API with some hacked together id addressing to do that if there is no more elegant way. JS is not a Language I'm super fluent in.
I concur with this example the difference is irrelevant, because of this I wrote "Minor nitpick"
I know many people, even senior programmers, who have problems with regexp. Therefore I think your solution will be copy&pasted by some without real comprehension. For these people .* will be better
Thank you for the quick answer, this was however not the solution for me. I have tried it, it still does not work. I had a similar idea once, i had been adding the rest of the line to the regex, that also didn't work.
as you can see, there is still nothing showing up next to my pressed Get Position button.
I have also, thanks to jandar been trying it out with a * instead of a +, this too did not work.
I wonder if this is an issue with getAdditionalControls versus being in the config.yaml file directly. I would think all the same things are available but have recently come across an issue with my BLTouch plugin that the buttons aren't disabled by default the same way they are if in config.yaml.
Oh about the config.yaml, another thing on that, when I try to add the reporting button to my controls in the config.yaml directly, it doesn't show up in my octoprint at all... So I can't really test if that is different
it doesn't make a difference to the functionality not working but this should be
type: `command`
After a little javascript debugging I found that the objects getting passed to the observable when building the buttons is completely different between the two.
in config.yaml I have this on load.
and from getAdditionalControls I only get this.
So looking at the code for the control tab it seems that because there is no key or template_key the data does not get linked to the control the same way. I attempted adding the missing key and template_key to my return value and it still doesn't work, so honestly think this is a bug.
oh wow, you're right, i totaly forgot that I can test without using my printer
I'll try that later today
good to know, then maybe I'll try to find a way around using the getAdditionalControls method, maybe even piping it through my Blueprint plugin part and back xD
that sounds clever, maybe I'll have to look into it more later, however, I just had a breakthrough for me, I noticed that I completely overlooked the Eventhandler Mixin. I was a bit unsure how to use it, maybe I'll add a PR to the docs later but i figured the Eventhandlers out
So any M114 result triggers the PositionUpdate Event, and from the PositionUpdate event the payload is just the Positiondata the way I wanted it. So I can just trigger that, take the result and then I have a python script running with all the data that I can use, I can store the height and... well, no idea from there... Will look into UI Mixins next or try a Controls overlay like you suggested to make sure my users don't press the wrong Movement buttons xD
Oh and for no apparent reason, the button from the config.yaml started working today and the regex even reacts to M114 Commands it doesn't trigger like ones triggered by the home buttons
yay, thanks to your help I found the things I needed, the rest was... not easy but possible, it is published now if anyone has a failed prusaprinter print and is willing to take the risk to restart a file from tested but arbitrary so dangerous GCode (or just wants to see how i made it): https://gitlab.com/Grosskopfgames/octoprint-gcode-restarter/