node-red-contrib-homebridge-automation 0.1.12-beta.8 → 0.2.0

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.
Files changed (41) hide show
  1. package/.github/workflows/Build and Publish.yml +81 -75
  2. package/README.md +7 -4
  3. package/eslint.config.mjs +34 -0
  4. package/package.json +35 -26
  5. package/src/HAP-NodeRed.html +71 -71
  6. package/src/HAP-NodeRed.js +32 -1082
  7. package/src/HapDeviceRoutes.js +59 -0
  8. package/src/hbBaseNode.js +94 -0
  9. package/src/hbConfigNode.js +239 -0
  10. package/src/hbConfigNode.test.js +2179 -0
  11. package/src/hbControlNode.js +77 -0
  12. package/src/hbEventNode.js +23 -0
  13. package/src/hbResumeNode.js +63 -0
  14. package/src/hbStatusNode.js +37 -0
  15. package/test/node-red/.config.nodes.json +453 -0
  16. package/test/node-red/.config.nodes.json.backup +453 -0
  17. package/test/node-red/.config.runtime.json +4 -0
  18. package/test/node-red/.config.runtime.json.backup +3 -0
  19. package/test/node-red/.config.users.json +23 -0
  20. package/test/node-red/.config.users.json.backup +20 -0
  21. package/test/node-red/.flows.json.backup +2452 -0
  22. package/test/node-red/flows.json +2453 -0
  23. package/test/node-red/package.json +6 -0
  24. package/test/node-red/settings.js +593 -0
  25. package/test/node-red/test/node-red/.config.nodes.json +430 -0
  26. package/test/node-red/test/node-red/.config.runtime.json +4 -0
  27. package/test/node-red/test/node-red/.config.runtime.json.backup +3 -0
  28. package/test/node-red/test/node-red/.config.users.json +20 -0
  29. package/test/node-red/test/node-red/.config.users.json.backup +17 -0
  30. package/test/node-red/test/node-red/package.json +6 -0
  31. package/test/node-red/test/node-red/settings.js +593 -0
  32. package/.eslintrc.js +0 -24
  33. package/.github/npm-version-script.js +0 -93
  34. package/.nycrc.json +0 -11
  35. package/src/lib/Accessory.js +0 -126
  36. package/src/lib/Characteristic.js +0 -30
  37. package/src/lib/HbAccessories.js +0 -167
  38. package/src/lib/Homebridge.js +0 -71
  39. package/src/lib/Homebridges.js +0 -68
  40. package/src/lib/Service.js +0 -307
  41. package/src/lib/register.js +0 -156
@@ -1,13 +1,14 @@
1
- name: "Build, Publish and Release"
2
-
3
- #
4
- # Automatically publish beta releases on pushes, require a manual workflow action for production releases
5
- #
6
- # Does the following
7
- # 1 - Run the documentation script against the package
8
- # 2 - Create the npm package using the package.json version tag ( or for beta releases, adds a beta tag and increments as needed )
9
- # 3 - Publish the npm package
10
- # 4 - For releases against the main branch, create a github release as well
1
+ name:
2
+ 'Build, Publish and Release'
3
+
4
+ #
5
+ # Automatically publish beta releases on pushes, require a manual workflow action for production releases
6
+ #
7
+ # Does the following
8
+ # 1 - Run the documentation script against the package
9
+ # 2 - Create the npm package using the package.json version tag ( or for beta releases, adds a beta tag and increments as needed )
10
+ # 3 - Publish the npm package
11
+ # 4 - For releases against the latest branch, create a github release as well
11
12
 
12
13
  on:
13
14
  push:
@@ -19,24 +20,24 @@ jobs:
19
20
  runs-on: ubuntu-latest
20
21
 
21
22
  steps:
