[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>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
Cody Cutrer 2024-07-26 01:12:25 -06:00 committed by Ciprian Pascu
parent 3808984572
commit 180a78e461

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.