homebridge-mqttswitch icon indicating copy to clipboard operation
homebridge-mqttswitch copied to clipboard

Homekit doesn't read status correctly

Open HairBear22 opened this issue 8 years ago • 6 comments

I have a MQTT switch set up, with the config attached below. When I use the correct get topic, Homekit won't retain the switch being on (when I flip it to on on my phone, it publishes the right topic, but the switch on homekit instantly returns to "off", while the device is "on".


"accessory": "mqttswitch",
		"name": "Sonoff A1",
		"url": "mqtt://127.0.0.1",
		"username": "",
		"password": "",
		"caption": "Christmas Lights",
				"topics": {
			"statusGet": "stat/sonoffA1/POWER",
			"statusSet": "cmnd/sonoffA1/power"
		},
		"onValue": "ON",
		"offValue": "OFF",
		"integerValue": "false"

HairBear22 avatar Dec 31 '16 18:12 HairBear22

Use topics like this: "topics": {"statusGet":"cmnd/sonoff/light","statusSet":"cmnd/sonoff/light"}

osvaldoasn avatar Jan 01 '17 20:01 osvaldoasn

Hi, homekit default off reconnect wifi. Not read status HomeBridge?

bleachhun avatar Jan 09 '17 11:01 bleachhun

@HairBear22 I'm having the exact same problem.

Have put it all on one line as @osvaldoasn suggested but it didn't fix the issue...

gid204 avatar Jan 11 '17 05:01 gid204

Working around by reading the echo of the command instead of reading the status wont update when another HomeKit clients changes the switch. Sonoff-MQTT returns a capital ON or OFF. Line 85 that.switchStatus = (status == "ON") ? true : false; Is a quick fix. I'll work on weaving it in and adding one more configuration to implementing it properly and then do a pull request.

TLCary avatar Jan 11 '17 18:01 TLCary

Awesome! Any ETA on that? @TLCary

HairBear22 avatar Jan 20 '17 02:01 HairBear22

Great. For me works fine with "ON" in line 85. btw, "ON" "OFF" onValue and offValue gives default true and false. if you set onValue = "off" it will work with default true value. should use "true" and "false" values i config. the same is in case with the "integerValue": "true" onValue = 0 will work in the code like "true"

and MQTT responce are case sensetive.

Kisaua avatar Jan 24 '17 09:01 Kisaua