API.md
April 30, 2020 ยท View on GitHub
Table of Contents
- HAPNodeJSClient
- HAPNodeJSClient#Disconnected
- HAPNodeJSClient#hapEvent
- _reconnectServer
- services
- Request
HAPNodeJSClient
HAPNodeJSClient - Client for Homebridge and HAP-NodeJS in insecure mode.
Events
Parameters
optionstype description
Properties
debugboolean Enable debug logging, defaults to falsepinstring Homebridge PIN, defaults to '031-45-154'refreshnumber Discovery refresh, defaults to 15 minutestimeoutnumber Discovery timeout, defaults to 20 secondsreqTimeoutnumber Accessory request timeout, defaults to 7 seconds
HAPaccessories
HAPNodeJSClient.prototype.HAPaccessories - Returns an array of all homebridge instances, and the accessories for each.
Parameters
callbacktype description
Returns type description
HAPcontrolByDeviceID
HAPNodeJSClient.prototype.HAPcontrolByDeviceID - Send a characteristic PUT Message to a particular homebridge instance
Parameters
deviceIDtype deviceID of homebridge instancebodytype An array of HomeKit characteristic updates, [{ "aid": 2, "iid": 9, "value": 0}]callbacktype Callback to execute upon completion of characteristic setting, function(err, response)
HAPcontrol
HAPNodeJSClient.prototype.HAPcontrol - Send a characteristic PUT Message to a particular homebridge instance
Parameters
ipAddresstype IP Address of homebridge instanceporttype Port of homebridge instancebodytype An array of HomeKit characteristic updates, [{ "aid": 2, "iid": 9, "value": 0}]callbacktype Callback to execute upon completion of characteristic setting, function(err, response)
HAPeventByDeviceID
HAPNodeJSClient.prototype.HAPeventByDeviceID - Send a characteristic PUT Message to a particular homebridge instance, this maintains a socket connection for use in returning Events
Parameters
deviceIDtype deviceID homebridge instancebodytype An array of HomeKit characteristic updates, [{ "aid": 2, "iid": 9, "value": 0}]callbacktype Callback to execute upon completion of characteristic setting, function(err, response)
HAPevent
HAPNodeJSClient.prototype.HAPevent - Send a characteristic PUT Message to a particular homebridge instance, this maintains a socket connection for use in returning Events
Parameters
ipAddresstype IP Address of homebridge instanceporttype Port of homebridge instancebodytype An array of HomeKit characteristic updates, [{ "aid": 2, "iid": 9, "value": 0}]callbacktype Callback to execute upon completion of characteristic setting, function(err, response)
HAPresourceByDeviceID
HAPNodeJSClient.prototype.HAPresourceByDeviceID - Send a characteristic PUT Message to a particular homebridge instance using resource interface, ie camera
Parameters
deviceIDbodytype An array of HomeKit characteristic updates, [{ "aid": 2, "iid": 9, "value": 0}]callbacktype Callback to execute upon completion of characteristic setting, function(err, response)DeviceIDtype DeviceID of homebridge instance
HAPresource
HAPNodeJSClient.prototype.HAPresource - Send a characteristic PUT Message to a particular homebridge instance using resource interface, ie camera
Parameters
ipAddresstype IP Address of homebridge instanceporttype Port of homebridge instancebodytype An array of HomeKit characteristic updates, [{ "aid": 2, "iid": 9, "value": 0}]callbacktype Callback to execute upon completion of characteristic setting, function(err, response)
HAPstatusByDeviceID
HAPNodeJSClient.prototype.HAPstatusByDeviceID - Get current status for characteristics
Parameters
deviceIDtype deviceID of homebridge instancebodytype descriptioncallbacktype Callback to execute upon completion of characteristic getting, function(err, response)
HAPstatus
HAPNodeJSClient.prototype.HAPstatus - Get current status for characteristics
Parameters
ipAddresstype IP Address of homebridge instanceporttype Port of homebridge instancebodytype descriptioncallbacktype Callback to execute upon completion of characteristic getting, function(err, response)
HAPNodeJSClient#Disconnected
HomeKit Accessory Characteristic event pass thru
Properties
serverstring IP Address and port of disconnected homebridge
Examples
Sample Message
{ host: '192.168.1.4', port: 51826, aid: 16, iid: 11, status: false }
HAPNodeJSClient#hapEvent
HomeKit Accessory Characteristic event pass thru
Properties
hoststring IP Address of homebridge instance generating eventportnumber Port of homebridge instance generating eventdeviceIDnumber deviceID of homebridge instance generating eventaidnumber Accessory ID of accessory generating eventiidnumber Instance ID of accessory characteristic generating eventvalueobject Updated characteristic value
Examples
Sample Message
{ host: '192.168.1.4', port: 51826, aid: 16, iid: 11, status: false }
_reconnectServer
_reconnectServer - Reconnect to event server
Parameters
servertype IP Address and port of disconnected homebridge server
Returns type description
services
Ensure UUIDs are long form
Request
var q - Message queuing to prevent requests overstepping each other
Parameters
optionsfunctiontype (request descriptioncbtype description
Returns type description