New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

appliances

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appliances

Base classes for standarized API for smart appliances and devices

  • 0.5.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by200%
Maintainers
1
Weekly downloads
 
Created
Source

Appliances

Appliances is a JavaScript library with abstract base classes for building libraries that interact with smart appliances and devices. It helps with mapping many common appliances to a standarized API built around the type of appliance and its capabilities.

Types and capabilities

Devices from different manufacturers often support different things which makes creating a unified API hard. This library tries to solve this by both keeping track of the type of a smart appliance, such as if its a light or a sensor, and what actual capabilities it has, such as if it its power can be controlled or if it can dimmed.

Any appliance should have one or more types that describes what it is. In addition it should have capabilities that describes what it can do.

Building appliances

In your Node project do:

npm install appliances

Creating a light that can powered on or off via some random API:

const { Light, Switchable } = require('appliances');

class LightExample extends Light.with(Switchable) {
  constructor(externalLightApi) {
    super();

    this.externalLightApi = externalLightApi;

    // An identifier of the appliance should always be set - with a namespace
    this.id = 'light-example:' + externalLightApi.id;

    /*
     * You can update the power state at any time with updatePower. This
     * usually done either on an event or by polling the external device.
     */
    this.updatePower(externalLightApi.on);
  }

  changePower(power) {
    // Return a promise unless the power changes immediately
    return this.externalLightApi.setPower(power)
      .then(result => this.updatePower(result.on));
  }
}

Keywords

FAQs

Package last updated on 11 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc