Manuel83 / cbpi-mqtt

3 stars 11 forks source link

python3 support #13

Open jpgimenez opened 4 years ago

ste-ta commented 3 years ago

Hey @jpgimenez,

I used your fork in order to get cbpi3 back up running on python3. Thanks a lot. However I encounter one isse with the MQTTPlugin. It looks as if the MQTT data is in bytes and causes issues:

2021-04-08T14:00:52.518603552Z Traceback (most recent call last):

2021-04-08T14:00:52.518648181Z File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner

2021-04-08T14:00:52.518690088Z self.run()

2021-04-08T14:00:52.518729625Z File "/usr/src/app/modules/plugins/MQTTPlugin/init.py", line 51, in run

2021-04-08T14:00:52.518769440Z self.client.loop_forever()

2021-04-08T14:00:52.518808050Z File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 1779, in loop_forever

2021-04-08T14:00:52.518847513Z rc = self.loop(timeout, max_packets)

2021-04-08T14:00:52.518885920Z File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 1181, in loop

2021-04-08T14:00:52.518925198Z rc = self.loop_read(max_packets)

2021-04-08T14:00:52.518963568Z File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 1572, in loop_read

2021-04-08T14:00:52.519002734Z rc = self._packet_read()

2021-04-08T14:00:52.519040549Z File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 2310, in _packet_read

2021-04-08T14:00:52.519079511Z rc = self._packet_handle()

2021-04-08T14:00:52.519117511Z File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 2936, in _packet_handle

2021-04-08T14:00:52.519156548Z return self._handle_publish()

2021-04-08T14:00:52.519194677Z File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 3216, in _handle_publish

2021-04-08T14:00:52.519233640Z self._handle_on_message(message)

2021-04-08T14:00:52.519271658Z File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 3429, in _handle_on_message

2021-04-08T14:00:52.519355657Z callback(self, self._userdata, message)

2021-04-08T14:00:52.519394398Z File "/usr/src/app/modules/plugins/MQTTPlugin/init.py", line 187, in on_message

2021-04-08T14:00:52.519431527Z print(("payload " + msg.payload))

2021-04-08T14:00:52.519468083Z TypeError: can only concatenate str (not "bytes") to str