Connects SmartThings with Sense
-
This SmartApp is considered an early "beta" - functionality is limited and there are likely to be bugs. Feel free to create and track issues here.
-
The app does not currently handle when Sense devices are deleted - you'll need to manually delete the counterpart in SmartThings
-
The app does not offer the ability to exclude certain Sense devices from SmartThings; for now, they will all come over.
- This SmartApp is currently only supported in the SmartThings Classic mobile app; the new app does not yet support custom apps like this.
- The app requires a node server running on a machine (PC, Raspberry PI, etc.) on the same LAN as your SmartThings hub (don't worry - setup is quite simple). The node server creates a realtime websocket connection with Sense. On relevant events, the node server sends data over your LAN to the hub. The SmartApp listens for this data and then updates devices in SmartThings as needed.
- Special thanks to blandman for his work on the unofficial sense API node library
- This app automatically creates devices in SmartThings based on Sense devices. It also handles when those devices are renamed.
- Device status (on/off) and power usage is kept in sync within SmartThings. You can use these values to drive various other routines or ActionTiles panels.
- This app offers the option to send push notifications when devices turn on or off. Access push notification settings at each individual device in the SmartThings mobile app.
- You can set "quiet modes" during which notifications will not be sent. Go to the Sense SmartApp in the SmartThings mobile app to configure this.
There are 2 code files needed: 1 SmartApp and 1 Device Handler.
- Log in to the SmartThings IDE. If you don't have a login yet, create one.
- The first step is to create the device handler.
- Click on My Device Handlers -> Create new Device Handler -> From Code.
- Copy contents of Sense Device and paste into text area. Click Create. Click Publish > For Me
- Now we create the SmartApp code. Click My SmartApps -> New Smartapp -> From Code.
- Copy contents of SmartApp and paste into text area. Click Create. Click Publish > For Me
- In your SmartThings mobile app, tap Automation -> SmartApps -> Add a SmartApp. Scroll down and tap My Apps. Tap Sense. Tap save to complete the installation. Your SmartApp is now listening for Sense data. Move on to the node server setup!
If you have not set up the GitHub integration yet or do not know about it, take a look at the SmartThings documentation here. Note that if you do not have a GitHub account or are not familiar with GitHub, the manual method of installation is recommended.
- If you haven't already, click on enable GitHub button (upper right). Add a new repository with user
brbeaird
, repositorySmartThings_SenseMonitor
, and branchmaster
. This can be done in either the "My Device Handlers" or "My SmartApps" sections - Go to "My Device Handlers". Click "Update from Repo". Select the "SmartThings_SenseMonitor" repository. You should see the device type in the "New (only in GitHub)" section. Check the box next to it. Check the "Publish" checkbox in the bottom right hand corner. Click "Execute Update".
- Go to "My SmartApps". Click "Update from Repo". Select the "SmartThings_SenseMonitor" repository. You should see the SmartApp in the "New (only in GitHub)" section. Check both box next to it. Check the "Publish" checkbox in the bottom right hand corner. Click "Execute Update".
- In your SmartThings mobile app, tap Automation -> SmartApps -> Add a SmartApp. Scroll down and tap My Apps. Tap Sense. Tap save to complete the installation. Your SmartApp is now listening for Sense data. Move on to the node server setup!
In the future, should you wish to update, simply repeat steps 2 and 3. The only difference is you will see the device type/SmartApp show up in the "Obsolete (updated in GitHub)" column instead.
- If you don't already have it, Download and install Node.js
- Download (or git clone) the files in this repository. If you're new to git, you can click the green Download button and grab a zip file of everything. Extract the zip file.
- Open a command prompt and navigate to the location where you downloaded the files in step 2. Navigate down to SmartThings_SenseMonitor\node_server.
- Run
npm install
(this grabs needed libraries) - Open the server.js file in a text editor and put in your Sense login information and SmartThings hub IP under the required settings section. You can find your hub IP in the SmartThings IDE by clicking the Hub link, then clicking your hub, then scrolling down to IP Address. Be sure to save your changes.
- Run
node server.js
. This starts up the data connection. If all goes well, you should see a successful connection message. Leave this window running to continue collecting data and sending it to SmartThings. - I strongly recommend using something like PM2 to keep the node server running in the background. Will add more detailed steps on that later.
- Install Docker (see: Docker - Get Started) and Docker Compose for your environment.
- Change to the node_server directory.
- Copy or rename the docker.env.dist file to docker.env (
cp docker.env.dist docker.env
) - Edit the docker.env file and update the sense email, sense password, and smartthingsHubIp variables. Notes: 1) Quotes may cause passed parameters to be invalid. 2) Port must match the port exposed in the docker-compose.yml file (port 9021). The port can be changed, but needs to be updated in all places referenced.
- Save the docker.env file.
- Run
docker-commpose up
Add the -d option to run the container detached in the background:docker-compose up -d
. The first timedocker-compose up
is ran, Docker will build the image file used to run the Sense Monitor.
Note: Upon start up, docker-compose will make a copy of config-docker.js to use instead of config.js, the config-docker.js uses parameters from the docker.env file.
- Run
docker-compose ps
ordocker ps
- Run
docker-compose stop
or can rundocker stop <containerId>
(fromdocker ps
) if you have more than one container running.
- Update files for this project from github.
- Change to the node_server directory.
- Either run
docker-compose build
ordocker-compose up --build
- Run
docker ps
to view the containers id - Run
docker exec -it <containerId> bash
to open a bash window. Keep in mind that commands are limited since the container only has what it needs to run. - Type
exit
when you are ready to close the bash prompt.'
- Run
docker images
to get a list of images - Run
docker rmi <imageId>
to remove a specific image.