fizista / micropython-umqtt.robust2

MIT License
49 stars 7 forks source link

Topic names are bytes? #10

Closed guillochon closed 2 years ago

guillochon commented 2 years ago

Hi, I'm publishing from a sensor using the umqtt.robust2 library. It appears that the topic names are in bytes format, these topics don't seem to be subscribable by other services (e.g. mqttthing in homebridge) that expect topic names to be strings:

image

Is there a way to force a topic name to be a string? Even manually creating a topic with the same name as a string in MQTT Explorer results in a completely separate topic. Any workarounds/solutions here?

guillochon commented 2 years ago

As a datapoint here: I tried the mqtt_async library hello-world.py code and it properly sets a string topic rather than a bytes topic. The bytes sent in the preamble of that code's publish call is different from what this package sends. I'm not sure which differences matter but...maybe there's a clue there? https://github.com/tve/mqboard/blob/master/mqtt_async/mqtt_async.py#L361

guillochon commented 2 years ago

OK, figured out my stupidity: I had inadvertently formatted a bytes object into the topic string. Entirely my fault.