[homekit] Fix duplicate name characteristic errors (#17151)

Depending on how the accessory initializes, optional characteristics
may be added before or after the service. For IrrigationSystem, it's
added before optional characteristics.

Signed-off-by: Cody Cutrer <cody@cutrer.us>
This commit is contained in:
Cody Cutrer 2024-07-26 01:12:25 -06:00 committed by GitHub
parent 9ae9adf6f6
commit b39e3a79bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -451,6 +451,10 @@ public abstract class AbstractHomekitAccessoryImpl implements HomekitAccessory {
return;
}
rawCharacteristics.put(characteristic.getClass(), characteristic);
// belongs on the accessory information service
if (characteristic.getClass() == NameCharacteristic.class) {
return;
}
var service = getPrimaryService();
if (service != null) {
// find the corresponding add method at service and call it.