Custom Control: Z-Offset


I have added a costum command to read and set the Z offset. But the problem is, that reading does not work (setting the value works).
When I press "Get" no value appears.

I use pure marlin. I think that the line starting with " regex:" is not correct. Anyone can explain how to set this correcty?

Output of M851 is:

Send: M851
Recv: echo:Probe Z Offset: -4.20
Recv: ok P15 B3

Anyone can have a look at my code?
Thank you!

- children:
  - command: M851
    default: ''
    name: Get
    regex: z zero offset value:(?P<offset>\d+(\.\d*))
    template: 'Current: {offset} mm'
    width: '5'
  - command: M851 Z%(offset)s
    - default: '0.00'
      name: New (mm)
      parameter: offset
      slider: false
    name: Set
    width: '5'
  - command: G28 Z0
    name: Home Z
    width: '2'
  collapsed: true
  layout: horizontal_grid
  name: Adjust Z Offset


Your guess is probably right.

In OSX at a command prompt

echo "Probe Z Offset: -4.20" | sed -En 's/Probe Z Offset:[^\d]?(\d*)/\1/p'

Not knowing exactly what's going on behind-the-scenes, you might try:

  • Edit the regex to minimally make the search closer to your reality

I'm not sure if your config.yaml variable means:

  1. Create a json object behind-the-scenes which will read like z zero offset value: -4.20
  2. Look for "z zero offset value:" in the printer response followed by something else


I use this site when I have regex's to test. I have noticed though that sometimes regex's work there but not in other software and vise versa, but it seems to work there and octoprint. You could test your regexp to see if it's actually searching properly.

Copy your terminal output into its sample text box, and your regex up into the regex field up top. That's how I create my terminal filters to filter out random stuff. Usually works pretty well.