I have temperature sensor which sends data to mqtt in binary form. It means there is information about temperature on some bytes and humidity on another bytes.
Problem is that there are non utf-8 characters in message - it really binary format.
Data example is like that: [0x25, 0xA4, 0x4C, 0xE7, 0x51]. I need to do some binary operations to get temperature and humidity.
Can I work with this message on mqtt sensor? I think binary sensor si not solution because it is only true/false but I need to use byte array to read numbers.
Two days with ChatGPT and google doesn’t bring any solution.
Thanks.
I don’t normally like to get pedantic, but in this case it matters. That’s not binary data, it’s hexadecimal. You might have had more luck with Google (please don’t use ChatGPt, it mostly gives you back garbage when it comes to HA) if you had been searching for hexadecimal rather than binary. You can covert hexadecimal to decimal for display:
If you are getting all that data at once, I hope there is some pattern that tells you which of that is the temperature and which is humidity. You can either loop through the array of data or pick the item that corresponds to what you need and convert that. If that’s just a string, you’ll need to convert it into an array first and then do that.
I’m pretty sure all that is possible with Jinga templates, but it’s going to be complex.
Thank you. It is about data representation only. First problem what I have is
Can’t decode payload b’%\xa4L\xe7Q’ on mqtttopic with encoding utf-8. So I cannot data read from into value template.
It seams that HA read data as string.