-
Notifications
You must be signed in to change notification settings - Fork 61
Closed
Description
The @mqtt_trigger decorator fails to trigger when an MQTT message with a non-UTF-8 encoding is published to the subscribed topic.
This issue appears to be caused by the process where @mqtt_trigger attempts to decode the message payload into a string using the default utf-8 encoding.
Reproduction Steps
-
Define a Simple PyScript Function: Create a function that uses the
@mqtt_triggerdecorator to subscribe to a test topic (e.g.,'test_topic').@mqtt_trigger('test_topic') def test(**kwargs): log.info('triggered!')
-
Publish a Non-UTF-8 Payload: Use an MQTT client (like
mosquitto_pub) to publish a payload that contains bytes that are invalid for UTF-8 decoding (e.g.,\xfe\xff) to the topic defined in the trigger.printf '\xfe\xff' | mosquitto_pub -t test_topic -l
Outcome
When the non-UTF-8 payload is received:
- The function decorated with
@mqtt_triggeris not triggered. - An error message related to decoding is logged.
Error Message (From Home Assistant Log)
Can't decode payload b'\xfe\xff' on test_topic with encoding utf-8 (for <Job None HassJobType.Coroutinefunction functools.partial(<function _async_wrapper at 0xe34afe64a480>, <function Mqtt.mqtt_message_handler_maker.<locals>.mqtt_message_handler at 0xe34acc7ab4c0>, functools.partial(<bound method MQTT._exception_message of <homeassistant.components.mqtt.client.MQTT object at 0xe34ad2f68ec0>>, <function Mqtt.mqtt_message_handler_maker.<locals>.mqtt_message_handler at 0xe34acc7ab4c0>))>)
Metadata
Metadata
Assignees
Labels
No labels