node-red-contrib-zwave-js 7.0.0-alpha.21 → 7.0.0-alpha.22

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/CHANGELOG.md CHANGED
@@ -6,7 +6,10 @@
6
6
  - The **GET_VALUE_RESPONSE** object is no longer partitioned with **response** and **valueId** properties.
7
7
  Instead, the returned object now represents a shape simular to **VALUE_UPDATED** events.
8
8
  The value will now be attached to the **currentValue** property, along with the Value ID on the same level.
9
- - Much like above, **GET_VALUE_METADATA_RESPONSE** has also been simplified, where the result is attached to **metadata**, with the Value ID ID on the same level.
9
+ - Much like above, **GET_VALUE_METADATA_RESPONSE** has also been simplified, where the result is attached to **metadata**, with the Value ID on the same level.
10
+ - The module no longer attempts a restart on a fatal error (i.e the stick is pulled from the socket as an example)
11
+ This caused more problems than what they resolved, so the descision is made to not attempt recovery.
12
+ Restarting the node is just as good as a recovery attempt.
10
13
 
11
14
  **New Features**
12
15
  - **VALUE_UPDATED**, **VALUE_NOTIFICATION**, and **GET_VALUE_RESPONSE** now contain a **normalizedObject** property.
@@ -16,6 +19,7 @@
16
19
  - Network statistics now include route information that is obtained during communication, and is used
17
20
  as the basis of the new map.
18
21
  - Multiple ZWave sticks/Networks are now supported (finally)
22
+ - all message will contain a property of **networkId** to indentify the source network.
19
23
 
20
24
  **Fixes**
21
25
  - Nodes that are not marked as ready can now be removed correctly.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-zwave-js",
3
- "version": "7.0.0-alpha.21",
3
+ "version": "7.0.0-alpha.22",
4
4
  "license": "MIT",
5
5
  "description": "An extremely powerful, easy to use, and feature rich Z-Wave node for Node Red, based on Z-Wave JS.",
