node-red-contrib-homebridge-automation 0.0.86-beta.2 → 0.1.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/HAP-NodeRed.js CHANGED
@@ -4,12 +4,12 @@ var Queue = require('better-queue');
4
4
  var Homebridges = require('./lib/Homebridges.js').Homebridges;
5
5
  var HAPNodeJSClient = require('hap-node-client').HAPNodeJSClient;
6
6
 
7
- module.exports = function(RED) {
7
+ module.exports = function (RED) {
8
8
  var evDevices = [];
9
9
  var ctDevices = [];
10
10
  var hbDevices;
11
11
  var homebridge;
12
- var reqisterQueue = new Queue(function(node, cb) {
12
+ var reqisterQueue = new Queue(function (node, cb) {
13
13
  _register.call(node.that, node, cb);
14
14
  }, {
15
15
  concurrent: 1,
@@ -43,12 +43,12 @@ module.exports = function(RED) {
43
43
  homebridge = new HAPNodeJSClient({
44
44
  "pin": n.username,
45
45
  "refresh": 900,
46
- "debug": true,
46
+ "debug": false,
47
47
  "timeout": 20,
48
48
  "reqTimeout": 7000
49
49
  });
50
50
  reqisterQueue.pause();
51
- homebridge.on('Ready', function(accessories) {
51
+ homebridge.on('Ready', function (accessories) {
52
52
  // evDevices = register.registerEv(homebridge, accessories);
53
53
  // ctDevices = register.registerCt(homebridge, accessories);
54
54
  hbDevices = new Homebridges(accessories);
@@ -105,11 +105,11 @@ module.exports = function(RED) {
105
105
 
106
106
  var node = this;
107
107
 
108
- this.connect = function(callback) {
108
+ this.connect = function (callback) {
109
109
  callback();
110
110
  };
111
111
 
112
- this.register = function(deviceNode, callback) {
112
+ this.register = function (deviceNode, callback) {
113
113
  debug("hbConf.register", deviceNode.fullName);
114
114
  node.users[deviceNode.id] = deviceNode;
115
115
  debug("Register %s -> %s", deviceNode.type, deviceNode.fullName);
@@ -124,7 +124,7 @@ module.exports = function(RED) {
124
124
  // debug("Register Queue - push", reqisterQueue.getStats());
125
125
  };
126
126
 
127
- this.deregister = function(deviceNode, callback) {
127
+ this.deregister = function (deviceNode, callback) {
128
128
  deviceNode.status({
129
129
  text: 'disconnected',
130
130
  shape: 'ring',
@@ -134,14 +134,14 @@ module.exports = function(RED) {
134
134
  //
135
135
  // debug("hbEvent deregistered:", deviceNode.name);
136
136
  // if (homebridge.listenerCount(deviceNode.eventName)) {
137
- deviceNode.eventName.forEach(function(event) {
137
+ deviceNode.eventName.forEach(function (event) {
138
138
  homebridge.removeListener(event, deviceNode.listener);
139
139
  });
140
140
  // }
141
141
  callback();
142
142
  };
143
143
 
144
- this.on('close', function() {
144
+ this.on('close', function () {
145
145
  if (node.client && node.client.connected) {
146
146
  node.client.end();
147
147
  }
@@ -177,7 +177,7 @@ module.exports = function(RED) {
177
177
 
178
178
  var node = this;
179
179
 
180
- node.command = function(event) {
180
+ node.command = function (event) {
181
181
  // False messages can be received from accessories with multiple services
182
182
  // if (Object.keys(_convertHBcharactericToNode(event, node)).length > 0) {
183
183
  debug("hbEvent", node.name, event);
@@ -199,7 +199,7 @@ module.exports = function(RED) {
199
199
  fill: 'green'
200
200
  });
201
201
  clearTimeout(node.timeout);
202
- node.timeout = setTimeout(function() {
202
+ node.timeout = setTimeout(function () {
203
203
  node.status({});
204
204
  }, 10 * 1000);
205
205
  node.send(msg);
@@ -219,7 +219,7 @@ module.exports = function(RED) {
219
219
  };
220
220
  // };
221
221
 
222
- node.conf.register(node, function() {
222
+ node.conf.register(node, function () {
223
223
  debug("hbEvent.register", node.fullName);
224
224
  this.hbDevice = hbDevices.findDevice(node.device, {
225
225
  perms: 'pr'
@@ -230,7 +230,7 @@ module.exports = function(RED) {
230
230
 
231
231
  _status(node.device, node, {
232
232
  perms: 'ev'
233
- }, function(err, message) {
233
+ }, function (err, message) {
234
234
  if (!err) {
235
235
  node.state = _convertHBcharactericToNode(message.characteristics, node);
236
236
  debug("hbEvent received: %s = %s", node.fullName, JSON.stringify(message.characteristics), node.state);
@@ -251,7 +251,7 @@ module.exports = function(RED) {
251
251
  fill: 'green'
252
252
  });
253
253
  clearTimeout(node.timeout);
254
- node.timeout = setTimeout(function() {
254
+ node.timeout = setTimeout(function () {
255
255
  node.status({});
256
256
  }, 10 * 1000);
257
257
  node.send(msg);
@@ -265,7 +265,7 @@ module.exports = function(RED) {
265
265
  node.eventName = [];
266
266
  // node.eventName = this.hbDevice.host + this.hbDevice.port + this.hbDevice.aid;
267
267
  // debug("DEVICE", this.hbDevice);
268
- this.hbDevice.eventRegisters.forEach(function(event) {
268
+ this.hbDevice.eventRegisters.forEach(function (event) {
269
269
  homebridge.on(node.hbDevice.id + event.aid + event.iid, node.command);
270
270
  node.eventName.push(node.hbDevice.id + event.aid + event.iid);
271
271
  });
@@ -280,7 +280,7 @@ module.exports = function(RED) {
280
280
  }
281
281
  }.bind(this));
282
282
 
283
- node.on('close', function(callback) {
283
+ node.on('close', function (callback) {
284
284
  node.conf.deregister(node, callback);
285
285
  });
286
286
  }
@@ -325,7 +325,8 @@ module.exports = function(RED) {
325
325
  On: false
326
326
  };
327
327
 
328
- node.on('input', function(msg) {
328
+ node.on('input', function (msg) {
329
+ this.msg = msg;
329
330
  debug("hbResume.input: %s input", node.fullName, JSON.stringify(msg));
330
331
  if (typeof msg.payload === "object") {
331
332
  // Using this to validate input message contains valid Accessory Characteristics
@@ -370,7 +371,7 @@ module.exports = function(RED) {
370
371
  fill: 'green'
371
372
  });
372
373
  clearTimeout(node.timeout);
373
- node.timeout = setTimeout(function() {
374
+ node.timeout = setTimeout(function () {
374
375
  node.status({});
375
376
  }, 10 * 1000);
376
377
  node.lastMessageValue = newMsg.payload;
@@ -379,7 +380,7 @@ module.exports = function(RED) {
379
380
  node.lastPayload = JSON.parse(JSON.stringify(msg.payload)); // store value not reference
380
381
  }
381
382
  } else {
382
- node.error("Homebridge not initialized");
383
+ node.error("Homebridge not initialized", this.msg);
383
384
  node.status({
384
385
  text: 'Homebridge not initialized',
385
386
  shape: 'ring',
@@ -387,7 +388,7 @@ module.exports = function(RED) {
387
388
  });
388
389
  }
389
390
  } else {
390
- node.error("Payload should be an JSON object containing device characteristics and values, ie {\"On\":false, \"Brightness\":0 }\nValid values include: " + node.hbDevice.descriptions);
391
+ node.error("Payload should be an JSON object containing device characteristics and values, ie {\"On\":false, \"Brightness\":0 }\nValid values include: " + node.hbDevice.descriptions, this.msg);
391
392
  node.status({
392
393
  text: 'Invalid payload',
393
394
  shape: 'ring',
@@ -396,7 +397,7 @@ module.exports = function(RED) {
396
397
  }
397
398
  });
398
399
 
399
- node.command = function(event) {
400
+ node.command = function (event) {
400
401
  // debug("hbResume received event: %s ->", node.fullName, event);
401
402
  // debug("hbResume - internals %s millis, old %s, event %s, previous %s", Date.now() - node.lastMessageTime, node.lastMessageValue, event.status, node.state);
402
403
  // Don't update for events originating from here
@@ -436,7 +437,7 @@ module.exports = function(RED) {
436
437
  }
437
438
  };
438
439
 
439
- node.conf.register(node, function() {
440
+ node.conf.register(node, function () {
440
441
  debug("hbResume.register:", node.fullName);
441
442
  this.hbDevice = hbDevices.findDevice(node.device, {
442
443
  perms: 'pw'
@@ -444,7 +445,7 @@ module.exports = function(RED) {
444
445
  if (this.hbDevice) {
445
446
  _status(node.device, node, {
446
447
  perms: 'pw'
447
- }, function(err, message) {
448
+ }, function (err, message) {
448
449
  if (!err) {
449
450
  node.state = _convertHBcharactericToNode(message.characteristics, node);
450
451
  debug("hbResume received: %s = %s", node.fullName, JSON.stringify(message.characteristics), node.state);
@@ -459,7 +460,7 @@ module.exports = function(RED) {
459
460
  node.eventName = [];
460
461
  // node.eventName = this.hbDevice.host + this.hbDevice.port + this.hbDevice.aid;
461
462
  // homebridge.on(this.hbDevice.host + this.hbDevice.port + this.hbDevice.aid, node.command);
462
- this.hbDevice.eventRegisters.forEach(function(event) {
463
+ this.hbDevice.eventRegisters.forEach(function (event) {
463
464
  homebridge.on(node.hbDevice.id + event.aid + event.iid, node.command);
464
465
  node.eventName.push(node.hbDevice.id + event.aid + event.iid);
465
466
  });
@@ -469,7 +470,7 @@ module.exports = function(RED) {
469
470
  fill: 'green'
470
471
  });
471
472
  clearTimeout(node.timeout);
472
- node.timeout = setTimeout(function() {
473
+ node.timeout = setTimeout(function () {
473
474
  node.status({});
474
475
  }, 30 * 1000);
475
476
  } else {
@@ -477,7 +478,7 @@ module.exports = function(RED) {
477
478
  }
478
479
  }.bind(this));
479
480
 
480
- node.on('close', function(callback) {
481
+ node.on('close', function (callback) {
481
482
  node.conf.deregister(node, callback);
482
483
  });
483
484
  }
@@ -502,26 +503,29 @@ module.exports = function(RED) {
502
503
 
503
504
  var node = this;
504
505
 
505
- node.on('input', function(msg) {
506
+ node.on('input', function (msg) {
506
507
  const payload = {};
507
- Object.keys(msg.payload).sort().forEach(function(key) {
508
+ this.msg = msg;
509
+ Object.keys(msg.payload).sort().forEach(function (key) {
508
510
  payload[key] = msg.payload[key];
509
511
  });
510
- _control.call(this, node, msg.payload, function(err, data) {
512
+ _control.call(this, node, msg.payload, function (err, data) {
511
513
  if (!err && data) {
512
514
  // debug('hbControl', err, data); // Images produce alot of noise
513
515
  const msg = {};
514
516
  msg.payload = data;
515
517
  node.send(msg);
518
+ } else {
519
+ node.error(err, this.msg);
516
520
  }
517
- });
521
+ }.bind(this));
518
522
  });
519
523
 
520
- node.on('close', function(callback) {
524
+ node.on('close', function (callback) {
521
525
  callback();
522
526
  });
523
527
 
524
- node.conf.register(node, function() {
528
+ node.conf.register(node, function () {
525
529
  // debug("hbControl.register:", node.fullName, node);
526
530
  switch (node.service) {
527
531
  case "Camera Control": // Camera Control
@@ -552,7 +556,7 @@ module.exports = function(RED) {
552
556
 
553
557
  var node = this;
554
558
 
555
- node.conf.register(node, function() {
559
+ node.conf.register(node, function () {
556
560
  debug("hbStatus Registered:", node.fullName);
557
561
  this.hbDevice = hbDevices.findDevice(node.device);
558
562
  if (this.hbDevice) {
@@ -567,10 +571,11 @@ module.exports = function(RED) {
567
571
  }
568
572
  });
569
573
 
570
- node.on('input', function(msg) {
574
+ node.on('input', function (msg) {
575
+ this.msg = msg;
571
576
  _status(this.device, node, {
572
577
  perms: 'pr'
573
- }, function(err, message) {
578
+ }, function (err, message) {
574
579
  if (!err) {
575
580
  debug("hbStatus received: %s = %s", JSON.stringify(node.fullName), JSON.stringify(message));
576
581
  var msg = {
@@ -592,19 +597,19 @@ module.exports = function(RED) {
592
597
  });
593
598
  node.send(msg);
594
599
  } else {
595
- node.error(err);
600
+ node.error(err, this.msg);
596
601
  }
597
- });
602
+ }.bind(this));
598
603
  });
599
604
 
600
- node.on('close', function(callback) {
605
+ node.on('close', function (callback) {
601
606
  callback();
602
607
  });
603
608
  }
604
609
 
605
610
  RED.nodes.registerType("hb-status", hbStatus);
606
611
 
607
- RED.httpAdmin.post('/hap-device/refresh/:id', RED.auth.needsPermission('hb-event.read'), function(req, res) {
612
+ RED.httpAdmin.post('/hap-device/refresh/:id', RED.auth.needsPermission('hb-event.read'), function (req, res) {
608
613
  var id = req.params.id;
609
614
  var conf = RED.nodes.getNode(id);
610
615
  if (conf) {
@@ -616,7 +621,7 @@ module.exports = function(RED) {
616
621
  }
617
622
  });
618
623
 
619
- RED.httpAdmin.get('/hap-device/evDevices/', RED.auth.needsPermission('hb-event.read'), function(req, res) {
624
+ RED.httpAdmin.get('/hap-device/evDevices/', RED.auth.needsPermission('hb-event.read'), function (req, res) {
620
625
  debug("evDevices", hbDevices.toList({
621
626
  perms: 'ev'
622
627
  }).length);
@@ -629,7 +634,7 @@ module.exports = function(RED) {
629
634
  }
630
635
  });
631
636
 
632
- RED.httpAdmin.get('/hap-device/evDevices/:id', RED.auth.needsPermission('hb-event.read'), function(req, res) {
637
+ RED.httpAdmin.get('/hap-device/evDevices/:id', RED.auth.needsPermission('hb-event.read'), function (req, res) {
633
638
  debug("evDevices", hbDevices.toList({
634
639
  perms: 'ev'
635
640
  }).length);
@@ -642,7 +647,7 @@ module.exports = function(RED) {
642
647
  }
643
648
  });
644
649
 
645
- RED.httpAdmin.post('/hap-device/refresh/:id', RED.auth.needsPermission('hb-resume.read'), function(req, res) {
650
+ RED.httpAdmin.post('/hap-device/refresh/:id', RED.auth.needsPermission('hb-resume.read'), function (req, res) {
646
651
  var id = req.params.id;
647
652
  var conf = RED.nodes.getNode(id);
648
653
  if (conf) {
@@ -654,7 +659,7 @@ module.exports = function(RED) {
654
659
  }
655
660
  });
656
661
 
657
- RED.httpAdmin.get('/hap-device/evDevices/', RED.auth.needsPermission('hb-resume.read'), function(req, res) {
662
+ RED.httpAdmin.get('/hap-device/evDevices/', RED.auth.needsPermission('hb-resume.read'), function (req, res) {
658
663
  debug("evDevices", hbDevices.toList({
659
664
  perms: 'ev'
660
665
  }).length);
@@ -667,7 +672,7 @@ module.exports = function(RED) {
667
672
  }
668
673
  });
669
674
 
670
- RED.httpAdmin.get('/hap-device/evDevices/:id', RED.auth.needsPermission('hb-resume.read'), function(req, res) {
675
+ RED.httpAdmin.get('/hap-device/evDevices/:id', RED.auth.needsPermission('hb-resume.read'), function (req, res) {
671
676
  debug("evDevices", hbDevices.toList({
672
677
  perms: 'ev'
673
678
  }).length);
@@ -680,7 +685,7 @@ module.exports = function(RED) {
680
685
  }
681
686
  });
682
687
 
683
- RED.httpAdmin.get('/hap-device/ctDevices/', RED.auth.needsPermission('hb-control.read'), function(req, res) {
688
+ RED.httpAdmin.get('/hap-device/ctDevices/', RED.auth.needsPermission('hb-control.read'), function (req, res) {
684
689
  debug("ctDevices", hbDevices.toList({
685
690
  perms: 'pw'
686
691
  }).length);
@@ -693,7 +698,7 @@ module.exports = function(RED) {
693
698
  }
694
699
  });
695
700
 
696
- RED.httpAdmin.get('/hap-device/ctDevices/:id', RED.auth.needsPermission('hb-control.read'), function(req, res) {
701
+ RED.httpAdmin.get('/hap-device/ctDevices/:id', RED.auth.needsPermission('hb-control.read'), function (req, res) {
697
702
  debug("ctDevices", hbDevices.toList({
698
703
  perms: 'pw'
699
704
  }).length);
@@ -716,19 +721,24 @@ module.exports = function(RED) {
716
721
 
717
722
  function _convertHBcharactericToNode(hbMessage, node) {
718
723
  // debug("_convertHBcharactericToNode", node.device);
719
- var device = hbDevices.findDevice(node.device);
720
- // debug("Device", device);
721
724
  var payload = {};
722
- // characteristics = Object.assign(characteristics, characteristic.characteristic);
723
- if (device) {
724
- hbMessage.forEach(function(characteristic) {
725
- // debug("Exists", (device.characteristics[characteristic.aid + '.' + characteristic.iid]));
726
- if (device.characteristics[characteristic.aid + '.' + characteristic.iid]) {
727
- payload = Object.assign(payload, {
728
- [device.characteristics[characteristic.aid + '.' + characteristic.iid].characteristic]: characteristic.value
729
- });
730
- }
731
- });
725
+ if (!hbMessage.payload) {
726
+ var device = hbDevices.findDevice(node.device);
727
+ // debug("Device", device);
728
+
729
+ // characteristics = Object.assign(characteristics, characteristic.characteristic);
730
+ if (device) {
731
+ hbMessage.forEach(function(characteristic) {
732
+ // debug("Exists", (device.characteristics[characteristic.aid + '.' + characteristic.iid]));
733
+ if (device.characteristics[characteristic.aid + '.' + characteristic.iid]) {
734
+ payload = Object.assign(payload, {
735
+ [device.characteristics[characteristic.aid + '.' + characteristic.iid].characteristic]: characteristic.value
736
+ });
737
+ }
738
+ });
739
+ }
740
+ } else {
741
+ payload = hbMessage.payload;
732
742
  }
733
743
  // debug("payload", payload);
734
744
  return (payload);
@@ -786,12 +796,50 @@ module.exports = function(RED) {
786
796
  try {
787
797
  var device = hbDevices.findDevice(node.device, perms);
788
798
  if (device) {
789
- switch (device.service) {
790
- // Nothing specialized, yet
799
+ // debug("device.type", device.type);
800
+ switch (device.type) {
801
+ case "00000110": // Camera RTPStream Management
802
+ case "00000111": // Camera Control
803
+ var message = {
804
+ "resource-type": "image",
805
+ "image-width": 1920,
806
+ "image-height": 1080
807
+ };
808
+ debug("Control %s:%s ->", device.host, device.port, JSON.stringify(message));
809
+ homebridge.HAPresource(device.host, device.port, JSON.stringify(message), function(err, status) {
810
+ // debug("status", btoa(status));
811
+ if (!err) {
812
+ debug("Controlled %s:%s ->", device.host, device.port);
813
+ node.status({
814
+ text: 'sent',
815
+ shape: 'dot',
816
+ fill: 'green'
817
+ });
818
+ clearTimeout(node.timeout);
819
+ node.timeout = setTimeout(function() {
820
+ node.status({});
821
+ }, 30 * 1000);
822
+ // {"characteristics":[{"aid":19,"iid":10,"value":false},{"aid":19,"iid":11,"value":0}]}
823
+ callback(null, {
824
+ characteristics: {
825
+ payload: btoa(status)
826
+ }
827
+ });
828
+ } else {
829
+ node.error(device.host + ":" + device.port + " -> " + err);
830
+ node.status({
831
+ text: 'error',
832
+ shape: 'ring',
833
+ fill: 'red'
834
+ });
835
+ callback(err);
836
+ }
837
+ });
838
+ break;
791
839
  default:
792
840
  var message = '?id=' + device.getCharacteristics;
793
841
  debug("_status request: %s -> %s:%s ->", node.fullName, device.id, message);
794
- homebridge.HAPstatusByDeviceID(device.id, message, function(err, status) {
842
+ homebridge.HAPstatusByDeviceID(device.id, message, function (err, status) {
795
843
  if (!err) {
796
844
  // debug("Status %s:%s ->", device.host, device.port, status);
797
845
  node.status({
@@ -800,7 +848,7 @@ module.exports = function(RED) {
800
848
  fill: 'green'
801
849
  });
802
850
  clearTimeout(node.timeout);
803
- node.timeout = setTimeout(function() {
851
+ node.timeout = setTimeout(function () {
804
852
  node.status({});
805
853
  }, 30 * 1000);
806
854
  callback(null, status);
@@ -846,7 +894,6 @@ module.exports = function(RED) {
846
894
  */
847
895
 
848
896
  function _control(node, payload, callback) {
849
- // debug("_control", node.device);
850
897
  try {
851
898
  var device = hbDevices.findDevice(node.device, {
852
899
  perms: 'pw'
@@ -862,7 +909,7 @@ module.exports = function(RED) {
862
909
  "image-height": 1080
863
910
  };
864
911
  debug("Control %s ->", device.id, JSON.stringify(message));
865
- homebridge.HAPresourceByDeviceID(device.id, JSON.stringify(message), function(err, status) {
912
+ homebridge.HAPresourceByDeviceID(device.id, JSON.stringify(message), function (err, status) {
866
913
  if (!err) {
867
914
  debug("Controlled %s ->", device.id, JSON.stringify(payload));
868
915
  node.status({
@@ -871,7 +918,7 @@ module.exports = function(RED) {
871
918
  fill: 'green'
872
919
  });
873
920
  clearTimeout(node.timeout);
874
- node.timeout = setTimeout(function() {
921
+ node.timeout = setTimeout(function () {
875
922
  node.status({});
876
923
  }, 30 * 1000);
877
924
  callback(null, status);
@@ -892,7 +939,7 @@ module.exports = function(RED) {
892
939
  message = _createControlMessage.call(this, payload, node, device);
893
940
  debug("Control %s ->", device.id, JSON.stringify(message));
894
941
  if (message.characteristics.length > 0) {
895
- homebridge.HAPcontrolByDeviceID(device.id, JSON.stringify(message), function(err, status) {
942
+ homebridge.HAPcontrolByDeviceID(device.id, JSON.stringify(message), function (err, status) {
896
943
  if (!err && status && status.characteristics[0].status === 0) {
897
944
  debug("Controlled %s ->", device.id, JSON.stringify(status));
898
945
  node.status({
@@ -901,7 +948,7 @@ module.exports = function(RED) {
901
948
  fill: 'green'
902
949
  });
903
950
  clearTimeout(node.timeout);
904
- node.timeout = setTimeout(function() {
951
+ node.timeout = setTimeout(function () {
905
952
  node.status({});
906
953
  }, 10 * 1000);
907
954
  callback(null);
@@ -913,7 +960,7 @@ module.exports = function(RED) {
913
960
  fill: 'green'
914
961
  });
915
962
  clearTimeout(node.timeout);
916
- node.timeout = setTimeout(function() {
963
+ node.timeout = setTimeout(function () {
917
964
  node.status({});
918
965
  }, 10 * 1000);
919
966
  callback(null);
@@ -963,7 +1010,6 @@ module.exports = function(RED) {
963
1010
  }
964
1011
  } catch (err) {
965
1012
  var error = "Homebridge not initialized";
966
- node.error(error);
967
1013
  node.status({
968
1014
  text: error,
969
1015
  shape: 'ring',
@@ -991,7 +1037,7 @@ module.exports = function(RED) {
991
1037
  "characteristics": device.eventRegisters
992
1038
  };
993
1039
  debug("_register", node.fullName, device.id, message);
994
- homebridge.HAPeventByDeviceID(device.id, JSON.stringify(message), function(err, status) {
1040
+ homebridge.HAPeventByDeviceID(device.id, JSON.stringify(message), function (err, status) {
995
1041
  if (!err && status === null) {
996
1042
  debug("%s registered: %s -> %s", node.type, node.fullName, device.id);
997
1043
  callback(null);
@@ -1034,3 +1080,15 @@ function _getKey(obj, value) {
1034
1080
  }
1035
1081
  return null;
1036
1082
  }
1083
+
1084
+ function btoa(str) {
1085
+ var buffer;
1086
+
1087
+ if (str instanceof Buffer) {
1088
+ buffer = str;
1089
+ } else {
1090
+ buffer = Buffer.from(str.toString(), 'binary');
1091
+ }
1092
+
1093
+ return buffer.toString('base64');
1094
+ }
package/README.md CHANGED
@@ -9,51 +9,51 @@ The above Node-RED Flow, turns on my 'Outside Office' light when the powder room
9
9
  # Table of Contents
10
10
 
11
11
  <!--ts-->
12
- * [Homebridge Automation powered by Node-RED](#homebridge-automation-powered-by-node-red)
13
- * [Table of Contents](#table-of-contents)
14
- * [Introduction](#introduction)
15
- * [Caveats](#caveats)
16
- * [Changes](#changes)
17
- * [Mar 18, 2019 - Version 0.0.39](#mar-18-2019---version-0039)
18
- * [Mar 19, 2019 - Version 0.0.42](#mar-19-2019---version-0042)
19
- * [Mar 31, 2019 - Version 0.0.](#mar-31-2019---version-00)
20
- * [May 9, 2019 - Version 0.0.43](#may-9-2019---version-0043)
21
- * [May 15, 2019 - Version 0.0.44](#may-15-2019---version-0044)
22
- * [May 29, 2019 - Version 0.0.45](#may-29-2019---version-0045)
23
- * [July 27, 2019 - Version 0.0.50](#july-27-2019---version-0050)
24
- * [Feb 24, 2020 - Version 0.0.56](#feb-24-2020---version-0056)
25
- * [Mar 18, 2020 - Version 0.0.59](#mar-18-2020---version-0059)
26
- * [Oct 13, 2020 - Version 0.0.71](#oct-13-2020---version-0071)
27
- * [Oct 24, 2020 - Version 0.0.71](#oct-24-2020---version-0071)
28
- * [Nov 1, 2020 - Version 0.0.73](#nov-1-2020---version-0073)
29
- * [Nov 13, 2020 - Version 0.0.76](#nov-13-2020---version-0076)
30
- * [Feb 2, 2021 - Version 0.0.78](#feb-2-2021---version-0078)
31
- * [Mar 9, 2021 - Version 0.0.80](#mar-9-2021---version-0080)
32
- * [April 23, 2021 - Version 0.0.82](#april-23-2021---version-0082)
33
- * [April 23, 2022 - Version 0.0.86](#april-23-2022---version-0086)
34
- * [Backlog / Roadmap](#backlog--roadmap)
35
- * [Dropped items](#dropped-items)
36
- * [Installation Steps](#installation-steps)
37
- * [1 - Install Node-RED and Homebridge](#1---install-node-red-and-homebridge)
38
- * [2 - Prepare Homebridge for integration with Homebridge-Automation](#2---prepare-homebridge-for-integration-with-homebridge-automation)
39
- * [3 - Install Homebridge-Automation into Node-Red](#3---install-homebridge-automation-into-node-red)
40
- * [4 - Start Node-Red](#4---start-node-red)
41
- * [5 - Initial setup and configuration inside Node-Red](#5---initial-setup-and-configuration-inside-node-red)
42
- * [6 - Configure 'hb event' to receive updates from your Accessories](#6---configure-hb-event-to-receive-updates-from-your-accessories)
43
- * [Node-RED Homebridge-Automation Message Structure](#node-red-homebridge-automation-message-structure)
44
- * [hb event](#hb-event)
45
- * [Output](#output)
46
- * [hb resume](#hb-resume)
47
- * [input](#input)
48
- * [output](#output-1)
49
- * [hb status](#hb-status)
50
- * [input](#input-1)
51
- * [output](#output-2)
52
- * [hb control](#hb-control)
53
- * [Input](#input-2)
54
- * [Flows Shared from Community](#flows-shared-from-community)
55
- * [Troubleshooting / DEBUG MODE](#troubleshooting--debug-mode)
56
- * [To start Node-RED in DEBUG mode, and output Homebridge-Automation debug logs start Node-RED like this.](#to-start-node-red-in-debug-mode-and-output-homebridge-automation-debug-logs-start-node-red-like-this)
12
+ * [Homebridge Automation powered by Node-RED]()
13
+ * [Table of Contents]()
14
+ * [Introduction]()
15
+ * [Caveats]()
16
+ * [Changes]()
17
+ * [Mar 18, 2019 - Version 0.0.39]()
18
+ * [Mar 19, 2019 - Version 0.0.42]()
19
+ * [Mar 31, 2019 - Version 0.0.]()
20
+ * [May 9, 2019 - Version 0.0.43]()
21
+ * [May 15, 2019 - Version 0.0.44]()
22
+ * [May 29, 2019 - Version 0.0.45]()
23
+ * [July 27, 2019 - Version 0.0.50]()
24
+ * [Feb 24, 2020 - Version 0.0.56]()
25
+ * [Mar 18, 2020 - Version 0.0.59]()
26
+ * [Oct 13, 2020 - Version 0.0.71]()
27
+ * [Oct 24, 2020 - Version 0.0.71]()
28
+ * [Nov 1, 2020 - Version 0.0.73]()
29
+ * [Nov 13, 2020 - Version 0.0.76]()
30
+ * [Feb 2, 2021 - Version 0.0.78]()
31
+ * [Mar 9, 2021 - Version 0.0.80]()
32
+ * [April 23, 2021 - Version 0.0.82]()
33
+ * [April 23, 2022 - Version 0.0.86]()
34
+ * [Backlog / Roadmap]()
35
+ * [Dropped items]()
36
+ * [Installation Steps]()
37
+ * [1 - Install Node-RED and Homebridge]()
38
+ * [2 - Prepare Homebridge for integration with Homebridge-Automation]()
39
+ * [3 - Install Homebridge-Automation into Node-Red]()
40
+ * [4 - Start Node-Red]()
41
+ * [5 - Initial setup and configuration inside Node-Red]()
42
+ * [6 - Configure 'hb event' to receive updates from your Accessories]()
43
+ * [Node-RED Homebridge-Automation Message Structure]()
44
+ * [hb event]()
45
+ * [Output]()
46
+ * [hb resume]()
47
+ * [input]()
48
+ * [output]()
49
+ * [hb status]()
50
+ * [input]()
51
+ * [output]()
52
+ * [hb control]()
53
+ * [Input]()
54
+ * [Flows Shared from Community]()
55
+ * [Troubleshooting / DEBUG MODE]()
56
+ * [To start Node-RED in DEBUG mode, and output Homebridge-Automation debug logs start Node-RED like this.]()
57
57
 
58
58
  <!-- Added by: sgracey, at: -->
59
59
 
package/beta.sh CHANGED
@@ -13,4 +13,4 @@ npm audit fix
13
13
  git push origin beta --tags
14
14
  #else
15
15
  # echo "Not publishing due to security vulnerabilites"
16
- #fi
16
+ #fi
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-homebridge-automation",
3
- "version": "0.0.86-beta.2",
3
+ "version": "0.1.0-beta.3",
4
4
  "description": "NodeRED Automation for HomeBridge",
5
5
  "main": "HAP-NodeRed.js",
6
6
  "scripts": {
@@ -22,12 +22,12 @@
22
22
  "url": "git+https://github.com/NorthernMan54/node-red-contrib-homebridge-automation.git"
23
23
  },
24
24
  "devDependencies": {
25
- "documentation": "^13.2.5"
25
+ "documentation": "^14.0.1"
26
26
  },
27
27
  "dependencies": {
28
28
  "better-queue": ">=3.8.10",
29
29
  "debug": ">2.6.9",
30
- "hap-node-client": ">=0.1.22-beta.2"
30
+ "hap-node-client": ">=0.1.30-beta.0"
31
31
  },
32
32
  "author": "NorthernMan54",
33
33
  "license": "ISC",