arachnetech / homebridge-mqttthing

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

Xiaomi RTCGQ11LM is support? #315

Closed roysbike closed 3 years ago

roysbike commented 4 years ago

I using Xiaomi Aqara human body movement and illuminance sensor (occupancy and illuminance)


{
            "type": "occupancySensor",
            "name": "Sensor Bathroom",
            "url": "mqtt://192.168.88.3:1883",
            "logMqtt": true,
            "topics": {
                "getOnline": "zigbee2mqtt/0x00158d00054a726a",
                "getBatteryLevel": "zigbee2mqtt/0x00158d00054a726a",
                "getOccupancyDetected": "zigbee2mqtt/0x00158d00054a726a",
                "getStatusActive": "zigbee2mqtt/0x00158d00054a726a",
                "getStatusFault": "zigbee2mqtt/0x00158d00054a726a",
                "getStatusLowBattery": "zigbee2mqtt/0x00158d00054a726a"
            },
            "onValue": "true",
            "offValue": "false",
            "accessory": "mqttthing"
        }

But Occupancy not Detected ..

JSON output from mqtt topic zigbee2mqtt/0x00158d00054a726a {"battery":100,"voltage":3055,"illuminance":7,"illuminance_lux":7,"linkquality":26,"occupancy":true}

roysbike commented 4 years ago

Is work!!!

{
            "type": "occupancySensor",
            "name": "Sensor Bathroom",
            "url": "mqtt://192.168.88.3:1883",
            "accessory": "mqttthing",
            "logMqtt": true,
            "topics": {
                "getOccupancyDetected": {
                    "topic": "zigbee2mqtt/0x00158d00054a726a",
                    "apply": "return JSON.parse(message).occupancy;"
                },
                "getStatusLowBattery": {
                    "topic": "zigbee2mqtt/0x00158d00054a726a",
                    "apply": "if (JSON.parse(message).battery < 20) return 1; else return 0;"
                },
                "getBatteryLevel": {
                    "topic": "zigbee2mqtt/0x00158d00054a726a",
                    "apply": "return JSON.parse(message).battery;"
                }
            },
            "integerValue": true
        }