Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 106602

Decoding binary mqtt payload

$
0
0

Greetings All,

A new HA users here. I’d appreciate some help with decoding a binary
mqtt payload (not a binary sensor in a sense that it only has two states, but the
actual binary payload sent as a stream of bytes). I am throwing into a towel
after searching for a few hours.

The payload looks like this in C:

struct Message {
    struct Header {
       uint16_t id; // 2 bytes
       uint64_t timestamp;  // 8 bytes
       uint64_t sequence; 
    } header;
    uint8_t value1;
    uint8_t value2;
    uint16_t value3;
};

This struct is packed i.e. there are no holes.
A message like the one above is published on a mqtt topic, with the struct above
cast to uint8 and used as a payload.

What I know so far: I managed to configure a few sensors in HA that publish
a single value in json format.

If someone has a simple example on how to read the binary payload and make it
available to HA, I would appreciate it.

Thanks!

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 106602

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>