Xcomfort
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 = ; const xapi = 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;
API reference
- Xcomfort ⇐
EventEmitter
⏏- new Xcomfort(params)
- instance
- .login()
- .query(method, [params], [cb]) ⇒
Promise
- .setDimState(deviceName, state, [cb]) ⇒
Promise
- .dimBrighter(deviceName, cb) ⇒
Promise
- .dimDarker(deviceName, cb) ⇒
Promise
- .dimStop(deviceName, cb) ⇒
Promise
- .triggerScene(sceneName, [cb]) ⇒
Promise
- .getDeviceNames() ⇒
Array.<string>
- .getSceneNames() ⇒
Array.<string>
- .getNameObject() ⇒
Object
- Event: "ready"
- Event: "error"
- inner
- ~initialSetup()
- ~getZoneDevices(zoneId) ⇒
Promise
- ~getZoneScenes(zoneId) ⇒
Promise
- ~importSetup(importPath)
- ~getQueryParams(method, params) ⇒
Object
- ~checkIfDeviceExists(deviceName, deviceType) ⇒
Promise
- ~invokeDCOOperation(id, type, operation, params) ⇒
Promise
- ~deviceDetail :
object
- ~sceneDetail :
object
- ~callback :
function
EventEmitter
⏏
Xcomfort ⇐ Kind: Exported class
Extends: EventEmitter
Emits: error
, ready
Properties
Name | Type | Description |
---|---|---|
baseUrl | string | baseUrl from params |
username | string | username from params |
password | string | password from params |
sessionId | string | The session cookie from a valid login |
deviceMap | Map.<string, module:Xcomfort~deviceDetail> | Map with all device details |
sceneMap | Map.<string, module:Xcomfort~sceneDetail> | Map with all scene details |
new Xcomfort(params)
Param | Type | Default | Description |
---|---|---|---|
params | object | config for the SHC |
|
params.baseUrl | string | the url to your SHC |
|
params.username | string | username to login to SHC |
|
params.password | string | password to login to SHC |
|
[params.autoSetup] | boolean | true | If true, class will login and setup device and scene map automatically |
[params.importSetupPath] | object | Path to json setup file with device and scene maps |
xcomfort.login()
Sends login request to SHC and stores cookie in sessionId
Kind: instance method of Xcomfort
Promise
xcomfort.query(method, [params], [cb]) ⇒ 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
Param | Type | Default | Description |
---|---|---|---|
method | string | Method to run |
|
[params] | Array | ['',''] | Array with arguments for method |
[cb] | callback | Callback (err,result) |
Promise
xcomfort.setDimState(deviceName, state, [cb]) ⇒ Sets dimactuator to new state
Kind: instance method of Xcomfort
Returns: Promise
- Resolves with true or false. True if SHC confirmed action
Param | Type | Description |
---|---|---|
deviceName | string | Name of device(same as configured on SHC). Not case sensitive |
state | number | string | New state of device. Valid values are 0-100(integer) or 'on'/'off' |
[cb] | callback | Callback with true or false result. True if SHC confirmed action |
Promise
xcomfort.dimBrighter(deviceName, cb) ⇒ 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
Param | Type | Description |
---|---|---|
deviceName | String | Device name of DimActuator |
cb | callback | Callback |
Promise
xcomfort.dimDarker(deviceName, cb) ⇒ 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
Param | Type | Description |
---|---|---|
deviceName | String | Device name of DimActuator |
cb | callback | Callback |
Promise
xcomfort.dimStop(deviceName, cb) ⇒ Tells DimActuator to stop the continous dimming.
Kind: instance method of Xcomfort
Returns: Promise
- - Resolves undefined
Param | Type | Description |
---|---|---|
deviceName | String | Device name of DimActuator |
cb | callback | Callback |
Promise
xcomfort.triggerScene(sceneName, [cb]) ⇒ Triggers scene
Kind: instance method of Xcomfort
Returns: Promise
- Resolves with true or false. True if SHC confirmed action
Param | Type | Description |
---|---|---|
sceneName | string | Name of scene(same as configured on SHC). Not case sensitive |
[cb] | callback | Callback with true or false result. True if SHC confirmed action |
Array.<string>
xcomfort.getDeviceNames() ⇒ Generates list of all device names
Kind: instance method of Xcomfort
Array.<string>
xcomfort.getSceneNames() ⇒ Generates list of all scene names
Kind: instance method of Xcomfort
Object
xcomfort.getNameObject() ⇒ 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
Promise
Xcomfort~getZoneDevices(zoneId) ⇒ 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
Param | Type | Description |
---|---|---|
zoneId | string | name of zone to get devices in |
Promise
Xcomfort~getZoneScenes(zoneId) ⇒ 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
Param | Type | Description |
---|---|---|
zoneId | string | name of zone to get devices in |
Xcomfort~importSetup(importPath)
Imports existing setup file and creates new device and scene maps
Kind: inner method of Xcomfort
Emits: ready
, error
Param | Type | Description |
---|---|---|
importPath | string | Relative path to file |
Object
Xcomfort~getQueryParams(method, params) ⇒ Configure request parameters
Kind: inner method of Xcomfort
Returns: Object
- Object to pass to request as options
Param | Type | Description |
---|---|---|
method | String | Remote method to query on SHC |
params | Array | Array of arguments to pass to method |
Promise
Xcomfort~checkIfDeviceExists(deviceName, deviceType) ⇒ 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 stringNo device with that name exists
: Device not foundNo deviceType with that name exists
: No device with correct type found
Param | Type | Description |
---|---|---|
deviceName | String | SHC id of the device |
deviceType | String | SHC devicetype |
Promise
Xcomfort~invokeDCOOperation(id, type, operation, params) ⇒ Invoke DCO operation on SHC
Kind: inner method of Xcomfort
Returns: Promise
- - resolves undefined if no error during query
Param | Type | Description |
---|---|---|
id | String | SHC id of the device |
type | String | SHC devicetype |
operation | String | Operation on deviceclass to invoke |
params | Object | key-value pairs of arguments for operation |
object
Xcomfort~deviceDetail : Kind: inner typedef of Xcomfort
Properties
Name | Type | Description |
---|---|---|
zoneId | string | Zone id |
id | string | Device id |
type | string | SHC class type |
value | string | Device value |
object
Xcomfort~sceneDetail : Kind: inner typedef of Xcomfort
Properties
Name | Type | Description |
---|---|---|
zoneId | string | Zone id |
id | string | Scene id |
function
Xcomfort~callback : Callback with result or error
Kind: inner typedef of Xcomfort
Param | Type | Description |
---|---|---|
error | Error | null if no error |
result | null if error |