Log filling with MQTT Errors

For a while my appdaemon.log has contained references to being unable to read MQTT messages. With a recent update to the AppDaemon add-on, the error message has become much more verbose and now fills the log.

2023-06-21 10:37:13.528901 ERROR MQTT: Unable to decode MQTT message, with Traceback: Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/appdaemon/plugins/mqtt/mqttplugin.py", line 271, in mqtt_on_message
    payload = payload.decode()
              ^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

I’ve tried tweaking the config, but nothing seems to make any difference.
Any suggestions to a fix so I can not have logs constantly rotating becuase they are full of this message?

did you find a solution to this?

Nope. Still filling up my logs. Not had any responses or suggestions from anyone. Few vaguely related posts I’ve found in the wild have all failed.

So I’m now actively moving towards removing AppDaemon.

At a glance it seems like AppDaemon is expecting a text payload and it is receiving binary. Have you seen this: MQTT: Unable to decode MQTT message. · Issue #1832 · AppDaemon/appdaemon · GitHub

No I hadn’t seen that issue, but that also seems to be a bug related to the configuration of the MQTT topics. Mine are already configured as a list:

      client_topics:
        - frigate/#
        - zigbee2mqtt/#

But the binary point is relevant as the Frigate topic includes camera snapshots that won’t be string based data. This is the solution to the log issue.

I imagine that will be the problem.

There are probably cases where you might want AD to act on image messages and other non-text data, so it might be worth logging an issue so they can have it fail gracefully.

I don’t really know Frigate but assuming you aren’t currently acting on the images (presumably not since it seems like it wouldn’t be working) you can probably adjust your topic list to something like:

frigate/#/status
frigate/#/objects
etc.

to avoid receiving the frigate/#/image messages (those topics are made up, but I expect frigate has some sort of structure to it’s topics that would make the basic idea viable).

I am still kind of new to sharing solutions but for anyone still having issues, especially for those intending to use Frigate mqtt topics, I resolved mine by simply changing the python line in mqttplugin.py file to ignore errors.

From:

  payload = payload.decode()

To:

  payload = payload.decode(errors='ignore')

Seems to work for me.