From 9a1a069644109610c18d4de2dd1ca48dcb130e51 Mon Sep 17 00:00:00 2001 From: Robin Rainton Date: Tue, 27 Dec 2022 18:43:53 +0100 Subject: [PATCH] #10 Slight clean up. Forget about serialNumber. --- main.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/main.js b/main.js index e792c51..9805fb9 100644 --- a/main.js +++ b/main.js @@ -166,7 +166,7 @@ class HikvisionAlarmserver extends utils.Adapter { } // Channel name is optional - const channelName = this.config.useChannels && xml.EventNotificationAlert.hasOwnProperty('channelName') ? + const channelName = this.config.useChannels && xml.EventNotificationAlert?.channelName ? xml.EventNotificationAlert.channelName[0] : null; // Strip colons from ID to be consistent with net-tools @@ -191,12 +191,9 @@ class HikvisionAlarmserver extends utils.Adapter { mac: macAddress }; // Add optional parts - if (xml.EventNotificationAlert.hasOwnProperty('ipAddress')) { + if (xml.EventNotificationAlert?.ipAddress) { native.ipAddress = xml.EventNotificationAlert.ipAddress[0]; } - if (xml.EventNotificationAlert.hasOwnProperty('serialNumber')) { - native.serialNumber = xml.EventNotificationAlert.serialNumber[0]; - } await this.setObjectNotExistsAsync(device, { type: 'device', common: {