node-red-contrib-homebridge-automation 0.1.12-beta.0 → 0.1.12-beta.1

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 ADDED
@@ -0,0 +1,24 @@
1
+ module.exports = {
2
+ env: {
3
+ es6: true,
4
+ node: true,
5
+ mocha: true,
6
+ },
7
+ extends: ['eslint:recommended', 'plugin:mocha/recommended'],
8
+ globals: {
9
+ Atomics: 'readonly',
10
+ SharedArrayBuffer: 'readonly',
11
+ },
12
+ parserOptions: {
13
+ ecmaVersion: 2018,
14
+ sourceType: 'module',
15
+ },
16
+ plugins: ['mocha'],
17
+ rules: {
18
+ indent: ['error', 2, { SwitchCase: 1 }],
19
+ 'linebreak-style': ['error', 'unix'],
20
+ quotes: ['error', 'single'],
21
+ semi: ['error', 'always'],
22
+ 'no-console': 'off',
23
+ },
24
+ };
package/.nycrc.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "reporter": [
3
+ "lcov",
4
+ "text-summary"
5
+ ],
6
+ "lines": 100,
7
+ "statements": 100,
8
+ "functions": 100,
9
+ "branches": 100,
10
+ "check-coverage": true
11
+ }
package/.prettierrc ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "printWidth": 120,
3
+ "tabWidth": 2,
4
+ "trailingComma": "all",
5
+ "singleQuote": true
6
+ }
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:40:07 UTC 2024 -->
63
+ <!-- Added by: runner, at: Fri Jul 5 02:43:29 UTC 2024 -->
64
64
 
65
65
  <!--te-->
66
66
 
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "node-red-contrib-homebridge-automation",
3
- "version": "0.1.12-beta.0",
3
+ "version": "0.1.12-beta.1",
4
4
  "description": "NodeRED Automation for HomeBridge",
5
5
  "main": "src/HAP-NodeRed.js",
6
6
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1",
8
7
  "api": "documentation build HAP-NodeRed.js -f md --config docs/documentation.yml > docs/API.md",
9
8
  "document": "./gh-md-toc --insert README.md; rm README.md.orig.* README.md.toc.*",
10
9
  "watch": "nodemon"
@@ -23,8 +22,17 @@
23
22
  "url": "git+https://github.com/NorthernMan54/node-red-contrib-homebridge-automation.git"
24
23
  },
25
24
  "devDependencies": {
26
- "documentation": "^14.0.3",
25
+ "@types/node-red": "^0.20.7",
26
+ "documentation": "14.0.3",
27
+ "eslint": "^9.6.0",
28
+ "eslint-plugin-mocha": "^10.4.3",
29
+ "mocha": "^10.6.0",
30
+ "node-red": "^4.0.2",
31
+ "node-red-node-test-helper": "^0.3.4",
27
32
  "nodemon": "^3.1.4",
33
+ "nyc": "^17.0.0",
34
+ "prettier": "^3.3.2",
35
+ "rimraf": "^5.0.7",
28
36
  "semver": "^7.6.2"
29
37
  },
30
38
  "dependencies": {
package/test/flows.js ADDED
@@ -0,0 +1,42 @@
1
+ const Flows = {
2
+ getDefault: function (options) {
3
+ let defaultFlow = [
4
+ {
5
+ id: 'status1',
6
+ type: 'hb-status',
7
+ name: 'StatusNode1',
8
+ Homebridge: 'homebridge',
9
+ Manufacturer: 'TestModule',
10
+ Service: 'Switch',
11
+ device: 'homebridgeAA:BB:CC:DD:EE:FF0StatusNode100000049',
12
+ conf: 'conf1',
13
+ wires: [['n2']],
14
+ },
15
+ {
16
+ id: 'control1',
17
+ type: 'hb-control',
18
+ name: 'ControlNode1',
19
+ Homebridge: 'homebridge',
20
+ Manufacturer: 'TestModule',
21
+ Service: 'Outlet',
22
+ device: 'homebridgeAA:BB:CC:DD:EE:FF0ControlNode1h00000047',
23
+ conf: 'conf1',
24
+ outputs: 0,
25
+ wires: [],
26
+ },
27
+ {
28
+ id: 'conf1',
29
+ type: 'hb-conf',
30
+ username: '031-45-154',
31
+ macAddress: 'AA:BB:CC:DD:EE:FF',
32
+ },
33
+ { id: 'n2', type: 'helper' },
34
+ { id: 'n3', type: 'helper' },
35
+ ];
36
+
37
+ defaultFlow[0] = Object.assign(defaultFlow[0], options);
38
+ return defaultFlow;
39
+ },
40
+ };
41
+
42
+ module.exports = Flows;
@@ -0,0 +1,40 @@
1
+ // var should = require('should');
2
+ var os = require('os');
3
+ var path = require('path');
4
+ var helper = require('node-red-node-test-helper');
5
+ helper.init(require.resolve('node-red'), { userDir: os.tmpdir() });
6
+
7
+ var flows = require('./flows');
8
+ var hapNode = require('../HAP-NodeRed.js');
9
+
10
+ describe('HAP node', function () {
11
+ before(function (done) {
12
+ helper.startServer(done);
13
+ });
14
+
15
+ after(function (done) {
16
+ helper.stopServer(done);
17
+ });
18
+
19
+ afterEach(function () {
20
+ helper.unload();
21
+ });
22
+
23
+ it('should be loaded', function (done) {
24
+ var flow = flows.getDefault();
25
+
26
+ helper.load(hapNode, flow, function () {
27
+ var conf1 = helper.getNode('conf1');
28
+ conf1.should.have.property('macAddress', 'AA:BB:CC:DD:EE:FF');
29
+ var stat1 = helper.getNode('status1');
30
+ stat1.should.have.property('name', 'StatusNode1');
31
+ var ctl1 = helper.getNode('control1');
32
+ ctl1.should.have.property('name', 'ControlNode1');
33
+ var logEvents = helper.log().args.filter(function (evt) {
34
+ return evt[0].type == 'hb-conf' || evt[0].type == 'hb-status';
35
+ });
36
+ logEvents.should.have.length(0);
37
+ done();
38
+ });
39
+ });
40
+ });