https://github.com/node-alarm-dot-com/node-alarm-dot-com
A module written in Node.js to interface with Alarm.com security systems.
https://github.com/node-alarm-dot-com/node-alarm-dot-com
Last synced: 2 months ago
JSON representation
A module written in Node.js to interface with Alarm.com security systems.
- Host: GitHub
- URL: https://github.com/node-alarm-dot-com/node-alarm-dot-com
- Owner: node-alarm-dot-com
- License: mit
- Created: 2018-08-20T02:12:54.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-09-21T15:36:09.000Z (over 1 year ago)
- Last Synced: 2025-04-02T07:51:17.838Z (about 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 298 KB
- Stars: 26
- Watchers: 6
- Forks: 15
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Node.js Alarm.com Interface
Unofficial interface module written in Node.js to access and operate [Alarm.com](https://www.alarm.com/) security systems.
This interface works best with the fork: [https://github.com/node-alarm-dot-com/homebridge-node-alarm-dot-com](https://github.com/node-alarm-dot-com/homebridge-node-alarm-dot-com), based off of John Hurliman's FrontPoint\* plugin for Homebridge[↗](https://github.com/jhurliman/homebridge-frontpoint). This variation adds changes the default login authentication for to Alarm.com. with a switch to use the FrontPoint login authentication process if desired.
\*FrontPoint is simply a rebranded service provider for Alarm.com.
Originally intended for use with the fork: [https://github.com/node-alarm-dot-com/homebridge-node-alarm-dot-com](https://github.com/node-alarm-dot-com/homebridge-node-alarm-dot-com), originally created by Bryan Bartow for his Alarm.com plugin for Homebridge[↗](https://github.com/bryan-bartow/homebridge-alarm.com).
## Supported Features
- Querying panels
- Arming
- Disarming
- Sensors
- Contact states
- Occupancy states (this does not work due to lag in the Alarm.com webAPI itself)
- Water Leak states
- Lights
- On/Off switch
- Dimmer switch
- Locks
- Lock/Unlock switch
- Thermostats
- State (Off, Heat, Cool, Auto)
- Desired Heat setpoint
- Desired Cool setpoint
## Usage
**Install:**
`npm i node-alarm-dot-com`
**Querying:**
```js
const nodeADC = require('node-alarm-dot-com');
nodeADC
.login('your_username', 'your_password')
.then((authOpts) => nodeADC.getCurrentState(authOpts.systems[0], authOpts))
.then((res) => {
console.log('Security Systems:', res.partitions);
console.log('Sensors:', res.sensors);
})
.catch((err) => console.error(err));
```
**Arming:**
```js
const nodeADC = require('node-alarm-dot-com');
nodeADC
.login('your_username', 'your_password')
.then((authOpts) => {
return nodeADC.getCurrentState(authOpts.systems[0], authOpts).then((res) => {
// This will take 20-30 seconds
nodeADC.armStay(res.partitions[0].id, authOpts).then((res) => {
console.log(res);
});
});
})
.catch((err) => console.error(err));
```
## Documentation
- [nodeADC](#module_nodeADC)
- [~login(username, password)](#module_nodeADCmodule_nodeADC..login) ⇒ Promise
- [~getCurrentState(systemID, authOpts)](#module_nodeADC..getCurrentState) ⇒ Promise
- [~getPartition(partitionID, authOpts)](#module_nodeADC..getPartition) ⇒ Promise
- [~getSensors(sensorIDs, authOpts)](#module_nodeADC..getSensors) ⇒ Promise
- [~getLights(lightIDs, authOpts)](#module_nodeADC..getLights) ⇒ Promise
- [~turnOnLight(lightID, brightness, authOpts)](#module_nodeADC..turnOnLight) ⇒ Promise
- [~turnOffLight(lightID, brightness, authOpts)](#module_nodeADC..turnOffLight) ⇒ Promise
- [~getLocks(lockIDs, authOpts)](#module_nodeADC..getLocks) ⇒ Promise
- [~setLockSecure(lockID, authOpts)](#module_nodeADC..setLockSecure) ⇒ Promise
- [~setLockUnsecure(lockID, authOpts)](#module_nodeADC..setLockUnsecure) ⇒ Promise
- [~setThermostatState(thermostatID, newState, authOpts)](#module_nodeADC..setThermostatState) ⇒ Promise
- [~setThermostatTargetHeatTemperature(thermostatID, newTemp, authOpts)](#module_nodeADC..setThermostatTargetHeatTemperature) ⇒ Promise
- [~setThermostatTargetCoolTemperature(thermostatID, newTemp, authOpts)](#module_nodeADC..setThermostatTargetCoolTemperature) ⇒ Promise
- [~armStay(partitionID, authOpts, opts)](#module_nodeADC..armStay) ⇒ Promise
- [~armAway(partitionID, authOpts, opts)](#module_nodeADC..armAway) ⇒ Promise
- [~disarm(partitionID, authOpts)](#module_nodeADC..disarm) ⇒ Promise
### nodeADC~login(username, password) ⇒ Promise
Authenticate with alarm.com using the mobile webpage login form (loads faster than the desktop webpage login form). Returns an authentication object that can be passed to other methods.
**Kind**: inner method of [module_nodeADC](#module_nodeADC)
| Param | Type | Description |
| -------- | ------------------- | -------------------- |
| username | string | FrontPoint username. |
| password | string | FrontPoint password. |
### nodeADC~getCurrentState(systemID, authOpts) ⇒ Promise
Retrieve information about the current state of a security system including attributes, partitions, sensors, and relationships.
**Kind**: inner method of [nodeADC](#module_nodeADC)
| Param | Type | Description |
| -------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| systemID | string | ID of the FrontPoint system to query. The Authentication object returned from the `login` method contains a `systems` property which is an array of system IDs. |
| authOpts | Object | Authentication object returned from the `login` method. |
### nodeADC~getPartition(partitionID, authOpts) ⇒ Promise
Get information for a single security system partition.
**Kind**: inner method of [nodeADC](#module_nodeADC)
| Param | Type | Description |
| ----------- | ------------------- | ------------------------------------------------------- |
| partitionID | string | Partition ID to retrieve |
| authOpts | Object | Authentication object returned from the `login` method. |
### nodeADC~getSensors(sensorIDs, authOpts) ⇒ Promise
Get information for one or more sensors.
**Kind**: inner method of [nodeADC](#module_nodeADC)
| Param | Type | Description |
| --------- | -------------------------------------------------------- | ------------------------------------------------------- |
| sensorIDs | string \| Array.<string> | Array of sensor ID strings. |
| authOpts | Object | Authentication object returned from the `login` method. |
### nodeADC~getLights(lightIDs, authOpts) ⇒ Promise
Get information for one or more lights.
**Kind**: inner method of [nodeADC](#module_nodeADC)
| Param | Type | Description |
| -------- | -------------------------------------------------------- | ------------------------------------------------------- |
| lightIDs | string \| Array.<string> | Array of light ID strings. |
| authOpts | Object | Authentication object returned from the `login` method. |
### nodeADC~turnOnLight(lightID, brightness, authOpts) ⇒ Promise
Sets a light to ON and adjusts brightness level (1-100) of dimmable lights.
**Kind**: inner method of [nodeADC](#module_nodeADC)
| Param | Type | Description |
| ---------- | ------------------- | ------------------------------------------------------- |
| lightID | string | Light ID string. |
| brightness | number | An integer, 1-100, indicating brightness. |
| authOpts | Object | Authentication object returned from the `login` method. |
### nodeADC~turnOffLight(lightID, brightness, authOpts) ⇒ Promise
Sets a light to OFF. The brightness level is ignored.
**Kind**: inner method of [nodeADC](#module_nodeADC)
| Param | Type | Description |
| ---------- | ------------------- | ------------------------------------------------------------- |
| lightID | string | Light ID string. |
| brightness | number | An integer, 1-100, indicating brightness. Ignored. |
| authOpts | Object | Authentication object returned from the `login` method. |
### nodeADC~getLocks(lightIDs, authOpts) ⇒ Promise
Get information for one or more locks.
**Kind**: inner method of [nodeADC](#module_nodeADC)
| Param | Type | Description |
| -------- | -------------------------------------------------------- | ------------------------------------------------------- |
| lockIDs | string \| Array.<string> | Array of lock ID strings. |
| authOpts | Object | Authentication object returned from the `login` method. |
### nodeADC~setLockSecure(lockID, authOpts) ⇒ Promise
Sets a lock to "locked" (SECURED).
**Kind**: inner method of [nodeADC](#module_nodeADC)
| Param | Type | Description |
| -------- | ------------------- | ------------------------------------------------------- |
| lockID | string | Lock ID string. |
| authOpts | Object | Authentication object returned from the `login` method. |
### nodeADC~setLockUnsecure(lockID, authOpts) ⇒ Promise
Sets a lock to "unlocked" (UNSECURED).
**Kind**: inner method of [nodeADC](#module_nodeADC)
| Param | Type | Description |
| -------- | ------------------- | ------------------------------------------------------- |
| lockID | string | Lock ID string. |
| authOpts | Object | Authentication object returned from the `login` method. |
### nodeADC~setThermostatState(thermostatID, newState, authOpts) ⇒ Promise
Update Thermostat State (see `THERMOSTAT_STATES`)
**Kind**: inner method of [nodeADC](#module_nodeADC)
| Param | Type | Description |
| ------------ | ------------------------------ | ----------------------------------------------------------- |
| thermostatID | string | Thermostat ID string. |
| newState | THERMOSTAT_STATES | Desired state, `THERMOSTAT_STATES.OFF`/`HEAT`/`COOL`/`AUTO` |
| authOpts | Object | Authentication object returned from the `login` method. |
### nodeADC~setThermostatTargetHeatTemperature(thermostatID, newTemp, authOpts) ⇒ Promise
Set desired Heat setpoint temperature for Thermostat
**Kind**: inner method of [nodeADC](#module_nodeADC)
| Param | Type | Description |
| ------------ | ------------------- | ------------------------------------------------------- |
| thermostatID | string | Thermostat ID string. |
| newTemp | number | Desired temperature |
| authOpts | Object | Authentication object returned from the `login` method. |
### nodeADC~setThermostatTargetCoolTemperature(thermostatID, newTemp, authOpts) ⇒ Promise
Set desired Cool setpoint temperature for Thermostat
**Kind**: inner method of [nodeADC](#module_nodeADC)
| Param | Type | Description |
| ------------ | ------------------- | ------------------------------------------------------- |
| thermostatID | string | Thermostat ID string. |
| newTemp | number | Desired temperature |
| authOpts | Object | Authentication object returned from the `login` method. |
### nodeADC~armStay(partitionID, authOpts, opts) ⇒ Promise
Arm a security system panel in "stay" mode. NOTE: This call may take 20-30 seconds to complete.
**Kind**: inner method of [nodeADC](#module_nodeADC)
| Param | Type | Description |
| ----------------- | -------------------- | ------------------------------------------------------- |
| partitionID | string | Partition ID to arm. |
| authOpts | Object | Authentication object returned from the `login` method. |
| opts | Object | Optional arguments for arming the system. |
| opts.noEntryDelay | boolean | Disable the 30-second entry delay. |
| opts.silentArming | boolean | Disable audible beeps and double the exit delay. |
### nodeADC~armAway(partitionID, authOpts, opts) ⇒ Promise
Arm a security system panel in "away" mode. NOTE: This call may take 20-30 seconds to complete.
**Kind**: inner method of [nodeADC](#module_nodeADC)
| Param | Type | Description |
| ----------------- | -------------------- | ------------------------------------------------------- |
| partitionID | string | Partition ID to arm. |
| authOpts | Object | Authentication object returned from the `login` method. |
| opts | Object | Optional arguments for arming the system. |
| opts.noEntryDelay | boolean | Disable the 30-second entry delay. |
| opts.silentArming | boolean | Disable audible beeps and double the exit delay. |
### nodeADC~disarm(partitionID, authOpts) ⇒ Promise
Disarm a security system panel.
**Kind**: inner method of [nodeADC](#module_nodeADC)
| Param | Type | Description |
| ----------- | ------------------- | ------------------------------------------------------- |
| partitionID | string | Partition ID to disarm. |
| authOpts | Object | Authentication object returned from the `login` method. |
## Notes
In efforts to maintain this project as a native Alarm.com implementation, authentication and reference to FrontPoint have been removed altogether within the code as of versions 1.6.0. This allows for the codebase to be cleaner without having to solve everyone else's extraneous Alarm.com Verified-Partner setups, encouraging separate forks and augmentation for those unique scenarios.
## Acknowledgements
- **Original Code:** [https://github.com/jhurliman/node-frontpoint](https://github.com/jhurliman/node-frontpoint)
- **Alarm.com Login Process:** [Schwark Satyavolu](https://github.com/schwark), original author of [pyalarmcom](https://github.com/schwark/pyalarmcom)
- **Alarm.com Mobile Login Tips:** [Bryan Bartow](https://github.com/bryan-bartow), original author of [homebridge-alarm.com](https://github.com/bryan-bartow/homebridge-alarm.com)
- **Lights/Locks Implementation:** [Chase Lau](https://github.com/chase9)