Skip to content

Commit

Permalink
reject device when mac or ip not exist or in the wrong format
Browse files Browse the repository at this point in the history
  • Loading branch information
nitaybz committed Nov 10, 2020
1 parent dc28d43 commit 626d52f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/accessory.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ class OccupancySensor {

this.thresholdTimer = null

if (!this.serial) {
this.log(`Can't initiate ${this.name} device without mac address or ip address`)
this.log(`Please change your config`)
return
}

if (typeof this.serial !== 'string') {
this.log(`Wrong mac/ip address format`)
this.log(`Please adjust your config to include proper ip address (10.0.0.x) or mac address (3e:34:ae:87:f1:cc)`)
return
}

this.UUID = this.api.hap.uuid.generate(this.serial)
this.accessory = platform.accessories.find(accessory => accessory.UUID === this.UUID)

Expand Down

0 comments on commit 626d52f

Please sign in to comment.