forked from NRCHKB/node-red-contrib-homekit-bridged
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhomekit.js
28 lines (22 loc) · 833 Bytes
/
homekit.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module.exports = function(RED) {
;('use strict')
const debug = require('debug')('NRCHKB')
const HapNodeJS = require('hap-nodejs')
const Service = HapNodeJS.Service
const API = require('./lib/api.js')(RED)
const HAPBridgeNode = require('./lib/HAPBridgeNode.js')(RED)
const HAPServiceNode = require('./lib/HAPServiceNode.js')(RED)
// Initialize our storage system
if (RED.settings.available()) {
debug('RED settings available')
const userDir = RED.settings.userDir
HapNodeJS.init(userDir + '/homekit-persist')
} else {
debug('RED settings not available')
HapNodeJS.init()
}
// Initialize API
API.init()
RED.nodes.registerType('homekit-bridge', HAPBridgeNode.init)
RED.nodes.registerType('homekit-service', HAPServiceNode.init)
}