Fibaro HomeCenter2 client
Javascript client for communicating with Fibaro HomeCenter2 smart home controllers.
Requirements
- NodeJS (>=10)
- Fibaro Home Center 2
Installation
yarn add fibaro-home-center2-client
or
npm install --save fibaro-home-center2-client
Usage
Get rooms:
const Fibaro = ; const client = host: '192.168.1.69' user: 'foo' password: 'bar';client;
Get all available devices:
const Fibaro = ; const client = host: '192.168.1.69' user: 'foo' password: 'bar';client;
Poll devices properties' updates:
const Fibaro = ; const client = host: '192.168.1.69' user: 'foo' password: 'bar';client;
Control devices:
const Fibaro = ; const client = host: '192.168.1.69' user: 'foo' password: 'bar';client;
Control devices based on events from other devices:
const Fibaro = ; const client = host: '192.168.1.69' user: 'foo' password: 'bar';client;
Dump all devices' identifiers
const Fibaro = ; const client = host: '192.168.1.69' user: 'foo' password: 'bar';client;
List all powered devices
const Fibaro = ; const client = host: '192.168.1.69' user: 'foo' password: 'bar';client;
Output example:
hall/lights/lamp: 39.4w
garage/lights/lamp: 79.1w
List all devices' actions and their possible arguments
const Fibaro = ; const client = host: '192.168.1.69' user: 'foo' password: 'bar';client;
Output example:
...
bedroom/blinds/curtains {
close: 0,
open: 0,
reconfigure: 0,
reset: 0,
sceneActivationSet: 0,
setValue: 1,
setValue2: 1,
startLevelDecrease: 0,
startLevelIncrease: 0,
stop: 0,
stopLevelChange: 0
}
bathroom/safety/flood-sensor {
abortUpdate: 1,
forceArm: 0,
meetArmConditions: 0,
reconfigure: 0,
retryUpdate: 1,
setArmed: 1,
setInterval: 1,
startUpdate: 1,
updateFirmware: 1
}
bedroom/lights/led-strip {
abortUpdate: 1,
reconfigure: 0,
reset: 0,
retryUpdate: 1,
setB: 1,
setBrightness: 1,
setColor: 1,
setFavoriteProgram: 2,
setG: 1,
setR: 1,
setValue: 1,
setW: 1,
startLevelDecrease: 0,
startLevelIncrease: 0,
startProgram: 1,
startUpdate: 1,
stopLevelChange: 0,
turnOff: 0,
turnOn: 0,
updateFirmware: 1
}
...
API Reference
Classes
Constants
- CLIENT_OPTIONS
Client options
Typedefs
- DevicePropertyUpdateEvent :
Object
- EventCriteria :
Object
- SystemEvent :
Object
- Room :
Object
- Device :
Object
Client
Kind: global class
new Client(options)
Creates a new client.
Param | Type |
---|---|
options | CLIENT_OPTIONS | Object |
Observable.<DevicePropertyUpdateEvent>
client.events() ⇒ Subscribe on device property update events
Kind: instance method of Client
Properties
Name | Type | Description |
---|---|---|
criteria | EventCriteria |
Optional event filtering |
Observable.<SystemEvent>
client.system() ⇒ Subscribe on client system events
Kind: instance method of Client
Observable.<Object>
client.query(query, retry) ⇒ Make a GET API request to HC2
Kind: instance method of Client
Param | Type | Default |
---|---|---|
query | string |
|
retry | boolean |
false |
client.getRooms() ⇒
Get rooms
Kind: instance method of Client
Returns: Observable<Room[]>
Example
const Fibaro = ; const client = host: '192.168.1.69' user: 'foo' password: 'bar';client;
client.getDevices() ⇒
Returns devices with properties and actions
Kind: instance method of Client
Returns: Observable<Device[]>
Example
const Fibaro = ; const client = host: '192.168.1.69' user: 'foo' password: 'bar';client; client;
client.callAction(deviceId, action, options) ⇒
Low level method to call an action on a given device. Applications are supposed to call actions on devices instead of this function.
Kind: instance method of Client
Returns: Observable
Param | Type |
---|---|
deviceId | number |
action | string |
options | array |
Example
const Fibaro = ; // call an action on an ID known deviceconst client = host: '192.168.1.69' user: 'foo' password: 'bar';client; // call an action on a device objectclient;
CLIENT_OPTIONS
Client options
Kind: global constant
Read only: true
Properties
Name | Type | Default | Description |
---|---|---|---|
host | string |
"192.168.1.69" |
HC2 controller ip-address |
port | number |
80 |
HC2 controller port |
user | string |
"admin" |
username |
password | string |
user password | |
connectTimeout | number |
7000 |
Reconnect to controller if no success timeout |
pollingInterval | number |
1000 |
Controller devices properties polling interval |
pollingTimeout | number |
3000 |
Controller devices properties polling timeout |
debug | boolean |
false |
Trace debug information |
Object
DevicePropertyUpdateEvent : Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
id | number |
Room id provided by HC |
identifier | number |
Generated literal identifier |
property | string |
Updated property |
newValue | string |
updated value |
oldValue | string |
previous value |
Object
EventCriteria : Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
device | Device | null |
Subscribe only on a specific device events |
properties | Array.<string> | null |
Subscribe only on a specific property change events |
Object
SystemEvent : Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
id | number |
Room id provided by HC |
name | number |
Room name provided by HC |
identifier | number |
Generated literal identifier |
Object
Room : Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
id | number |
Room id provided by HC |
name | number |
Room name provided by HC |
identifier | number |
Generated literal identifier |
Object
Device : Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
id | number |
Device id provided by HC |
name | number |
Device name provided by HC |
room | Room |
Device room |
identifiers | Array.<string> |
Generated literal identifiers |
properties | Object |
Device properties |
actions | Object |
Available device actions |
License
This project is licensed under the GNU GPLv3 - see the LICENSE file for details