homebridge-cmd4 5.1.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/Cmd4Platform.js CHANGED
@@ -10,10 +10,13 @@ const { parseAddQueueTypes } = require( "./Cmd4PriorityPollingQueue" );
10
10
 
11
11
  let Logger = require( "./utils/Logger" );
12
12
  let getAccessoryUUID = require( "./utils/getAccessoryUUID" );
13
- let ucFirst = require( "./utils/ucFirst" );
13
+ let lcFirst = require( "./utils/lcFirst" );
14
14
  let isNumeric = require( "./utils/isNumeric" );
15
15
  let trueTypeOf = require( "./utils/trueTypeOf" );
16
16
 
17
+ // Hierarchy variables
18
+ let HV = require( "./utils/HV" );
19
+
17
20
  let createAccessorysInformationService = require( "./utils/createAccessorysInformationService" );
18
21
 
19
22
  // Pretty Colors
@@ -34,7 +37,6 @@ const Cmd4Accessory = require( "./Cmd4Accessory" ).Cmd4Accessory;
34
37
  // Settings, Globals and Constants
35
38
  let settings = require( "./cmd4Settings" );
36
39
  const constants = require( "./cmd4Constants" );
37
- let cmd4Dbg = settings.cmd4Dbg;
38
40
 
39
41
  // Platform definition
40
42
  class Cmd4Platform
@@ -48,7 +50,7 @@ class Cmd4Platform
48
50
  this.log = log;
49
51
 
50
52
  // Carry the debug flag from the platform
51
- cmd4Dbg = log.debugEnabled;
53
+ settings.cmd4Dbg = log.debugEnabled;
52
54
  }
53
55
  else
54
56
  {
@@ -56,17 +58,16 @@ class Cmd4Platform
56
58
  this.log = new Logger( );
57
59
 
58
60
  if ( config[ constants.DEBUG ] == true ||
59
- config[ constants.DEBUG_l ] == true ||
61
+ config[ "Debug" ] == true ||
60
62
  process.env.DEBUG == settings.PLATFORM_NAME )
61
63
  {
62
64
  settings.cmd4Dbg = true;
63
- cmd4Dbg = true;
64
65
  }
65
66
  }
66
67
 
67
- this.log.setDebugEnabled( cmd4Dbg );
68
+ this.log.setDebugEnabled( settings.cmd4Dbg );
68
69
 
69
- if ( cmd4Dbg ) this.log.debug( chalk.blue( `Class Cmd4Platform` ) );
70
+ if ( settings.cmd4Dbg ) this.log.debug( chalk.blue( `Class Cmd4Platform` ) );
70
71
 
71
72
  if ( config === undefined )
72
73
  return;
@@ -88,22 +89,26 @@ class Cmd4Platform
88
89
  this.toBeRestoredPlatforms = [ ];
89
90
  this.createdCmd4Accessories = [ ];
90
91
  this.createdCmd4Platforms = [ ];
92
+ this.globalconstants = null;
91
93
 
92
94
  this.services = [ ];
93
95
 
94
96
  // These would be queues of Characteristics to be polled or get/set via IOS.
95
97
  settings.listOfCreatedPriorityQueues = { };
96
98
 
97
-
98
- // Defaults before parse
99
- this.outputConstants = constants.DEFAULT_OUTPUTCONSTANTS;
100
- this.statusMsg = constants.DEFAULT_STATUSMSG;
101
-
102
99
  // Track the polling timers only so that unit testing can cancel them.
103
100
  this.pollingTimers = [ ];
104
101
 
102
+ // Create the hierarhy variables
103
+ this.hV = new HV();
104
+
105
105
  this.parseConfigForCmd4Directives( this.config );
106
106
 
107
+ // Update the namespace for stored variables
108
+ // like timeout, stateChangeResponseTime ... As it may require
109
+ // changes from parseConfig.
110
+ this.hV.update( this );
111
+
107
112
  this.processNewCharacteristicDefinitions( );
108
113
 
109
114
 
