@switchbot/homebridge-switchbot 3.6.1-beta.9 → 3.7.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 (118) hide show
  1. package/CHANGELOG.md +2 -1
  2. package/dist/device/blindtilt.js +3 -3
  3. package/dist/device/blindtilt.js.map +1 -1
  4. package/dist/device/bot.js +12 -12
  5. package/dist/device/bot.js.map +1 -1
  6. package/dist/device/ceilinglight.js +1 -1
  7. package/dist/device/ceilinglight.js.map +1 -1
  8. package/dist/device/colorbulb.js +1 -1
  9. package/dist/device/colorbulb.js.map +1 -1
  10. package/dist/device/contact.js +4 -4
  11. package/dist/device/contact.js.map +1 -1
  12. package/dist/device/curtain.js +3 -3
  13. package/dist/device/curtain.js.map +1 -1
  14. package/dist/device/device.d.ts +1 -9
  15. package/dist/device/device.d.ts.map +1 -1
  16. package/dist/device/device.js +14 -38
  17. package/dist/device/device.js.map +1 -1
  18. package/dist/device/fan.js +3 -3
  19. package/dist/device/fan.js.map +1 -1
  20. package/dist/device/hub.js +3 -3
  21. package/dist/device/hub.js.map +1 -1
  22. package/dist/device/humidifier.js +2 -2
  23. package/dist/device/humidifier.js.map +1 -1
  24. package/dist/device/iosensor.js +3 -3
  25. package/dist/device/iosensor.js.map +1 -1
  26. package/dist/device/lightstrip.js +1 -1
  27. package/dist/device/lightstrip.js.map +1 -1
  28. package/dist/device/lock.js +4 -4
  29. package/dist/device/lock.js.map +1 -1
  30. package/dist/device/meter.js +3 -3
  31. package/dist/device/meter.js.map +1 -1
  32. package/dist/device/meterplus.js +3 -3
  33. package/dist/device/meterplus.js.map +1 -1
  34. package/dist/device/motion.d.ts.map +1 -1
  35. package/dist/device/motion.js +4 -5
  36. package/dist/device/motion.js.map +1 -1
  37. package/dist/device/plug.js +2 -2
  38. package/dist/device/plug.js.map +1 -1
  39. package/dist/device/robotvacuumcleaner.js +3 -3
  40. package/dist/device/robotvacuumcleaner.js.map +1 -1
  41. package/dist/device/waterdetector.js +2 -2
  42. package/dist/device/waterdetector.js.map +1 -1
  43. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  44. package/dist/irdevice/airconditioner.js +4 -3
  45. package/dist/irdevice/airconditioner.js.map +1 -1
  46. package/dist/irdevice/airpurifier.js +2 -2
  47. package/dist/irdevice/airpurifier.js.map +1 -1
  48. package/dist/irdevice/camera.js +1 -1
  49. package/dist/irdevice/camera.js.map +1 -1
  50. package/dist/irdevice/fan.js +1 -1
  51. package/dist/irdevice/fan.js.map +1 -1
  52. package/dist/irdevice/irdevice.d.ts +1 -0
  53. package/dist/irdevice/irdevice.d.ts.map +1 -1
  54. package/dist/irdevice/irdevice.js +14 -11
  55. package/dist/irdevice/irdevice.js.map +1 -1
  56. package/dist/irdevice/light.js +3 -3
  57. package/dist/irdevice/light.js.map +1 -1
  58. package/dist/irdevice/other.d.ts +1 -1
  59. package/dist/irdevice/other.d.ts.map +1 -1
  60. package/dist/irdevice/other.js +26 -36
  61. package/dist/irdevice/other.js.map +1 -1
  62. package/dist/irdevice/tv.js +3 -3
  63. package/dist/irdevice/tv.js.map +1 -1
  64. package/dist/irdevice/vacuumcleaner.js +1 -1
  65. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  66. package/dist/irdevice/waterheater.js +2 -2
  67. package/dist/irdevice/waterheater.js.map +1 -1
  68. package/dist/platform.d.ts +9 -0
  69. package/dist/platform.d.ts.map +1 -1
  70. package/dist/platform.js +310 -91
  71. package/dist/platform.js.map +1 -1
  72. package/dist/settings.d.ts +1 -1
  73. package/dist/settings.d.ts.map +1 -1
  74. package/docs/.nojekyll +1 -0
  75. package/docs/assets/highlight.css +22 -0
  76. package/docs/assets/icons.js +18 -0
  77. package/docs/assets/icons.svg +1 -0
  78. package/docs/assets/main.js +60 -0
  79. package/docs/assets/navigation.js +1 -0
  80. package/docs/assets/search.js +1 -0
  81. package/docs/assets/style.css +1448 -0
  82. package/docs/functions/default.html +1 -0
  83. package/docs/index.html +368 -0
  84. package/docs/modules.html +2 -0
  85. package/package.json +10 -7
  86. package/src/device/blindtilt.ts +3 -3
  87. package/src/device/bot.ts +12 -12
  88. package/src/device/ceilinglight.ts +1 -1
  89. package/src/device/colorbulb.ts +1 -1
  90. package/src/device/contact.ts +4 -4
  91. package/src/device/curtain.ts +3 -3
  92. package/src/device/device.ts +15 -44
  93. package/src/device/fan.ts +3 -3
  94. package/src/device/hub.ts +3 -3
  95. package/src/device/humidifier.ts +2 -2
  96. package/src/device/iosensor.ts +3 -3
  97. package/src/device/lightstrip.ts +1 -1
  98. package/src/device/lock.ts +4 -4
  99. package/src/device/meter.ts +4 -4
  100. package/src/device/meterplus.ts +4 -4
  101. package/src/device/motion.ts +6 -7
  102. package/src/device/plug.ts +2 -2
  103. package/src/device/robotvacuumcleaner.ts +3 -3
  104. package/src/device/waterdetector.ts +2 -2
  105. package/src/irdevice/airconditioner.ts +5 -4
  106. package/src/irdevice/airpurifier.ts +2 -2
  107. package/src/irdevice/camera.ts +1 -1
  108. package/src/irdevice/fan.ts +1 -1
  109. package/src/irdevice/irdevice.ts +15 -11
  110. package/src/irdevice/light.ts +3 -3
  111. package/src/irdevice/other.ts +26 -34
  112. package/src/irdevice/tv.ts +3 -3
  113. package/src/irdevice/vacuumcleaner.ts +1 -1
  114. package/src/irdevice/waterheater.ts +2 -2
  115. package/src/platform.ts +315 -90
  116. package/src/settings.ts +1 -1
  117. package/typedoc.json +17 -0
  118. package/.github/npm-version-script.cjs +0 -81
