Skip to content

Commit

Permalink
#10 Slight clean up. Forget about serialNumber.
Browse files Browse the repository at this point in the history
  • Loading branch information
raintonr committed Dec 27, 2022
1 parent bd97b80 commit 9a1a069
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: {
Expand Down

0 comments on commit 9a1a069

Please sign in to comment.