homebridge-cmd4 6.0.0 → 6.0.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/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # Homebridges-cmd4 - CMD4 Plugin for Homebridge - Supports ~All Accessory Types and now all Characteristics too!!
2
+ #### 6.0.1 (2021-11-07)
3
+
4
+ ##### Bug Fixes
5
+
6
+ * For bug[#116](https://github.com/ztalbot2000/homebridge-cmd4/pull/116) remove stateCmd validation and for AirCon add global const parsing ([e7bc4963](https://github.com/ztalbot2000/homebridge-cmd4/commit/e7bc49630c47d16d296ff9751df7c7666cf2ecd3))
7
+
8
+
1
9
  # Homebridges-cmd4 - CMD4 Plugin for Homebridge - Supports ~All Accessory Types and now all Characteristics too!!
2
10
  ## 6.0.0 (2021-10-01)
3
11
 
package/Cmd4Accessory.js CHANGED
@@ -1,8 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  const moment = require( "moment" );
4
- const fs = require( "fs" );
5
- const commandExistsSync = require( "command-exists" ).sync;
6
4
 
7
5
  // Settings, Globals and Constants
8
6
  let settings = require( "./cmd4Settings" );
@@ -1237,68 +1235,7 @@ class Cmd4Accessory
1237
1235
  if ( typeof state_cmd != "string" )
1238
1236
  throw new Error( `No state_cmd for: "${ this.displayName }".` );
1239
1237
 
1240
-
1241
- // Split the state_cmd into words.
1242
- let cmdArray = state_cmd.match(/\S+/gi);
1243
-
1244
- // Assume no words
1245
- let arrayLength = 0;
1246
-
1247
- // Get the number of words
1248
- if ( cmdArray )
1249
- arrayLength = cmdArray.length;
1250
-
1251
- // Check that the state_cmd is valid.
1252
- // The first word must be in the persons path
1253
- // The second word, if it exists must be a file
1254
- // and have the correct path.
1255
- switch ( arrayLength )
1256
- {
1257
- case 0:
1258
- this.log.error( `No state_cmd given` );
1259
- return false;
1260
- default:
1261
- {
1262
- let checkFile = cmdArray[ arrayLength -1 ];
1263
-
1264
- try {
1265
- fs.accessSync( checkFile, fs.F_OK );
1266
- // File exists - OK
1267
-
1268
- } catch ( e ) {
1269
- // It isn't accessible
1270
- throw new Error( `The file: "${ checkFile }" does not exist, It is highly likely the state_cmd will fail. Hint: Do not use wildcards that would normally be expanded by a shell.` );
1271
- }
1272
- }
1273
- // Purposely fall through to check the command as well
1274
- // break omitted
1275
- case 1:
1276
- {
1277
- let checkCmd = cmdArray[ 0 ];
1278
-
1279
- // if the lone command is a path to a command
1280
- // Then check if it exists, oTherwise check if it is
1281
- // in Their path.
1282
- if ( checkCmd.charAt( 0 ) == "/" || (
1283
- checkCmd.length > 1 &&
1284
- checkCmd.charAt( 0 ) == "." &&
1285
- checkCmd.charAt( 1 ) == "/" )
1286
- )
1287
- {
1288
- try {
1289
- fs.accessSync( checkCmd, fs.F_OK );
1290
- // File exists - OK
1291
- } catch ( e ) {
1292
- throw new Error( `The file: "${ checkCmd }" does not exist, It is highly likely the state_cmd will fail. Hint: Do not use wildcards that would normally be expanded by a shell.` );
1293
- }
1294
- } else
1295
- {
1296
- if ( ! commandExistsSync( checkCmd ) )
1297
- throw new Error( `The file: "${ checkCmd }" does not exist, It is highly likely the state_cmd will fail. Hint: Do not use wildcards that would normally be expanded by a shell.` );
1298
- }
1299
- break;
1300
- }
1301
- }
1238
+ // This was messy, did not like spaces. let the user be the judge of it.
1302
1239
  return true;
1303
1240
  }
1304
1241
 
@@ -1321,11 +1258,8 @@ class Cmd4Accessory
1321
1258
  let accTypeEnumIndex = rcDirective.accTypeEnumIndex;
1322
1259
 
1323
1260
  // Do not update the stored values as it is being restored from cache
1324
- this.log.debug( `Checking to see if value should be set ${ parseConfigShouldUseCharacteristicValues }` );
1325
1261
  if ( parseConfigShouldUseCharacteristicValues == false )
1326
1262
  return;
1327
- //this.log.debug( `Going to set its value` );
1328
-
1329
1263
 
