[RELEASE] Smart Events - An unofficial Node.js Package for the Websocket API

logo

An unofficial SmartThings websocket API library (alpha)

:floppy_disk: Introduction

The SmartThings Core SDK provides a significant amount of capability to interact with the platform but lacks a simple way to subscribe to device events without creating a publicly exposed SmartApp.

This Node.js package makes use of a websocket API to provide a new way of integrating SmartThings connected devices into complex smart home configurations with minimal latency and without a publicly exposed endpoint.

If you would like an official library, help me convince SmartThings to share, document and include their websocket API as part of the SmartThings Core SDK in the comments below!

:electric_plug: Quick Start

const EventService = require('smart-events');

const st = new EventService();

st.connect('<csrfToken>', '<cookie>');

st.on('connected', () => {
    st.subscribe('<locationId>'); // Subscribe to All Events @ Location
});

// Event Handler
st.on('event', data => {
    console.log('Device Event:', data);
}

/*
Event handler 'data' param contains many fields such as:
deviceId: '<uuid>',
capability: 'powerMeter',
attribute: 'power',
value: 9.2,
valueType: 'number',
stateChange: true,
*/

:crystal_ball: Features

  • Entirely asynchronous event emitter based API
  • Does not require long/short polling, REST endpoints or a webhook based SmartApp
  • Provides location, room, device and event information
  • Easy integration into other projects (custom dashboards, automations, monitoring, logging, etc)

:eyeglasses: Transparency

  • This is an early stage, alpha level project and may be unstable for some time
  • Should not be considered ‘production ready’ or used in critical implementations
  • Subject to unpredictable changes which can break this implementation without notice

:hammer_and_wrench: Setup, Getting Started & Contributing

  • Detailed documentation available on GitHub!

SmartThings is a registered trademark of SmartThings, Inc.

6 Likes

@jody.albritton , have you seen this?