I'm trying to come up with a robust way to know if printer is in error state.
What I initially did was:
has_error = state['flags']['error']
However, I ran into this:
'state': {'text': "Offline (Error: SerialException: 'device reports readiness to read but returned no data (device disconnec ted or multiple access on port?)' @ comm.py:_readline:2793)", 'flags': {'cancelling': False, 'paused': False, 'operational': False, 'pausing': False, 'printing': False, 're suming': False, 'sdReady': False, 'error': False, 'ready': False, 'finishing': False, 'closedOrError': True}}
Then I changed to:
has_error = state['flags']['error'] or state['flags']['closedOrError']
However, when the printer is disconnected the state string looks like this:
'state': {'text': 'Offline', 'flags': {'cancelling': False, 'paused': False, 'operational': False, 'pausing': False, 'printing': False, 'resuming': False, 'sdReady': False, 'error': False, 'ready': False, 'finishing': False, 'closedOrError': True}}
I have also seen state string like this:
'state': {'text': 'Error: Connection error, see Terminal tab', 'flags': {'cancelling': False, 'paused': False, 'operational': False, 'pausing': False, 'printing': False, 'resuming': False, 'sdReady': False, 'error': True, 'ready': False, 'finishing': False, 'closedOrError': True}},
What will be the robust way to know the printer is in error state and the user should know about it?