npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

iotdb-smartthings

v0.0.10

Published

Node.JS SmartThings Library

Downloads

23

Readme

iotdb-smartthings

Well-documented code to:

  • Demo how to write using the SmartThings API
  • Control / Monitor SmartThings from Python
  • Control / Monitor SmartThings from Node-JS
  • Broadcast SmartThings events to MQTT

Courtesy of IOTDB. Follow us on Twitter:

  • @iotdb
  • @dpjanes

Important Notes

The SmartThings code broadcasts everything you do to MQTT. It's anonymous enough but you may find it creepy and it's easily turned off by editing smartthings.groovy.

Shards

If you are having trouble connecting to SmartThings, you may have to change your shard. Add to smartthings.json

"api_location": "<shard-url>"

You can find out your shard following the instructions here: https://community.smartthings.com/t/faq-how-to-find-out-what-shard-cloud-slice-ide-url-your-account-location-is-on/53923

Installation

This is somewhat developer-y. At some point we'll make a more general user friendly version of this.

Clone this project into a local directory

git clone https://github.com/dpjanes/iotdb-smartthings.git

Log into SmartThings

https://graph.api.smartthings.com/

If necessary, do what it takes to become a Developer

Create New App

Go to:

https://graph.api.smartthings.com/ide/apps

Click on "+ New SmartApp"

Fill in the App Details

Make sure to "Enable OAuth" and to copy the two values produced. You'll need them them later. Press the Create (or Update maybe) button. Authorize access to as much as your comfortable with, you can always change this later from your iPhone or Android app.

Add the code

  • Press the Code button
  • Copy the code from smartthings.groovy and paste
  • Press Save
  • Press Publish

Authorize

To access the API key, you need an access_token. Normally this is a real pain in the arse to generate, but we've done the hard work.

You'll need the OAuth Client ID and OAuth Client Secret, which you copied from the last major step. If you didn't, you can go back and get them now.

  • Go to this page: https://iotdb.org/playground/oauthorize/smartthings
  • Fill in the form
  • Press Submit
  • You'll be brought to the SmartThings website, where you'll allow access to your stuff
  • When that's done, you'll be brought back to IOTDB OAuthorize
  • copy the JSON data displayed and save it in a file called smartthings.json in the same directory

Keep that file to yourself. If you need to turn off access to your things, you can just go generate new OAuth keys in SmartThings.

If you add new devices to your SmartThings setup, you can give the API access using your SmartThings phone app.

API Access

Python

List all the motion detectors

$ python smartthings.py --type motion
[
  {
    "id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 
    "label": "Motion LivingRoom", 
    "type": "motion", 
    "url": "http://graph.api.smartthings.com/api/smartapps/installations/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/motion/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 
    "value": {
      "motion": false, 
      "timestamp": "2014-02-03T13:30:31.361Z"
    }
  }
]

Turn off a switch

$ python smartthings.py --type switch --id "My Z-Wave Switch" --request switch=0

Toggle a switch

$ python smartthings.py --type switch --id "My Z-Wave Switch" --request switch=-1

Node

A work in progress. The code is solid, but there's no command line argument parsing