node-red-contrib-homebridge-automation 0.3.0-beta.1 → 0.3.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/README.md CHANGED
@@ -9,59 +9,59 @@ 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
- - [Dec 31, 2022 - Version 0.1.3](#dec-31-2022---version-013)
34
- - [Jan 6, 2023 - Version 0.1.5](#jan-6-2023---version-015)
35
- - [Jan 11, 2023 - Version 0.1.7](#jan-11-2023---version-017)
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)
38
- - [April 15, 2025 - Version 0.3.0](#april-15-2025---version-030)
39
- - [Breaking Change](#breaking-change)
40
- - [Fixes](#fixes)
41
- - [Backlog / Roadmap](#backlog--roadmap)
42
- - [Dropped items](#dropped-items)
43
- - [Installation Steps](#installation-steps)
44
- - [1 - Install Node-RED and Homebridge](#1---install-node-red-and-homebridge)
45
- - [2 - Prepare Homebridge for integration with Homebridge-Automation](#2---prepare-homebridge-for-integration-with-homebridge-automation)
46
- - [3 - Install Homebridge-Automation into Node-Red](#3---install-homebridge-automation-into-node-red)
47
- - [4 - Start Node-Red](#4---start-node-red)
48
- - [5 - Initial setup and configuration inside Node-Red](#5---initial-setup-and-configuration-inside-node-red)
49
- - [6 - Configure 'hb event' to receive updates from your Accessories](#6---configure-hb-event-to-receive-updates-from-your-accessories)
50
- - [Node-RED Homebridge-Automation Message Structure](#node-red-homebridge-automation-message-structure)
51
- - [hb event](#hb-event)
52
- - [Output](#output)
53
- - [hb resume](#hb-resume)
54
- - [input](#input)
55
- - [output](#output-1)
56
- - [hb status](#hb-status)
57
- - [input](#input-1)
58
- - [output](#output-2)
59
- - [hb control](#hb-control)
60
- - [Input](#input-2)
61
- - [Flows Shared from Community](#flows-shared-from-community)
62
- - [Donations](#donations)
63
- - [Troubleshooting / DEBUG MODE](#troubleshooting--debug-mode)
64
- - [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](#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
+ * [Dec 31, 2022 - Version 0.1.3](#dec-31-2022---version-013)
34
+ * [Jan 6, 2023 - Version 0.1.5](#jan-6-2023---version-015)
35
+ * [Jan 11, 2023 - Version 0.1.7](#jan-11-2023---version-017)
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)
38
+ * [April 15, 2025 - Version 0.3.0](#april-15-2025---version-030)
39
+ * [Breaking Change](#breaking-change)
40
+ * [Fixes](#fixes)
41
+ * [Backlog / Roadmap](#backlog--roadmap)
42
+ * [Dropped items](#dropped-items)
43
+ * [Installation Steps](#installation-steps)
44
+ * [1 - Install Node-RED and Homebridge](#1---install-node-red-and-homebridge)
45
+ * [2 - Prepare Homebridge for integration with Homebridge-Automation](#2---prepare-homebridge-for-integration-with-homebridge-automation)
46
+ * [3 - Install Homebridge-Automation into Node-Red](#3---install-homebridge-automation-into-node-red)
47
+ * [4 - Start Node-Red](#4---start-node-red)
48
+ * [5 - Initial setup and configuration inside Node-Red](#5---initial-setup-and-configuration-inside-node-red)
49
+ * [6 - Configure 'hb event' to receive updates from your Accessories](#6---configure-hb-event-to-receive-updates-from-your-accessories)
50
+ * [Node-RED Homebridge-Automation Message Structure](#node-red-homebridge-automation-message-structure)
51
+ * [hb event](#hb-event)
52
+ * [Output](#output)
53
+ * [hb resume](#hb-resume)
54
+ * [input](#input)
55
+ * [output](#output-1)
56
+ * [hb status](#hb-status)
57
+ * [input](#input-1)
58
+ * [output](#output-2)
59
+ * [hb control](#hb-control)
60
+ * [Input](#input-2)
61
+ * [Flows Shared from Community](#flows-shared-from-community)
62
+ * [Donations](#donations)
63
+ * [Troubleshooting / DEBUG MODE](#troubleshooting--debug-mode)
64
+ * [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)
65
65
  <!--te-->
66
66
 
67
67
  # Introduction
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-homebridge-automation",
3
- "version": "0.3.0-beta.1",
3
+ "version": "0.3.0-beta.3",
4
4
  "description": "NodeRED Automation for HomeBridge",
5
5
  "main": "src/HAP-NodeRed.js",
6
6
  "scripts": {
@@ -60,7 +60,7 @@ class HBConfigNode {
60
60
  fs.writeFileSync(storagePath, JSON.stringify(updatedDevices, null, 2));
61
61
  } catch (e) {
62
62
  this.error(`Error writing Homebridge endpoints to file: ${e.message}`);
63
- }
63
+ }
64
64
  }
65
65
  // Fix broken uniqueId's from HAP-Client
66
66
  updatedDevices.forEach((service) => {
@@ -136,10 +136,12 @@ class HBConfigNode {
136
136
  async connectClientNodes() {
137
137
  debug('connect %s nodes', Object.keys(this.clientNodes).length);
138
138
  for (const [key, clientNode] of Object.entries(this.clientNodes)) {
139
- // debug('_Register: %s type: %s', clientNode.type, clientNode.name, clientNode.instance);
140
- const matchedDevice = this.hbDevices.find(service =>
141
- clientNode.device === `${service.instance.name}${service.instance.username}${service.accessoryInformation.Manufacturer}${service.serviceName}${service.uuid.slice(0, 8)}`
142
- );
139
+ // debug('_Register: %s type: "%s" "%s" "%s"', clientNode.type, clientNode.name, clientNode.instance, clientNode.device);
140
+ const matchedDevice = this.hbDevices.find(service => {
141
+ const friendlyName = (service.accessoryInformation.Name ? service.accessoryInformation.Name : service.serviceName);
142
+ const deviceIdentifier = `${service.instance.name}${service.instance.username}${service.accessoryInformation.Manufacturer}${friendlyName}${service.uuid.slice(0, 8)}`;
143
+ return clientNode.device === deviceIdentifier;
144
+ });
143
145
 
144
146
  if (matchedDevice) {
145
147
  clientNode.hbDevice = matchedDevice;
@@ -147,7 +149,7 @@ class HBConfigNode {
147
149
  clientNode.emit('hbReady', matchedDevice);
148
150
  debug('_Registered: %s type: %s', clientNode.type, matchedDevice.type, matchedDevice.serviceName);
149
151
  } else {
150
- this.error(`ERROR: Device registration failed '${clientNode.fullName}'`);
152
+ this.error(`ERROR: Device registration failed '${clientNode.fullName}' - '${clientNode.device}'`);
151
153
  }
152
154
  };
153
155
 
@@ -16,7 +16,7 @@ jest.mock('@homebridge/hap-client', () => {
16
16
  };
17
17
  });
18
18
 
19
- describe.skip('Issue 142', () => {
19
+ describe('Issue 142', () => {
20
20
  let mockConfig;
21
21
  let RED;
22
22
  let node;
@@ -90,7 +90,7 @@ describe('HBConfigNode', () => {
90
90
  });
91
91
  });
92
92
 
93
- describe.only('from files', () => {
93
+ describe('from files', () => {
94
94
  let mockConfig;
95
95
  let RED;
96
96
  let node;
@@ -114,10 +114,10 @@ describe.only('from files', () => {
114
114
  node.log = console.log;
115
115
  });
116
116
 
117
- test('Retrieve devices, and compare with current (v2)', async () => {
118
- console.log('Reading Homebridge endpoints from file', process.cwd());
117
+ test.skip('Retrieve devices, and compare with current (v2)', async () => {
118
+ // console.log('Reading Homebridge endpoints from file', process.cwd());
119
119
  var storagePath = path.join(process.cwd(), 'test/homebridge-automation-endpoints.json');
120
- console.log(`Reading Homebridge endpoints from ${storagePath}`);
120
+ // console.log(`Reading Homebridge endpoints from ${storagePath}`);
121
121
  const fileHbDevices = JSON.parse(fs.readFileSync(storagePath, 'utf8'));
122
122
 
123
123
  node.hapClient.getAllServices.mockResolvedValue(fileHbDevices);
@@ -126,7 +126,7 @@ describe.only('from files', () => {
126
126
  const result = node.toList({ perms: 'ev' });
127
127
 
128
128
  storagePath = path.join(process.cwd(), 'test/homebridge-automation-hbDevices-v2.json');
129
- console.log(`Reading Homebridge results from ${storagePath}`);
129
+ // console.log(`Reading Homebridge results from ${storagePath}`);
130
130
  const fileResult = JSON.parse(fs.readFileSync(storagePath, 'utf8'));
131
131
  expect(result.length).toBe(107);
132
132
  expect(result).toEqual(fileResult);
@@ -138,9 +138,9 @@ describe.only('from files', () => {
138
138
  });
139
139
 
140
140
  test('Retrieve devices, and compare with future (v3)', async () => {
141
- console.log('Reading Homebridge endpoints from file', process.cwd());
141
+ // console.log('Reading Homebridge endpoints from file', process.cwd());
142
142
  var storagePath = path.join(process.cwd(), 'test/homebridge-automation-endpoints.json');
143
- console.log(`Reading Homebridge endpoints from ${storagePath}`);
143
+ // console.log(`Reading Homebridge endpoints from ${storagePath}`);
144
144
  const fileHbDevices = JSON.parse(fs.readFileSync(storagePath, 'utf8'));
145
145
 
146
146
  node.hapClient.getAllServices.mockResolvedValue(fileHbDevices);
@@ -149,7 +149,7 @@ describe.only('from files', () => {
149
149
  const result = node.toList({ perms: 'ev' });
150
150
 
151
151
  storagePath = path.join(process.cwd(), 'test/homebridge-automation-hbDevices-v3.json');
152
- console.log(`Reading Homebridge results from ${storagePath}`);
152
+ // console.log(`Reading Homebridge results from ${storagePath}`);
153
153
  const fileResult = JSON.parse(fs.readFileSync(storagePath, 'utf8'));
154
154
  expect(result.length).toBe(107);
155
155
  expect(result).toEqual(fileResult);