dawidchyrzynski / arduino-home-assistant

ArduinoHA allows to integrate an Arduino/ESP based device with Home Assistant using MQTT.
https://dawidchyrzynski.github.io/arduino-home-assistant/
GNU Affero General Public License v3.0
480 stars 116 forks source link

MQTT Payload always contains HA Config #138

Closed Blueforcer closed 1 year ago

Blueforcer commented 1 year ago

besides HA i use the libs MQTT cleint also for other things. if i receive a message, there is always some ha config in the payload. in following example i only send "hallo"

hallo1097bd33921c/BTN8/config���␄�B���>5E��;w��EY�f��R␑�␎6�&��␛�R�W��ԙb���p�ė�I␗�␎&l*�����J꣨:mb␝���W␝:l�^A���␗]۪�S�{�[�����h␇�ە���s␜�␗�␆{|����~��␚�␡2l␚H�^��*'␑�m���␘�Fӟ;>��,��␅�Lg2̹@�>���7�j���mrG�q_��^ A�␎=^�0�t��GUjIxV��T

i cannot find my error:)

dawidchyrzynski commented 1 year ago

Hi @Blueforcer,

Please provide the source code.

Blueforcer commented 1 year ago

Hi @dawidchyrzynski

there is nothing wich could change my payload i think image

Output is image

you can find the complete sourcecode here: https://github.com/Blueforcer/SmartPusher/blob/c8526b3a6932edda5b40b5a14447f0397fd892fd/src/MqttManager.cpp#L90

dawidchyrzynski commented 1 year ago

The onMessage callback function is designed to handle both external and internal messages that are processed by the library. However, if the message topic does not meet your requirements, it should be ignored. Therefore, it is important to implement the necessary checks to filter out irrelevant messages. It's expected behaviour. See the documentation: https://dawidchyrzynski.github.io/arduino-home-assistant/documents/api/core/ha-mqtt.html

Blueforcer commented 1 year ago

@dawidchyrzynski I already filter my topics. While the topic is correct the payload is still messed up. It contains my external message (green box) AND some internal data (Red) image

The length of the payload is also correct. i will now try to cut the payload according to the lenght

dawidchyrzynski commented 1 year ago

@Blueforcer That's due to an invalid conversion of uint8_t to String. The payload buffer doesn't contain a null terminator.