Getting Snapmaker U1 to turn off Tapo Matter wifi outlet P125M after print finishes via Hubitat and Klipper. This outlet controls the chamber heater plug.
NOTE: when setting up new matter device on Hubitat, the device and hubitat must be on same subnet or device discovery will not work; this is even if there are 2 routers configured to access IP addresses on either network. Matter device must be on same wifi network as hubitat.
The Components
Hubitat Maker API — exposes your Tapo outlet (device ID 133) to your local network via HTTP. You added the outlet to the allowed devices list and the API handles on/off commands via simple URLs.
Moonraker [power] device — defined in moonraker.conf, this registers the outlet as a controllable power device that Moonraker can switch on and off. It polls the status URL to know the current state and uses the response_template to parse Hubitat’s JSON response.
extended/klipper/hubitat.cfg — four Klipper macros:
CHAMBER_HEATER_ON— turns the outlet on and sets a variable active=1CHAMBER_HEATER_OFF— turns the outlet off and sets active=0_PRINT_END_HUBITAT— PAXX lifecycle hook that checks if active=1 and calls CHAMBER_HEATER_OFF_CANCEL_PRINT_HUBITAT— same as above but fires on print cancel
OrcaSlicer Nylon CF filament profile — calls CHAMBER_HEATER_ON in filament start G-code and CHAMBER_HEATER_OFF in filament end G-code.
The Flow
Print start:
OrcaSlicer sends CHAMBER_HEATER_ON via the filament start G-code
Klipper receives it, calls Moonraker’s set_device_power method
Moonraker sends an HTTP GET to Hubitat’s on URL
Hubitat switches the Tapo outlet on
Chamber heater starts warming up
Print end:
OrcaSlicer sends CHAMBER_HEATER_OFF via filament end G-code
Additionally the PAXX _PRINT_END_HUBITAT hook fires automatically
Either way, Moonraker sends an HTTP GET to Hubitat’s off URL
Hubitat switches the Tapo outlet off
Print cancel:
The PAXX _CANCEL_PRINT_HUBITAT hook fires
Checks if active=1 — if the heater was on, turns it off
Outlet turns off cleanly
Files Modified
moonraker.conf — added [power chamber_heater] section
extended/klipper/hubitat.cfg — created with four macros
OrcaSlicer Nylon CF filament profile — added start/end G-code
If Something Goes Wrong
Outlet doesn’t turn on — check Fluidd console, type CHAMBER_HEATER_ON manually to test
Outlet doesn’t turn off — type CHAMBER_HEATER_OFF in Fluidd console, or use the Hubitat app directly
Klipper fails to start — go to http://PRINTER_IP/firmware-config → Recovery → Reset Extended to Defaults
Moonraker power device shows init — check moonraker.log via SSH for errors in the response template
Code and Setup Instructions
1. Hubitat Setup – add plug. Go to Apps > Add App > Maker API. Setup new API and note endpoint with key. Example: http://HUBITAT_IP/apps/api/280/devices?access_token=XXXXXXXXXXXX
2. Go to Fluidd interface via printer IP address. Configuration > moonraker.conf. Add at bottom:
[power chamber_heater]
type: http
on_url: http://HUBITAT_IP/apps/api/280/devices/[DEVICE-ID]/on?access_token=XXXXXX
off_url: http://HUBITAT_IP/apps/api/280/devices/[DEVICE-ID]/off?access_token=XXXXXX
status_url: http://HUBITAT_IP/apps/api/280/devices/[DEVICE-ID]/attribute/switch?access_token=XXXXXX
response_template:
{% set resp = http_request.last_response().json() %}
{resp.value}
Add hubitat.cfg to /extended/klipper:
[gcode_macro CHAMBER_HEATER_ON]
variable_active: 0
gcode:
SET_GCODE_VARIABLE MACRO=CHAMBER_HEATER_ON VARIABLE=active VALUE=1
{action_call_remote_method("set_device_power", device="chamber_heater", state="on")}
[gcode_macro CHAMBER_HEATER_OFF]
gcode:
{action_call_remote_method("set_device_power", device="chamber_heater", state="off")}
SET_GCODE_VARIABLE MACRO=CHAMBER_HEATER_ON VARIABLE=active VALUE=0
[gcode_macro _PRINT_END_HUBITAT]
gcode:
{% if printer["gcode_macro CHAMBER_HEATER_ON"].active == 1 %}
CHAMBER_HEATER_OFF
{% endif %}
[gcode_macro _CANCEL_PRINT_HUBITAT]
gcode:
{% if printer["gcode_macro CHAMBER_HEATER_ON"].active == 1 %}
CHAMBER_HEATER_OFF
{% endif %}
3. Add gcode to filament profile in Orca Slicer: Advanced tab –
- Filament Start G-Code:
CHAMBER_HEATER_ON - Filament End G-Code:
CHAMBER_HEATER_OFF