@@ -75,7 +75,7 @@ export class Contact extends deviceBase {
75
75
  // Initialize Contact Sensor Service
76
76
  accessory.context.ContactSensor = accessory.context.ContactSensor ?? {};
77
77
  this.ContactSensor = {
78
- Name: accessory.context.ContactSensor.Name ?? accessory.displayName,
78
+ Name: accessory.displayName,
79
79
  Service: accessory.getService(this.hap.Service.ContactSensor) ?? accessory.addService(this.hap.Service.ContactSensor) as Service,
80
80
  ContactSensorState: accessory.context.ContactSensorState ?? this.hap.Characteristic.ContactSensorState.CONTACT_DETECTED,
81
81
  };
@@ -93,7 +93,7 @@ export class Contact extends deviceBase {
93
93
  // Initialize Battery Service
94
94
  accessory.context.Battery = accessory.context.Battery ?? {};
95
95
  this.Battery = {
96
- Name: accessory.context.Battery.Name ?? `${accessory.displayName} Battery`,
96
+ Name: `${accessory.displayName} Battery`,
97
97
  Service: accessory.getService(this.hap.Service.Battery) ?? accessory.addService(this.hap.Service.Battery) as Service,
98
98
  BatteryLevel: accessory.context.BatteryLevel ?? 100,
99
99
  StatusLowBattery: accessory.context.StatusLowBattery ?? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
@@ -126,7 +126,7 @@ export class Contact extends deviceBase {
126
126
  } else {
127
127
  accessory.context.MotionSensor = accessory.context.MotionSensor ?? {};
128
128
  this.MotionSensor = {
129
- Name: accessory.context.MotionSensor.Name ?? `${accessory.displayName} Motion Sensor`,
129
+ Name: `${accessory.displayName} Motion Sensor`,
130
130
  Service: accessory.getService(this.hap.Service.MotionSensor) ?? accessory.addService(this.hap.Service.MotionSensor) as Service,
131
131
  MotionDetected: accessory.context.MotionDetected ?? false,
132
132
  };
@@ -152,7 +152,7 @@ export class Contact extends deviceBase {
152
152
  } else {
153
153
  accessory.context.LightSensor = accessory.context.LightSensor ?? {};
154
154
  this.LightSensor = {
155
- Name: accessory.context.LightSensor.Name ?? `${accessory.displayName} Light Sensor`,
155
+ Name: `${accessory.displayName} Light Sensor`,
156
156
  Service: accessory.getService(this.hap.Service.LightSensor) ?? accessory.addService(this.hap.Service.LightSensor) as Service,
157
157
  CurrentAmbientLightLevel: accessory.context.CurrentAmbientLightLevel ?? 0.0001,
158
158
  };
@@ -74,7 +74,7 @@ export class Curtain extends deviceBase {
74
74
  // Initialize WindowCovering Service
75
75
  accessory.context.WindowCovering = accessory.context.WindowCovering ?? {};
76
76
  this.WindowCovering = {
77
- Name: accessory.context.WindowCovering.Name ?? accessory.displayName,
77
+ Name: accessory.displayName,
78
78
  Service: accessory.getService(this.hap.Service.WindowCovering) ?? accessory.addService(this.hap.Service.WindowCovering) as Service,
79
79
  PositionState: accessory.context.PositionState ?? this.hap.Characteristic.PositionState.STOPPED,
80
80
  TargetPosition: accessory.context.TargetPosition ?? 100,
@@ -130,7 +130,7 @@ export class Curtain extends deviceBase {
130
130
  // Initialize Battery Service
131
131
  accessory.context.Battery = accessory.context.Battery ?? {};
132
132
  this.Battery = {
133
- Name: accessory.context.Battery.Name ?? `${accessory.displayName} Battery`,
133
+ Name: `${accessory.displayName} Battery`,
134
134
  Service: accessory.getService(this.hap.Service.Battery) ?? accessory.addService(this.hap.Service.Battery) as Service,
135
135
  BatteryLevel: accessory.context.BatteryLevel ?? 100,
136
136
  StatusLowBattery: accessory.context.StatusLowBattery ?? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
@@ -169,7 +169,7 @@ export class Curtain extends deviceBase {
169
169
  } else {
170
170
  accessory.context.LightSensor = accessory.context.LightSensor ?? {};
171
171
  this.LightSensor = {
172
- Name: accessory.context.LightSensor.Name ?? `${accessory.displayName} Light Sensor`,
172
+ Name: `${accessory.displayName} Light Sensor`,
173
173
  Service: accessory.getService(this.hap.Service.LightSensor) ?? this.accessory.addService(this.hap.Service.LightSensor) as Service,
174
174
  CurrentAmbientLightLevel: accessory.context.CurrentAmbientLightLevel ?? 0.0001,
175
175
  };
@@ -79,20 +79,13 @@ export abstract class deviceBase {
79
79
  .getService(this.hap.Service.AccessoryInformation)!
80
80
  .setCharacteristic(this.hap.Characteristic.Manufacturer, 'SwitchBot')
81
81
  .setCharacteristic(this.hap.Characteristic.AppMatchingIdentifier, 'id1087374760')
82
- .setCharacteristic(this.hap.Characteristic.Name, this.validName(accessory, device))
83
- .setCharacteristic(this.hap.Characteristic.ConfiguredName, this.validName(accessory, device))
84
- .setCharacteristic(this.hap.Characteristic.Model, device.model ?? accessory.context.model)
85
- .setCharacteristic(this.hap.Characteristic.ProductData, device.deviceId ?? accessory.context.deviceId)
82
+ .setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
83
+ .setCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName)
84
+ .setCharacteristic(this.hap.Characteristic.Model, device.model)
85
+ .setCharacteristic(this.hap.Characteristic.ProductData, device.deviceId)
86
86
  .setCharacteristic(this.hap.Characteristic.SerialNumber, device.deviceId);
87
87
  }
88
88
 
89
- public validName(accessory: PlatformAccessory, device: device & devicesConfig) {
90
- const Name = device.configDeviceName ?? device.deviceName ?? accessory.displayName;
91
- const NameOfName = device.configDeviceName ? 'configDeviceName' : device.deviceName ? 'deviceName' : 'displayName';
92
- const validName = this.validateAndCleanString(Name, NameOfName, Name);
93
- return validName;
94
- }
95
-
96
89
  async getDeviceLogSettings(accessory: PlatformAccessory, device: device & devicesConfig): Promise<void> {
97
90
  this.deviceLogging = this.platform.debugMode ? 'debugMode' : device.logging ?? this.config.logging ?? 'standard';
98
91
  const logging = this.platform.debugMode ? 'Debug Mode' : device.logging ? 'Device Config' : this.config.logging ? 'Platform Config' : 'Default';
@@ -444,9 +437,9 @@ export abstract class deviceBase {
444
437
  }
445
438
  Service.updateCharacteristic(Characteristic, CharacteristicValue);
446
439
  this.debugLog(`updateCharacteristic ${CharacteristicName}: ${CharacteristicValue}`);
447
- this.debugWarnLog(`context before: ${this.accessory.context[CharacteristicName]}`);
440
+ this.debugWarnLog(`${CharacteristicName} context before: ${this.accessory.context[CharacteristicName]}`);
448
441
  this.accessory.context[CharacteristicName] = CharacteristicValue;
449
- this.debugWarnLog(`context after: ${this.accessory.context[CharacteristicName]}`);
442
+ this.debugWarnLog(`${CharacteristicName} context after: ${this.accessory.context[CharacteristicName]}`);
450
443
  }
451
444
  }
452
445
 
@@ -772,32 +765,6 @@ export abstract class deviceBase {
772
765
  }
773
766
  }
774
767
 
775
- /**
776
- * Validate and clean a string value for a Name Characteristic.
777
- * @param displayName
778
- * @param name
779
- * @param value
780
- * @returns string value
781
- */
782
- validateAndCleanString(displayName: string, name: string, value: string): string {
783
- const validPattern = /^[a-zA-Z0-9][a-zA-Z0-9 ']*[a-zA-Z0-9]$/;
784
- const invalidCharsPattern = /[^a-zA-Z0-9 ']/g;
785
-
786
- if (!validPattern.test(value)) {
787
- this.warnLog(`WARNING: The accessory '${displayName}' has an invalid '${name}' characteristic ('${value}'). Please use only alphanumeric,`
788
- + ' space, and apostrophe characters. Ensure it starts and ends with an alphabetic or numeric character, and avoid emojis. This may'
789
- + ' prevent the accessory from being added in the Home App or cause unresponsiveness.');
790
-
791
- // Remove invalid characters
792
- value = value.replace(invalidCharsPattern, '');
793
-
794
- // Ensure it starts and ends with an alphanumeric character
795
- value = value.replace(/^[^a-zA-Z0-9]+|[^a-zA-Z0-9]+$/g, '');
796
- }
797
-
798
- return value;
799
- }
800
-
801
768
  /**
802
769
  * Logging for Device
803
770
  */
@@ -815,7 +782,7 @@ export abstract class deviceBase {
815
782
 
816
783
  async debugSuccessLog(...log: any[]): Promise<void> {
817
784
  if (await this.enablingDeviceLogging()) {
818
- if (this.deviceLogging?.includes('debug')) {
785
+ if (await this.loggingIsDebug()) {
819
786
  this.log.success(`[DEBUG] ${this.device.deviceType}: ${this.accessory.displayName}`, String(...log));
820
787
  }
821
788
  }
@@ -829,7 +796,7 @@ export abstract class deviceBase {
829
796
 
830
797
  async debugWarnLog(...log: any[]): Promise<void> {
831
798
  if (await this.enablingDeviceLogging()) {
832
- if (this.deviceLogging?.includes('debug')) {
799
+ if (await this.loggingIsDebug()) {
833
800
  this.log.warn(`[DEBUG] ${this.device.deviceType}: ${this.accessory.displayName}`, String(...log));
834
801
  }
835
802
  }
@@ -843,7 +810,7 @@ export abstract class deviceBase {
843
810
 
844
811
  async debugErrorLog(...log: any[]): Promise<void> {
845
812
  if (await this.enablingDeviceLogging()) {
846
- if (this.deviceLogging?.includes('debug')) {
813
+ if (await this.loggingIsDebug()) {
847
814
  this.log.error(`[DEBUG] ${this.device.deviceType}: ${this.accessory.displayName}`, String(...log));
848
815
  }
849
816
  }
@@ -853,13 +820,17 @@ export abstract class deviceBase {
853
820
  if (await this.enablingDeviceLogging()) {
854
821
  if (this.deviceLogging === 'debug') {
855
822
  this.log.info(`[DEBUG] ${this.device.deviceType}: ${this.accessory.displayName}`, String(...log));
856
- } else {
823
+ } else if (this.deviceLogging === 'debugMode') {
857
824
  this.log.debug(`${this.device.deviceType}: ${this.accessory.displayName}`, String(...log));
858
825
  }
859
826
  }
860
827
  }
861
828
 
829
+ async loggingIsDebug(): Promise<boolean> {
830
+ return this.deviceLogging === 'debugMode' || this.deviceLogging === 'debug';
831
+ }
832
+
862
833
  async enablingDeviceLogging(): Promise<boolean> {
863
- return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
834
+ return this.deviceLogging === 'debugMode' || this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
864
835
  }
865
836
  }
package/src/device/fan.ts CHANGED
@@ -68,7 +68,7 @@ export class Fan extends deviceBase {
68
68
  // Initialize Fan Service
69
69
  accessory.context.Fan = accessory.context.Fan ?? {};
70
70
  this.Fan = {
71
- Name: accessory.context.Fan.Name ?? accessory.displayName,
71
+ Name: accessory.displayName,
72
72
  Service: accessory.getService(this.hap.Service.Fanv2) ?? accessory.addService(this.hap.Service.Fanv2) as Service,
73
73
  Active: accessory.context.Active ?? this.hap.Characteristic.Active.INACTIVE,
74
74
  SwingMode: accessory.context.SwingMode ?? this.hap.Characteristic.SwingMode.SWING_DISABLED,
@@ -103,7 +103,7 @@ export class Fan extends deviceBase {
103
103
  // Initialize Battery Service
104
104
  accessory.context.Battery = accessory.context.Battery ?? {};
105
105
  this.Battery = {
106
- Name: accessory.context.Battery.Name ?? accessory.displayName,
106
+ Name: `${accessory.displayName} Battery`,
107
107
  Service: accessory.getService(this.hap.Service.Battery) ?? accessory.addService(this.hap.Service.Battery) as Service,
108
108
  BatteryLevel: accessory.context.BatteryLevel ?? 100,
109
109
  StatusLowBattery: accessory.context.StatusLowBattery ?? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
@@ -136,7 +136,7 @@ export class Fan extends deviceBase {
136
136
  // Initialize LightBulb Service
137
137
  accessory.context.LightBulb = accessory.context.LightBulb ?? {};
138
138
  this.LightBulb = {
139
- Name: accessory.context.LightBulb.Name ?? accessory.displayName,
139
+ Name: `${accessory.displayName} Night Light`,
140
140
  Service: accessory.getService(this.hap.Service.Lightbulb) ?? accessory.addService(this.hap.Service.Lightbulb) as Service,
141
141
  On: accessory.context.On ?? false,
142
142
  Brightness: accessory.context.Brightness ?? 0,
package/src/device/hub.ts CHANGED
@@ -72,7 +72,7 @@ export class Hub extends deviceBase {
72
72
  } else {
73
73
  accessory.context.TemperatureSensor = accessory.context.TemperatureSensor ?? {};
74
74
  this.TemperatureSensor = {
75
- Name: accessory.context.TemperatureSensor.Name ?? `${accessory.displayName} Temperature Sensor`,
75
+ Name: `${accessory.displayName} Temperature Sensor`,
76
76
  Service: accessory.getService(this.hap.Service.TemperatureSensor) ?? this.accessory.addService(this.hap.Service.TemperatureSensor) as Service,
77
77
  CurrentTemperature: accessory.context.CurrentTemperature ?? 0,
78
78
  };
@@ -104,7 +104,7 @@ export class Hub extends deviceBase {
104
104
  } else {
105
105
  accessory.context.HumiditySensor = accessory.context.HumiditySensor ?? {};
106
106
  this.HumiditySensor = {
107
- Name: accessory.context.HumiditySensor.Name ?? `${accessory.displayName} Humidity Sensor`,
107
+ Name: `${accessory.displayName} Humidity Sensor`,
108
108
  Service: accessory.getService(this.hap.Service.HumiditySensor) ?? this.accessory.addService(this.hap.Service.HumiditySensor) as Service,
109
109
  CurrentRelativeHumidity: accessory.context.CurrentRelativeHumidity ?? 0,
110
110
  };
@@ -132,7 +132,7 @@ export class Hub extends deviceBase {
132
132
  } else {
133
133
  accessory.context.LightSensor = accessory.context.LightSensor ?? {};
134
134
  this.LightSensor = {
135
- Name: accessory.context.LightSensor.Name ?? `${accessory.displayName} Light Sensor`,
135
+ Name: `${accessory.displayName} Light Sensor`,
136
136
  Service: accessory.getService(this.hap.Service.LightSensor) ?? this.accessory.addService(this.hap.Service.LightSensor) as Service,
137
137
  CurrentAmbientLightLevel: accessory.context.CurrentAmbientLightLevel ?? 0.0001,
138
138
  };
@@ -68,7 +68,7 @@ export class Humidifier extends deviceBase {
68
68
  // Initialize the HumidifierDehumidifier Service
69
69
  accessory.context.HumidifierDehumidifier = accessory.context.HumidifierDehumidifier ?? {};
70
70
  this.HumidifierDehumidifier = {
71
- Name: accessory.context.HumidifierDehumidifier.Name ?? accessory.displayName,
71
+ Name: accessory.displayName,
72
72
  Service: accessory.getService(this.hap.Service.HumidifierDehumidifier)
73
73
  ?? accessory.addService(this.hap.Service.HumidifierDehumidifier) as Service,
74
74
  Active: accessory.context.Active ?? this.hap.Characteristic.Active.ACTIVE,
@@ -129,7 +129,7 @@ export class Humidifier extends deviceBase {
129
129
  } else {
130
130
  accessory.context.TemperatureSensor = accessory.context.TemperatureSensor ?? {};
131
131
  this.TemperatureSensor = {
132
- Name: accessory.context.TemperatureSensor.Name ?? `${accessory.displayName} Temperature Sensor`,
132
+ Name: `${accessory.displayName} Temperature Sensor`,
133
133
  Service: accessory.getService(this.hap.Service.TemperatureSensor) ?? this.accessory.addService(this.hap.Service.TemperatureSensor) as Service,
134
134
  CurrentTemperature: accessory.context.CurrentTemperature || 30,
135
135
  };
@@ -71,7 +71,7 @@ export class IOSensor extends deviceBase {
71
71
  // Initialize Battery Service
72
72
  accessory.context.Battery = accessory.context.Battery ?? {};
73
73
  this.Battery = {
74
- Name: accessory.context.Battery.Name ?? `${accessory.displayName} Battery`,
74
+ Name: `${accessory.displayName} Battery`,
75
75
  Service: accessory.getService(this.hap.Service.Battery) ?? accessory.addService(this.hap.Service.Battery) as Service,
76
76
  BatteryLevel: accessory.context.BatteryLevel ?? 100,
77
77
  StatusLowBattery: accessory.context.StatusLowBattery ?? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
@@ -104,7 +104,7 @@ export class IOSensor extends deviceBase {
104
104
  } else {
105
105
  accessory.context.TemperatureSensor = accessory.context.TemperatureSensor ?? {};
106
106
  this.TemperatureSensor = {
107
- Name: accessory.context.TemperatureSensor.Name ?? `${accessory.displayName} Temperature Sensor`,
107
+ Name: `${accessory.displayName} Temperature Sensor`,
108
108
  Service: accessory.getService(this.hap.Service.TemperatureSensor) ?? this.accessory.addService(this.hap.Service.TemperatureSensor) as Service,
109
109
  CurrentTemperature: accessory.context.CurrentTemperature ?? 30,
110
110
  };
@@ -136,7 +136,7 @@ export class IOSensor extends deviceBase {
136
136
  } else {
137
137
  accessory.context.HumiditySensor = accessory.context.HumiditySensor ?? {};
138
138
  this.HumiditySensor = {
139
- Name: accessory.context.HumiditySensor.Name ?? `${accessory.displayName} Humidity Sensor`,
139
+ Name: `${accessory.displayName} Humidity Sensor`,
140
140
  Service: accessory.getService(this.hap.Service.HumiditySensor) ?? this.accessory.addService(this.hap.Service.HumiditySensor) as Service,
141
141
  CurrentRelativeHumidity: accessory.context.CurrentRelativeHumidity ?? 50,
142
142
  };
@@ -69,7 +69,7 @@ export class StripLight extends deviceBase {
69
69
  // Initialize the LightBulb Service
70
70
  accessory.context.LightBulb = accessory.context.LightBulb ?? {};
71
71
  this.LightBulb = {
72
- Name: accessory.context.LightBulb.Name ?? accessory.displayName,
72
+ Name: accessory.displayName,
73
73
  Service: accessory.getService(this.hap.Service.Lightbulb) ?? accessory.addService(this.hap.Service.Lightbulb) as Service,
74
74
  On: accessory.context.On ?? false,
75
75
  Hue: accessory.context.Hue ?? 0,
@@ -71,7 +71,7 @@ export class Lock extends deviceBase {
71
71
  // Initialize LockMechanism Service
72
72
  accessory.context.LockMechanism = accessory.context.LockMechanism ?? {};
73
73
  this.LockMechanism = {
74
- Name: accessory.context.LockMechanism.Name ?? accessory.displayName,
74
+ Name: accessory.displayName,
75
75
  Service: accessory.getService(this.hap.Service.LockMechanism) ?? accessory.addService(this.hap.Service.LockMechanism) as Service,
76
76
  LockTargetState: accessory.context.LockTargetState ?? this.hap.Characteristic.LockTargetState.SECURED,
77
77
  LockCurrentState: accessory.context.LockCurrentState ?? this.hap.Characteristic.LockCurrentState.SECURED,
@@ -90,7 +90,7 @@ export class Lock extends deviceBase {
90
90
  // Initialize Battery property
91
91
  accessory.context.Battery = accessory.context.Battery ?? {};
92
92
  this.Battery = {
93
- Name: accessory.context.Battery.Name ?? `${accessory.displayName} Battery`,
93
+ Name: `${accessory.displayName} Battery`,
94
94
  Service: accessory.getService(this.hap.Service.Battery) ?? accessory.addService(this.hap.Service.Battery) as Service,
95
95
  BatteryLevel: accessory.context.BatteryLevel ?? 100,
96
96
  StatusLowBattery: accessory.context.StatusLowBattery ?? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
@@ -122,7 +122,7 @@ export class Lock extends deviceBase {
122
122
  } else {
123
123
  accessory.context.ContactSensor = accessory.context.ContactSensor ?? {};
124
124
  this.ContactSensor = {
125
- Name: accessory.context.ContactSensor.Name ?? `${accessory.displayName} Contact Sensor`,
125
+ Name: `${accessory.displayName} Contact Sensor`,
126
126
  Service: accessory.getService(this.hap.Service.ContactSensor) ?? this.accessory.addService(this.hap.Service.ContactSensor) as Service,
127
127
  ContactSensorState: accessory.context.ContactSensorState ?? this.hap.Characteristic.ContactSensorState.CONTACT_DETECTED,
128
128
  };
@@ -148,7 +148,7 @@ export class Lock extends deviceBase {
148
148
  } else {
149
149
  accessory.context.Switch = accessory.context.Switch ?? {};
150
150
  this.Switch = {
151
- Name: accessory.context.Switch.Name ?? `${accessory.displayName} Latch`,
151
+ Name: `${accessory.displayName} Latch`,
152
152
  Service: accessory.getService(this.hap.Service.Switch) ?? accessory.addService(this.hap.Service.Switch) as Service,
153
153
  On: accessory.context.On ?? false,
154
154
  };
@@ -66,7 +66,7 @@ export class Meter extends deviceBase {
66
66
  // Initialize Battery Service
67
67
  accessory.context.Battery = accessory.context.Battery ?? {};
68
68
  this.Battery = {
69
- Name: accessory.context.Battery.Name ?? `${accessory.displayName} Battery`,
69
+ Name: `${accessory.displayName} Battery`,
70
70
  Service: accessory.getService(this.hap.Service.Battery) ?? accessory.addService(this.hap.Service.Battery) as Service,
71
71
  BatteryLevel: accessory.context.BatteryLevel ?? 100,
72
72
  StatusLowBattery: accessory.context.StatusLowBattery ?? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
@@ -98,7 +98,7 @@ export class Meter extends deviceBase {
98
98
  } else {
99
99
  accessory.context.TemperatureSensor = accessory.context.TemperatureSensor ?? {};
100
100
  this.TemperatureSensor = {
101
- Name: accessory.context.TemperatureSensor.Name ?? `${accessory.displayName} Temperature Sensor`,
101
+ Name: `${accessory.displayName} Temperature Sensor`,
102
102
  Service: accessory.getService(this.hap.Service.TemperatureSensor) ?? this.accessory.addService(this.hap.Service.TemperatureSensor) as Service,
103
103
  CurrentTemperature: accessory.context.CurrentTemperature ?? 30,
104
104
  };
@@ -129,14 +129,14 @@ export class Meter extends deviceBase {
129
129
  } else {
130
130
  accessory.context.HumiditySensor = accessory.context.HumiditySensor ?? {};
131
131
  this.HumiditySensor = {
132
- Name: accessory.context.HumiditySensorName ?? `${accessory.displayName} Humidity Sensor`,
132
+ Name: `${accessory.displayName} Humidity Sensor`,
133
133
  Service: accessory.getService(this.hap.Service.HumiditySensor) ?? this.accessory.addService(this.hap.Service.HumiditySensor) as Service,
134
134
  CurrentRelativeHumidity: accessory.context.CurrentRelativeHumidity ?? 50,
135
135
  };
136
136
  accessory.context.HumiditySensor = this.HumiditySensor as object;
137
137
 
138
138
  // Initialize Humidity Sensor Characteristics
139
- this.HumiditySensor!.Service
139
+ this.HumiditySensor.Service
140
140
  .setCharacteristic(this.hap.Characteristic.Name, this.HumiditySensor.Name)
141
141
  .getCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity)
142
142
  .setProps({
@@ -71,7 +71,7 @@ export class MeterPlus extends deviceBase {
71
71
  // Initialize Battery Service
72
72
  accessory.context.Battery = accessory.context.Battery ?? {};
73
73
  this.Battery = {
74
- Name: accessory.context.Battery.Name ?? `${accessory.displayName} Battery`,
74
+ Name: `${accessory.displayName} Battery`,
75
75
  Service: accessory.getService(this.hap.Service.Battery) ?? accessory.addService(this.hap.Service.Battery) as Service,
76
76
  BatteryLevel: accessory.context.BatteryLevel ?? 100,
77
77
  StatusLowBattery: accessory.context.StatusLowBattery ?? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
@@ -103,7 +103,7 @@ export class MeterPlus extends deviceBase {
103
103
  } else {
104
104
  accessory.context.TemperatureSensor = accessory.context.TemperatureSensor ?? {};
105
105
  this.TemperatureSensor = {
106
- Name: accessory.context.TemperatureSensor.Name ?? `${accessory.displayName} Temperature Sensor`,
106
+ Name: `${accessory.displayName} Temperature Sensor`,
107
107
  Service: accessory.getService(this.hap.Service.TemperatureSensor) ?? this.accessory.addService(this.hap.Service.TemperatureSensor) as Service,
108
108
  CurrentTemperature: accessory.context.CurrentTemperature ?? 30,
109
109
  };
@@ -134,14 +134,14 @@ export class MeterPlus extends deviceBase {
134
134
  } else {
135
135
  accessory.context.HumiditySensor = accessory.context.HumiditySensor ?? {};
136
136
  this.HumiditySensor = {
137
- Name: accessory.context.HumiditySensor.Name ?? `${accessory.displayName} Humidity Sensor`,
137
+ Name: `${accessory.displayName} Humidity Sensor`,
138
138
  Service: accessory.getService(this.hap.Service.HumiditySensor) ?? this.accessory.addService(this.hap.Service.HumiditySensor) as Service,
139
139
  CurrentRelativeHumidity: accessory.context.CurrentRelativeHumidity ?? 50,
140
140
  };
141
141
  accessory.context.HumiditySensor = this.HumiditySensor as object;
142
142
 
143
143
  // Initialize Humidity Sensor Characteristics
144
- this.HumiditySensor!.Service
144
+ this.HumiditySensor.Service
145
145
  .setCharacteristic(this.hap.Characteristic.Name, this.HumiditySensor.Name)
146
146
  .getCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity)
147
147
  .setProps({
@@ -70,7 +70,7 @@ export class Motion extends deviceBase {
70
70
  // Initialize Motion Sensor property
71
71
  accessory.context.MotionSensor = accessory.context.MotionSensor ?? {};
72
72
  this.MotionSensor = {
73
- Name: accessory.context.MotionSensor.Name ?? `${accessory.displayName} Motion Sensor`,
73
+ Name: `${accessory.displayName} Motion Sensor`,
74
74
  Service: accessory.getService(this.hap.Service.MotionSensor) ?? accessory.addService(this.hap.Service.MotionSensor) as Service,
75
75
  MotionDetected: accessory.context.MotionDetected ?? false,
76
76
  };
@@ -78,18 +78,17 @@ export class Motion extends deviceBase {
78
78
 
79
79
  // Initialize Motion Sensor Characteristics
80
80
  this.MotionSensor.Service
81
- .setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
81
+ .setCharacteristic(this.hap.Characteristic.Name, this.MotionSensor.Name)
82
82
  .setCharacteristic(this.hap.Characteristic.StatusActive, true)
83
83
  .getCharacteristic(this.hap.Characteristic.MotionDetected)
84
84
  .onGet(() => {
85
85
  return this.MotionSensor.MotionDetected;
86
86
  });
87
- accessory.context.MotionSensorName = this.MotionSensor.Name;
88
87
 
89
88
  // Initialize Battery Service
90
89
  accessory.context.Battery = accessory.context.Battery ?? {};
91
90
  this.Battery = {
92
- Name: accessory.context.Battery.Name ?? `${accessory.displayName} Battery`,
91
+ Name: `${accessory.displayName} Battery`,
93
92
  Service: accessory.getService(this.hap.Service.Battery) ?? accessory.addService(this.hap.Service.Battery) as Service,
94
93
  BatteryLevel: accessory.context.BatteryLevel ?? 100,
95
94
  StatusLowBattery: accessory.context.StatusLowBattery ?? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
@@ -122,15 +121,15 @@ export class Motion extends deviceBase {
122
121
  } else {
123
122
  accessory.context.LightSensor = accessory.context.LightSensor ?? {};
124
123
  this.LightSensor = {
125
- Name: accessory.context.LightSensor.Name ?? `${accessory.displayName} Light Sensor`,
124
+ Name: `${accessory.displayName} Light Sensor`,
126
125
  Service: accessory.getService(this.hap.Service.LightSensor) ?? this.accessory.addService(this.hap.Service.LightSensor) as Service,
127
126
  CurrentAmbientLightLevel: accessory.context.CurrentAmbientLightLevel ?? 0.0001,
128
127
  };
129
128
  accessory.context.LightSensor = this.LightSensor as object;
130
129
 
131
130
  // Initialize LightSensor Characteristics
132
- this.LightSensor!.Service
133
- .setCharacteristic(this.hap.Characteristic.Name, this.LightSensor!.Name)
131
+ this.LightSensor.Service
132
+ .setCharacteristic(this.hap.Characteristic.Name, this.LightSensor.Name)
134
133
  .setCharacteristic(this.hap.Characteristic.StatusActive, true)
135
134
  .getCharacteristic(this.hap.Characteristic.CurrentAmbientLightLevel)
136
135
  .onGet(() => {
@@ -50,7 +50,7 @@ export class Plug extends deviceBase {
50
50
  // Initialize Outlet Service
51
51
  accessory.context.Outlet = accessory.context.Outlet ?? {};
52
52
  this.Outlet = {
53
- Name: accessory.context.Outlet.Name ?? accessory.displayName,
53
+ Name: accessory.displayName,
54
54
  Service: accessory.getService(this.hap.Service.Outlet) ?? accessory.addService(this.hap.Service.Outlet) as Service,
55
55
  On: accessory.context.On || false,
56
56
  };
@@ -58,7 +58,7 @@ export class Plug extends deviceBase {
58
58
 
59
59
  // Initialize Outlet Characteristics
60
60
  this.Outlet.Service
61
- .setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
61
+ .setCharacteristic(this.hap.Characteristic.Name, this.Outlet.Name)
62
62
  .getCharacteristic(this.hap.Characteristic.On)
63
63
  .onGet(() => {
64
64
  return this.Outlet.On;
@@ -64,7 +64,7 @@ export class RobotVacuumCleaner extends deviceBase {
64
64
  // Initialize Lightbulb Service
65
65
  accessory.context.LightBulb = accessory.context.LightBulb ?? {};
66
66
  this.LightBulb = {
67
- Name: accessory.context.LightBulb.Name ?? accessory.displayName,
67
+ Name: accessory.displayName,
68
68
  Service: accessory.getService(this.hap.Service.Lightbulb) ?? accessory.addService(this.hap.Service.Lightbulb) as Service,
69
69
  On: accessory.context.On ?? false,
70
70
  Brightness: accessory.context.Brightness ?? 0,
@@ -73,7 +73,7 @@ export class RobotVacuumCleaner extends deviceBase {
73
73
 
74
74
  // Initialize LightBulb Characteristics
75
75
  this.LightBulb.Service
76
- .setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
76
+ .setCharacteristic(this.hap.Characteristic.Name, this.LightBulb.Name)
77
77
  .getCharacteristic(this.hap.Characteristic.On)
78
78
  .onGet(() => {
79
79
  return this.LightBulb.On;
@@ -98,7 +98,7 @@ export class RobotVacuumCleaner extends deviceBase {
98
98
  // Initialize Battery Service
99
99
  accessory.context.Battery = accessory.context.Battery ?? {};
100
100
  this.Battery = {
101
- Name: accessory.context.Battery.Name ?? `${accessory.displayName} Battery`,
101
+ Name: `${accessory.displayName} Battery`,
102
102
  Service: accessory.getService(this.hap.Service.Battery) ?? accessory.addService(this.hap.Service.Battery) as Service,
103
103
  BatteryLevel: accessory.context.BatteryLevel ?? 100,
104
104
  StatusLowBattery: accessory.context.StatusLowBattery ?? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
@@ -65,7 +65,7 @@ export class WaterDetector extends deviceBase {
65
65
  // Initialize Battery Service
66
66
  accessory.context.Battery = accessory.context.Battery ?? {};
67
67
  this.Battery = {
68
- Name: accessory.context.Battery.Name ?? `${accessory.displayName} Battery`,
68
+ Name: `${accessory.displayName} Battery`,
69
69
  Service: accessory.getService(this.hap.Service.Battery) ?? accessory.addService(this.hap.Service.Battery) as Service,
70
70
  BatteryLevel: accessory.context.BatteryLevel ?? 100,
71
71
  StatusLowBattery: accessory.context.StatusLowBattery ?? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
@@ -100,7 +100,7 @@ export class WaterDetector extends deviceBase {
100
100
  } else {
101
101
  accessory.context.LeakSensor = accessory.context.LeakSensor ?? {};
102
102
  this.LeakSensor = {
103
- Name: accessory.context.LeakSensor.Name ?? `${accessory.displayName} Leak Sensor`,
103
+ Name: `${accessory.displayName} Leak Sensor`,
104
104
  Service: accessory.getService(this.hap.Service.LeakSensor) ?? this.accessory.addService(this.hap.Service.LeakSensor) as Service,
105
105
  StatusActive: accessory.context.StatusActive ?? false,
106
106
  LeakDetected: accessory.context.LeakDetected ?? this.hap.Characteristic.LeakDetected.LEAK_NOT_DETECTED,
@@ -67,7 +67,7 @@ export class AirConditioner extends irdeviceBase {
67
67
  // Initialize HeaterCooler Service
68
68
  accessory.context.HeaterCooler = accessory.context.HeaterCooler ?? {};
69
69
  this.HeaterCooler = {
70
- Name: accessory.context.HeaterCooler.Name ?? `${accessory.displayName} ${device.remoteType}`,
70
+ Name: accessory.displayName,
71
71
  Service: accessory.getService(this.hap.Service.HeaterCooler) ?? accessory.addService(this.hap.Service.HeaterCooler) as Service,
72
72
  Active: accessory.context.Active ?? this.hap.Characteristic.Active.INACTIVE,
73
73
  CurrentHeaterCoolerState: accessory.context.CurrentHeaterCoolerState ?? this.hap.Characteristic.CurrentHeaterCoolerState.IDLE,
@@ -152,7 +152,7 @@ export class AirConditioner extends irdeviceBase {
152
152
  this.meter = this.platform.accessories.find((accessory) => accessory.UUID === meterUuid);
153
153
  accessory.context.HumiditySensor = accessory.context.HumiditySensor ?? {};
154
154
  this.HumiditySensor = {
155
- Name: accessory.context.HumiditySensor ?? this.meter!.displayName,
155
+ Name: this.meter!.displayName,
156
156
  Service: this.meter!.getService(this.hap.Service.HumiditySensor) ?? this.meter!.addService(this.hap.Service.HumiditySensor) as Service,
157
157
  CurrentRelativeHumidity: this.meter!.context.CurrentRelativeHumidity || 0,
158
158
  };
@@ -164,8 +164,9 @@ export class AirConditioner extends irdeviceBase {
164
164
  this.meter = this.platform.accessories.find((accessory) => accessory.UUID === meterUuid);
165
165
  }
166
166
 
167
- if (this.meter) {
168
- this.HumiditySensor!.Service
167
+ if (this.meter && this.HumiditySensor) {
168
+ this.HumiditySensor.Service
169
+ .setCharacteristic(this.hap.Characteristic.Name, this.HumiditySensor.Name)
169
170
  .getCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity)
170
171
  .onGet(async () => {
171
172
  return await this.CurrentRelativeHumidityGet();
@@ -60,7 +60,7 @@ export class AirPurifier extends irdeviceBase {
60
60
  // Initialize AirPurifier Service
61
61
  accessory.context.AirPurifier = accessory.context.AirPurifier ?? {};
62
62
  this.AirPurifier = {
63
- Name: accessory.context.AirPurifier.Name ?? `${accessory.displayName} Air Purifier`,
63
+ Name: accessory.displayName,
64
64
  Service: accessory.getService(this.hap.Service.AirPurifier) ?? accessory.addService(this.hap.Service.AirPurifier) as Service,
65
65
  Active: accessory.context.Active ?? this.hap.Characteristic.Active.INACTIVE,
66
66
  RotationSpeed: accessory.context.RotationSpeed ?? 0,
@@ -94,7 +94,7 @@ export class AirPurifier extends irdeviceBase {
94
94
  // Initialize TemperatureSensor Service
95
95
  accessory.context.TemperatureSensor = accessory.context.TemperatureSensor ?? {};
96
96
  this.TemperatureSensor = {
97
- Name: accessory.context.TemperatureSensor.Name ?? `${accessory.displayName} Temperature Sensor`,
97
+ Name: `${accessory.displayName} Temperature Sensor`,
98
98
  Service: accessory.getService(this.hap.Service.TemperatureSensor) ?? accessory.addService(this.hap.Service.TemperatureSensor) as Service,
99
99
  CurrentTemperature: accessory.context.CurrentTemperature || 24,
100
100
  };
@@ -34,7 +34,7 @@ export class Camera extends irdeviceBase {
34
34
  // Initialize Switch Service
35
35
  accessory.context.Switch = accessory.context.Switch ?? {};
36
36
  this.Switch = {
37
- Name: accessory.context.Switch.Name ?? `${accessory.displayName} Camera`,
37
+ Name: accessory.displayName,
38
38
  Service: accessory.getService(this.hap.Service.Switch) ?? accessory.addService(this.hap.Service.Switch) as Service,
39
39
  On: accessory.context.On ?? false,
40
40
  };
@@ -37,7 +37,7 @@ export class IRFan extends irdeviceBase {
37
37
  // Initialize Switch Service
38
38
  accessory.context.Fan = accessory.context.Fan ?? {};
39
39
  this.Fan = {
40
- Name: accessory.context.Fan.Name ?? `${accessory.displayName} Fan`,
40
+ Name: accessory.displayName,
41
41
  Service: accessory.getService(this.hap.Service.Fanv2) ?? accessory.addService(this.hap.Service.Fanv2) as Service,
42
42
  Active: accessory.context.Active ?? this.hap.Characteristic.Active.INACTIVE,
43
43
  SwingMode: accessory.context.SwingMode ?? this.hap.Characteristic.SwingMode.SWING_DISABLED,