HomeKit Unique Identifiers

Just some observations.


It appears that a uniqueidentifier attribute with a type of NSUUID has been added to most, if not all, HomeKit objects (see iOS 9.0 API Diffs). I haven't found any further documentation detailing the semantics of these new attributes. However, I have noticed that the values are apparently not ubiquitous, meaning that the values are different across multiple devices.


As an example, I'm testing the same application on both an iPhone and iPad. When I log the uniqueidentifier of a specific home on each device, I see two different UUID values. Needless to say, this makes it difficult to associate context with HomeKit objects and then share that context across devices.

Due to the privacy concern, the uniqueIdentifier of each HomeKit object will be different across multiple devices. To sync customized content associated with HomeKit object, I'd suggest you match the object by name and type...

Unique identifiers shared across a user's devices should no more of a privacy concern than the use of unique object names. The issue with object names is that they can be subsequently changed, even from other HomeKit enabled applications, which would immediately orphan any supplemental data associated with the object.

Yeah, I agree that decision is strange... If you have time, feel free to file a bug report ask for enhancement to uniqueIdentifier 🙂

Just a thought. It appears that HomeKit utilizes a type 5 UUID, which is based on a SHA-1 hash of other data. It is possible that HomeKit includes a random salt local to the device. Without the salt value, it would be difficult for even Apple to associated a particular UUID with a given user.

I did file an enhancement request. Unfortunately, since iOS 9 is now released, any change to the UUID scheme will break existing applications which utilize those values.

Hope they can fix this with a migration path... otherwise it's painful for developer to sync data associated to HomeKit across multiple devices...

I have another question regarding these identifiers. We learned already that the UUIDs are not equal across several devices. My question is whether they are unique for a device or just unique for a device / home.


For example:

Home A - accessory 1 & accessory 2

Home B - accessory 3


Is it possible that accessory 1 and accessory 3 will get the same identifiers?

those UUIDs follows RFC 4122 Version 4 which the uniqueness is guaranteed.

The UUIDs I've seen appear to type 5 which are based on a SHA-1 hash of some presumably unique data. Despite the way RFC-4122 reads, the UUID generation algorithms cannot guarantee uniqueness. I’ve seen the term “statistically unique” used, which seems to imply a small chance of duplication, with the chance of duplication depending on the algorithm and quality of input.


To answer your question, it hard to say since Apple doesn’t reveal a great deal of detail regarding their implementation. However, from what I’ve seen so far, it seems likely that all the UUIDs will be “statistically unique” in the situation you’ve described.

I just realized, that all the UUIDs changed after I updated to iOS 9.3 beta 4.

Some objects like rooms, zones and scenes I had identified by the unique identifier now have completely different IDs

is this what is to expect with every update?

The UUID implementation seems to be not very solid. What I found out is that UUIDs change between Testflight and final release environment. Not very handy for testing.


Can somebody confirm this behavior?

I'm wondering how Apple implemented the re-ordering of accessories in the control center & home app - which is indeed synced across multiple devices. Does anybody has a sugestion? I do not like the approach to sync the data based on object name + type.

Another thought that you could try out if you'd like some sort of identifier that is the same amongst devices: Every Accessory has a Service with AccessoryInformation. In there you can access values such as the SerialNumber, the Model, and so on. (I know these are deprecated as for the newest HomeKit version coming for iOS 11) - But! These identifiers are unique and you can use them to map to Accessories. Now, every service has a certain type, which you can also use for identifying. And since one service cannot have multiple values of the same characteristicTypes (Why should a "lightbulb" service have two characteristics "Brightness") you can identify those too, clearly. The only issue you might run into is that an accessory can have mulitple services with the same serviceType. Now, if this is not applicable for your case, you can move on. But there is one very ugly approach that will work: You can just save the index of the service in the services Array for the accessory :') There you go, a uniquely identified accessory amongst devices.

HomeKit Unique Identifiers
 
 
Q