UniversalDevicesInc-PG3 / udi-poly-ELK

MIT License
2 stars 1 forks source link

MQTT Send Error: Object of type ElkRPStatus is not JSON serializable #96

Open jimboca opened 1 year ago

jimboca commented 1 year ago

Code must be printing this somewhere?

2023-03-24 03:03:12,660 Command    udi_interface.interface ERROR    interface:send: MQTT Send Error: Object of type ElkRPStatus is not JSON serializable
Traceback (most recent call last):
  File "/var/polyglot/pg3/ns/0021b9025d7d_4/.local/lib/python3.9/site-packages/udi_interface/interface.py", line 619, in send
    self._mqttc.publish(topic, json.dumps(message), retain=False)
  File "/usr/local/lib/python3.9/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/usr/local/lib/python3.9/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/local/lib/python3.9/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/usr/local/lib/python3.9/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type ElkRPStatus is not JSON serializable
bpaauwe commented 1 year ago

That's coming from the interface.py send() method. It does a try/except around the mqttc.publish() call and it looks like the json.dumps() for the message that's being passed into send is failing.

It can't convert ElkRPStatus into a string.