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
{
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);
}
}

View File

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