node-red-contrib-homebridge-automation 0.1.12-beta.1 → 0.1.12-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/.eslintrc.js CHANGED
@@ -21,4 +21,4 @@ module.exports = {
21
21
  semi: ['error', 'always'],
22
22
  'no-console': 'off',
23
23
  },
24
- };
24
+ };
package/README.md CHANGED
@@ -60,7 +60,7 @@ The above Node-RED Flow, turns on my 'Outside Office' light when the powder room
60
60
  * [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)
61
61
 
62
62
  <!-- Created by https://github.com/ekalinin/github-markdown-toc -->
63
- <!-- Added by: runner, at: Fri Jul 5 02:43:29 UTC 2024 -->
63
+ <!-- Added by: runner, at: Fri Jul 5 23:39:42 UTC 2024 -->
64
64
 
65
65
  <!--te-->
66
66
 
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "node-red-contrib-homebridge-automation",
3
- "version": "0.1.12-beta.1",
3
+ "version": "0.1.12-beta.3",
4
4
  "description": "NodeRED Automation for HomeBridge",
5
5
  "main": "src/HAP-NodeRed.js",
6
6
  "scripts": {
7
7
  "api": "documentation build HAP-NodeRed.js -f md --config docs/documentation.yml > docs/API.md",
8
8
  "document": "./gh-md-toc --insert README.md; rm README.md.orig.* README.md.toc.*",
9
- "watch": "nodemon"
9
+ "watch": "nodemon",
10
+ "coverage": "nyc npm t",
11
+ "format": "prettier --write {.,test}/*.js *.html *.md",
12
+ "lint": "eslint {.,test}/*.js",
13
+ "test": "mocha \"test/**/*_spec.js\""
10
14
  },
11
15
  "keywords": [
12
16
  "node-red",
@@ -23,9 +27,14 @@
23
27
  },
24
28
  "devDependencies": {
25
29
  "@types/node-red": "^0.20.7",
30
+ "@types/jest": "^29.5.12",
26
31
  "documentation": "14.0.3",
27
- "eslint": "^9.6.0",
28
- "eslint-plugin-mocha": "^10.4.3",
32
+ "eslint": "^8.57.0",
33
+ "eslint-config-airbnb-typescript": "^18.0.0",
34
+ "eslint-plugin-import": "^2.29.1",
35
+ "eslint-plugin-import-newlines": "^1.4.0",
36
+ "eslint-plugin-jest": "^28.6.0",
37
+ "eslint-plugin-sort-exports": "^0.9.1",
29
38
  "mocha": "^10.6.0",
30
39
  "node-red": "^4.0.2",
31
40
  "node-red-node-test-helper": "^0.3.4",
@@ -233,7 +233,7 @@ module.exports = function (RED) {
233
233
  }, function (err, message) {
234
234
  if (!err) {
235
235
  node.state = _convertHBcharactericToNode(message.characteristics, node);
236
- debug("hbEvent received: %s = %s", node.fullName, JSON.stringify(message.characteristics), node.state);
236
+ debug("hbEvent received: %s = %s", node.fullName, JSON.stringify(message.characteristics).slice(0, 80)+'...');
237
237
  if (node.sendInitialState) {
238
238
  var msg = {
239
239
  name: node.name,
@@ -17,14 +17,21 @@ function Accessory(devices, context) {
17
17
  this.homebridge = context.homebridge;
18
18
  this.id = context.id;
19
19
  this.services = [];
20
- devices.services.forEach(function(element) {
20
+ devices.services.forEach(function (element) {
21
21
  // debug("Service", element);
22
22
  switch (element.type.substring(0, 8)) {
23
23
  case "0000003E": // Accessory Information
24
24
  this.info = information(element.characteristics);
25
25
  break;
26
- // case "00000110": // Camera RTPStream Management generates duplicates
27
- // break;
26
+ case "00000110": // Camera RTPStream Management generates duplicates
27
+ var service = new Service(element, this);
28
+ // console.log('services', this.services);
29
+ if (this.services.some(e => e.type === '00000110')) {
30
+
31
+ } else {
32
+ this.services.push(service);
33
+ }
34
+ break;
28
35
  case "000000D9": // Input Source from webosTV has a dummy input source
29
36
  var service = new Service(element, this);
30
37
  if (service.name !== "dummy") {
@@ -39,7 +46,7 @@ function Accessory(devices, context) {
39
46
  // debug("Info", this.info);
40
47
  }
41
48
 
42
- Accessory.prototype.toList = function(context) {
49
+ Accessory.prototype.toList = function (context) {
43
50
  var list = [];
44
51
  // debug("toList", context);
45
52
  context.aid = this.aid;
@@ -109,7 +116,7 @@ Accessory.prototype.toList = function(context) {
109
116
 
110
117
  function information(characteristics) {
111
118
  var result = {};
112
- characteristics.forEach(function(characteristic) {
119
+ characteristics.forEach(function (characteristic) {
113
120
  if (characteristic.description) {
114
121
  var key = characteristic.description.replace(/ /g, '').replace(/\./g, '_');
115
122
  result[key] = characteristic.value;
package/test/test_spec.js CHANGED
@@ -5,7 +5,7 @@ var helper = require('node-red-node-test-helper');
5
5
  helper.init(require.resolve('node-red'), { userDir: os.tmpdir() });
6
6
 
7
7
  var flows = require('./flows');
8
- var hapNode = require('../HAP-NodeRed.js');
8
+ var hapNode = require('../src/HAP-NodeRed.js');
9
9
 
10
10
  describe('HAP node', function () {
11
11
  before(function (done) {