From 28a35cbdb67a8908c9023c9a67dd3c1c44fbb0ac Mon Sep 17 00:00:00 2001 From: Luis Riegger Date: Sun, 9 May 2021 19:02:02 +0200 Subject: [PATCH] fix registering --- src/accessories/koboldVacuumRobot.ts | 10 +++++----- src/homebridgeKoboldPlatform.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/accessories/koboldVacuumRobot.ts b/src/accessories/koboldVacuumRobot.ts index 758245b..0e07e78 100644 --- a/src/accessories/koboldVacuumRobot.ts +++ b/src/accessories/koboldVacuumRobot.ts @@ -177,17 +177,17 @@ export class KoboldVacuumRobotAccessory private registerService(serviceName: RobotService, serviceType: WithUUID) : Service | undefined { - const displayName = this.prefix ? this.robot.name + serviceName : localize(serviceName, this.locale); - + const displayName = (this.prefix ? (this.robot.name + " ") : "") + localize(serviceName, this.locale); + // query existing service by type and subtype const existingService = this.accessory.getServiceById(serviceType, serviceName) if (this.availableServices.has(serviceName)) { - if (existingService) { - existingService.displayName = displayName // reset display name in case of locale change - return this.accessory.getServiceById(serviceType, serviceName) + if (existingService && existingService.displayName === displayName) { + return existingService } else { + if (existingService) {this.accessory.removeService(existingService);} // delete to reset display name in case of locale or prefix change return this.accessory.addService(serviceType, displayName, serviceName); } } diff --git a/src/homebridgeKoboldPlatform.ts b/src/homebridgeKoboldPlatform.ts index 2be8910..b42658b 100644 --- a/src/homebridgeKoboldPlatform.ts +++ b/src/homebridgeKoboldPlatform.ts @@ -40,7 +40,7 @@ export class HomebridgeKoboldPlatform implements DynamicPlatformPlugin discoverRobots() { const client = new KoboldApi.Client(); - this.log.debug("blubb"); + this.log.debug("blub"); try {