fix registering

This commit is contained in:
Luis Riegger 2021-05-09 19:02:02 +02:00
parent ca4b672bee
commit 28a35cbdb6
2 changed files with 6 additions and 6 deletions

View File

@ -177,17 +177,17 @@ export class KoboldVacuumRobotAccessory
private registerService(serviceName: RobotService, serviceType: WithUUID<typeof Service>) : Service | undefined private registerService(serviceName: RobotService, serviceType: WithUUID<typeof Service>) : 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 // query existing service by type and subtype
const existingService = this.accessory.getServiceById(serviceType, serviceName) const existingService = this.accessory.getServiceById(serviceType, serviceName)
if (this.availableServices.has(serviceName)) if (this.availableServices.has(serviceName))
{ {
if (existingService) { if (existingService && existingService.displayName === displayName) {
existingService.displayName = displayName // reset display name in case of locale change return existingService
return this.accessory.getServiceById(serviceType, serviceName)
} else { } 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); return this.accessory.addService(serviceType, displayName, serviceName);
} }
} }

View File

@ -40,7 +40,7 @@ export class HomebridgeKoboldPlatform implements DynamicPlatformPlugin
discoverRobots() discoverRobots()
{ {
const client = new KoboldApi.Client(); const client = new KoboldApi.Client();
this.log.debug("blubb"); this.log.debug("blub");
try try
{ {