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

UUID Error with multi-service accessory #303

Open chrismsnz opened 4 years ago

chrismsnz commented 4 years ago

I attempted to make a multi-service accessory for my aeotec trisensor (one device, has light, motion and temp).

accessory block from config file:

    "accessories": [
        {
            "accessory": "mqttthing",
            "type": "custom",
            "name": "Office TriSensor",
            "manufacturer": "Aeotec",
            "model": "TriSensor",
            "url": "http://10.71.10.83:1883",
            "logMqtt": true,
            "services": [
                {
                    "type": "motionSensor",
                    "name": "Office Motion",
                    "topics": {
                        "getBatteryLevel": "zwave/office/trisensor/128/1/0",
                        "getMotionDetected": {
                            "topic": "zwave/office/trisensor/113/1/256",
                            "apply": "return message == '0' ? true : false"
                        }
                    }
                },
                {
                    "type": "temperatureSensor",
                    "name": "Office Temperature",
                    "topics": {
                        "getBatteryLevel": "zwave/office/trisensor/128/1/0",
                        "getCurrentTemperature": "zwave/office/trisensor/49/1/1"
                    }
                }
            ]
        },

Error on restarting homebridge:

[7/20/2020, 8:32:17 PM] Error: Cannot add a Service with the same UUID '00000096-0000-1000-8000-0026BB765291' as another Service in this Accessory without also defining a unique 'subtype' proper
ty.
    at Accessory._this.addService (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:276:17)
    at /usr/local/lib/node_modules/homebridge/src/server.ts:488:21
    at Array.forEach (<anonymous>)
    at Server.createHAPAccessory (/usr/local/lib/node_modules/homebridge/src/server.ts:477:16)
    at /usr/local/lib/node_modules/homebridge/src/server.ts:360:30
    at Array.forEach (<anonymous>)
    at Server._loadAccessories (/usr/local/lib/node_modules/homebridge/src/server.ts:330:29)
    at Server.start (/usr/local/lib/node_modules/homebridge/src/server.ts:156:12)
    at cli (/usr/local/lib/node_modules/homebridge/src/cli.ts:80:10)
    at Object.<anonymous> (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22)

Error still occurred with just one accessory defined in config. I also tried setting a "subtype" property in the service and it didnt work.

I also tried dumping out the services block to log last night to see if I could find what might be clashing but don't really know what I'm doing. Possibly something to do with the battery service also being created?

arachnetech commented 3 years ago

00000096-0000-1000-8000-0026BB765291 corresponds to BatteryService.

If you remove one of your getBatteryLevel lines, then the composite accessory can be created. However, because they are grouped together Homekit correctly picks up the battery level and shows it in both sensors.

Curiously, Homekit doesn't actually show the sensors together - they are shown separately within the 'Motion Sensors' and 'Climate' sections; I don't know whether there a way to change this in iOS 14.

chrismsnz commented 3 years ago

Hmm, I'm sure I tried removing various battery services but it was a while ago now. Thanks for taking a look at it I will get around to testing it in the next week or so.