Skip to content

PrinterNamespace

pymoonraker.api.PrinterNamespace

Klipper printer administration.

Auto-generated from schema/moonraker_api.yaml.

Source code in src/pymoonraker/api/_generated.py
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
class PrinterNamespace:
    """Klipper printer administration.

    Auto-generated from schema/moonraker_api.yaml.
    """

    def __init__(self, client: MoonrakerClient) -> None:
        self._client = client

    async def info(self) -> PrinterInfo:
        """Get Klipper host information (state, hostname, versions)."""
        raw = await self._client.call("printer.info")
        return PrinterInfo.model_validate(raw)

    async def emergency_stop(self) -> str:
        """Immediately halt the printer."""
        raw = await self._client.call("printer.emergency_stop")
        return cast("str", raw)

    async def restart(self) -> str:
        """Soft-restart Klipper host software."""
        raw = await self._client.call("printer.restart")
        return cast("str", raw)

    async def firmware_restart(self) -> str:
        """Restart Klipper via firmware restart (MCU reset)."""
        raw = await self._client.call("printer.firmware_restart")
        return cast("str", raw)

    async def gcode_script(self, script: str) -> str:
        """Execute a G-code script.

        Args:
            script: G-code to execute

        """
        params: dict[str, Any] = {}
        params["script"] = script
        raw = await self._client.call("printer.gcode.script", params)
        return cast("str", raw)

    async def gcode_help(self) -> builtins.dict[str, str]:
        """List all available G-code commands with descriptions."""
        raw = await self._client.call("printer.gcode.help")
        return cast("builtins.dict[str, str]", raw)

    async def objects_list(self) -> PrinterObjectList:
        """List all available printer objects."""
        raw = await self._client.call("printer.objects.list")
        return PrinterObjectList.model_validate(raw)

    async def objects_query(
        self,
        objects: builtins.dict[str, builtins.list[str] | None],
    ) -> PrinterObjectsStatusResponse:
        """Query printer object status.

        Args:
            objects: Mapping of object name to list of fields (or None for all fields)

        """
        params: dict[str, Any] = {}
        params["objects"] = objects
        raw = await self._client.call("printer.objects.query", params)
        return PrinterObjectsStatusResponse.model_validate(raw)

    async def objects_subscribe(
        self,
        objects: builtins.dict[str, builtins.list[str] | None],
    ) -> PrinterObjectsStatusResponse:
        """Subscribe to printer object status updates.

        Args:
            objects: Objects and fields to subscribe to

        """
        params: dict[str, Any] = {}
        params["objects"] = objects
        raw = await self._client.call("printer.objects.subscribe", params)
        return PrinterObjectsStatusResponse.model_validate(raw)

    async def print_start(self, filename: str) -> str:
        """Start printing a file.

        Args:
            filename: Path to the G-code file to print

        """
        params: dict[str, Any] = {}
        params["filename"] = filename
        raw = await self._client.call("printer.print.start", params)
        return cast("str", raw)

    async def print_pause(self) -> str:
        """Pause the current print."""
        raw = await self._client.call("printer.print.pause")
        return cast("str", raw)

    async def print_resume(self) -> str:
        """Resume a paused print."""
        raw = await self._client.call("printer.print.resume")
        return cast("str", raw)

    async def print_cancel(self) -> str:
        """Cancel the current print."""
        raw = await self._client.call("printer.print.cancel")
        return cast("str", raw)

emergency_stop async

emergency_stop() -> str

Immediately halt the printer.

Source code in src/pymoonraker/api/_generated.py
67
68
69
70
async def emergency_stop(self) -> str:
    """Immediately halt the printer."""
    raw = await self._client.call("printer.emergency_stop")
    return cast("str", raw)

firmware_restart async

firmware_restart() -> str

Restart Klipper via firmware restart (MCU reset).

Source code in src/pymoonraker/api/_generated.py
77
78
79
80
async def firmware_restart(self) -> str:
    """Restart Klipper via firmware restart (MCU reset)."""
    raw = await self._client.call("printer.firmware_restart")
    return cast("str", raw)

gcode_help async

gcode_help() -> builtins.dict[str, str]

List all available G-code commands with descriptions.

Source code in src/pymoonraker/api/_generated.py
94
95
96
97
async def gcode_help(self) -> builtins.dict[str, str]:
    """List all available G-code commands with descriptions."""
    raw = await self._client.call("printer.gcode.help")
    return cast("builtins.dict[str, str]", raw)

gcode_script async

