New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MQTT random binary or other formats data #116437
Comments
Hey there @emontnemery, @jbouwh, @bdraco, mind taking a look at this issue as it has been labeled with an integration ( Code owner commandsCode owners of
(message by CodeOwnersMention) mqtt documentation |
Nothing changed between the tagged versions of Home Assistant related to encoding. By default we try to decode incoming payloads as This this signature of API method for @bind_hass
async def async_subscribe(
hass: HomeAssistant,
topic: str,
msg_callback: AsyncMessageCallbackType | MessageCallbackType,
qos: int = DEFAULT_QOS,
encoding: str | None = DEFAULT_ENCODING,
) -> CALLBACK_TYPE:
"""Subscribe to an MQTT topic.
.... |
Yes it is a custom component @jbouwh, the problem was that I had to implement that function as per sometimes the value is output as binary and sometime as string.. anyhow so far the work around works fine and of course if you do not plan to correct it (and thanks for the clarification) it is fine for me too.
Anyhow NodeRed and other "custom components" later on.. did become add-on or integrations, and as soon I can clean the code as it should be I hope to present it to you guys (so far I test it in the real world and it is not creating problems to the core) as per I try to keep up with your development as well. |
The problem
The subscribed topics format changed somehow, normally the strings are set as b"mystring" for this reason is necessary to convert the topic with my_variable.decode("utf-8"). I'm developing an "integration" and I had to, as work around, create a function to check the payload format. The $state of the entity sampled is a b"string" usually.. but sometimes it was output as str not binary value from MQTT (there was no change either on the way to subscribe the topic or in the vacuum data as there was no update on both).
What version of Home Assistant Core has the issue?
2024.5.b02
What was the last working version of Home Assistant Core?
2024.4.4
What type of installation are you running?
Home Assistant OS
Integration causing the issue
MQTT
Link to integration documentation on our website
https://www.home-assistant.io/integrations/mqtt/
Diagnostics information
Sorry no diagnostic available.
Example YAML snippet
No response
Anything in the logs that might be useful for us?
Additional information
https://github.com/sca075/valetudo_vacuum_camera/blob/2024.05/custom_components/valetudo_vacuum_camera/valetudo/MQTT/connector.py
The text was updated successfully, but these errors were encountered: