octoprint_compat: correctly report printer state

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2021-04-18 06:20:27 -04:00
parent e8f6862fd2
commit 9873084667
1 changed files with 6 additions and 3 deletions

View File

@ -88,15 +88,17 @@ class OctoprintCompat:
async def printer_state(self): async def printer_state(self):
if not self.klippy_apis: if not self.klippy_apis:
return 'Offline' return 'Offline'
if self.server.klippy_state != 'ready': klippy_state = self.server.get_klippy_info().get('state')
if klippy_state != 'ready':
return 'Error' return 'Error'
result = await self.klippy_apis.query_objects({'print_stats': None}) result = await self.klippy_apis.query_objects({'print_stats': None})
pstats = result.get('print_stats', {})
return { return {
'standby': 'Operational', 'standby': 'Operational',
'printing': 'Printing', 'printing': 'Printing',
'paused': 'Paused', 'paused': 'Paused',
'complete': 'Operational' 'complete': 'Operational'
}.get(result.get('state', 'standby'), 'Error') }.get(pstats.get('state', 'standby'), 'Error')
async def printer_temps(self): async def printer_temps(self):
temps = {} temps = {}
@ -139,10 +141,11 @@ class OctoprintCompat:
""" """
Server status Server status
""" """
klippy_state = self.server.get_klippy_info().get('state')
return { return {
'server': OCTO_VERSION, 'server': OCTO_VERSION,
'safemode': ( 'safemode': (
None if self.server.klippy_state == 'ready' else 'settings') None if klippy_state == 'ready' else 'settings')
} }
async def _post_login_user(self, web_request): async def _post_login_user(self, web_request):