/Dear @MTrab ,
I think I've found a situation in which the JSON sent from the Positech cloud is missing the key : DATA.MODULES.4G.GPS .
if this happens an exception is thrown :
Exception in thread Thread-1 (_thread_main):
Traceback (most recent call last):
File "/usr/local/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.11/threading.py", line 982, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.11/site-packages/paho/mqtt/client.py", line 3591, in _thread_main
self.loop_forever(retry_first_connection=True)
File "/usr/local/lib/python3.11/site-packages/paho/mqtt/client.py", line 1756, in loop_forever
rc = self._loop(timeout)
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/paho/mqtt/client.py", line 1164, in _loop
rc = self.loop_read()
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/paho/mqtt/client.py", line 1556, in loop_read
rc = self._packet_read()
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/paho/mqtt/client.py", line 2439, in _packet_read
rc = self._packet_handle()
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/paho/mqtt/client.py", line 3033, in _packet_handle
return self._handle_publish()
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/paho/mqtt/client.py", line 3330, in _handle_publish
self._handle_on_message(message)
File "/usr/local/lib/python3.11/site-packages/paho/mqtt/client.py", line 3570, in _handle_on_message
on_message(self, self._userdata, message)
File "/code/pyworxcloud/utils/mqtt.py", line 149, in _forward_on_message
self._on_update(msg)
File "/code/pyworxcloud/__init__.py", line 395, in _on_update
self._decode_data(device)
File "/code/pyworxcloud/__init__.py", line 475, in _decode_data
data["dat"]["modules"]["4G"]["gps"]["coo"][0],
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^
this error seems to stop the connection to the MQTT server , thus interrupting data receive.
as you can see the library correctly issue a force update, but no data is received:
I suggest to add Key verification to the code at line 471:
# Check for extra module availability
if "modules" in data["dat"]:
if "4G" in data["dat"]["modules"]:
if "gps" in data["dat"]["modules"]["4G"]:
device.gps = Location(
data["dat"]["modules"]["4G"]["gps"]["coo"][0],
data["dat"]["modules"]["4G"]["gps"]["coo"][1],
)
/Dear @MTrab , I think I've found a situation in which the JSON sent from the Positech cloud is missing the key : DATA.MODULES.4G.GPS .
if this happens an exception is thrown :
this error seems to stop the connection to the MQTT server , thus interrupting data receive.
as you can see the library correctly issue a force update, but no data is received:
I suggest to add Key verification to the code at line 471: