moonraker-home-assistant
moonraker-home-assistant copied to clipboard
Printer power switch generating errors
Version of the moonraker integration
1.3.4
Describe your setup
Klipper, Moonraker, Mainsail, Raspi.
Relay connected to the GPIO on the pi to control power to the printer board (SKR mini)
[power printer]
type: gpio
pin: gpio4
off_when_shutdown: True
initial_state: off
restart_klipper_when_powered: true
bound_services:
klipper
klipper-mcu
Describe the bug
My power controls though moonraker work fine. When toggling the power switch entity through HA (switch.am8_printer
) the UI shows an error Failed to perform the action switch/turn off. state
but the power does toggle correctly.
HA Logs
2024-09-03 19:00:29.076 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 258, in _handle_refresh_interval
await self._async_refresh(log_failures=True, scheduled=True)
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 453, in _async_refresh
self.async_update_listeners()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 168, in async_update_listeners
update_callback()
File "/config/custom_components/moonraker/sensor.py", line 796, in _handle_coordinator_update
self._attr_native_value = self.entity_description.value_fn(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/moonraker/sensor.py", line 46, in <lambda>
value_fn=lambda sensor: sensor.coordinator.data["printer.info"]["state"],
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
KeyError: 'state'
2024-09-03 19:00:35.086 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 462, in _handle_request
resp = await request_handler(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 537, in _handle
resp = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 210, in forwarded_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
response = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
result = await handler(request, **request.match_info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 813, in get
return await self.handle(request, camera)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 831, in handle
image = await _async_get_image(
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 185, in _async_get_image
else await camera.async_camera_image(width=width, height=height)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/moonraker/camera.py", line 162, in async_camera_image
self.coordinator.data["status"]["print_stats"]["state"]
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
KeyError: 'status'
The corresponding error from moonraker.log
...
2024-09-04 17:53:12,032 [common.py:build_error()] - JSON-RPC Request Error - Requested Method: printer.objects.query, Code: 503, Message: Klippy Host not connected
2024-09-04 17:53:12,039 [common.py:build_error()] - JSON-RPC Request Error - Requested Method: printer.info, Code: 503, Message: Klippy Host not connected
Klippy being disconnected is expected if the printer is off. Any suggestions?