Control via MQTT publish

Not sure if right forum, forgive me since it seems like MQTT is new to Bond and everybody’s still working out where it fits into The Order of Things.

I have my SBB device (Minka fan) configured to talk to my local MQTT broker and that’s working well, near as I can figure. To wit, (details changed for clarity, privacy and simplicity), if I do

mosquitto_pub.exe -h 192.168.1.1 -t v2/XYZ123/down/devices/00000001/state/ -m “{}”

The fan spits out

Topic: v2/XYZ123/up/devices/00000001/state/
Message: {“B”:“XYZ123”,“d”:0,“v”:“v3.5.0.3”,“i”:“blahblah”,“f”:4,“s”:200,“m”:0,“x”:“mqtt”,“b”:{“power”:0,“speed”:2,“light”:1,“brightness”:60,“brightness_cycle_phase”:-1,“timer”:0,“breeze”:[0,50,50],“direction”:1,“_”:“whatever”,“__”:“whatever”}}

So that says to me that the MQTT config is good on the fan.

But if I do

mosquitto_pub.exe -h 192.168.1.1 -t v2/XYZ123/down/devices/00000001/actions/TurnLightOff -m “{}”

which should turn off the light, right? I get

Topic: v2/XYZ123/up/devices/1/actions/TurnLightOff
Message: {“B”:“XYZ123”,“d”:0,“v”:“v3.5.0.3”,“i”:“blahblah”,“f”:4,“s”:204,“m”:0,“x”:“mqtt”}

Seems like I’d want a status code of 200, not 204, so I’m guessing I’m missing something in the publish to the fan to turn off the light. I have the same problem with other actions, SetBrightness (with -m “{"argument": 60}” or whatever, TurnOff for the fan itself, no change.

If this was connecting via http, I feel like I’d change the method to PUT instead of GET and it would magically work. I would strongly prefer to use MQTT because that plays nicely with everything else I’m doing (broker ALL the things!) and saves me having to do lots of custom coding.

Regardless, I don’t see anywhere in the API doc that mentions changing the method (or otherwise publishing TO the device.)

Or maybe I should be using a different topic, maybe it’s formatting? But it’s formatted just like the state one, right?

Any guidance appreciated.

– A

Relevant section of the docs: Bond Local API

What’s missing there is a good example of the payload. Try this body:

{"m": 2}

which means “method = PUT”.

And if you want to set the position of a shade, or speed of a fan:

{"m": 2, "b":{"argument": 42}}

Let us know how it goes. You will be (one of) the first to use third-party MQTT.

Well, things are happening. Now I see this

Topic v2/XYZ123/down/devices/00000001/actions/TurnLightOff
Message {“m”: 2}

Topic v2/XYZ123/up/devices/00000001/actions/TurnLightOff
Message {“B”:“XYZ123”,“d”:0,“v”:“v3.5.0.3”,“i”:“ff00002bda816104”,“f”:4,“s”:400,“m”:2,“x”:“mqtt”,“b”:{“_error_id”:747,“_error_msg”:“body must be object”}}

As for being bleeding edge / first / idiot (pick any ), I am finding that (when it all plays nice) MQTT allows the widely disparate Things in my house to talk to each other on an equal footing, all at once, so it is becoming my protocol of choice. That opinion is of course subject to change :slight_smile:

Thanks for the quick reply!

– A

Ah, sorry, should have been:

{"m": 2, "b":{}}

1 Like

Woot, that’s it. Other than remembering to escape quotes here and there, of course Perl is different than the command line, but it works.

Thanks again!

– A

2 Likes