Can't seem to send a hex value to an MQTT broker as bytes

I’m trying to hook up a wifi light bulb to Home Assistant via MQTT and I’m having an issue with the payload. The light is a TechLife Pro (cheap as chips Chinese thing from AliExpress) and so far I’ve figured out that it works by connecting to an MQTT broker in China (not ideal, but ok for now) and sending 0xfa0x230x000x000x000x000x000x000x000x000x000x000x000x000x230xfb as the payload for “on” and 0xfa0x240x000x000x000x000x000x000x000x000x000x000x000x000x240xfb as the payload for off. If I send these values via mosquitto_pub, it works as expected:

echo -en "\xfa\x23\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x23\xfb" | mosquitto_pub -t "dev_sub_mylightsmac" -s -h "cloud.qh-tek.com" -u "myuser" -P "mypass"

That switches the light on, correctly, and the equivalent (with 24 instead of 23) switches it off again.

For the life of me, I can’t find the equivalent string to put in the payload_on and payload_off lines of my MQTT light config in configuration.yaml. I’ve googled everything I can think of, I can only assume my query is either so simple nobody else ever needed to ask, or impossible and no one else was daft enough to ask.

How do I instruct Home Assistant to send the actual bytes and not the string representation?

The problem, i think, is that you need to configure the china mqtt broker in HA.

I would use a command_line switch with the two mosquitto_pub commands, but that depends on your HA installation method.

The broker is configured, actually. That part is fine. If I use mosquitto_sub to listen to requests for my bulb, I can see requests from HA come in, so they’re being sent to the broker fine, it’s just that what’s being sent isn’t what the broker wants to see.

I could make it work with the two mosquitto_pub commands, I guess. It just seemed neater this way. I presume there just isn’t a way to tell HA “this string I’m giving you should be treated as bytes”.

I’ll have a look at the command_line switch method. I can see what would be required there, I think. I just need to get the mosquitto executables and all relevant libs into my docker container.

Thanks

Good question. Maybe a suitable topic for a WTH.