6
6
  "dependencies": {
@@ -6,7 +6,7 @@ module.exports = function (RED) {
6
6
  RED.nodes.createNode(this, config);
7
7
  const RedNode = this;
8
8
 
9
- const NetworkIdentifier = (config.networkIdentifier || 1);
9
+ const NetworkIdentifier = config.networkIdentifier || 1;
10
10
 
11
11
  function UpdateStatus(Color, Shape, Text) {
12
12
  if (config.showStatus === undefined || config.showStatus) {
@@ -75,14 +75,20 @@ module.exports = function (RED) {
75
75
  }
76
76
  VarNode = VarValue;
77
77
  if (Out) {
78
- NodeEventEmitter.on(`zwjs:${NetworkIdentifier}:node:event:${VarNode}`, processEventMessage);
78
+ NodeEventEmitter.on(
79
+ `zwjs:${NetworkIdentifier}:node:event:${VarNode}`,
80
+ processEventMessage
81
+ );
79
82
  }
80
83
  }
81
84
 
82
85
  if (Array.isArray(config.filteredNodeId)) {
83
86
  if (Out) {
84
87
  config.filteredNodeId.forEach((N) => {
85
- NodeEventEmitter.on(`zwjs:${NetworkIdentifier}:node:event:${N}`, processEventMessage);
88
+ NodeEventEmitter.on(
89
+ `zwjs:${NetworkIdentifier}:node:event:${N}`,
90
+ processEventMessage
91
+ );
86
92
  });
87
93
  }
88
94
  if (config.multicast) {
@@ -108,7 +114,10 @@ module.exports = function (RED) {
108
114
  } else if (config.filteredNodeId === 'All') {
109
115
  DeviceMode = 'All';
110
116
  if (Out) {
111
- NodeEventEmitter.on(`zwjs:${NetworkIdentifier}:node:event:all`, processEventMessage);
117
+ NodeEventEmitter.on(
118
+ `zwjs:${NetworkIdentifier}:node:event:all`,
119
+ processEventMessage
120
+ );
112
121
  }
113
122
  UpdateStatus('green', 'dot', 'Mode: All Nodes');
114
123
  } else if (config.filteredNodeId === 'AS') {
@@ -72,9 +72,6 @@ module.exports = function (RED) {
72
72
  let _DSKResolve = undefined;
73
73
  let _ClientSideAuth = undefined;
74
74
 
75
- const MaxDriverAttempts = 3;
76
- let DriverAttempts = 0;
77
- const RetryTime = 5000;
78
75
  let DriverOptions = {};
79
76
 
80
77
  // Log function
@@ -1469,6 +1466,7 @@ module.exports = function (RED) {
1469
1466
 
1470
1467
  function Send(Node, Subject, Value, send) {
1471
1468
  const PL = {};
1469
+ PL.networkId = NetworkIdentifier;
1472
1470
 
1473
1471
  let IsolatedNodeId;
1474
1472
 
@@ -1563,7 +1561,6 @@ module.exports = function (RED) {
1563
1561
  StartDriver();
1564
1562
 
1565
1563
  function InitDriver() {
1566
- DriverAttempts++;
1567
1564
  try {
1568
1565
  Log('info', 'NDERED', undefined, undefined, 'Initializing driver...');
1569
1566
  Driver = new ZWaveJS.Driver(config.serialPort, DriverOptions);
@@ -1588,43 +1585,15 @@ module.exports = function (RED) {
1588
1585
  }
1589
1586
 
1590
1587
  WireDriverEvents();
1591
- //UI.Unregister();
1592
1588
  UI.Register(Driver, Input);
1593
1589
  }
1594
1590
 
1595
1591
  function WireDriverEvents() {
1596
1592
  Driver.on('error', (e) => {
1597
1593
  if (e.code === ZWaveErrorCodes.Driver_Failed) {
1598
- if (DriverAttempts >= MaxDriverAttempts) {
1599
- Log('error', 'NDERED', undefined, '[ERROR] [DRIVER]', e.message);
1600
- RedNode.error(e);
1601
- } else {
1602
- Log('error', 'NDERED', undefined, '[ERROR] [DRIVER]', e.message);
1603
- Log(
1604
- 'debug',
1605
- 'NDERED',
1606
- undefined,
1607
- undefined,
1608
- 'Will retry in ' +
1609
- RetryTime +
1610
- 'ms. Attempted: ' +
1611
- DriverAttempts +
1612
- ', Max: ' +
1613
- MaxDriverAttempts
1614
- );
1615
- RedNode.error(
1616
- new Error(
1617
- 'Driver Failed: Will retry in ' +
1618
- RetryTime +
1619
- 'ms. Attempted: ' +
1620
- DriverAttempts +
1621
- ', Max: ' +
1622
- MaxDriverAttempts
1623
- )
1624
- );
1625
- InitDriver();
1626
- setTimeout(StartDriver, RetryTime);
1627
- }
1594
+ Log('error', 'NDERED', undefined, '[ERROR] [DRIVER]', e.message);
1595
+ UI.Unregister();
1596
+ RedNode.error(e);
1628
1597
  } else {
1629
1598
  Log('error', 'NDERED', undefined, '[ERROR] [DRIVER]', e.message);
1630
1599
  RedNode.error(e);
@@ -1644,8 +1613,6 @@ module.exports = function (RED) {
1644
1613
 
1645
1614
  // driver ready
1646
1615
  Driver.once(event_DriverReady.zwaveName, () => {
1647
- DriverAttempts = 0;
1648
-
1649
1616
  RedNode.status({
1650
1617
  fill: 'yellow',
1651
1618
  shape: 'dot',
@@ -1896,43 +1863,16 @@ module.exports = function (RED) {
1896
1863
  Driver.start()
1897
1864
  .catch((e) => {
1898
1865
  if (e.code === ZWaveErrorCodes.Driver_Failed) {
1899
- if (DriverAttempts >= MaxDriverAttempts) {
1900
- Log('error', 'NDERED', undefined, '[ERROR] [DRIVER]', e.message);
1901
- RedNode.error(e);
1902
- } else {
1903
- Log('error', 'NDERED', undefined, '[ERROR] [DRIVER]', e.message);
1904
- Log(
1905
- 'debug',
1906
- 'NDERED',
1907
- undefined,
1908
- undefined,
1909
- 'Will retry in ' +
1910
- RetryTime +
1911
- 'ms. Attempted: ' +
1912
- DriverAttempts +
1913
- ', Max: ' +
1914
- MaxDriverAttempts
1915
- );
1916
- RedNode.error(
1917
- new Error(
1918
- 'Driver failed: Will retry in ' +
1919
- RetryTime +
1920
- 'ms. Attempted: ' +
1921
- DriverAttempts +
1922
- ', Max: ' +
1923
- MaxDriverAttempts
1924
- )
1925
- );
1926
- InitDriver();
1927
- setTimeout(StartDriver, RetryTime);
1928
- }
1866
+ Log('error', 'NDERED', undefined, '[ERROR] [DRIVER]', e.message);
1867
+ UI.Unregister();
1868
+ RedNode.error(e);
1929
1869
  } else {
1930
1870
  Log('error', 'NDERED', undefined, '[ERROR] [DRIVER]', e.message);
1931
1871
  RedNode.error(e);
1932
1872
  }
1933
1873
  })
1934
1874
  .then(() => {
1935
- // now what - just sit and wait.
1875
+ // we are live!
1936
1876
  });
1937
1877
  }
1938
1878
  }