From b6131d9abdf63ee8bef04c6e3cf3821796eefe60 Mon Sep 17 00:00:00 2001 From: HJD Date: Thu, 26 Sep 2024 10:35:49 -0500 Subject: [PATCH] Housekeeping. --- src/devices/protect-camera.ts | 5 +++-- src/devices/protect-device.ts | 2 +- src/protect-nvr.ts | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/devices/protect-camera.ts b/src/devices/protect-camera.ts index a450d55..e12a22f 100644 --- a/src/devices/protect-camera.ts +++ b/src/devices/protect-camera.ts @@ -712,7 +712,7 @@ export class ProtectCamera extends ProtectDevice { let cameraChannels = this.ufp.channels.filter(x => x.isRtspEnabled); // Set the camera and shapshot URLs. - const cameraUrl = "rtsps://" + (this.nvr.config.overrideAddress ?? this.ufp.connectionHost) + ":" + this.nvr.ufp.ports.rtsps.toString() + "/"; + const cameraUrl = "rtsps://" + (this.nvr.config.overrideAddress ?? this.ufp.connectionHost ?? this.nvr.ufp.host) + ":" + this.nvr.ufp.ports.rtsps.toString() + "/"; // Filter out any package camera entries. We deal with those independently in the package camera class. cameraChannels = cameraChannels.filter(x => x.name !== "Package Camera"); @@ -1217,7 +1217,8 @@ export class ProtectCamera extends ProtectDevice { // Grab all the available RTSP channels and return them as a JSON. return JSON.stringify(Object.assign({}, ...this.ufp.channels.filter(channel => channel.isRtspEnabled) - .map(channel => ({ [channel.name]: "rtsps://" + this.nvr.ufp.host + ":" + this.nvr.ufp.ports.rtsp + "/" + channel.rtspAlias + "?enableSrtp" })))); + .map(channel => ({ [channel.name]: "rtsps://" + (this.nvr.config.overrideAddress ?? this.ufp.connectionHost ?? this.nvr.ufp.host) + ":" + + this.nvr.ufp.ports.rtsp + "/" + channel.rtspAlias + "?enableSrtp" })))); }); // Trigger snapshots when requested. diff --git a/src/devices/protect-device.ts b/src/devices/protect-device.ts index f0303b3..4faad70 100644 --- a/src/devices/protect-device.ts +++ b/src/devices/protect-device.ts @@ -222,7 +222,7 @@ export abstract class ProtectDevice extends ProtectBase { // Sync the Protect name with HomeKit, if configured. if(this.hints.syncName) { - this.accessoryName = this.ufp.name; + this.accessoryName = this.ufp.name ?? this.ufp.marketName ?? ("Unknown Device" + (this.ufp.mac ? ": " + this.ufp.mac : "")); } return this.setInfo(this.accessory, this.ufp); diff --git a/src/protect-nvr.ts b/src/protect-nvr.ts index 3f71ad6..0e8e2c5 100644 --- a/src/protect-nvr.ts +++ b/src/protect-nvr.ts @@ -341,7 +341,7 @@ export class ProtectNvr { // See if we already know about this accessory or if it's truly new. If it is new, add it to HomeKit. if((accessory = this.platform.accessories.find(x => x.UUID === uuid)) === undefined) { - accessory = new this.api.platformAccessory(device.name ?? device.marketName, uuid); + accessory = new this.api.platformAccessory(device.name ?? device.marketName ?? ("Unknown Device" + (device.mac ? ": " + device.mac : "")), uuid); this.log.info("%s: Adding %s to HomeKit%s.", this.ufpApi.getDeviceName(device), device.modelKey, this.hasFeature("Device.Standalone", device) ? " as a standalone device" : "");