@@ -145,7 +150,7 @@ class Cmd4Platform
145
150
  {
146
151
  if ( platformAccessory )
147
152
  {
148
- if ( cmd4Dbg ) this.log.debug( `Found cached accessory: ${ platformAccessory.displayName }` );
153
+ if ( settings.cmd4Dbg ) this.log.debug( `Found cached accessory: ${ platformAccessory.displayName }` );
149
154
  this.toBeRestoredPlatforms.push( platformAccessory );
150
155
  }
151
156
  }
@@ -178,14 +183,22 @@ class Cmd4Platform
178
183
  {
179
184
  for ( let key in config )
180
185
  {
181
- let value = config[ key ];
186
+ let lcKey = lcFirst( key );
187
+ if ( key == "UUID" )
188
+ {
189
+ lcKey = "uuid";
190
+ } else
191
+ {
192
+ // warn now
193
+ if ( key.charAt( 0 ) === key.charAt( 0 ).toUpperCase( ) )
194
+ {
195
+ this.log.warn( `The config.json Platform key: ${ key } is Capitalized. All keys in the near future will ALWAYS start with a lower case character for homebridge-ui integration.\nTo remove this Warning, Please fix your config.json.` );
196
+ }
197
+ }
182
198
 
183
- // I made the stupid mistake of not having all characteristics in
184
- // the config.json file not upper case to match that in State.js.
185
- // So instead of having everyone fix their scripts, fix it here.
186
- let ucKey = ucFirst( key );
199
+ let value = config[ key ];
187
200
 
188
- switch ( ucKey )
201
+ switch ( lcKey )
189
202
  {
190
203
  case constants.TIMEOUT:
191
204
  // Timers are in milliseconds. A low value can result in
@@ -235,12 +248,6 @@ class Cmd4Platform
235
248
 
236
249
  break;
237
250
  case "QueueStatMsgInterval":
238
-
239
- // Never put into production
240
- this.log.warn( `Warning: ${ key } has been deprecated. It was never even used.` );
241
- this.log.warn( `To remove this message, just remove ${ key } from your config.json` );
242
-
243
- break;
244
251
  case "QueueMsg":
245
252
 
246
253
  // Never put into production
@@ -253,6 +260,7 @@ class Cmd4Platform
253
260
 
254
261
  break;
255
262
  case "Cmd4_Mode":
263
+ case "cmd4_Mode":
256
264
  this.log.warn( `Warning: ${ key } has been deprecated.` );
257
265
  if ( value == "Demo" )
258
266
  {
@@ -264,10 +272,10 @@ class Cmd4Platform
264
272
  this.log.warn( `To remove this message, just remove "${ key }" from your config.json` );
265
273
  break;
266
274
  case constants.STORAGE:
267
- if ( value == constants.FS_l || value == constants.GOOGLEDRIVE_l )
275
+ if ( value == constants.FS || value == constants.GOOGLEDRIVEl )
268
276
  this.storage = value;
269
277
  else
270
- this.log.warn( chalk.yellow( `WARNING` ) + `: Cmd4 Unknown platform.config.storage:{ this.storage } Expected:${ constants.FS_l } or ${ constants.GOOGLEDRIVE_l }` );
278
+ this.log.warn( chalk.yellow( `WARNING` ) + `: Cmd4 Unknown platform.config.storage:{ this.storage } Expected:${ constants.FS } or ${ constants.GOOGLEDRIVE }` );
271
279
 
272
280
  break;
273
281
  case constants.STORAGEPATH:
@@ -286,6 +294,12 @@ class Cmd4Platform
286
294
  this.definitions = value;
287
295
 
288
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
289
303
  case constants.PLATFORM:
290
304
  // Noop
291
305
 
@@ -315,7 +329,7 @@ class Cmd4Platform
315
329
 
316
330
  this.definitions.forEach( ( definition, definitionIndex ) =>
317
331
  {
318
- if ( cmd4Dbg ) this.log.debug( `Processing definition index: ${ definitionIndex }` );
332
+ if ( settings.cmd4Dbg ) this.log.debug( `Processing definition index: ${ definitionIndex }` );
319
333
 
320
334
  if ( trueTypeOf( definition.type ) != String )
321
335
  throw new Error( `definition.type at index: ${ definitionIndex } is not a String.` );
@@ -383,7 +397,7 @@ class Cmd4Platform
383
397
  }
384
398
 
385
399
  CMD4_ACC_TYPE_ENUM.add( this.api, definition.type, definition.description, definition.props, definition.validValues );
386
- if ( cmd4Dbg ) this.log.debug( `Created definition type: "${ definition.type }".` );
400
+ if ( settings.cmd4Dbg ) this.log.debug( `Created definition type: "${ definition.type }".` );
387
401
 
388
402
  });
389
403
  }
@@ -398,7 +412,7 @@ class Cmd4Platform
398
412
  // already been registered.
399
413
  this.config.accessories && this.config.accessories.forEach( ( device ) =>
400
414
  {
401
- if ( cmd4Dbg ) this.log.debug( `Fetching config.json Platform accessories.` );
415
+ if ( settings.cmd4Dbg ) this.log.debug( `Fetching config.json Platform accessories.` );
402
416
  this.Service=this.api.hap.Service;
403
417
 
404
418
  device.name = getAccessoryName( device );
@@ -407,19 +421,24 @@ class Cmd4Platform
407
421
  // generate a unique id for the accessory this should be generated from
408
422
  // something globally unique, but constant, for example, the device serial
409
423
  // number or MAC address.
410
- let UUID = getAccessoryUUID( device, this.api.hap.uuid );
424
+ let uuid = getAccessoryUUID( device, this.api.hap.uuid );
411
425
 
412
426
  // See if an accessory with the same UUID has already been registered and
413
427
  // restored from the cached devices we stored in the `configureAccessory`
414
428
  // method above
415
- const existingAccessory = this.toBeRestoredPlatforms.find(accessory => accessory.UUID === UUID);
429
+
430
+ // NOTE: HOMEBRIDGE EXAMPLES HAVE THIS AS UPPERCASE UUID.
431
+ // lower case uuid will not be found.
432
+ const existingAccessory = this.toBeRestoredPlatforms.find(accessory => accessory.UUID === uuid);
416
433
 
417
434
  if (existingAccessory)
418
435
  {
436
+ // NOTE: HOMEBRIDGE EXAMPLES HAVE THIS AS UPPERCASE UUID.
437
+ // lower case uuid will not be found.
419
438
  let duplicatePlatformAccessory = this.createdCmd4Platforms.find(accessory => accessory.UUID === existingAccessory.UUID);
420
439
  if ( duplicatePlatformAccessory )
421
440
  {
422
- this.log( chalk.red( `Error duplicate platform accessory: ${ duplicatePlatformAccessory.name } UUID:${ duplicatePlatformAccessory.UUID }` ) );
441
+ this.log( chalk.red( `Error duplicate platform accessory: ${ duplicatePlatformAccessory.name } uuid:${ duplicatePlatformAccessory.UUID }` ) );
423
442
  // Next in for.Each object iteration
424
443
  return;
425
444
  }
@@ -441,8 +460,13 @@ class Cmd4Platform
441
460
  platform.Service = this.Service;
442
461
 
443
462
  // This is how we keep the device status information over restart.
463
+ // Version 0
444
464
  // Within STORED_DATA_ARRAY is a list of UUID identified objects
445
465
  // of storedValuesPerCharacteristic.
466
+ // Version 1
467
+ // Within STORED_DATA_ARRAY is a list of UUID identified objects
468
+ // of Cmd4Storage.
469
+
446
470
  // If the accessory has linked accessories or standalone accessories,
447
471
  // there infomation gets put in this as well. I'm pretty sure
448
472
  // that previosly these states were lost.
@@ -454,18 +478,9 @@ class Cmd4Platform
454
478
  // If the saved context has our STORED_DATA_ARRAY, then use it.
455
479
  if ( existingAccessory.context.STORED_DATA_ARRAY )
456
480
  {
457
- if ( cmd4Dbg ) this.log.debug(`Cmd4Platform: Using context.STORED_DATA_ARRAY` );
481
+ if ( settings.cmd4Dbg ) this.log.debug(`Cmd4Platform: Using context.STORED_DATA_ARRAY` );
458
482
  STORED_DATA_ARRAY = existingAccessory.context.STORED_DATA_ARRAY;
459
- } else if ( existingAccessory.context.device.storedValuesPerCharacteristic )
460
- {
461
- // If we have an old version of the stored status, convert it to our new format.
462
- if ( cmd4Dbg ) this.log.debug(`Cmd4Platform: Creating STORED_DATA_ARRAY with existing storedValuesPerCharacteristic UUID:${ existingAccessory.UUID }` );
463
- STORED_DATA_ARRAY = [ {[ constants.UUID ]: existingAccessory.UUID,
464
- [ constants.STORED_VALUES_PER_CHARACTERISTIC_lv ]: existingAccessory.context.device.storedValuesPerCharacteristic }
465
- ];
466
- // Get rid of old persistance data
467
- existingAccessory.context.device = undefined;
468
- delete( existingAccessory.context.device );
483
+
469
484
  }
470
485
 
471
486
  let that = this;
@@ -483,7 +498,7 @@ class Cmd4Platform
483
498
  // Get the properties for this accessories device type
484
499
  let devProperties = CMD4_DEVICE_TYPE_ENUM.properties[ accessory.typeIndex ];
485
500
 
486
- if ( cmd4Dbg ) this.log.debug( `Step 2. ${ accessory.displayName }.service = platform.getService( Service.${ devProperties.deviceName }, ${ accessory.subType })` );
501
+ if ( settings.cmd4Dbg ) this.log.debug( `Step 2. ${ accessory.displayName }.service = platform.getService( Service.${ devProperties.deviceName }, ${ accessory.subType })` );
487
502
  accessory.service = platform.getService( devProperties.service, accessory.name, accessory.subType );
488
503
 
489
504
  // Determine which characteristics, if any, will be polled. This
@@ -511,8 +526,8 @@ class Cmd4Platform
511
526
  // Create the new PlatformAccessory
512
527
  if ( device.category == undefined )
513
528
  {
514
- if ( cmd4Dbg ) this.log.debug( `Step 1. platformAccessory = new platformAccessory( ${ displayName }, ${ UUID } )` );
515
- platform = new this.api.platformAccessory( displayName, UUID );
529
+ if ( settings.cmd4Dbg ) this.log.debug( `Step 1. platformAccessory = new platformAccessory( ${ displayName }, ${ uuid } )` );
530
+ platform = new this.api.platformAccessory( displayName, uuid );
516
531
 
517
532
  } else
518
533
  {
@@ -523,9 +538,9 @@ class Cmd4Platform
523
538
  if ( ! category )
524
539
  throw new Error( `Category specified: ${ device.category } is not a valid homebridge category.` );
525
540
 
526
- if ( cmd4Dbg ) this.log.debug( `Step 1. platformAccessory = new platformAccessory( ${ displayName }, ${ UUID }, ${ category } )` );
541
+ if ( settings.cmd4Dbg ) this.log.debug( `Step 1. platformAccessory = new platformAccessory( ${ displayName }, ${ uuid }, ${ category } )` );
527
542
 
528
- platform = new this.api.platformAccessory( displayName, UUID, category );
543
+ platform = new this.api.platformAccessory( displayName, uuid, category );
529
544
  }
530
545
 
531
546
  platform.Service = this.Service;
@@ -538,7 +553,7 @@ class Cmd4Platform
538
553
  // Put the accessory into its correct collection array.
539
554
  this.createdCmd4Accessories.push( accessory );
540
555
 
541
- if ( cmd4Dbg ) this.log.debug( `Created platformAccessory: ${ accessory.displayName }` );
556
+ if ( settings.cmd4Dbg ) this.log.debug( `Created platformAccessory: ${ accessory.displayName }` );
542
557
 
543
558
  // Store a copy of the device object in the `accessory.context`
544
559
  // the `context` property can be used to store any data about the
@@ -550,7 +565,7 @@ class Cmd4Platform
550
565
 
551
566
  // MOVE OUSTSIDE
552
567
  // Platform Step 2. const tvService = this.tvAccessory.addService( this.Service.Television );
553
- if ( cmd4Dbg ) this.log.debug( `Step 2. ${ accessory.displayName }.service = platform.addService( this.Service.${ devProperties.deviceName }, ${ accessory.name }, ${ accessory.subType })` );
568
+ if ( settings.cmd4Dbg ) this.log.debug( `Step 2. ${ accessory.displayName }.service = platform.addService( this.Service.${ devProperties.deviceName }, ${ accessory.name }, ${ accessory.subType })` );
554
569
  accessory.service = platform.addService( new devProperties.service( accessory.name, accessory.subType ) );
555
570
 
556
571
  // Create all the services for the accessory, including fakegato
@@ -560,12 +575,12 @@ class Cmd4Platform
560
575
  // Step 6. this.api.publishExternalAccessories( PLUGIN_NAME, [ this.tvAccessory ] );
561
576
  if ( accessory.publishExternally )
562
577
  {
563
- if ( cmd4Dbg ) this.log.debug( `Step 6. publishExternalAccessories( ${ settings.PLUGIN_NAME }, [ ${accessory.displayName } ] )` );
578
+ if ( settings.cmd4Dbg ) this.log.debug( `Step 6. publishExternalAccessories( ${ settings.PLUGIN_NAME }, [ ${accessory.displayName } ] )` );
564
579
 
565
580
  this.api.publishExternalAccessories( settings.PLUGIN_NAME, [ platform ] );
566
581
 
567
582
  } else {
568
- if ( cmd4Dbg ) this.log.debug( `Step 6. registerPlatformAccessories( ${ settings.PLUGIN_NAME }, ${ settings.PLATFORM_NAME }, [ ${ accessory.displayName } ] ) `);
583
+ if ( settings.cmd4Dbg ) this.log.debug( `Step 6. registerPlatformAccessories( ${ settings.PLUGIN_NAME }, ${ settings.PLATFORM_NAME }, [ ${ accessory.displayName } ] ) `);
569
584
 
570
585
  this.api.registerPlatformAccessories( settings.PLUGIN_NAME, settings.PLATFORM_NAME, [ platform ] );
571
586
  }
@@ -589,28 +604,28 @@ class Cmd4Platform
589
604
  // for us and the getService hangs off the platform, not the accessory.
590
605
  if ( cmd4PlatformAccessory.model )
591
606
  {
592
- if ( cmd4Dbg ) cmd4PlatformAccessory.log.debug( `Adding model( ${ cmd4PlatformAccessory.model } ) to information service of ${ cmd4PlatformAccessory.displayName }` );
607
+ if ( settings.cmd4Dbg ) cmd4PlatformAccessory.log.debug( `Adding model( ${ cmd4PlatformAccessory.model } ) to information service of ${ cmd4PlatformAccessory.displayName }` );
593
608
  cmd4PlatformAccessory.platform.getService( cmd4PlatformAccessory.platform.Service.AccessoryInformation )
594
609
  .setCharacteristic( this.api.hap.Characteristic.Model, cmd4PlatformAccessory.model );
595
610
  }
596
611
 
597
612
  if ( cmd4PlatformAccessory.manufacturer )
598
613
  {
599
- if ( cmd4Dbg ) cmd4PlatformAccessory.log.debug( `Adding manufacturer( ${ cmd4PlatformAccessory.manufacturer } ) to information service of ${ cmd4PlatformAccessory.displayName }` );
614
+ if ( settings.cmd4Dbg ) cmd4PlatformAccessory.log.debug( `Adding manufacturer( ${ cmd4PlatformAccessory.manufacturer } ) to information service of ${ cmd4PlatformAccessory.displayName }` );
600
615
  cmd4PlatformAccessory.platform.getService( cmd4PlatformAccessory.platform.Service.AccessoryInformation )
601
616
  .setCharacteristic( this.api.hap.Characteristic.Manufacturer, cmd4PlatformAccessory.manufacturer );
602
617
  }
603
618
 
604
619
  if ( cmd4PlatformAccessory.serialNumber )
605
620
  {
606
- if ( cmd4Dbg ) cmd4PlatformAccessory.log.debug( `Adding serial Number( ${ cmd4PlatformAccessory.serialNumber } ) to information service of ${ cmd4PlatformAccessory.displayName }` );
621
+ if ( settings.cmd4Dbg ) cmd4PlatformAccessory.log.debug( `Adding serial Number( ${ cmd4PlatformAccessory.serialNumber } ) to information service of ${ cmd4PlatformAccessory.displayName }` );
607
622
  cmd4PlatformAccessory.platform.getService( cmd4PlatformAccessory.platform.Service.AccessoryInformation )
608
623
  .setCharacteristic( this.api.hap.Characteristic.SerialNumber, cmd4PlatformAccessory.serialNumber );
609
624
  }
610
625
 
611
626
  if ( cmd4PlatformAccessory.firmwareRevision )
612
627
  {
613
- if ( cmd4Dbg ) cmd4PlatformAccessory.log.debug( `Adding Firmware Revision( ${ cmd4PlatformAccessory.firmwareRevision } ) to information service of ${ cmd4PlatformAccessory.displayName }` );
628
+ if ( settings.cmd4Dbg ) cmd4PlatformAccessory.log.debug( `Adding Firmware Revision( ${ cmd4PlatformAccessory.firmwareRevision } ) to information service of ${ cmd4PlatformAccessory.displayName }` );
614
629
  cmd4PlatformAccessory.platform.getService( cmd4PlatformAccessory.platform.Service.AccessoryInformation )
615
630
  .setCharacteristic( this.api.hap.Characteristic.FirmwareRevision, cmd4PlatformAccessory.firmwareRevision );
616
631
  }
@@ -630,19 +645,19 @@ class Cmd4Platform
630
645
  // Existing Accessories would have existing services
631
646
  if ( fromExisting == true )
632
647
  {
633
- if ( cmd4Dbg ) this.log.debug( `Platform (AddedAccessory-existing) Step 3, ${ addedAccessory.displayName }.service = accessory.platform.getService( Service.${ devProperties.deviceName }, ${ addedAccessory.name }, ${ addedAccessory.subType }` );
648
+ if ( settings.cmd4Dbg ) this.log.debug( `Platform (AddedAccessory-existing) Step 3, ${ addedAccessory.displayName }.service = accessory.platform.getService( Service.${ devProperties.deviceName }, ${ addedAccessory.name }, ${ addedAccessory.subType }` );
634
649
  addedAccessory.service = addedAccessory.platform.getService( devProperties.service, addedAccessory.name, addedAccessory.subType );
635
650
  } else
636
651
  {
637
652
 
638
- if ( cmd4Dbg ) this.log.debug( `Platform (AddedAccessory-new) Step 3, ${ addedAccessory.displayName }.service = PlatformAccessory: ${ cmd4PlatformAccessory.displayName } addService( Service:${ devProperties.deviceName }, ${ addedAccessory.name }, ${ addedAccessory.subType } )` );
653
+ if ( settings.cmd4Dbg ) this.log.debug( `Platform (AddedAccessory-new) Step 3, ${ addedAccessory.displayName }.service = PlatformAccessory: ${ cmd4PlatformAccessory.displayName } addService( Service:${ devProperties.deviceName }, ${ addedAccessory.name }, ${ addedAccessory.subType } )` );
639
654
 
640
655
  addedAccessory.service = cmd4PlatformAccessory.platform.addService( new devProperties.service( addedAccessory.name, addedAccessory.subType ) );
641
656
  }
642
657
 
643
658
  addedAccessory.addAllServiceCharacteristicsForAccessory( addedAccessory );
644
659
  // Create Information Service for the addedAccessory
645
- if ( cmd4Dbg ) addedAccessory.log.debug( `Creating information service for AddedAccessory: ${ addedAccessory.displayName }` );
660
+ if ( settings.cmd4Dbg ) addedAccessory.log.debug( `Creating information service for AddedAccessory: ${ addedAccessory.displayName }` );
646
661
  createAccessorysInformationService( addedAccessory );
647
662
 
648
663
  // Setup the fakegato service if defined in the config.json file
@@ -669,12 +684,12 @@ class Cmd4Platform
669
684
  // Existing Accessories would have existing services
670
685
  if ( fromExisting == true )
671
686
  {
672
- if ( cmd4Dbg ) this.log.debug( `Platform (LinkedAccessory-existing) Step 4. ${ linkedAccessory.displayName }.service = ${ cmd4PlatformAccessory.displayName }.getService:( ${ devProperties.deviceName }.service, ${linkedAccessory.name }, ${linkedAccessory.subType } )` );
687
+ if ( settings.cmd4Dbg ) this.log.debug( `Platform (LinkedAccessory-existing) Step 4. ${ linkedAccessory.displayName }.service = ${ cmd4PlatformAccessory.displayName }.getService:( ${ devProperties.deviceName }.service, ${linkedAccessory.name }, ${linkedAccessory.subType } )` );
673
688
 
674
689
  linkedAccessory.service = linkedAccessory.platform.getService( devProperties.service, linkedAccessory.name, linkedAccessory.subType );
675
690
  } else
676
691
  {
677
- if ( cmd4Dbg ) this.log.debug( `Platform (LinkedAccessory-new) Step 4. ${ linkedAccessory.displayName }.service = ${ cmd4PlatformAccessory.displayName }.addService:( ${ devProperties.deviceName }.service, ${linkedAccessory.name }, ${linkedAccessory.subType } )` );
692
+ if ( settings.cmd4Dbg ) this.log.debug( `Platform (LinkedAccessory-new) Step 4. ${ linkedAccessory.displayName }.service = ${ cmd4PlatformAccessory.displayName }.addService:( ${ devProperties.deviceName }.service, ${linkedAccessory.name }, ${linkedAccessory.subType } )` );
678
693
 
679
694
  linkedAccessory.service = cmd4PlatformAccessory.platform.addService( new devProperties.service( linkedAccessory.name, linkedAccessory.subType ) );
680
695
  }
@@ -683,12 +698,12 @@ class Cmd4Platform
683
698
 
684
699
  if ( fromExisting == false )
685
700
  {
686
- if ( cmd4Dbg ) this.log.debug( `Platform Step 5. ${ cmd4PlatformAccessory.displayName }.service.addLinkedService( ${ linkedAccessory.displayName }.service )` );
701
+ if ( settings.cmd4Dbg ) this.log.debug( `Platform Step 5. ${ cmd4PlatformAccessory.displayName }.service.addLinkedService( ${ linkedAccessory.displayName }.service )` );
687
702
  cmd4PlatformAccessory.service.addLinkedService( linkedAccessory.service );
688
703
  }
689
704
 
690
705
  // Create Information Service for the linkedAccessory
691
- if ( cmd4Dbg ) linkedAccessory.log.debug( `Creating information service for Linked Platform Accessory: ${ linkedAccessory.displayName }` );
706
+ if ( settings.cmd4Dbg ) linkedAccessory.log.debug( `Creating information service for Linked Platform Accessory: ${ linkedAccessory.displayName }` );
692
707
  createAccessorysInformationService( linkedAccessory );
693
708
 
694
709
  // Setup the fakegato service if defined in the config.json file
@@ -715,7 +730,7 @@ class Cmd4Platform
715
730
  // Check for any queued characteristics
716
731
  if ( Object.keys( settings.listOfCreatedPriorityQueues ).length == 0 )
717
732
  {
718
- if ( cmd4Dbg ) this.log.debug( `No queued polling characteristics` );
733
+ if ( settings.cmd4Dbg ) this.log.debug( `No queued polling characteristics` );
719
734
  return;
720
735
  }
721
736