From 1a2be5929a8bbacc4e57a5b40459433f02c20e7c Mon Sep 17 00:00:00 2001 From: Brett Date: Thu, 20 Jun 2024 07:53:02 +1000 Subject: [PATCH] Add configured name --- src/vehicle-services/base.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/vehicle-services/base.ts b/src/vehicle-services/base.ts index 6eb0f54..cff12ef 100644 --- a/src/vehicle-services/base.ts +++ b/src/vehicle-services/base.ts @@ -26,14 +26,24 @@ export abstract class BaseService { name = `${this.parent.accessory.displayName} ${name}`; - if (this.parent.accessory.getServiceById(definition, subtype)) { + if (this.accessory.getServiceById(definition, subtype)) { this.log.info(`Restoring service ${name}`); } else { this.log.info(`Creating service ${name}`); } this.service = - this.parent.accessory.getServiceById(definition, subtype) || - this.parent.accessory.addService(definition, name, subtype); + this.accessory.getServiceById(definition, subtype) || + this.accessory.addService(definition, name, subtype); + + // Set the configured name if it's not already set since Homekit wont use the display name + const ConfiguredName = this.service.getCharacteristic(this.platform.Characteristic.ConfiguredName); + if (!ConfiguredName.value) { + this.log.debug(`Configured name changing to ${name}`); + ConfiguredName.updateValue(name); + } else { + this.log.debug(`Configured name of ${name} is already set to ${ConfiguredName.value}`); + } + } }