def process_octoprint_status(printer, status): octoprint_settings = status.get('octoprint_settings') if octoprint_settings: redis.printer_settings_set(printer.id, settings_dict(octoprint_settings)) octoprint_data = dict() set_as_str_if_present(octoprint_data, status.get('octoprint_data', {}), 'state') set_as_str_if_present(octoprint_data, status.get('octoprint_data', {}), 'progress') set_as_str_if_present(octoprint_data, status, 'octoprint_temperatures', 'temperatures') redis.printer_status_set(printer.id, octoprint_data, ex=STATUS_TTL_SECONDS) if status.get('current_print_ts'): # New plugin version that passes current_print_ts process_octoprint_status_with_ts(status, printer) channels.send_status_to_web(printer.id) return ### Old way of determining a print. For backward compatibility filename, printing, cancelled = file_printing(status, printer) if printing is not None: if printing: printer.set_current_print(filename) else: printer.unset_current_print(cancelled) channels.send_status_to_web(printer.id)
def process_octoprint_status(printer, status): octoprint_settings = status.get('octoprint_settings') if octoprint_settings: redis.printer_settings_set(printer.id, settings_dict(octoprint_settings)) octoprint_data = dict() set_as_str_if_present(octoprint_data, status.get('octoprint_data', {}), 'state') set_as_str_if_present(octoprint_data, status.get('octoprint_data', {}), 'progress') set_as_str_if_present(octoprint_data, status, 'octoprint_temperatures', 'temperatures') redis.printer_status_set(printer.id, octoprint_data, ex=STATUS_TTL_SECONDS) if status.get('current_print_ts'): process_octoprint_status_with_ts(status, printer) channels.send_status_to_web(printer.id)
def process_octoprint_status(printer: Printer, status: Dict) -> None: octoprint_settings = status.get('octoprint_settings') if octoprint_settings: cache.printer_settings_set(printer.id, settings_dict(octoprint_settings)) # for backward compatibility if status.get('octoprint_data'): if 'octoprint_temperatures' in status: status['octoprint_data']['temperatures'] = status[ 'octoprint_temperatures'] if not status.get('octoprint_data'): cache.printer_status_delete(printer.id) elif status.get('octoprint_data', {}).get('_ts'): # data format for plugin 1.6.0 and higher cache.printer_status_set(printer.id, json.dumps(status.get('octoprint_data', {})), ex=STATUS_TTL_SECONDS) else: octoprint_data: Dict = dict() set_as_str_if_present(octoprint_data, status.get('octoprint_data', {}), 'state') set_as_str_if_present(octoprint_data, status.get('octoprint_data', {}), 'progress') set_as_str_if_present(octoprint_data, status.get('octoprint_data', {}), 'file_metadata') set_as_str_if_present(octoprint_data, status.get('octoprint_data', {}), 'currentZ') set_as_str_if_present(octoprint_data, status.get('octoprint_data', {}), 'job') set_as_str_if_present(octoprint_data, status.get('octoprint_data', {}), 'temperatures') cache.printer_status_set(printer.id, octoprint_data, ex=STATUS_TTL_SECONDS) if status.get('current_print_ts'): process_octoprint_status_with_ts(status, printer) channels.send_status_to_web(printer.id) temps = status.get('octoprint_data', {}).get('temperatures', None) if temps: process_heater_temps(printer, temps)
def process_octoprint_status(printer: Printer, status: Dict) -> None: octoprint_settings = status.get('octoprint_settings') if octoprint_settings: cache.printer_settings_set(printer.id, settings_dict(octoprint_settings)) octoprint_data: Dict = dict() set_as_str_if_present(octoprint_data, status.get('octoprint_data', {}), 'state') set_as_str_if_present(octoprint_data, status.get('octoprint_data', {}), 'progress') set_as_str_if_present(octoprint_data, status.get('octoprint_data', {}), 'file_metadata') set_as_str_if_present(octoprint_data, status.get('octoprint_data', {}), 'currentZ') set_as_str_if_present(octoprint_data, status.get('octoprint_data', {}), 'job') set_as_str_if_present(octoprint_data, status, 'octoprint_temperatures', 'temperatures') cache.printer_status_set(printer.id, octoprint_data, ex=STATUS_TTL_SECONDS) if status.get('current_print_ts'): process_octoprint_status_with_ts(status, printer) channels.send_status_to_web(printer.id) temps = status.get('octoprint_temperatures', None) if temps: process_heater_temps(printer, temps)