[SOLVED] MQTT breaking homekit binding

I’m trying to set up a MQTT switch in homekit. Everything works great in openHAB but when I add the [“Switchable”] tag, every single one of my homekit items disappears from my phone and the little openHAB “house” hub says "this accessory is not supported.

The offending item is below. Again - in openHAB without the [“Switchable”] everything works properly.

Switch MQTTTester "GARAGE" ["Switchable"]  { mqtt="<[mybroker:testing/mqtt/topic:state:ON:ON],<[mybroker:testing/mqtt/topic:state:OFF:OFF], >[mybroker:testing/mqtt/back-topic:command:ON:ON],>[mybroker:testing/mqtt/back-topic:command:OFF:OFF]" }

Have you tried it without the incoming state topics? (I’m just guessing).

I think I did try it without the state topics. I think I found a fix - I changed the final “ON” and “OFF” to “1” and “0” respectively. It runs properly now - I removed all of my other (30+) homekit switches to focus on just this one so I’m about to see if I am able to add everything back in without any issues.

Good news (for now) is that this works:

Switch MQTTTester "GARAGE"  ["Switchable"]  { mqtt="<[mybroker:testing/mqtt/topic:state:ON:1],<[mybroker:testing/mqtt/topic:state:OFF:0], >[mybroker:testing/mqtt/back-topic:command:ON:1],>[mybroker:testing/mqtt/back-topic:command:OFF:0]" }

Did you try:

Switch MQTTTester "GARAGE" ["Switchable"]  { mqtt="<[mybroker:testing/mqtt/topic:state:default], >[mybroker:testing/mqtt/back-topic:command:*:default]" }

@vzorglub - that is how I set it up originally, it also did not work but I don’t remember if it was a “homekit not working” or a “MQTT not working” issue.

I think it was a MQTT problem, possibly because the payload coming back from the broker was ON and OFF. Changing the payload to 1 and 0 seems to have fixed things, I can continue my setup like this and should work just fine.

You can make the binding shorter by using the map transform:

In your folder conf/transform create two files:





Then you item is:

Switch MQTTTester "GARAGE"  ["Switchable"]  { mqtt="<[mybroker:testing/mqtt/topic:state:MAP(0OFF1ON.map)], >[mybroker:testing/mqtt/back-topic:command:MAP(OFF0ON1.map)]" }

Good luck