martzmakes / SmartDSC

DSC and SmartThings Integration with NodeJS
20 stars 20 forks source link

SmartDSC


Update Section

2016-01-03: Major update. I finally am updating the README with better / up-to-date install instructions and I'm adding in Homebridge for siri support.

2015-01-14: Decided to share my "Everyone Away" App which is handy. If all presence sensors/mobile devices are away, it'll arm your alarm and set your home to away. Pretty straightforward... very handy.

End Update Section

Background

This Repo is going to focus on my specific implementation including:

What this project will not go over

This project will not go over:

Install AlarmServer on your server

Requirements

Environment / Config Variable Explanations

You can use either Environment Variables or the config file to configure your server. The demo app's preference is to use ENV variables before the config file ones.

Initial Steps

Before you get started, you need a SmartThings Developer Account: https://graph.api.smartthings.com

Create the SmartDSC App

  1. Create a new SmartApp and copy/paste the code from smartapp/dscAlarmIntegrationSmartApp.groovy into it

  2. Set your Location

  3. Click "App Settings"

  4. Go down to "OAuth" and "Enable OAuth in SmartApp", then click "Update" at the bottom of the page

  5. Once updated, click Code in the upper right to go back to the code view.

  6. Click Publish (for me)

Install the SmartDCS App on your device

  1. In the SmartThings App, go to the Marketplace (lower right button on iOS)

  2. Go to the SmartApps tab

  3. Scroll down to My Apps and add the SmartDSC App

  4. Tap Done in the upper right (you can configure the app later)

  5. In the SmartThings App, go to your SmartApps section. You should see the SmartDSC App. You may need to quit / reopen the app. Once you see it, tap the SmartApp.

  6. With the SmartDSC App open, tap the Config button. Copy the app_id and access_token for later...

Optional step (required for Homebridge)

Getting the server running

Method 1: Docker

If you don't have Docker already, skip to Method 2. If you already have a Docker instance on your home network or are comfortable setting it up, you can use the included Dockerfile to build the project and then run it with this command:

docker build -t smart-dsc .
docker run -d --name SmartDSC --publish 8086:8086 --publish 4025:4025 --restart always -e "NODE_ALARM_ACCESS_TOKEN=YOUR-ACCESS-TOKEN" -e "NODE_ALARM_APP_ID=YOUR-APP-ID" -e "NODE_ALARM_PASSWORD=YOUR-APP-PASSWORD" -e "NODE_ALARM_PIN=XXXX" -e "NODE_ALARM_PROXY_HOST=xxx.xxx.xxx.xxx" -e "NODE_ALARM_PROXY_PORT=4025" -e "NODE_ALARM_SERVER_PASSWORD=YOUR-ENVISALINK-PASSWORD" -e "NODE_ALARM_STPASS=password" -e "NODE_ALARM_ZONE_COUNT=numberofzones" -e "NODE_ALARM_PARTITION_COUNT=numberofpartitions" smart-dsc

Method 2: Copying the files

  1. Clone this Repo on your server (git clone https://github.com/oehokie/SmartDSC.git)

  2. cd SmartDSC/NAP-demo

  3. Edit the config.js file with your configuration values. Use the App Id and Access Token you found in the Initial Steps above.

  4. On the command line, first run: npm install which will install required dependencies for you.

  5. Then run node app which will start the server.

Setting up the SmartDSC Alarm Thing Device

Create the SmartDSC Alarm Thing Device

  1. Create a new SmartThing Device Type

  2. Copy and Paste the code from devicetypes/DSCAlarmThing.groovy and publish it for yourself

Install the device using the SmartThings app or Developer page

  1. On the SmartThings developer website, go to My Devices

  2. Click New Device

  3. Name it, provide required info and in the Type section at the bottom you should see your SmartDSC Alarm Thing

Configure the SmartDCS Alarm Thing Device in the SmartThings App

In order for commands to get sent from the SmartThings app to your Server, you need to edit the preferences of the SmartDSC Alarm Thing Device

  1. On your mobile device go to the SmartDSC Alarm Thing Device

  2. In the upper right click the "hamburger" (3 vertical dots) and select Edit Device

  3. For Server Password... this is the STPass variable in the config file / Environment variable. Use that.

  4. For IP Address for Server... this is your server's IP Address (should be on the same network as your SmartThings hub)

  5. For Port of Server... this is the server's port that you opened up. It defaults to 8086. NOTE: for some reason this likes to edit itself. If you open the Edit Device page and don't modify this value, it will blank itself. So change it every time (not my fault)

  6. Done... give it a test by Arming your system / disarming it.

Final steps

Setting up device types

Using the Smartthings IDE create 3 new device types using the code from the devicetypes directory.

There are 4 types of devices you can create:

In the Web IDE for Smartthings create a new device type for each of the above devices and paste in the code for each device from the corresponding groovy files in the repo.

You can name them whatever you like but I recommend using the names above 'DSC Panel', 'DSC ZoneContact', 'DSC ZoneMotion', 'DSC Thing' (I'm not creative - oehokie), since those names directly identify what they do.

For all the device types make sure you save them and then publish them for yourself.

Create panel device

Create a new device and choose the type of "DSC Panel" that you published earlier. The network id needs to be partition1.

Create individual zones

Create a new "Zone Device" for each Zone you want Smartthings to show you status for.

The network id needs to be the word 'zone' followed by the matching zone number that your DSC system sees it as.

For example: zone1 or zone5

Enjoy!