AppDaemon / appdaemon

:page_facing_up: Python Apps for Home Automation
Other
853 stars 419 forks source link

MQTT: Unable to decode MQTT message. #1832

Open i3p4 opened 1 year ago

i3p4 commented 1 year ago

What happened?

Hello. I have an appdaemon connected to rhasspy. Here are the settings: MQTT: type: mqtt namespace: "mqtt" client_host: "myhost" client_port: 12183 client_id: "appdaemon" client_topics: "hermes/intent/#" The logs keep repeating the error message: 2023-06-28 19:23:09.871337 ERROR MQTT: Unable to decode MQTT message, with Traceback: Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/appdaemon/plugins/mqtt/mqttplugin.py", line 271, in mqtt_on_message payload = payload.decode() UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 24: invalid start byte As I understand it, this happens because the appdaemon is trying to parse the audio: 2023-06-28 19:23:09.869275 DEBUG MQTT: Message Received: Topic = hermes/audioServer/default/audioFrame, Payload = I tried to subscribe only to the intent in the settings, but it didn't change anything. Problems:

  1. It is impossible to view the logs, and therefore it is not possible to debug your applications.
  2. I'm not sure, but I guess the whole mqtt plugin starts working somehow wrong after these errors. I have not been able to run a simple application on this plugin. And I can't find the error, see point 1.

Version

4.4.2

Installation type

Docker container

Relevant log output

No response

Relevant code in the app or config file that caused the issue

No response

Anything else?

No response

Odianosen25 commented 1 year ago

Hello @i3p4,

from all indications, it should be fine as in the settings above. But are you sure there isn’t an app subscribing to that topic? Also possible or it subscribed, but you might have removed it or shut it down before having it unsubscribe from that topic.

Since you only subscribing to the intent topic, should not be an issue really.

kind regards

i3p4 commented 1 year ago

Hello @Odianosen25. Thanks for the answer. I found what the problem is. The problem is in one value in the configuration file: client_topics: "hermes/intent/#" In this form, the mqtt client treats the string as a list and subscribes to each character. Line 42: self.mqtt_client_topics = self.config.get("client_topics", ["#"]) Line 55: if self.mqtt_client_topics == "NONE": self.mqtt_client_topics = [] Line 194: client_topics = copy.deepcopy(self.mqtt_client_topics) for topic in client_topics: self.mqtt_subscribe(topic, self.mqtt_qos) Please add to the documentation that client_topics must be a list, even with a single value. For example: client_topics:

Odianosen25 commented 1 year ago

Ah thanks for that @i3p4, it’s indeed a bug. Will try and get it fixed. Kind regards

amaisano commented 1 year ago

Would you happen to know if this is the same issue? I am not using client_topics

https://github.com/hassio-addons/addon-appdaemon/issues/275

vaibhav2912 commented 11 months ago

I am also seeing the same error since last few days.

I do NOT have client_id or client_topics fields defined in the configuration.

What can I do to debug this and find the root cause ?

2023-12-08 23:27:48.312498 INFO MQTT: Unable to decode MQTT message 2023-12-08 23:27:48.313944 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 0x89 in position 0: invalid start byte

vaibhav2912 commented 11 months ago

@Odianosen25, I see you created https://github.com/AppDaemon/appdaemon/pull/1771 and it was merged on April 24th. I am getting 100s of these Unable to decode MQTT message errors every day.

Do you know when a new release will be available with this commit ?

catdogmaus commented 5 months ago

Have same error 2024-06-12 22:05:55.120424 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 0x84 in position 3: invalid start byte

Oekn5w commented 2 months ago

Applying #1771 directly to my container via docker cp , I saw that for me this message was thrown by Valetudo's encoded map data topic. I didn't have client_topics defined in my config. I set client_topics: "NONE" (from the special handling in code) and my mqtt_subscribes continued to work from the apps. So, I'm unsure what these events are used for in AD