ilcato / homebridge-mqttswitch

Homebridge accessory plugin that create an HomeKit Switch based on MQTT topics
Apache License 2.0
31 stars 41 forks source link

Homekit doesn't read status correctly #11

Open HairBear22 opened 7 years ago

HairBear22 commented 7 years ago

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"
osvaldoasn commented 7 years ago

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

bleachhun commented 7 years ago

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

gid204 commented 7 years ago

@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...

TLCary commented 7 years ago

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.

HairBear22 commented 7 years ago

Awesome! Any ETA on that? @TLCary

Kisaua commented 7 years ago

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.