arachnetech / homebridge-mqttthing

A plugin for Homebridge allowing the integration of many different accessory types using MQTT.
Apache License 2.0
468 stars 103 forks source link

unable to add Xiaomi QBKG24LM switch #432

Open zuhair68 opened 3 years ago

zuhair68 commented 3 years ago

Hi, I'm unable to add Xiaomi QBKG24LM switch https://bit.ly/3vslrgg This is the configuration I'm using, which is not working:

{
    "accessory": "mqttthing",
    "type": "lightbulb-OnOff",
    "name": "Light",
    "topics": {
        "getOnline": "zigbee2mqtt/Switch1",
        "getOn": {
            "topic": "zigbee2mqtt/Switch1/get",
            "apply": "return JSON.parse(message).state_right === 'ON' ? true : false;"
        },
        "setOn": {
            "topic": "zigbee2mqtt/Switch1/set",
            "apply": "return JSON.stringify({state_right: (message ? \"ON\" : \"OFF\")});"

        }
    }
}

This is the zigbee2mqtt documentation for that switch:

Switch (right endpoint) #

zuhair68 commented 3 years ago

For the benefit of all, I solved it!

{
            "accessory": "mqttthing",
            "type": "switch",
            "name": "Basement Entrance 1",
            "url": "mqtt://192.168.3.100:1883",
            "username": "username",
            "password": "password",
            "logMqtt": true,
            "mqttPubOptions": {
                "retain": true
            },
            "topics": {
                "getOn": {
                    "topic": "zigbee2mqtt/zSwitchBasementEnt",
                    "apply": "return JSON.parse(message).state_right === 'ON' ? true : false;"
                },
                "setOn": {
                    "topic": "zigbee2mqtt/zSwitchBasementEnt/set",
                    "apply": "return JSON.stringify({state_right: (message ? \"ON\" : \"OFF\")});"
                }
            }
        }