From 4389ea76fd38788501e8b88d3f8734af97eb0050 Mon Sep 17 00:00:00 2001 From: Brett Date: Wed, 4 Sep 2024 07:27:00 +1000 Subject: [PATCH] Use generic names with nullish assignment --- src/platform.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/platform.ts b/src/platform.ts index 3f95076..17ebe9a 100644 --- a/src/platform.ts +++ b/src/platform.ts @@ -71,6 +71,7 @@ export class TeslaFleetApiPlatform implements DynamicPlatformPlugin { return; } this.TeslaFleetApi.vehicle!; + product.display_name ??= "Tesla"; const uuid = this.api.hap.uuid.generate( `${PLATFORM_NAME}:${product.vin}`, ); @@ -98,7 +99,7 @@ export class TeslaFleetApiPlatform implements DynamicPlatformPlugin { accessory.context.vin = product.vin; accessory.context.state = product.state; - accessory.displayName = product.display_name ?? "Tesla"; + accessory.displayName = product.display_name; new VehicleAccessory(this, accessory); }); @@ -117,6 +118,8 @@ export class TeslaFleetApiPlatform implements DynamicPlatformPlugin { return; } this.TeslaFleetApi.energy!; + product.site_name ??= "Tesla Energy"; + const uuid = this.api.hap.uuid.generate( `${PLATFORM_NAME}:${product.id}`, ); @@ -143,7 +146,7 @@ export class TeslaFleetApiPlatform implements DynamicPlatformPlugin { accessory.context.battery = product.components.battery; accessory.context.grid = product.components.grid; accessory.context.solar = product.components.solar; - accessory.displayName = product.site_name ?? "Tesla Energy"; + accessory.displayName = product.site_name; new EnergyAccessory(this, accessory); });