1330
1264
  if ( Object.keys( CMD4_ACC_TYPE_ENUM.properties[ accTypeEnumIndex ].validValues ).length > 0 )
1331
1265
  {
@@ -1408,11 +1342,11 @@ class Cmd4Accessory
1408
1342
  valueToAdd.replace(/'$/, "")
1409
1343
 
1410
1344
  this.listOfConstants[ keyToAdd ] = valueToAdd;
1411
- }
1412
- return;
1345
+ }
1346
+ return;
1413
1347
  }
1414
1348
 
1415
- throw new Error( `Constants must be an array of/or list of key/value pairs: "${ constantArg }".` );
1349
+ throw new Error( `Constants must be an array of/or list of key/value pairs: "${ constantArg }".` );
1416
1350
  }
1417
1351
 
1418
1352
  processVariables( variables )
@@ -1656,6 +1590,7 @@ class Cmd4Accessory
1656
1590
  break;
1657
1591
  case constants.STATE_CMD_SUFFIX:
1658
1592
  // This gets added after any Get/Set <value>
1593
+ // We replace any constants already defined
1659
1594
  this.state_cmd_suffix = value;
1660
1595
 
1661
1596
  break;
@@ -1758,6 +1693,10 @@ class Cmd4Accessory
1758
1693
  this.log.info( chalk.blue( `Cmd4 is running in Demo Mode for ${ this.displayName }` ) );
1759
1694
  }
1760
1695
 
1696
+ // Add the global constants to the listOfConstants
1697
+ if ( this.parentInfo.globalConstants != null )
1698
+ this.processConstants( this.parentInfo.globalConstants );
1699
+
1761
1700
  // Handle seperation of strings of state_cmd for a prefix
1762
1701
  if ( this.state_cmd_prefix )
1763
1702
  this.state_cmd_prefix = this.state_cmd_prefix + " ";
@@ -1766,9 +1705,15 @@ class Cmd4Accessory
1766
1705
 
1767
1706
  // Handle seperation of strings of state_cmd for a suffix
1768
1707
  if ( this.state_cmd_suffix )
1769
- this.state_cmd_suffix = " " + this.state_cmd_suffix;
1770
- else
1708
+ {
1709
+ if ( typeof this.state_cmd_suffix != "string" )
1710
+ throw new Error( `state_cmd_suffix must be a string: "${ this.state_cmd_suffix }".` );
1711
+
1712
+ this.state_cmd_suffix = " " + this.replaceConstantsInString( this.state_cmd_suffix );
1713
+ } else
1714
+ {
1771
1715
  this.state_cmd_suffix = "";
1716
+ }
1772
1717
 
1773
1718
  if ( this.typeIndex == CMD4_DEVICE_TYPE_ENUM.Television )
