Skip to content

Commit

Permalink
Adds ignore devices feature from issue jhurliman#4 and jhurliman#13.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkormendy committed May 20, 2019
1 parent cc87b77 commit 4a14bfc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ Forked from John Hurliman's FrontPoint* plugin for Homebridge<small>[↗](https:
"noEntryDelay": false,
"silentArming": false
}
}
},
"ignoredDevices": [
"96922426-1",
"96922426-4"
]
}
```
### Fields:
Expand All @@ -73,6 +77,7 @@ Forked from John Hurliman's FrontPoint* plugin for Homebridge<small>[↗](https:
* "authTimeoutMinutes": Timeout to Re-Authenticate session (**WARNING:** choosing a time less than 10 minutes could possibly ban/disable your account from Alarm.com)
* "pollTimeoutSeconds": Device polling interval (**WARNING:** choosing a time less than 60 seconds could possibly ban/disable your account from Alarm.com)
* <details><summary>"logLevel": Adjust what gets reported in the logs <strong>(click to expand)</strong></summary><ul><li>0 = NO LOG ENTRIES</li><li>1 = ONLY ERRORS</li><li>2 = ONLY WARNINGS and ERRORS</li><li><strong>3 = GENERAL NOTICES, ERRORS and WARNINGS (default)</strong></li><li>4 = VERBOSE (everything including development output)</li></ul></details>
* "ignoredDevices": An array of IDs for Alarm.com accessories you wish to hide in Homekit

# Troubleshooting

Expand Down Expand Up @@ -113,3 +118,8 @@ To modify the log behaviour, add the "logLevel" field to the Alarmdotcom platfor
"logLevel": 1
}
```

### Ignoring Devices

Accessories that you wish to hide in Homekit (e.g., fobs) can be identified by finding the Serial Number in the settings of the accessory in the Apple Home app, or alternatively in your output log (log level 3 or higher) when Homebridge starts up. If the accessories still exist in Homekit, please make sure that you have typed the serial number exactly. If they still continue to be displayed (or vice-versa they still don't show up after un-ignoring them), then you may be required to delete the `~/.homebridge/accessories/cachedAccessories` file as they may still be stored in the cache within Homebridge.

32 changes: 22 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ADCPlatform {
this.config = config || { platform: PLUGIN_NAME }
this.debug = this.config.debug || false
this.config.logLevel = this.config.logLevel || LOG_LEVEL
this.ignoredDevices = this.config.ignoredDevices || []

if (!this.config.username)
throw new Error('Alarm.com: Missing required username in config')
Expand Down Expand Up @@ -85,9 +86,16 @@ class ADCPlatform {
})

res.sensors.forEach(s => {
this.addSensor(s)
if (this.config.logLevel > 2)
this.log(`Added sensor ${s.attributes.description} (${s.id})`)
// if the sensor id is not in the ignore list in the homebridge config
if (!this.ignoredDevices.includes(s.id)) {
this.addSensor(s)
if (this.config.logLevel > 2)
this.log(`Added sensor ${s.attributes.description} (${s.id})`)
}
else {
if (this.config.logLevel > 2)
this.log(`Ignored sensor ${s.attributes.description} (${s.id})`)
}
})
})
.catch(err => {
Expand Down Expand Up @@ -366,6 +374,8 @@ class ADCPlatform {
addSensor(sensor) {
const id = sensor.id
let accessory = this.accessories[id]
// in an ideal world, homebridge shouldn't be restarted too often
// so upon starting we clean out the cache of alarm accessories
if (accessory)
this.removeAccessory(accessory)

Expand All @@ -389,15 +399,17 @@ class ADCPlatform {
sensorType: model
}

if (this.config.logLevel > 2)
this.log(`Adding ${model} "${name}" (id=${id}, uuid=${uuid})`)

this.addAccessory(accessory, type, model)
// if the sensor id is not in the ignore list in the homebridge config
if (!this.ignoredDevices.includes(id)) {
if (this.config.logLevel > 2)
this.log(`Adding ${model} "${name}" (id=${id}, uuid=${uuid})`)

this.setupSensor(accessory)
this.addAccessory(accessory, type, model)
this.setupSensor(accessory)

// Set the initial sensor state
this.setSensorState(accessory, sensor)
// Set the initial sensor state
this.setSensorState(accessory, sensor)
}
}

setupSensor(accessory) {
Expand Down

0 comments on commit 4a14bfc

Please sign in to comment.