gcode_script(script: str) -> str

Execute a G-code script.

Parameters:

Name Type Description Default
script str

G-code to execute

required
Source code in src/pymoonraker/api/_generated.py
82
83
84
85
86
87
88
89
90
91
92
async def gcode_script(self, script: str) -> str:
    """Execute a G-code script.

    Args:
        script: G-code to execute

    """
    params: dict[str, Any] = {}
    params["script"] = script
    raw = await self._client.call("printer.gcode.script", params)
    return cast("str", raw)

info async

info() -> PrinterInfo

Get Klipper host information (state, hostname, versions).

Source code in src/pymoonraker/api/_generated.py
62
63
64
65
async def info(self) -> PrinterInfo:
    """Get Klipper host information (state, hostname, versions)."""
    raw = await self._client.call("printer.info")
    return PrinterInfo.model_validate(raw)

objects_list async

objects_list() -> PrinterObjectList

List all available printer objects.

Source code in src/pymoonraker/api/_generated.py
 99
100
101
102
async def objects_list(self) -> PrinterObjectList:
    """List all available printer objects."""
    raw = await self._client.call("printer.objects.list")
    return PrinterObjectList.model_validate(raw)

objects_query async

objects_query(objects: dict[str, list[str] | None]) -> PrinterObjectsStatusResponse

Query printer object status.

Parameters:

Name Type Description Default
objects dict[str, list[str] | None]

Mapping of object name to list of fields (or None for all fields)

required
Source code in src/pymoonraker/api/_generated.py
104
105
106
107
108
109
110
111
112
113
114
115
116
117
async def objects_query(
    self,
    objects: builtins.dict[str, builtins.list[str] | None],
) -> PrinterObjectsStatusResponse:
    """Query printer object status.

    Args:
        objects: Mapping of object name to list of fields (or None for all fields)

    """
    params: dict[str, Any] = {}
    params["objects"] = objects
    raw = await self._client.call("printer.objects.query", params)
    return PrinterObjectsStatusResponse.model_validate(raw)

objects_subscribe async

objects_subscribe(objects: dict[str, list[str] | None]) -> PrinterObjectsStatusResponse

Subscribe to printer object status updates.

Parameters:

Name Type Description Default
objects dict[str, list[str] | None]

Objects and fields to subscribe to

required
Source code in src/pymoonraker/api/_generated.py
119
120
121
122
123
124
125
126
127
128
129
130
131
132
async def objects_subscribe(
    self,
    objects: builtins.dict[str, builtins.list[str] | None],
) -> PrinterObjectsStatusResponse:
    """Subscribe to printer object status updates.

    Args:
        objects: Objects and fields to subscribe to

    """
    params: dict[str, Any] = {}
    params["objects"] = objects
    raw = await self._client.call("printer.objects.subscribe", params)
    return PrinterObjectsStatusResponse.model_validate(raw)

print_cancel async

print_cancel() -> str

Cancel the current print.

Source code in src/pymoonraker/api/_generated.py
156
157
158
159
async def print_cancel(self) -> str:
    """Cancel the current print."""
    raw = await self._client.call("printer.print.cancel")
    return cast("str", raw)

print_pause async

print_pause() -> str

Pause the current print.

Source code in src/pymoonraker/api/_generated.py
146
147
148
149
async def print_pause(self) -> str:
    """Pause the current print."""
    raw = await self._client.call("printer.print.pause")
    return cast("str", raw)

print_resume async

print_resume() -> str

Resume a paused print.

Source code in src/pymoonraker/api/_generated.py
151
152
153
154
async def print_resume(self) -> str:
    """Resume a paused print."""
    raw = await self._client.call("printer.print.resume")
    return cast("str", raw)

print_start async

print_start(filename: str) -> str

Start printing a file.

Parameters:

Name Type Description Default
filename str

Path to the G-code file to print

required
Source code in src/pymoonraker/api/_generated.py
134
135
136
137
138
139
140
141
142
143
144
async def print_start(self, filename: str) -> str:
    """Start printing a file.

    Args:
        filename: Path to the G-code file to print

    """
    params: dict[str, Any] = {}
    params["filename"] = filename
    raw = await self._client.call("printer.print.start", params)
    return cast("str", raw)

restart async

restart() -> str

Soft-restart Klipper host software.

Source code in src/pymoonraker/api/_generated.py
72
73
74
75
async def restart(self) -> str:
    """Soft-restart Klipper host software."""
    raw = await self._client.call("printer.restart")
    return cast("str", raw)