Getting section name from Moonraker Component

I am in the process of converting KlipperMaintenance from a Klippy extra to a Moonraker component. I am having trouble, however, with getting the name of the configuration section and reading parameters. Example:

[maintain lubricate]
trigger: print_time
threshold: 250
message: Lubricate axes

When I read this in Klippy extras, I can read the lubricate name with

config.get_name().split()[1]

When I read this in a Moonraker component, I can’t get the lubricate name. I have tried:

  • config.get_name() (returns maintain)
  • config.section (returns maintain)

This also prevents me from reading parameters. For example, when I try to read the threshold:

self.threshold = config.getint('threshold')

It raises an error:

  File "/home/pi/moonraker/moonraker/confighelper.py", line 226, in getint
    return self._get_option(
           ^^^^^^^^^^^^^^^^^
  File "/home/pi/moonraker/moonraker/confighelper.py", line 148, in _get_option
    raise ConfigError(str(e)) from None
moonraker.confighelper.ConfigError: No section: 'maintain'

Any help would be appreciated.

Did you check Components - Moonraker?

Yes. I referred between that, the Moonraker source code, and Moonraker Timelapse’s code to make most of my code so far.