2.3.0 • Published 7 years ago

xcomfort-shc-api v2.3.0

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

Xcomfort

Travis Codecov

This module lets you send commands from node.js to the Xcomfort smart home controller(SHC) made by Eaton. It has no affiliation with Eaton, and is used at your own risk.

If you have xcomfort and a smart home controller at home, this module can be used to create custom software for your system. For example you can create a webpage customized for your home that controls your lighting instead of that generic app that ships with the SHC.

Install

npm install xcomfort-shc-api

Usage

For more details on usage see https://oanylund.github.io/xcomfort-shc-api and the API reference below.

const Xcomfort = require('xcomfort-shc-api');

const xapi = new Xcomfort({
  baseUrl: 'http://192.168.0.10', // The url to reach the SHC on your network
  username: 'user', // The username to login to the system
  password: '1234' // The password for that user
  autoSetup: true // Defaults to true.
});

xapi.on('ready', () => {
  xapi.setDimState('kitchen light', 20)
    .then((status) => {
      if(status) {
        console.log('Kitchen light set to 20%');
      }
    });
});

API reference

  • [Xcomfort](#expmodule_Xcomfort--Xcomfort) ⇐ [EventEmitter](http://nodejs.org/api/events.html) [new Xcomfort(params)](#new_module_Xcomfort--Xcomfort_new) _instance [.login()](#module_Xcomfort--Xcomfort+login) [.query(method, [params], [cb])](#moduleXcomfort--Xcomfort+query) ⇒ Promise [.setDimState(deviceName, state, [cb])](#module_Xcomfort--Xcomfort+setDimState) ⇒ Promise [.dimBrighter(deviceName, cb)](#module_Xcomfort--Xcomfort+dimBrighter) ⇒ Promise [.dimDarker(deviceName, cb)](#module_Xcomfort--Xcomfort+dimDarker) ⇒ Promise [.dimStop(deviceName, cb)](#module_Xcomfort--Xcomfort+dimStop) ⇒ Promise [.triggerScene(sceneName, [cb])](#module_Xcomfort--Xcomfort+triggerScene) ⇒ Promise [.getDeviceNames()](#module_Xcomfort--Xcomfort+getDeviceNames) ⇒ Array.<string> [.getSceneNames()](#module_Xcomfort--Xcomfort+getSceneNames) ⇒ Array.<string> [.getNameObject()](#module_Xcomfort--Xcomfort+getNameObject) ⇒ Object [Event: "ready"](#module_Xcomfort--Xcomfort+event_ready) [Event: "error"](#module_Xcomfort--Xcomfort+event_error) * _inner [~initialSetup()](#module_Xcomfort--Xcomfort..initialSetup) [~getZoneDevices(zoneId)](#module_Xcomfort--Xcomfort..getZoneDevices) ⇒ Promise [~getZoneScenes(zoneId)](#module_Xcomfort--Xcomfort..getZoneScenes) ⇒ Promise [~importSetup(importPath)](#module_Xcomfort--Xcomfort..importSetup) [~getQueryParams(method, params)](#module_Xcomfort--Xcomfort..getQueryParams) ⇒ Object [~checkIfDeviceExists(deviceName, deviceType)](#module_Xcomfort--Xcomfort..checkIfDeviceExists) ⇒ Promise [~invokeDCOOperation(id, type, operation, params)](#module_Xcomfort--Xcomfort..invokeDCOOperation) ⇒ Promise [~deviceDetail](#module_Xcomfort--Xcomfort..deviceDetail) : object [~sceneDetail](#module_Xcomfort--Xcomfort..sceneDetail) : object [~callback](#module_Xcomfort--Xcomfort..callback) : function

Xcomfort ⇐ EventEmitter

Kind: Exported class
Extends: EventEmitter
Emits: error, ready
Properties


new Xcomfort(params)


xcomfort.login()

Sends login request to SHC and stores cookie in sessionId

Kind: instance method of Xcomfort


xcomfort.query(method, params, cb) ⇒ Promise

Request method to run on SHC RPC interface

Kind: instance method of Xcomfort
Returns: Promise - Resolves with result
See: http://dz.prosyst.com/pdoc/mBS_SDK_8.0/modules/hdm/api-json/json_rpc_all.html


xcomfort.setDimState(deviceName, state, cb) ⇒ Promise

Sets dimactuator to new state

Kind: instance method of Xcomfort
Returns: Promise - Resolves with true or false. True if SHC confirmed action


xcomfort.dimBrighter(deviceName, cb) ⇒ Promise

Tells DimActuator to start continously dimming brighter. How fast is configured on the device by the MRF software

Kind: instance method of Xcomfort
Returns: Promise - - Resolves undefined


xcomfort.dimDarker(deviceName, cb) ⇒ Promise

Tells DimActuator to start continously dimming darker. How fast is configured on the device by the MRF software

Kind: instance method of Xcomfort
Returns: Promise - - Resolves undefined


xcomfort.dimStop(deviceName, cb) ⇒ Promise

Tells DimActuator to stop the continous dimming.

Kind: instance method of Xcomfort
Returns: Promise - - Resolves undefined


xcomfort.triggerScene(sceneName, cb) ⇒ Promise

Triggers scene

Kind: instance method of Xcomfort
Returns: Promise - Resolves with true or false. True if SHC confirmed action


xcomfort.getDeviceNames() ⇒ Array.<string>

Generates list of all device names

Kind: instance method of Xcomfort


xcomfort.getSceneNames() ⇒ Array.<string>

Generates list of all scene names

Kind: instance method of Xcomfort


xcomfort.getNameObject() ⇒ Object

Generates object with list of devices and scenes

Kind: instance method of Xcomfort


Event: "ready"

Ready event gets emitted when autosetup is complete

Kind: event emitted by Xcomfort


Event: "error"

General error event emitted when internal errors occur

Kind: event emitted by Xcomfort


Xcomfort~initialSetup()

Runs on initialisation. Logs in, then fetches devices and scenes from SHC

Kind: inner method of Xcomfort
Emits: ready


Xcomfort~getZoneDevices(zoneId) ⇒ Promise

Gets devices in zone from SHC and adds them to deviceMap with name of device as key and value of type deviceDetail

Kind: inner method of Xcomfort
Returns: Promise - - with no value, only used to tell when its done


Xcomfort~getZoneScenes(zoneId) ⇒ Promise

Gets scenes in zone from SHC and adds them to sceneMap with name of scene as key and value of type sceneDetail

Kind: inner method of Xcomfort
Returns: Promise - - with no value, only used to tell when its done


Xcomfort~importSetup(importPath)

Imports existing setup file and creates new device and scene maps

Kind: inner method of Xcomfort
Emits: ready, error


Xcomfort~getQueryParams(method, params) ⇒ Object

Configure request parameters

Kind: inner method of Xcomfort
Returns: Object - Object to pass to request as options


Xcomfort~checkIfDeviceExists(deviceName, deviceType) ⇒ Promise

Checks if devices with devicetype(optional) exists

Kind: inner method of Xcomfort
Fulfil: Object - Device properties
Reject: String - Error message of one of the following:

  • Device name must be of type string: deviceName was not a string
  • No device with that name exists: Device not found
  • No deviceType with that name exists: No device with correct type found

Xcomfort~invokeDCOOperation(id, type, operation, params) ⇒ Promise

Invoke DCO operation on SHC

Kind: inner method of Xcomfort
Returns: Promise - - resolves undefined if no error during query


Xcomfort~deviceDetail : object

Kind: inner typedef of Xcomfort
Properties


Xcomfort~sceneDetail : object

Kind: inner typedef of Xcomfort
Properties


Xcomfort~callback : function

Callback with result or error

Kind: inner typedef of Xcomfort


2.3.0

7 years ago

2.2.0

7 years ago

2.1.0

7 years ago

2.0.4

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.0

7 years ago