22
- # checkout repo
23
- - uses: actions/checkout@v4
24
-
25
- # get branch / tag name
26
- - name: Get Branch / Tag Name
27
- id: get_branch
28
- run: |
29
- export BRANCH_NAME=$(if [[ ${GITHUB_REF} =~ "refs/tags/" ]]; then echo ${GITHUB_REF/refs\/tags\//}; else echo ${GITHUB_REF/refs\/heads\//}; fi)
30
- echo $BRANCH_NAME
31
- echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_OUTPUT
32
-
33
- # generate the image tag
34
- - name: Get Image Tag
35
- id: get_tag
36
- run: |
37
- export TARGET_IMAGE_TAG=$(if [ "${{ steps.get_branch.outputs.BRANCH_NAME }}" = "main" ]; then echo "main"; else echo "${{ steps.get_branch.outputs.BRANCH_NAME }}" | awk -F- '{ print $1 }'; fi)
38
- echo $TARGET_IMAGE_TAG
39
- echo "TARGET_IMAGE_TAG=${TARGET_IMAGE_TAG}" >> $GITHUB_OUTPUT
23
+ # checkout repo
24
+ - uses: actions/checkout@v4
25
+
26
+ # get branch / tag name
27
+ - name: Get Branch / Tag Name
28
+ id: get_branch
29
+ run: |
30
+ export BRANCH_NAME=$(if [[ ${GITHUB_REF} =~ "refs/tags/" ]]; then echo ${GITHUB_REF/refs\/tags\//}; else echo ${GITHUB_REF/refs\/heads\//}; fi)
31
+ echo $BRANCH_NAME
32
+ echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_OUTPUT
33
+
34
+ # generate the image tag
35
+ - name: Get Image Tag
36
+ id: get_tag
37
+ run: |
38
+ export TARGET_IMAGE_TAG=$(if [ "${{ steps.get_branch.outputs.BRANCH_NAME }}" = "main" ]; then echo "main"; else echo "${{ steps.get_branch.outputs.BRANCH_NAME }}" | awk -F- '{ print $1 }'; fi)
39
+ echo $TARGET_IMAGE_TAG
40
+ echo "TARGET_IMAGE_TAG=${TARGET_IMAGE_TAG}" >> $GITHUB_OUTPUT
40
41
 
41
42
  outputs:
42
43
  BRANCH_NAME: ${{ steps.get_branch.outputs.BRANCH_NAME }}
@@ -46,50 +47,54 @@ jobs:
46
47
  runs-on: ubuntu-latest
47
48
 
48
49
  steps:
49
- # checkout repo
50
- - uses: actions/checkout@v4
51
- with:
52
- persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
53
- fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
54
-
55
- - uses: actions/setup-node@v4
56
- with:
57
- node-version: lts/*
58
-
59
- - name: Retrieve github-markdown-toc
60
- run: |
61
- wget -q https://raw.githubusercontent.com/ekalinin/github-markdown-toc/master/gh-md-toc
62
- chmod a+x gh-md-toc
63
-
64
- - name: Create Table of Contents
65
- run: |
66
- npm run-script document --if-present
67
- rm gh-md-toc
68
-
69
- - name: Commit files
70
- run: |
71
- git config --local user.email "github-actions[bot]@users.noreply.github.com"
72
- git config --local user.name "github-actions[bot]"
73
- git add *
74
- git commit -a -m "Update TOC" || true
75
-
76
- - name: Push changes
77
- uses: ad-m/github-push-action@master
78
- with:
79
- github_token: ${{ secrets.GITHUB_TOKEN }}
80
- branch: ${{ github.ref }}
50
+ # checkout repo
51
+ - uses: actions/checkout@v4
52
+ with:
53
+ persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
54
+ fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
55
+
56
+ - uses: actions/setup-node@v4
57
+ with:
58
+ node-version: lts/*
59
+
60
+ - name: Retrieve github-markdown-toc
61
+ run: |
62
+ wget -q https://raw.githubusercontent.com/ekalinin/github-markdown-toc/master/gh-md-toc
63
+ chmod a+x gh-md-toc
64
+
65
+ - name: Create Table of Contents
66
+ run: |
67
+ npm run-script document --if-present
68
+ rm gh-md-toc
69
+
70
+ - name: Commit files
71
+ run: |
72
+ git config --local user.email "github-actions[bot]@users.noreply.github.com"
73
+ git config --local user.name "github-actions[bot]"
74
+ git add * || true
75
+ git commit -a -m "Update TOC" || true
76
+
77
+ - name: Push changes
78
+ uses: ad-m/github-push-action@master
79
+ with:
80
+ github_token: ${{ secrets.GITHUB_TOKEN }}
81
+ branch: ${{ github.ref }}
81
82
 
82
83
  publish_prod_release:
84
+ permissions:
85
+ id-token: write
83
86
  needs: [get_tags, create_documentation]
84
87
  name: Publish Release Version
85
88
  if: ${{ needs.get_tags.outputs.BRANCH_NAME == 'main' }}
86
89
  uses: homebridge/.github/.github/workflows/npm-publish.yml@latest
87
90
  with:
88
- install_cmd: npm ci
91
+ install_cmd: npm ci
89
92
  secrets:
90
- npm_auth_token: ${{ secrets.npm_token }}
93
+ npm_auth_token: ${{ secrets.NPM_TOKEN }}
91
94
 
92
95
  publish_test_release:
96
+ permissions:
97
+ id-token: write
93
98
  needs: [get_tags, create_documentation]
94
99
  name: Publish Test Version - ${{ needs.get_tags.outputs.BRANCH_NAME }}
95
100
  if: ${{ needs.get_tags.outputs.BRANCH_NAME != 'main' }}
@@ -97,23 +102,24 @@ jobs:
97
102
  with:
98
103
  tag: ${{ needs.get_tags.outputs.TARGET_IMAGE_TAG }}
99
104
  dynamically_adjust_version: true
100
- npm_version_command: 'pre'
105
+ npm_version_command: pre
101
106
  pre_id: ${{ needs.get_tags.outputs.TARGET_IMAGE_TAG }}
107
+ install_cmd: npm ci
102
108
  secrets:
103
- npm_auth_token: ${{ secrets.npm_token }}
109
+ npm_auth_token: ${{ secrets.NPM_TOKEN }}
104
110
 
105
111
  publish_github_release:
106
112
  needs: [publish_prod_release]
107
113
  runs-on: ubuntu-latest
108
114
  steps:
109
- - uses: actions/checkout@v4
110
- - name: Create Release
111
- uses: softprops/action-gh-release@v1
112
- env:
113
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114
- with:
115
- tag_name: ${{ needs.publish_prod_release.outputs.NPM_VERSION }}
116
- name: Release ${{ needs.publish_prod_release.outputs.NPM_VERSION }}
117
- generate_release_notes: true
118
- draft: false
119
- prerelease: false
115
+ - uses: actions/checkout@v4
116
+ - name: Create Release
117
+ uses: softprops/action-gh-release@v1
118
+ env:
119
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
120
+ with:
121
+ tag_name: ${{ needs.publish_prod_release.outputs.NPM_VERSION }}
122
+ name: Release ${{ needs.publish_prod_release.outputs.NPM_VERSION }}
123
+ generate_release_notes: true
124
+ draft: false
125
+ prerelease: false
package/README.md CHANGED
@@ -34,6 +34,7 @@ The above Node-RED Flow, turns on my 'Outside Office' light when the powder room
34
34
  * [Jan 6, 2023 - Version 0.1.5](#jan-6-2023---version-015)
35
35
  * [Jan 11, 2023 - Version 0.1.7](#jan-11-2023---version-017)
36
36
  * [Jan 15, 2023 - Version 0.1.8](#jan-15-2023---version-018)
37
+ * [Dec 15, 2024 - Version 0.2.0](#dec-15-2024---version-020)
37
38
  * [Backlog / Roadmap](#backlog--roadmap)
38
39
  * [Dropped items](#dropped-items)
39
40
  * [Installation Steps](#installation-steps)
@@ -58,10 +59,6 @@ The above Node-RED Flow, turns on my 'Outside Office' light when the powder room
58
59
  * [Donations](#donations)
59
60
  * [Troubleshooting / DEBUG MODE](#troubleshooting--debug-mode)
60
61
  * [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
-
62
- <!-- Created by https://github.com/ekalinin/github-markdown-toc -->
63
- <!-- Added by: runner, at: Sat Jul 6 23:29:21 UTC 2024 -->
64
-
65
62
  <!--te-->
66
63
 
67
64
  # Introduction
@@ -183,6 +180,12 @@ With a plugin, you can see if it supports Real Time events, by opening the Home
183
180
 
184
181
  - Workaround for #111
185
182
 
183
+ ### Dec 15, 2024 - Version 0.2.0
184
+
185
+ - Major code base refresh, and migration from hap-node-client to hap-client ( Potential fix for #120 )
186
+ - With the change in connectivity to homebridge, please validate all your nodes are connected after the update. And pay particular attention to `Camera` nodes, as for some devices the name has changed.
187
+ - Testing and Development was completed on Node-RED version: v4.0.2 and Node.js version: v20.18.1
188
+
186
189
  # Backlog / Roadmap
187
190
 
188
191
  * [x] - Update Node Information with Homebridge Accessory Details ( hapEndpoint, deviceType, description )
@@ -0,0 +1,34 @@
1
+ /** @type {import('eslint').FlatConfig[]} */
2
+ import pluginJs from "@eslint/js";
3
+ import pluginJest from "eslint-plugin-jest";
4
+ import globals from "globals";
5
+
6
+
7
+ export default [
8
+ {
9
+ files: ["**/*.js"],
10
+ languageOptions: {
11
+ sourceType: "commonjs", // This is necessary to parse imports/exports
12
+ globals: {
13
+ ...globals.browser,
14
+ ...globals.es2021,
15
+ ...globals.jest, // Add Jest globals
16
+ },
17
+ },
18
+ // Add any other specific rules here
19
+ },
20
+ pluginJs.configs.recommended,
21
+ {
22
+ plugins: {
23
+ jest: pluginJest,
24
+ },
25
+ rules: {
26
+ ...pluginJest.configs.recommended.rules,
27
+ "no-unused-vars": "warn", // Change no-unused-vars to a warning
28
+ },
29
+ },
30
+ {
31
+ // Exclude test, tools, and lib directories from linting
32
+ ignores: ["test/**/*", "tools/*js", "src/lib/*"], // Exclude these files from linting
33
+ }
34
+ ];
package/package.json CHANGED
@@ -1,16 +1,15 @@
1
1
  {
2
2
  "name": "node-red-contrib-homebridge-automation",
3
- "version": "0.1.12-beta.8",
3
+ "version": "0.2.0",
4
4
  "description": "NodeRED Automation for HomeBridge",
5
5
  "main": "src/HAP-NodeRed.js",
6
6
  "scripts": {
7
- "api": "documentation build HAP-NodeRed.js -f md --config docs/documentation.yml > docs/API.md",
8
- "document": "./gh-md-toc --insert README.md; rm README.md.orig.* README.md.toc.*",
7
+ "document": "./gh-md-toc --insert --no-backup --hide-footer README.md",
9
8
  "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\""
9
+ "lint": "eslint --max-warnings=10 .",
10
+ "lint:fix": "eslint --fix --max-warnings=0 .",
11
+ "test": "jest --detectOpenHandles",
12
+ "test-coverage": "jest --coverage"
14
13
  },
15
14
  "keywords": [
16
15
  "node-red",
@@ -26,28 +25,24 @@
26
25
  "url": "git+https://github.com/NorthernMan54/node-red-contrib-homebridge-automation.git"
27
26
  },
28
27
  "devDependencies": {
29
- "@types/node-red": "^0.20.7",
30
- "@types/jest": "^29.5.12",
31
- "documentation": "14.0.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",
38
- "mocha": "^10.6.0",
28
+ "@types/node-red": "^1.3.5",
29
+ "@types/jest": "^29.5.14",
30
+ "@eslint/js": "^9.16.0",
31
+ "eslint": "^8.57.1",
32
+ "eslint-plugin-format": "^0.1.2",
33
+ "eslint-plugin-jest": "^28.8.3",
34
+ "globals": "^15.13.0",
35
+ "jest": "^29.7.0",
39
36
  "node-red": "^4.0.2",
40
37
  "node-red-node-test-helper": "^0.3.4",
41
- "nodemon": "^3.1.4",
42
- "nyc": "^17.0.0",
43
- "prettier": "^3.3.2",
44
- "rimraf": "^5.0.7",
45
- "semver": "^7.6.2"
38
+ "nodemon": "^3.1.7",
39
+ "rimraf": "^6.0.1",
40
+ "semver": "^7.6.3"
46
41
  },
47
42
  "dependencies": {
48
43
  "better-queue": ">=3.8.12",
49
- "debug": "^4.3.5",
50
- "hap-node-client": ">=0.2.7"
44
+ "debug": "^4.3.7",
45
+ "@homebridge/hap-client": "^2.0.5"
51
46
  },
52
47
  "author": "NorthernMan54",
53
48
  "license": "ISC",
@@ -61,10 +56,24 @@
61
56
  ],
62
57
  "ext": "js,html",
63
58
  "ignore": [],
64
- "exec": "DEBUG=hapNodeRed ~/npm/bin/node-red",
59
+ "exec": "DEBUG=hapNodeRed* ~/npm/bin/node-red -v -u test/node-red",
65
60
  "signal": "SIGTERM",
66
61
  "env": {
67
62
  "NODE_OPTIONS": "--trace-warnings"
68
63
  }
64
+ },
65
+ "jest": {
66
+ "testEnvironment": "node",
67
+ "modulePathIgnorePatterns": [],
68
+ "coverageReporters": [
69
+ "lcov"
70
+ ],
71
+ "collectCoverageFrom": [
72
+ "src/**",
73
+ "!src/accessories/**",
74
+ "!src/lib/definitions/generate-definitions.ts",
75
+ "!src/lib/definitions/generator-configuration.ts",
76
+ "!src/test-utils"
77
+ ]
69
78
  }
70
- }
79
+ }
@@ -52,14 +52,14 @@
52
52
  // var pass = $('#node-config-input-password').val();
53
53
  // console.log("pass: ", pass);
54
54
  // if (pass != '_PWD_') {
55
- // var account = {
55
+ // var configNode = {
56
56
  // id: node.id,
57
57
  // user: user,
58
58
  // pass: pass
59
59
  // }
60
60
  // $.ajax({
61
- // data: JSON.stringify(account),
62
- // url: 'alexa-home/new-account',
61
+ // data: JSON.stringify(configNode),
62
+ // url: 'alexa-home/new-configNode',
63
63
  // contentType: 'application/json',
64
64
  // type: 'POST',
65
65
  // processData: false
@@ -167,14 +167,14 @@
167
167
  oneditprepare: function() {
168
168
  var node = this;
169
169
  // console.log("foo " + node.device);
170
- if (typeof node.acknoledge === 'undefined') {
171
- $('#node-input-acknoledge').prop('checked', true);
170
+ if (typeof node.acknowledge === 'undefined') {
171
+ $('#node-input-acknowledge').prop('checked', true);
172
172
  }
173
173
  $('#node-input-device').change(function() {
174
174
  $('#node-input-name').val($('#node-input-device option:selected').text());
175
175
  });
176
- var getDevs = function(account) {
177
- $.getJSON('hap-device/evDevices/' + account, function(data) {
176
+ var getDevs = function(configNode) {
177
+ $.getJSON('hap-device/evDevices/' + configNode, function(data) {
178
178
  $('#node-input-device').find('option').remove().end();
179
179
  for (d in data) {
180
180
  $('<option/>', {
@@ -190,38 +190,38 @@
190
190
  $('#node-input-device').val(node.device);
191
191
  }
192
192
  }).fail(function(jqXHR, textStatus, errorThrown) {
193
- console.log("problem getting evDevices");
193
+ console.log("[hb-config] problem getting evDevices");
194
194
  console.log(textStatus);
195
195
  });
196
196
 
197
197
  }
198
198
  if (node.conf) {
199
- var account = $('#node-input-conf').val();
200
- // console.log("account: ", account);
201
- if (account != '_ADD_') {
202
- getDevs(account);
199
+ var configNode = $('#node-input-conf').val();
200
+ // console.log("configNode: ", configNode);
201
+ if (configNode != '_ADD_') {
202
+ getDevs(configNode);
203
203
  }
204
204
  }
205
205
  $('#node-input-conf').change(function() {
206
- var account = $('#node-input-conf').val();
207
- // console.log("account changed: ", account);
208
- if (account != '_ADD_') {
209
- getDevs(account);
206
+ var configNode = $('#node-input-conf').val();
207
+ // console.log("configNode changed: ", configNode);
208
+ if (configNode != '_ADD_') {
209
+ getDevs(configNode);
210
210
  } else {
211
- // console.log("new account");
211
+ // console.log("new configNode");
212
212
  $('#node-input-device').find('option').remove().end();
213
213
  $('#node-input-device').val("");
214
214
  }
215
215
  });
216
216
  $('#node-input-device-refresh').click(function() {
217
217
  $('#node-input-device-refresh').addClass('disabled');
218
- var account = $('#node-input-conf').val();
218
+ var configNode = $('#node-input-conf').val();
219
219
  $.ajax({
220
- url: 'hap-device/refresh/' + account,
220
+ url: 'hap-device/refresh/' + configNode,
221
221
  type: 'POST'
222
222
  }).done(function(data) {
223
223
  setTimeout(function() {
224
- getDevs(account);
224
+ getDevs(configNode);
225
225
  $('#node-input-device-refresh').removeClass('disabled');
226
226
  }, 3000);
227
227
  });
@@ -317,15 +317,15 @@
317
317
  oneditprepare: function() {
318
318
  var node = this;
319
319
  // console.log("foo " + node.device);
320
- if (typeof node.acknoledge === 'undefined') {
320
+ if (typeof node.acknowledge === 'undefined') {
321
321
  // console.log("ben");
322
- $('#node-input-acknoledge').prop('checked', true);
322
+ $('#node-input-acknowledge').prop('checked', true);
323
323
  }
324
324
  $('#node-input-device').change(function() {
325
325
  $('#node-input-name').val($('#node-input-device option:selected').text());
326
326
  });
327
- var getDevs = function(account) {
328
- $.getJSON('hap-device/evDevices/' + account, function(data) {
327
+ var getDevs = function(configNode) {
328
+ $.getJSON('hap-device/evDevices/' + configNode, function(data) {
329
329
  $('#node-input-device').find('option').remove().end();
330
330
  for (d in data) {
331
331
  $('<option/>', {
@@ -342,38 +342,38 @@
342
342
  $('#node-input-device').val(node.device);
343
343
  }
344
344
  }).fail(function(jqXHR, textStatus, errorThrown) {
345
- console.log("problem getting evDevices");
345
+ console.log("[hb-config] problem getting evDevices");
346
346
  console.log(textStatus);
347
347
  });
348
348
 
349
349
  }
350
350
  if (node.conf) {
351
- var account = $('#node-input-conf').val();
352
- // console.log("account: ", account);
353
- if (account != '_ADD_') {
354
- getDevs(account);
351
+ var configNode = $('#node-input-conf').val();
352
+ // console.log("configNode: ", configNode);
353
+ if (configNode != '_ADD_') {
354
+ getDevs(configNode);
355
355
  }
356
356
  }
357
357
  $('#node-input-conf').change(function() {
358
- var account = $('#node-input-conf').val();
359
- // console.log("account changed: ", account);
360
- if (account != '_ADD_') {
361
- getDevs(account);
358
+ var configNode = $('#node-input-conf').val();
359
+ // console.log("configNode changed: ", configNode);
360
+ if (configNode != '_ADD_') {
361
+ getDevs(configNode);
362
362
  } else {
363
- // console.log("new account");
363
+ // console.log("new configNode");
364
364
  $('#node-input-device').find('option').remove().end();
365
365
  $('#node-input-device').val("");
366
366
  }
367
367
  });
368
368
  $('#node-input-device-refresh').click(function() {
369
369
  $('#node-input-device-refresh').addClass('disabled');
370
- var account = $('#node-input-conf').val();
370
+ var configNode = $('#node-input-conf').val();
371
371
  $.ajax({
372
- url: 'hap-device/refresh/' + account,
372
+ url: 'hap-device/refresh/' + configNode,
373
373
  type: 'POST'
374
374
  }).done(function(data) {
375
375
  setTimeout(function() {
376
- getDevs(account);
376
+ getDevs(configNode);
377
377
  $('#node-input-device-refresh').removeClass('disabled');
378
378
  }, 3000);
379
379
  });
@@ -467,15 +467,15 @@
467
467
  oneditprepare: function() {
468
468
  var node = this;
469
469
  // console.log("foo " + node.device);
470
- if (typeof node.acknoledge === 'undefined') {
470
+ if (typeof node.acknowledge === 'undefined') {
471
471
  // console.log("ben");
472
- $('#node-input-acknoledge').prop('checked', true);
472
+ $('#node-input-acknowledge').prop('checked', true);
473
473
  }
474
474
  $('#node-input-device').change(function() {
475
475
  $('#node-input-name').val($('#node-input-device option:selected').text());
476
476
  });
477
- var getDevs = function(account) {
478
- $.getJSON('hap-device/evDevices/' + account, function(data) {
477
+ var getDevs = function(configNode) {
478
+ $.getJSON('hap-device/evDevices/' + configNode, function(data) {
479
479
  $('#node-input-device').find('option').remove().end();
480
480
  for (d in data) {
481
481
  $('<option/>', {
@@ -492,38 +492,38 @@
492
492
  $('#node-input-device').val(node.device);
493
493
  }
494
494
  }).fail(function(jqXHR, textStatus, errorThrown) {
495
- console.log("problem getting ctDevices");
495
+ console.log("[hb-config] problem getting ctDevices");
496
496
  console.log(textStatus);
497
497
  });
498
498
 
499
499
  }
500
500
  if (node.conf) {
501
- var account = $('#node-input-conf').val();
502
- // console.log("account: ", account);
503
- if (account != '_ADD_') {
504
- getDevs(account);
501
+ var configNode = $('#node-input-conf').val();
502
+ // console.log("configNode: ", configNode);
503
+ if (configNode != '_ADD_') {
504
+ getDevs(configNode);
505
505
  }
506
506
  }
507
507
  $('#node-input-conf').change(function() {
508
- var account = $('#node-input-conf').val();
509
- // console.log("account changed: ", account);
510
- if (account != '_ADD_') {
511
- getDevs(account);
508
+ var configNode = $('#node-input-conf').val();
509
+ // console.log("configNode changed: ", configNode);
510
+ if (configNode != '_ADD_') {
511
+ getDevs(configNode);
512
512
  } else {
513
- // console.log("new account");
513
+ // console.log("new configNode");
514
514
  $('#node-input-device').find('option').remove().end();
515
515
  $('#node-input-device').val("");
516
516
  }
517
517
  });
518
518
  $('#node-input-device-refresh').click(function() {
519
519
  $('#node-input-device-refresh').addClass('disabled');
520
- var account = $('#node-input-conf').val();
520
+ var configNode = $('#node-input-conf').val();
521
521
  $.ajax({
522
- url: 'hap-device/refresh/' + account,
522
+ url: 'hap-device/refresh/' + configNode,
523
523
  type: 'POST'
524
524
  }).done(function(data) {
525
525
  setTimeout(function() {
526
- getDevs(account);
526
+ getDevs(configNode);
527
527
  $('#node-input-device-refresh').removeClass('disabled');
528
528
  }, 3000);
529
529
  });
@@ -620,15 +620,15 @@
620
620
  oneditprepare: function() {
621
621
  var node = this;
622
622
  // console.log("foo " + node.device);
623
- if (typeof node.acknoledge === 'undefined') {
623
+ if (typeof node.acknowledge === 'undefined') {
624
624
  // console.log("ben");
625
- $('#node-input-acknoledge').prop('checked', true);
625
+ $('#node-input-acknowledge').prop('checked', true);
626
626
  }
627
627
  $('#node-input-device').change(function() {
628
628
  $('#node-input-name').val($('#node-input-device option:selected').text());
629
629
  });
630
- var getDevs = function(account) {
631
- $.getJSON('hap-device/ctDevices/' + account, function(data) {
630
+ var getDevs = function(configNode) {
631
+ $.getJSON('hap-device/ctDevices/' + configNode, function(data) {
632
632
  $('#node-input-device').find('option').remove().end();
633
633
  for (d in data) {
634
634
  $('<option/>', {
@@ -645,38 +645,38 @@
645
645
  $('#node-input-device').val(node.device);
646
646
  }
647
647
  }).fail(function(jqXHR, textStatus, errorThrown) {
648
- console.log("problem getting ctDevices");
648
+ console.log("[hb-config] problem getting ctDevices");
649
649
  console.log(textStatus);
650
650
  });
651
651
 
652
652
  }
653
653
  if (node.conf) {
654
- var account = $('#node-input-conf').val();
655
- // console.log("account: ", account);
656
- if (account != '_ADD_') {
657
- getDevs(account);
654
+ var configNode = $('#node-input-conf').val();
655
+ // console.log("configNode: ", configNode);
656
+ if (configNode != '_ADD_') {
657
+ getDevs(configNode);
658
658
  }
659
659
  }
660
660
  $('#node-input-conf').change(function() {
661
- var account = $('#node-input-conf').val();
662
- // console.log("account changed: ", account);
663
- if (account != '_ADD_') {
664
- getDevs(account);
661
+ var configNode = $('#node-input-conf').val();
662
+ // console.log("configNode changed: ", configNode);
663
+ if (configNode != '_ADD_') {
664
+ getDevs(configNode);
665
665
  } else {
666
- // console.log("new account");
666
+ // console.log("new configNode");
667
667
  $('#node-input-device').find('option').remove().end();
668
668
  $('#node-input-device').val("");
669
669
  }
670
670
  });
671
671
  $('#node-input-device-refresh').click(function() {
672
672
  $('#node-input-device-refresh').addClass('disabled');
673
- var account = $('#node-input-conf').val();
673
+ var configNode = $('#node-input-conf').val();
674
674
  $.ajax({
675
- url: 'hap-device/refresh/' + account,
675
+ url: 'hap-device/refresh/' + configNode,
676
676
  type: 'POST'
677
677
  }).done(function(data) {
678
678
  setTimeout(function() {
679
- getDevs(account);
679
+ getDevs(configNode);
680
680
  $('#node-input-device-refresh').removeClass('disabled');
681
681
  }, 3000);
682
682
  });