1774
1719
  {
package/Cmd4Platform.js CHANGED
@@ -89,6 +89,7 @@ class Cmd4Platform
89
89
  this.toBeRestoredPlatforms = [ ];
90
90
  this.createdCmd4Accessories = [ ];
91
91
  this.createdCmd4Platforms = [ ];
92
+ this.globalconstants = null;
92
93
 
93
94
  this.services = [ ];
94
95
 
@@ -293,6 +294,12 @@ class Cmd4Platform
293
294
  this.definitions = value;
294
295
 
295
296
  break;
297
+ case constants.CONSTANTS:
298
+ // Save the constants defined globally so the accessory
299
+ // can parse it.
300
+ this.globalconstants = value;
301
+
302
+ break
296
303
  case constants.PLATFORM:
297
304
  // Noop
298
305
 
@@ -3,6 +3,7 @@
3
3
  ## Homebridge UI User. Do not click on any inline links. Homebridge UI does not supprt them. Bug#1098
4
4
 
5
5
  ## ChangeLog
6
+ * <a href="#Whats-new-in-6-0-1">**Whats new in 6.0.1**</a>
6
7
  * <a href="#Whats-new-in-6-0-0">**Whats new in 6.0.0**</a>
7
8
  * <a href="#Whats-new-in-6-0-0-beta1">**Whats new in 6.0.0.beta1**</a>
8
9
  * <a href="#Whats-new-in-5-1-1">**Whats new in 5.1.1**</a>
@@ -75,6 +76,14 @@
75
76
  * <a href="#Whats-new-in-2-1">**Whats new in 2.1**</a>
76
77
  * <a href="#Whats-new-in-2-0">**Whats new in 2.0**</a>
77
78
 
79
+ <a name="Whats-new-in-6-0-1">## Whats new in 6.0.1</a>
80
+ #### 6.0.1 (2021-11-07)
81
+
82
+ ##### Bug Fixes
83
+
84
+ * For bug[#116](https://github.com/ztalbot2000/homebridge-cmd4/pull/116) remove stateCmd validation and for AirCon add global const parsing ([e7bc4963](https://github.com/ztalbot2000/homebridge-cmd4/commit/e7bc49630c47d16d296ff9751df7c7666cf2ecd3))
85
+
86
+
78
87
  <a name="Whats-new-in-6-0-0">## Whats new in 6.0.0</a>
79
88
  ## 6.0.0 (2021-10-01)
80
89
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "homebridge-cmd4",
3
3
  "description": "Exec Plugin for Homebridge supporting all accessorys and characteristics",
4
- "version": "6.0.0",
4
+ "version": "6.0.1",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "John Talbot"
@@ -112,4 +112,4 @@
112
112
  "release:minor": "tools/generateChangeLog --type minor --cleanup",
113
113
  "release:major": "tools/generateChangeLog --type major --cleanup"
114
114
  }
115
- }
115
+ }
@@ -1,248 +0,0 @@
1
- <link rel="stylesheet" href="css/style.css">
2
-
3
- <div id="main" class="card card-body pb-5">
4
-
5
- <!-- start -->
6
- <div id="start">
7
- <img src="images/Cmd4_icon.svg" alt="Scripting with Cmd4 for Homebridge" width="150px" class="center-it cmd4Logo">
8
- <h3 class="text-center">Welcome to <br> <b style="font-weight: 800;">Cmd4 Platform</b></h3>
9
- <h6 class="text-center">Cmd4 Homebridge plugin for Scripting</h6>
10
- <button id="startButton" type="submit" class="btn btn-primary center-it mt-3">Start</button>
11
- </div>
12
-
13
- <!-- newAccessory -->
14
- <div id="newAccessory" style="display:none;">
15
- <button type="submit" class="btn btn-elegant backButton" style="position: absolute;">
16
- <i class="fa fa-arrow-left" aria-hidden="true"></i>
17
- </button>
18
- <button type="submit" class="btn btn-primary float-right showConfigureGlobalsPageButton">
19
- <i class="fa fa-globe fa-border" aria-hidden="true"></i>
20
- </button>
21
- <img src="images/Cmd4_icon.svg" alt="Scripting with Cmd4 for Homebridge" width="150px" class="center-it mt-4 cmd4Logo">
22
- <h6 class="text-center">To start the process, we need some data for the accessory. <br> Please fill out all marked fields.</h6>
23
- <div class="container mt-5">
24
- <div class="form-group">
25
- <label for="accessoryType">Type <span class="text-danger">*</span> </label>
26
- <select name="accessoryTypeSelect" class="form-control" id="accessoryTypeSelect">
27
- </select>
28
- </div>
29
- <div class="form-group">
30
- <label for="accessoryName">Name <span class="text-danger">*</span> </label>
31
- <input type="text" class="form-control" id="accessoryName">
32
- </div>
33
- <div class="form-group">
34
- <label for="polling">Polling <span class="text-danger">*</span> </label>
35
- <input type="checkbox" class="form-control" id="polling">
36
- </div>
37
- <div class="form-group">
38
- <label for="accessoryCharacteristics">Accessory Characteristics<span class="text-danger">*</span> </label>
39
- <input type="text" class="form-control" id="accessoryCharacteristics">
40
- </div>
41
- <button id="auth" type="submit" class="btn btn-primary float-right mt-3 mr-0">Next</button>
42
- </div>
43
- </div>
44
-
45
- <!-- selectExistingAccessory -->
46
- <div id="selectExistingAccessory" style="display:none;">
47
- <button type="submit" class="btn btn-elegant backButton" style="position: absolute;">
48
- <i class="fa fa-arrow-left" aria-hidden="true"></i>
49
- </button>
50
- <button type="submit" class="btn btn-primary float-right showConfigureGlobalsPageButton">
51
- <i class="fa fa-globe fa-border" aria-hidden="true"></i>
52
- </button>
53
- <img src="images/HB_Cmd4.png" alt="Scripting with Cmd4 for Homebridge" width="150px" class="center-it cmd4Logo">
54
- <h3 class="text-center"><span style="font-size: 20px">Welcome to</span> <br> <b style="font-weight: 800;">Cmd4 Platform</b></h3>
55
- <h6 class="text-center">Cmd4 Homebridge plugin for Scripting</h6>
56
- <div class="container mt-4" style="max-width: 360px;">
57
- <div class="form-row">
58
- <div class="col-10">
59
- <select class="custom-select" id="accessorySelect"></select>
60
- </div>
61
- <div class="col-2">
62
- <button id="editAccessory" type="submit" class="btn btn-elegant m-0">
63
- <i class="fas fa-edit"></i>
64
- </button>
65
- </div>
66
- </div>
67
- <div class="d-flex justify-content-center mt-4">
68
- <a href="#" id="addAccessory" class="d-flex justify-content-center align-items-center btn-primary addBtn">
69
- <i class="fas fa-plus"></i>
70
- </a>
71
- </div>
72
- </div>
73
- </div>
74
-
75
- <!-- accessoryGlobals -->
76
- <div id="accessoryGlobals" style="display:none;">
77
- <button type="submit" class="btn btn-elegant backButton" style="position: absolute;">
78
- <i class="fa fa-arrow-left" aria-hidden="true"></i>
79
- </button>
80
- <img src="images/Cmd4_icon.svg" alt="Cmd4 Icon" width="150px" class="center-it mt-4 cmd4Logo">
81
- <h6 class="text-center">Accessory Globals<br> The defaults are pre-defined. Press back to continue.</h6>
82
- <div class="container mt-5">
83
- </div>
84
- </div>
85
-
86
- <!-- queueGlobalsPage -->
87
- <div id="queueGlobalsPage" style="display:none;">
88
- <button type="submit" class="btn btn-elegant backButton" style="position: absolute;">
89
- <i class="fa fa-arrow-left" aria-hidden="true"></i>
90
- </button>
91
- <img src="images/Cmd4_icon.svg" alt="Queue Globals Page" width="150px" class="center-it mt-4 cmd4Logo">
92
- <h6 class="text-center">Queue Globals<br> Polling queues are done by default via interval. Queues allow finer controls like Worm or Sequential.</h6>
93
- <div class="container mt-4" style="max-width: 360px;">
94
- <div class="form-row">
95
- <h4 id="notusedyet" Queueclass="text-left">There are no defined global queues.</h4>
96
- </div>
97
- </div>
98
- <a href="#" id="showQueueGlobalsPageButton" class="d-flex justify-content-center align-items-center btn-primary showQueueGlobalsPageButton">
99
- <i class="fas fa-plus"></i>
100
- </a>
101
- </div>
102
-
103
- <!-- requiredCharacteristics -->
104
- <div id="requiredCharacteristics" style="display:none;">
105
- <button type="submit" class="btn btn-elegant backButton" style="position: absolute;">
106
- <i class="fa fa-arrow-left" aria-hidden="true"></i>
107
- </button>
108
- <button type="submit" class="btn btn-primary float-right showConfigureGlobalsPageButton">
109
- <i class="fa fa-globe fa-border" aria-hidden="true"></i>
110
- </button>
111
- <img src="images/Cmd4_icon.svg" alt="Cmd4 Globals" width="150px" class="center-it mt-4 cmd4Logo">
112
- <h6 class="text-center">Required Characteristics<br> The defaults are pre-defined. Press back to continue.</h6>
113
- <div class="container mt-5">
114
- </div>
115
- </div>
116
-
117
- <!-- optionalCharacteristics -->
118
- <div id="optionalCharacteristics" style="display:none;">
119
- <button type="submit" class="btn btn-elegant backButton" style="position: absolute;">
120
- <i class="fa fa-arrow-left" aria-hidden="true"></i>
121
- </button>
122
- <button type="submit" class="btn btn-primary float-right showConfigureGlobalsPageButton">
123
- <i class="fa fa-globe fa-border" aria-hidden="true"></i>
124
- </button>
125
- <img src="images/Cmd4_icon.svg" alt="Cmd4 Globals" width="150px" class="center-it mt-4 cmd4Logo">
126
- <h6 class="text-center">Optional Characteristics<br> The defaults are pre-defined. Press back to continue.</h6>
127
- <div class="container mt-5">
128
- </div>
129
- </div>
130
-
131
- <!-- stateCmd -->
132
- <div id="stateCmd" style="display:none;">
133
- <button type="submit" class="btn btn-elegant backButton" style="position: absolute;">
134
- <i class="fa fa-arrow-left" aria-hidden="true"></i>
135
- </button>
136
- <img src="images/Cmd4_icon.svg" alt="Cmd4 Icon" width="150px" class="center-it mt-4 cmd4Logo">
137
- <h6 class="text-center">Optional Characteristics<br> The defaults are pre-defined. Press back to continue.</h6>
138
- <div class="container mt-5">
139
- </div>
140
- </div>
141
-
142
-
143
-
144
- <!-- configureGlobals -->
145
- <div id="configureGlobals" style="display:none;">
146
- <button type="submit" class="btn btn-elegant backButton" style="position: absolute;">
147
- <i class="fa fa-arrow-left" aria-hidden="true"></i>
148
- </button>
149
- <img src="images/Cmd4_icon.svg" alt="Cmd4 Globals" width="150px" class="center-it mt-4 cmd4Logo">
150
- <h6 class="text-center">Global Definitions<br> The defaults are pre-defined. Press back to continue.</h6>
151
- <div class="container mt-5">
152
- <div class="form-group">
153
- <label for="debug">Debug <span class="text-danger">*</span> </label>
154
- <input type="checkbox" class="form-control" id="debug">
155
- </div>
156
- <div class="form-group">
157
- <label for="outputConstants">Output Constants<span class="text-danger">*</span>
158
- </label>
159
- <input type="checkbox" class="form-control" id="outputConstants">
160
- </div>
161
- <div class="form-group">
162
- <label for="allowTLV8">Allow TLV8 Characteristics<span class="text-danger">*</span>
163
- </label>
164
- <input type="checkbox" class="form-control" id="allowTLV8">
165
- </div>
166
- <div class="form-group">
167
- <label for="statusMsg">Show Status Messages in Logs<span class="text-danger">*</span>
168
- </label>
169
- <input type="checkbox" class="form-control" id="statusMsg" checked>
170
- </div>
171
- <div class="form-group">
172
- <label for="timeout">Default polling timeout (sec)<span class="text-danger">*</span>
173
- </label>
174
- <input type="number" class="form-control" id="timeout" name="timeout" min="5" max="20" value="3">
175
- </div>
176
- <div class="form-group">
177
- <label for="stateChangeResponseTime">Default State Change Response Time (sec)<span class="text-danger">*</span>
178
- </label>
179
- <input type="number" class="form-control" id="globalStateChangeResponseTime" name="globalStateChangeResponseTime" min="0" max="20" value="3">
180
- </div>
181
- <div class="form-group">
182
- <label for="stateCmdPrefix">Default State Command Prefix to use<span class="text-danger">*</span>
183
- </label>
184
- <input type="string" class="form-control" id="globalStateCmdPrefix" name="globalStateCmdPrefix" value="">
185
- </div>
186
- <div class="form-group">
187
- <label for="stateCmd">Default State Command to use<span class="text-danger">*</span>
188
- </label>
189
- <input type="string" class="form-control" id="globalStateCmd" name="globalStateCmd" value="">
190
- </div>
191
- <div class="form-group">
192
- <label for="stateCmdSuffix">Default State Command Suffix to use<span class="text-danger">*</span>
193
- </label>
194
- <input type="string" class="form-control" id="globalStateCmdPrefix" name="globalStateCmdSuffix" value="">
195
- </div>
196
-
197
- <label>Pre-Defined Global Queues</label>
198
-
199
- <div id="globalQueueMessage">
200
- <label>There are no defined global queues.</label>
201
- <h3 class="text-center">There are no defined global queues.</h3>
202
- </div>
203
- <div id="globalQueueContainer" class="container">
204
- <div id="globalQueuesForm">
205
- <div class="row no-gutters">
206
- <div class="col">
207
- <div class="card card-body text-success" style="visibility:hidden;">
208
- <h5 class="card-title">Queue Name</h5>
209
- </div>
210
- </div>
211
- <div class="col">
212
- <div class="card card-body text-success">
213
- <h5 class="card-title">Queue Name</h5>
214
- </div>
215
- </div>
216
- <div class="col">
217
- <div class="card card-body text-success">
218
- <h5 class="card-title">Queue Type</h5>
219
- </div>
220
- </div>
221
- </div>
222
- </div>
223
-
224
- <div class="d-flex justify-content-center mt-4">
225
- <a href="#" id="configureNewQueuePageButton" class="d-flex justify-content-center align-items-center btn-primary configureNewQueuePageButton">
226
- <i class="fas fa-plus"></i>
227
- </a>
228
- </div>
229
- </div>
230
- <button id="configureGlobals" type="submit" class="btn btn-primary float-right mt-3 mr-0">Update</button>
231
- </div>
232
- </div>
233
-
234
- </div>
235
-
236
-
237
-
238
- </div>
239
-
240
- <!-- Modules -->
241
- <script type="text/javascript" src="js/modules/jquery.min.js"></script>
242
-
243
- <!-- Custom Schema -->
244
- <script type="text/javascript" src="js/schema.js?v=0.0.7"></script>
245
-
246
- <!-- Main -->
247
- <script type="text/javascript" src="js/main.js?v=0.0.7"></script>
248
-