Blinkt MQTT and Python 3.9

Hi,

I have a new freshly installed Pi0 with the Blinkt connected to it, and it works great with the examples provided. However I’m trying to set it up with MQTT and everytime I send a message it crashes with the message
TypeError: a bytes-like object is required, not ‘str’

I’ve been doing some googling, and it looks like somehow python now requires changing of the topics to bytes, but I can’t really figure out if I should do it in the code and where, or when I’m sending the messages and in that case how.

Does anyone have a working example of the MQTT example for Python 3.9?

Traceback (most recent call last):
File “/home/nbla/Pimoroni/blinkt3/examples/./mqtt.py”, line 105, in
client.loop_forever()
File “/home/nbla/.local/lib/python3.9/site-packages/paho/mqtt/client.py”, line 1756, in loop_forever
rc = self._loop(timeout)
File “/home/nbla/.local/lib/python3.9/site-packages/paho/mqtt/client.py”, line 1164, in _loop
rc = self.loop_read()
File “/home/nbla/.local/lib/python3.9/site-packages/paho/mqtt/client.py”, line 1556, in loop_read
rc = self._packet_read()
File “/home/nbla/.local/lib/python3.9/site-packages/paho/mqtt/client.py”, line 2439, in _packet_read
rc = self._packet_handle()
File “/home/nbla/.local/lib/python3.9/site-packages/paho/mqtt/client.py”, line 3033, in _packet_handle
return self._handle_publish()
File “/home/nbla/.local/lib/python3.9/site-packages/paho/mqtt/client.py”, line 3327, in _handle_publish
self._handle_on_message(message)
File “/home/nbla/.local/lib/python3.9/site-packages/paho/mqtt/client.py”, line 3570, in _handle_on_message
on_message(self, self._userdata, message)
File “/home/nbla/Pimoroni/blinkt3/examples/./mqtt.py”, line 55, in on_message
data = msg.payload.split(‘,’)
TypeError: a bytes-like object is required, not ‘str’