@switchbot/homebridge-switchbot 3.6.1-beta.14 → 3.6.1-beta.16

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 (126) hide show
  1. package/dist/device/blindtilt.d.ts.map +1 -1
  2. package/dist/device/blindtilt.js +3 -12
  3. package/dist/device/blindtilt.js.map +1 -1
  4. package/dist/device/bot.d.ts.map +1 -1
  5. package/dist/device/bot.js +11 -44
  6. package/dist/device/bot.js.map +1 -1
  7. package/dist/device/ceilinglight.d.ts.map +1 -1
  8. package/dist/device/ceilinglight.js +1 -4
  9. package/dist/device/ceilinglight.js.map +1 -1
  10. package/dist/device/colorbulb.d.ts.map +1 -1
  11. package/dist/device/colorbulb.js +1 -4
  12. package/dist/device/colorbulb.js.map +1 -1
  13. package/dist/device/contact.d.ts.map +1 -1
  14. package/dist/device/contact.js +4 -16
  15. package/dist/device/contact.js.map +1 -1
  16. package/dist/device/curtain.d.ts.map +1 -1
  17. package/dist/device/curtain.js +3 -12
  18. package/dist/device/curtain.js.map +1 -1
  19. package/dist/device/device.d.ts +1 -9
  20. package/dist/device/device.d.ts.map +1 -1
  21. package/dist/device/device.js +12 -43
  22. package/dist/device/device.js.map +1 -1
  23. package/dist/device/fan.d.ts.map +1 -1
  24. package/dist/device/fan.js +3 -12
  25. package/dist/device/fan.js.map +1 -1
  26. package/dist/device/hub.d.ts.map +1 -1
  27. package/dist/device/hub.js +3 -12
  28. package/dist/device/hub.js.map +1 -1
  29. package/dist/device/humidifier.d.ts.map +1 -1
  30. package/dist/device/humidifier.js +2 -8
  31. package/dist/device/humidifier.js.map +1 -1
  32. package/dist/device/iosensor.d.ts.map +1 -1
  33. package/dist/device/iosensor.js +3 -12
  34. package/dist/device/iosensor.js.map +1 -1
  35. package/dist/device/lightstrip.d.ts.map +1 -1
  36. package/dist/device/lightstrip.js +1 -4
  37. package/dist/device/lightstrip.js.map +1 -1
  38. package/dist/device/lock.d.ts.map +1 -1
  39. package/dist/device/lock.js +4 -16
  40. package/dist/device/lock.js.map +1 -1
  41. package/dist/device/meter.d.ts.map +1 -1
  42. package/dist/device/meter.js +3 -12
  43. package/dist/device/meter.js.map +1 -1
  44. package/dist/device/meterplus.d.ts.map +1 -1
  45. package/dist/device/meterplus.js +3 -12
  46. package/dist/device/meterplus.js.map +1 -1
  47. package/dist/device/motion.d.ts.map +1 -1
  48. package/dist/device/motion.js +3 -13
  49. package/dist/device/motion.js.map +1 -1
  50. package/dist/device/plug.d.ts.map +1 -1
  51. package/dist/device/plug.js +1 -4
  52. package/dist/device/plug.js.map +1 -1
  53. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  54. package/dist/device/robotvacuumcleaner.js +2 -8
  55. package/dist/device/robotvacuumcleaner.js.map +1 -1
  56. package/dist/device/waterdetector.d.ts.map +1 -1
  57. package/dist/device/waterdetector.js +2 -8
  58. package/dist/device/waterdetector.js.map +1 -1
  59. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  60. package/dist/irdevice/airconditioner.js +2 -8
  61. package/dist/irdevice/airconditioner.js.map +1 -1
  62. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  63. package/dist/irdevice/airpurifier.js +2 -8
  64. package/dist/irdevice/airpurifier.js.map +1 -1
  65. package/dist/irdevice/camera.d.ts.map +1 -1
  66. package/dist/irdevice/camera.js +1 -4
  67. package/dist/irdevice/camera.js.map +1 -1
  68. package/dist/irdevice/fan.d.ts.map +1 -1
  69. package/dist/irdevice/fan.js +1 -4
  70. package/dist/irdevice/fan.js.map +1 -1
  71. package/dist/irdevice/irdevice.d.ts +1 -9
  72. package/dist/irdevice/irdevice.d.ts.map +1 -1
  73. package/dist/irdevice/irdevice.js +12 -43
  74. package/dist/irdevice/irdevice.js.map +1 -1
  75. package/dist/irdevice/light.d.ts.map +1 -1
  76. package/dist/irdevice/light.js +3 -12
  77. package/dist/irdevice/light.js.map +1 -1
  78. package/dist/irdevice/other.d.ts.map +1 -1
  79. package/dist/irdevice/other.js +20 -50
  80. package/dist/irdevice/other.js.map +1 -1
  81. package/dist/irdevice/tv.d.ts.map +1 -1
  82. package/dist/irdevice/tv.js +3 -12
  83. package/dist/irdevice/tv.js.map +1 -1
  84. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  85. package/dist/irdevice/vacuumcleaner.js +1 -4
  86. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  87. package/dist/irdevice/waterheater.js +1 -1
  88. package/dist/irdevice/waterheater.js.map +1 -1
  89. package/dist/platform.d.ts +9 -0
  90. package/dist/platform.d.ts.map +1 -1
  91. package/dist/platform.js +310 -91
  92. package/dist/platform.js.map +1 -1
  93. package/dist/settings.d.ts +1 -1
  94. package/dist/settings.d.ts.map +1 -1
  95. package/package.json +4 -4
  96. package/src/device/blindtilt.ts +3 -15
  97. package/src/device/bot.ts +11 -55
  98. package/src/device/ceilinglight.ts +1 -5
  99. package/src/device/colorbulb.ts +1 -5
  100. package/src/device/contact.ts +4 -20
  101. package/src/device/curtain.ts +3 -15
  102. package/src/device/device.ts +13 -49
  103. package/src/device/fan.ts +3 -15
  104. package/src/device/hub.ts +3 -15
  105. package/src/device/humidifier.ts +2 -10
  106. package/src/device/iosensor.ts +3 -15
  107. package/src/device/lightstrip.ts +1 -5
  108. package/src/device/lock.ts +4 -20
  109. package/src/device/meter.ts +4 -16
  110. package/src/device/meterplus.ts +4 -16
  111. package/src/device/motion.ts +4 -17
  112. package/src/device/plug.ts +1 -5
  113. package/src/device/robotvacuumcleaner.ts +2 -10
  114. package/src/device/waterdetector.ts +2 -10
  115. package/src/irdevice/airconditioner.ts +2 -10
  116. package/src/irdevice/airpurifier.ts +2 -10
  117. package/src/irdevice/camera.ts +1 -5
  118. package/src/irdevice/fan.ts +1 -5
  119. package/src/irdevice/irdevice.ts +13 -49
  120. package/src/irdevice/light.ts +3 -15
  121. package/src/irdevice/other.ts +20 -60
  122. package/src/irdevice/tv.ts +3 -15
  123. package/src/irdevice/vacuumcleaner.ts +1 -5
  124. package/src/irdevice/waterheater.ts +1 -1
  125. package/src/platform.ts +315 -90
  126. package/src/settings.ts +1 -1
@@ -70,12 +70,8 @@ export class IOSensor extends deviceBase {
70
70
 
71
71
  // Initialize Battery Service
72
72
  accessory.context.Battery = accessory.context.Battery ?? {};
73
- if (accessory.context.Battery.Name) {
74
- accessory.context.Battery.Name = this.validateAndCleanString(accessory.context.Battery.Name,
75
- 'Battery Name', accessory.context.Battery.Name);
76
- }
77
73
  this.Battery = {
78
- Name: accessory.context.Battery.Name ?? `${accessory.displayName} Battery`,
74
+ Name: `${accessory.displayName} Battery`,
79
75
  Service: accessory.getService(this.hap.Service.Battery) ?? accessory.addService(this.hap.Service.Battery) as Service,
80
76
  BatteryLevel: accessory.context.BatteryLevel ?? 100,
81
77
  StatusLowBattery: accessory.context.StatusLowBattery ?? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
@@ -107,12 +103,8 @@ export class IOSensor extends deviceBase {
107
103
  }
108
104
  } else {
109
105
  accessory.context.TemperatureSensor = accessory.context.TemperatureSensor ?? {};
110
- if (accessory.context.TemperatureSensor.Name) {
111
- accessory.context.TemperatureSensor.Name = this.validateAndCleanString(accessory.context.TemperatureSensor.Name,
112
- 'TemperatureSensor Name', accessory.context.TemperatureSensor.Name);
113
- }
114
106
  this.TemperatureSensor = {
115
- Name: accessory.context.TemperatureSensor.Name ?? `${accessory.displayName} Temperature Sensor`,
107
+ Name: `${accessory.displayName} Temperature Sensor`,
116
108
  Service: accessory.getService(this.hap.Service.TemperatureSensor) ?? this.accessory.addService(this.hap.Service.TemperatureSensor) as Service,
117
109
  CurrentTemperature: accessory.context.CurrentTemperature ?? 30,
118
110
  };
@@ -143,12 +135,8 @@ export class IOSensor extends deviceBase {
143
135
  }
144
136
  } else {
145
137
  accessory.context.HumiditySensor = accessory.context.HumiditySensor ?? {};
146
- if (accessory.context.HumiditySensor.Name) {
147
- accessory.context.HumiditySensor.Name = this.validateAndCleanString(accessory.context.HumiditySensor.Name,
148
- 'HumiditySensor Name', accessory.context.HumiditySensor.Name);
149
- }
150
138
  this.HumiditySensor = {
151
- Name: accessory.context.HumiditySensor.Name ?? `${accessory.displayName} Humidity Sensor`,
139
+ Name: `${accessory.displayName} Humidity Sensor`,
152
140
  Service: accessory.getService(this.hap.Service.HumiditySensor) ?? this.accessory.addService(this.hap.Service.HumiditySensor) as Service,
153
141
  CurrentRelativeHumidity: accessory.context.CurrentRelativeHumidity ?? 50,
154
142
  };
@@ -68,12 +68,8 @@ export class StripLight extends deviceBase {
68
68
 
69
69
  // Initialize the LightBulb Service
70
70
  accessory.context.LightBulb = accessory.context.LightBulb ?? {};
71
- if (accessory.context.LightBulb.Name) {
72
- accessory.context.LightBulb.Name = this.validateAndCleanString(accessory.context.LightBulb.Name,
73
- 'LightBulb Name', accessory.context.LightBulb.Name);
74
- }
75
71
  this.LightBulb = {
76
- Name: accessory.context.LightBulb.Name ?? accessory.displayName,
72
+ Name: accessory.displayName,
77
73
  Service: accessory.getService(this.hap.Service.Lightbulb) ?? accessory.addService(this.hap.Service.Lightbulb) as Service,
78
74
  On: accessory.context.On ?? false,
79
75
  Hue: accessory.context.Hue ?? 0,
@@ -70,12 +70,8 @@ export class Lock extends deviceBase {
70
70
 
71
71
  // Initialize LockMechanism Service
72
72
  accessory.context.LockMechanism = accessory.context.LockMechanism ?? {};
73
- if (accessory.context.LockMechanism.Name) {
74
- accessory.context.LockMechanism.Name = this.validateAndCleanString(accessory.context.LockMechanism.Name,
75
- 'LockMechanism Name', accessory.context.LockMechanism.Name);
76
- }
77
73
  this.LockMechanism = {
78
- Name: accessory.context.LockMechanism.Name ?? accessory.displayName,
74
+ Name: accessory.displayName,
79
75
  Service: accessory.getService(this.hap.Service.LockMechanism) ?? accessory.addService(this.hap.Service.LockMechanism) as Service,
80
76
  LockTargetState: accessory.context.LockTargetState ?? this.hap.Characteristic.LockTargetState.SECURED,
81
77
  LockCurrentState: accessory.context.LockCurrentState ?? this.hap.Characteristic.LockCurrentState.SECURED,
@@ -93,12 +89,8 @@ export class Lock extends deviceBase {
93
89
 
94
90
  // Initialize Battery property
95
91
  accessory.context.Battery = accessory.context.Battery ?? {};
96
- if (accessory.context.Battery.Name) {
97
- accessory.context.Battery.Name = this.validateAndCleanString(accessory.context.Battery.Name,
98
- 'Battery Name', accessory.context.Battery.Name);
99
- }
100
92
  this.Battery = {
101
- Name: accessory.context.Battery.Name ?? `${accessory.displayName} Battery`,
93
+ Name: `${accessory.displayName} Battery`,
102
94
  Service: accessory.getService(this.hap.Service.Battery) ?? accessory.addService(this.hap.Service.Battery) as Service,
103
95
  BatteryLevel: accessory.context.BatteryLevel ?? 100,
104
96
  StatusLowBattery: accessory.context.StatusLowBattery ?? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
@@ -129,12 +121,8 @@ export class Lock extends deviceBase {
129
121
  }
130
122
  } else {
131
123
  accessory.context.ContactSensor = accessory.context.ContactSensor ?? {};
132
- if (accessory.context.ContactSensor.Name) {
133
- accessory.context.ContactSensor.Name = this.validateAndCleanString(accessory.context.ContactSensor.Name,
134
- 'ContactSensor Name', accessory.context.ContactSensor.Name);
135
- }
136
124
  this.ContactSensor = {
137
- Name: accessory.context.ContactSensor.Name ?? `${accessory.displayName} Contact Sensor`,
125
+ Name: `${accessory.displayName} Contact Sensor`,
138
126
  Service: accessory.getService(this.hap.Service.ContactSensor) ?? this.accessory.addService(this.hap.Service.ContactSensor) as Service,
139
127
  ContactSensorState: accessory.context.ContactSensorState ?? this.hap.Characteristic.ContactSensorState.CONTACT_DETECTED,
140
128
  };
@@ -159,12 +147,8 @@ export class Lock extends deviceBase {
159
147
  }
160
148
  } else {
161
149
  accessory.context.Switch = accessory.context.Switch ?? {};
162
- if (accessory.context.Switch.Name) {
163
- accessory.context.Switch.Name = this.validateAndCleanString(accessory.context.Switch.Name,
164
- 'Switch Name', accessory.context.Switch.Name);
165
- }
166
150
  this.Switch = {
167
- Name: accessory.context.Switch.Name ?? `${accessory.displayName} Latch`,
151
+ Name: `${accessory.displayName} Latch`,
168
152
  Service: accessory.getService(this.hap.Service.Switch) ?? accessory.addService(this.hap.Service.Switch) as Service,
169
153
  On: accessory.context.On ?? false,
170
154
  };
@@ -65,12 +65,8 @@ export class Meter extends deviceBase {
65
65
 
66
66
  // Initialize Battery Service
67
67
  accessory.context.Battery = accessory.context.Battery ?? {};
68
- if (accessory.context.Battery.Name) {
69
- accessory.context.Battery.Name = this.validateAndCleanString(accessory.context.Battery.Name,
70
- 'Battery Name', accessory.context.Battery.Name);
71
- }
72
68
  this.Battery = {
73
- Name: accessory.context.Battery.Name ?? `${accessory.displayName} Battery`,
69
+ Name: `${accessory.displayName} Battery`,
74
70
  Service: accessory.getService(this.hap.Service.Battery) ?? accessory.addService(this.hap.Service.Battery) as Service,
75
71
  BatteryLevel: accessory.context.BatteryLevel ?? 100,
76
72
  StatusLowBattery: accessory.context.StatusLowBattery ?? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
@@ -101,12 +97,8 @@ export class Meter extends deviceBase {
101
97
  }
102
98
  } else {
103
99
  accessory.context.TemperatureSensor = accessory.context.TemperatureSensor ?? {};
104
- if (accessory.context.TemperatureSensor.Name) {
105
- accessory.context.TemperatureSensor.Name = this.validateAndCleanString(accessory.context.TemperatureSensor.Name,
106
- 'TemperatureSensor Name', accessory.context.TemperatureSensor.Name);
107
- }
108
100
  this.TemperatureSensor = {
109
- Name: accessory.context.TemperatureSensor.Name ?? `${accessory.displayName} Temperature Sensor`,
101
+ Name: `${accessory.displayName} Temperature Sensor`,
110
102
  Service: accessory.getService(this.hap.Service.TemperatureSensor) ?? this.accessory.addService(this.hap.Service.TemperatureSensor) as Service,
111
103
  CurrentTemperature: accessory.context.CurrentTemperature ?? 30,
112
104
  };
@@ -136,19 +128,15 @@ export class Meter extends deviceBase {
136
128
  }
137
129
  } else {
138
130
  accessory.context.HumiditySensor = accessory.context.HumiditySensor ?? {};
139
- if (accessory.context.HumiditySensor.Name) {
140
- accessory.context.HumiditySensor.Name = this.validateAndCleanString(accessory.context.HumiditySensor.Name,
141
- 'HumiditySensor Name', accessory.context.HumiditySensor.Name);
142
- }
143
131
  this.HumiditySensor = {
144
- Name: accessory.context.HumiditySensorName ?? `${accessory.displayName} Humidity Sensor`,
132
+ Name: `${accessory.displayName} Humidity Sensor`,
145
133
  Service: accessory.getService(this.hap.Service.HumiditySensor) ?? this.accessory.addService(this.hap.Service.HumiditySensor) as Service,
146
134
  CurrentRelativeHumidity: accessory.context.CurrentRelativeHumidity ?? 50,
147
135
  };
148
136
  accessory.context.HumiditySensor = this.HumiditySensor as object;
149
137
 
150
138
  // Initialize Humidity Sensor Characteristics
151
- this.HumiditySensor!.Service
139
+ this.HumiditySensor.Service
152
140
  .setCharacteristic(this.hap.Characteristic.Name, this.HumiditySensor.Name)
153
141
  .getCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity)
154
142
  .setProps({
@@ -70,12 +70,8 @@ export class MeterPlus extends deviceBase {
70
70
 
71
71
  // Initialize Battery Service
72
72
  accessory.context.Battery = accessory.context.Battery ?? {};
73
- if (accessory.context.Battery.Name) {
74
- accessory.context.Battery.Name = this.validateAndCleanString(accessory.context.Battery.Name,
75
- 'Battery Name', accessory.context.Battery.Name);
76
- }
77
73
  this.Battery = {
78
- Name: accessory.context.Battery.Name ?? `${accessory.displayName} Battery`,
74
+ Name: `${accessory.displayName} Battery`,
79
75
  Service: accessory.getService(this.hap.Service.Battery) ?? accessory.addService(this.hap.Service.Battery) as Service,
80
76
  BatteryLevel: accessory.context.BatteryLevel ?? 100,
81
77
  StatusLowBattery: accessory.context.StatusLowBattery ?? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
@@ -106,12 +102,8 @@ export class MeterPlus extends deviceBase {
106
102
  }
107
103
  } else {
108
104
  accessory.context.TemperatureSensor = accessory.context.TemperatureSensor ?? {};
109
- if (accessory.context.TemperatureSensor.Name) {
110
- accessory.context.TemperatureSensor.Name = this.validateAndCleanString(accessory.context.TemperatureSensor.Name,
111
- 'TemperatureSensor Name', accessory.context.TemperatureSensor.Name);
112
- }
113
105
  this.TemperatureSensor = {
114
- Name: accessory.context.TemperatureSensor.Name ?? `${accessory.displayName} Temperature Sensor`,
106
+ Name: `${accessory.displayName} Temperature Sensor`,
115
107
  Service: accessory.getService(this.hap.Service.TemperatureSensor) ?? this.accessory.addService(this.hap.Service.TemperatureSensor) as Service,
116
108
  CurrentTemperature: accessory.context.CurrentTemperature ?? 30,
117
109
  };
@@ -141,19 +133,15 @@ export class MeterPlus extends deviceBase {
141
133
  }
142
134
  } else {
143
135
  accessory.context.HumiditySensor = accessory.context.HumiditySensor ?? {};
144
- if (accessory.context.HumiditySensor.Name) {
145
- accessory.context.HumiditySensor.Name = this.validateAndCleanString(accessory.context.HumiditySensor.Name,
146
- 'HumiditySensor Name', accessory.context.HumiditySensor.Name);
147
- }
148
136
  this.HumiditySensor = {
149
- Name: accessory.context.HumiditySensor.Name ?? `${accessory.displayName} Humidity Sensor`,
137
+ Name: `${accessory.displayName} Humidity Sensor`,
150
138
  Service: accessory.getService(this.hap.Service.HumiditySensor) ?? this.accessory.addService(this.hap.Service.HumiditySensor) as Service,
151
139
  CurrentRelativeHumidity: accessory.context.CurrentRelativeHumidity ?? 50,
152
140
  };
153
141
  accessory.context.HumiditySensor = this.HumiditySensor as object;
154
142
 
155
143
  // Initialize Humidity Sensor Characteristics
156
- this.HumiditySensor!.Service
144
+ this.HumiditySensor.Service
157
145
  .setCharacteristic(this.hap.Characteristic.Name, this.HumiditySensor.Name)
158
146
  .getCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity)
159
147
  .setProps({
@@ -69,12 +69,8 @@ export class Motion extends deviceBase {
69
69
 
70
70
  // Initialize Motion Sensor property
71
71
  accessory.context.MotionSensor = accessory.context.MotionSensor ?? {};
72
- if (accessory.context.MotionSensor.Name) {
73
- accessory.context.MotionSensor.Name = this.validateAndCleanString(accessory.context.MotionSensor.Name,
74
- 'MotionSensor Name', accessory.context.MotionSensor.Name);
75
- }
76
72
  this.MotionSensor = {
77
- Name: accessory.context.MotionSensor.Name ?? `${accessory.displayName} Motion Sensor`,
73
+ Name: `${accessory.displayName} Motion Sensor`,
78
74
  Service: accessory.getService(this.hap.Service.MotionSensor) ?? accessory.addService(this.hap.Service.MotionSensor) as Service,
79
75
  MotionDetected: accessory.context.MotionDetected ?? false,
80
76
  };
@@ -88,16 +84,11 @@ export class Motion extends deviceBase {
88
84
  .onGet(() => {
89
85
  return this.MotionSensor.MotionDetected;
90
86
  });
91
- accessory.context.MotionSensorName = this.MotionSensor.Name;
92
87
 
93
88
  // Initialize Battery Service
94
89
  accessory.context.Battery = accessory.context.Battery ?? {};
95
- if (accessory.context.Battery.Name) {
96
- accessory.context.Battery.Name = this.validateAndCleanString(accessory.context.Battery.Name,
97
- 'Battery Name', accessory.context.Battery.Name);
98
- }
99
90
  this.Battery = {
100
- Name: accessory.context.Battery.Name ?? `${accessory.displayName} Battery`,
91
+ Name: `${accessory.displayName} Battery`,
101
92
  Service: accessory.getService(this.hap.Service.Battery) ?? accessory.addService(this.hap.Service.Battery) as Service,
102
93
  BatteryLevel: accessory.context.BatteryLevel ?? 100,
103
94
  StatusLowBattery: accessory.context.StatusLowBattery ?? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
@@ -129,19 +120,15 @@ export class Motion extends deviceBase {
129
120
  }
130
121
  } else {
131
122
  accessory.context.LightSensor = accessory.context.LightSensor ?? {};
132
- if (accessory.context.LightSensor.Name) {
133
- accessory.context.LightSensor.Name = this.validateAndCleanString(accessory.context.LightSensor.Name,
134
- 'LightSensor Name', accessory.context.LightSensor.Name);
135
- }
136
123
  this.LightSensor = {
137
- Name: accessory.context.LightSensor.Name ?? `${accessory.displayName} Light Sensor`,
124
+ Name: `${accessory.displayName} Light Sensor`,
138
125
  Service: accessory.getService(this.hap.Service.LightSensor) ?? this.accessory.addService(this.hap.Service.LightSensor) as Service,
139
126
  CurrentAmbientLightLevel: accessory.context.CurrentAmbientLightLevel ?? 0.0001,
140
127
  };
141
128
  accessory.context.LightSensor = this.LightSensor as object;
142
129
 
143
130
  // Initialize LightSensor Characteristics
144
- this.LightSensor!.Service
131
+ this.LightSensor.Service
145
132
  .setCharacteristic(this.hap.Characteristic.Name, this.LightSensor.Name)
146
133
  .setCharacteristic(this.hap.Characteristic.StatusActive, true)
147
134
  .getCharacteristic(this.hap.Characteristic.CurrentAmbientLightLevel)
@@ -49,12 +49,8 @@ export class Plug extends deviceBase {
49
49
 
50
50
  // Initialize Outlet Service
51
51
  accessory.context.Outlet = accessory.context.Outlet ?? {};
52
- if (accessory.context.Outlet.Name) {
53
- accessory.context.Outlet.Name = this.validateAndCleanString(accessory.context.Outlet.Name,
54
- 'Outlet Name', accessory.context.Outlet.Name);
55
- }
56
52
  this.Outlet = {
57
- Name: accessory.context.Outlet.Name ?? accessory.displayName,
53
+ Name: accessory.displayName,
58
54
  Service: accessory.getService(this.hap.Service.Outlet) ?? accessory.addService(this.hap.Service.Outlet) as Service,
59
55
  On: accessory.context.On || false,
60
56
  };
@@ -63,12 +63,8 @@ export class RobotVacuumCleaner extends deviceBase {
63
63
 
64
64
  // Initialize Lightbulb Service
65
65
  accessory.context.LightBulb = accessory.context.LightBulb ?? {};
66
- if (accessory.context.LightBulb.Name) {
67
- accessory.context.LightBulb.Name = this.validateAndCleanString(accessory.context.LightBulb.Name,
68
- 'LightBulb Name', accessory.context.LightBulb.Name);
69
- }
70
66
  this.LightBulb = {
71
- Name: accessory.context.LightBulb.Name ?? accessory.displayName,
67
+ Name: accessory.displayName,
72
68
  Service: accessory.getService(this.hap.Service.Lightbulb) ?? accessory.addService(this.hap.Service.Lightbulb) as Service,
73
69
  On: accessory.context.On ?? false,
74
70
  Brightness: accessory.context.Brightness ?? 0,
@@ -101,12 +97,8 @@ export class RobotVacuumCleaner extends deviceBase {
101
97
 
102
98
  // Initialize Battery Service
103
99
  accessory.context.Battery = accessory.context.Battery ?? {};
104
- if (accessory.context.Battery.Name) {
105
- accessory.context.Battery.Name = this.validateAndCleanString(accessory.context.Battery.Name,
106
- 'Battery Name', accessory.context.Battery.Name);
107
- }
108
100
  this.Battery = {
109
- Name: accessory.context.Battery.Name ?? `${accessory.displayName} Battery`,
101
+ Name: `${accessory.displayName} Battery`,
110
102
  Service: accessory.getService(this.hap.Service.Battery) ?? accessory.addService(this.hap.Service.Battery) as Service,
111
103
  BatteryLevel: accessory.context.BatteryLevel ?? 100,
112
104
  StatusLowBattery: accessory.context.StatusLowBattery ?? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
@@ -64,12 +64,8 @@ export class WaterDetector extends deviceBase {
64
64
 
65
65
  // Initialize Battery Service
66
66
  accessory.context.Battery = accessory.context.Battery ?? {};
67
- if (accessory.context.Battery.Name) {
68
- accessory.context.Battery.Name = this.validateAndCleanString(accessory.context.Battery.Name,
69
- 'Battery Name', accessory.context.Battery.Name);
70
- }
71
67
  this.Battery = {
72
- Name: accessory.context.Battery.Name ?? `${accessory.displayName} Battery`,
68
+ Name: `${accessory.displayName} Battery`,
73
69
  Service: accessory.getService(this.hap.Service.Battery) ?? accessory.addService(this.hap.Service.Battery) as Service,
74
70
  BatteryLevel: accessory.context.BatteryLevel ?? 100,
75
71
  StatusLowBattery: accessory.context.StatusLowBattery ?? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
@@ -103,12 +99,8 @@ export class WaterDetector extends deviceBase {
103
99
  }
104
100
  } else {
105
101
  accessory.context.LeakSensor = accessory.context.LeakSensor ?? {};
106
- if (accessory.context.LeakSensor.Name) {
107
- accessory.context.LeakSensor.Name = this.validateAndCleanString(accessory.context.LeakSensor.Name,
108
- 'LeakSensor Name', accessory.context.LeakSensor.Name);
109
- }
110
102
  this.LeakSensor = {
111
- Name: accessory.context.LeakSensor.Name ?? `${accessory.displayName} Leak Sensor`,
103
+ Name: `${accessory.displayName} Leak Sensor`,
112
104
  Service: accessory.getService(this.hap.Service.LeakSensor) ?? this.accessory.addService(this.hap.Service.LeakSensor) as Service,
113
105
  StatusActive: accessory.context.StatusActive ?? false,
114
106
  LeakDetected: accessory.context.LeakDetected ?? this.hap.Characteristic.LeakDetected.LEAK_NOT_DETECTED,
@@ -66,12 +66,8 @@ export class AirConditioner extends irdeviceBase {
66
66
 
67
67
  // Initialize HeaterCooler Service
68
68
  accessory.context.HeaterCooler = accessory.context.HeaterCooler ?? {};
69
- if (accessory.context.HeaterCooler.Name) {
70
- accessory.context.HeaterCooler.Name = this.validateAndCleanString(accessory.context.HeaterCooler.Name,
71
- 'HeaterCooler Name', accessory.context.HeaterCooler.Name);
72
- }
73
69
  this.HeaterCooler = {
74
- Name: accessory.context.HeaterCooler.Name ?? `${accessory.displayName} ${device.remoteType}`,
70
+ Name: accessory.displayName,
75
71
  Service: accessory.getService(this.hap.Service.HeaterCooler) ?? accessory.addService(this.hap.Service.HeaterCooler) as Service,
76
72
  Active: accessory.context.Active ?? this.hap.Characteristic.Active.INACTIVE,
77
73
  CurrentHeaterCoolerState: accessory.context.CurrentHeaterCoolerState ?? this.hap.Characteristic.CurrentHeaterCoolerState.IDLE,
@@ -155,12 +151,8 @@ export class AirConditioner extends irdeviceBase {
155
151
  const meterUuid = this.platform.api.hap.uuid.generate(`${this.device.irair.meterId}-${this.device.irair.meterType}`);
156
152
  this.meter = this.platform.accessories.find((accessory) => accessory.UUID === meterUuid);
157
153
  accessory.context.HumiditySensor = accessory.context.HumiditySensor ?? {};
158
- if (accessory.context.HumiditySensor.Name) {
159
- accessory.context.HumiditySensor.Name = this.validateAndCleanString(accessory.context.HumiditySensor.Name,
160
- 'HumiditySensor Name', accessory.context.HumiditySensor.Name);
161
- }
162
154
  this.HumiditySensor = {
163
- Name: accessory.context.HumiditySensor ?? this.meter!.displayName,
155
+ Name: this.meter!.displayName,
164
156
  Service: this.meter!.getService(this.hap.Service.HumiditySensor) ?? this.meter!.addService(this.hap.Service.HumiditySensor) as Service,
165
157
  CurrentRelativeHumidity: this.meter!.context.CurrentRelativeHumidity || 0,
166
158
  };
@@ -59,12 +59,8 @@ export class AirPurifier extends irdeviceBase {
59
59
 
60
60
  // Initialize AirPurifier Service
61
61
  accessory.context.AirPurifier = accessory.context.AirPurifier ?? {};
62
- if (accessory.context.AirPurifier.Name) {
63
- accessory.context.AirPurifier.Name = this.validateAndCleanString(accessory.context.AirPurifier.Name,
64
- 'AirPurifier Name', accessory.context.AirPurifier.Name);
65
- }
66
62
  this.AirPurifier = {
67
- Name: accessory.context.AirPurifier.Name ?? `${accessory.displayName} Air Purifier`,
63
+ Name: accessory.displayName,
68
64
  Service: accessory.getService(this.hap.Service.AirPurifier) ?? accessory.addService(this.hap.Service.AirPurifier) as Service,
69
65
  Active: accessory.context.Active ?? this.hap.Characteristic.Active.INACTIVE,
70
66
  RotationSpeed: accessory.context.RotationSpeed ?? 0,
@@ -97,12 +93,8 @@ export class AirPurifier extends irdeviceBase {
97
93
 
98
94
  // Initialize TemperatureSensor Service
99
95
  accessory.context.TemperatureSensor = accessory.context.TemperatureSensor ?? {};
100
- if (accessory.context.TemperatureSensor.Name) {
101
- accessory.context.TemperatureSensor.Name = this.validateAndCleanString(accessory.context.TemperatureSensor.Name,
102
- 'TemperatureSensor Name', accessory.context.TemperatureSensor.Name);
103
- }
104
96
  this.TemperatureSensor = {
105
- Name: accessory.context.TemperatureSensor.Name ?? `${accessory.displayName} Temperature Sensor`,
97
+ Name: `${accessory.displayName} Temperature Sensor`,
106
98
  Service: accessory.getService(this.hap.Service.TemperatureSensor) ?? accessory.addService(this.hap.Service.TemperatureSensor) as Service,
107
99
  CurrentTemperature: accessory.context.CurrentTemperature || 24,
108
100
  };
@@ -33,12 +33,8 @@ export class Camera extends irdeviceBase {
33
33
 
34
34
  // Initialize Switch Service
35
35
  accessory.context.Switch = accessory.context.Switch ?? {};
36
- if (accessory.context.Switch.Name) {
37
- accessory.context.Switch.Name = this.validateAndCleanString(accessory.context.Switch.Name,
38
- 'Switch Name', accessory.context.Switch.Name);
39
- }
40
36
  this.Switch = {
41
- Name: accessory.context.Switch.Name ?? `${accessory.displayName} Camera`,
37
+ Name: accessory.displayName,
42
38
  Service: accessory.getService(this.hap.Service.Switch) ?? accessory.addService(this.hap.Service.Switch) as Service,
43
39
  On: accessory.context.On ?? false,
44
40
  };
@@ -36,12 +36,8 @@ export class IRFan extends irdeviceBase {
36
36
 
37
37
  // Initialize Switch Service
38
38
  accessory.context.Fan = accessory.context.Fan ?? {};
39
- if (accessory.context.Fan.Name) {
40
- accessory.context.Fan.Name = this.validateAndCleanString(accessory.context.Fan.Name,
41
- 'Fan Name', accessory.context.Fan.Name);
42
- }
43
39
  this.Fan = {
44
- Name: accessory.context.Fan.Name ?? `${accessory.displayName} Fan`,
40
+ Name: accessory.displayName,
45
41
  Service: accessory.getService(this.hap.Service.Fanv2) ?? accessory.addService(this.hap.Service.Fanv2) as Service,
46
42
  Active: accessory.context.Active ?? this.hap.Characteristic.Active.INACTIVE,
47
43
  SwingMode: accessory.context.SwingMode ?? this.hap.Characteristic.SwingMode.SWING_DISABLED,
@@ -43,18 +43,11 @@ export abstract class irdeviceBase {
43
43
  .getService(this.hap.Service.AccessoryInformation)!
44
44
  .setCharacteristic(this.hap.Characteristic.Manufacturer, 'SwitchBot')
45
45
  .setCharacteristic(this.hap.Characteristic.AppMatchingIdentifier, 'id1087374760')
46
- .setCharacteristic(this.hap.Characteristic.Name, this.validName(accessory, device))
47
- .setCharacteristic(this.hap.Characteristic.ConfiguredName, this.validName(accessory, device))
46
+ .setCharacteristic(this.hap.Characteristic.Name, accessory.displayName)
47
+ .setCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName)
48
48
  .setCharacteristic(this.hap.Characteristic.Model, accessory.context.model ?? 'Unknown')
49
- .setCharacteristic(this.hap.Characteristic.ProductData, accessory.context.deviceId)
50
- .setCharacteristic(this.hap.Characteristic.SerialNumber, accessory.context.deviceId);
51
- }
52
-
53
- public validName(accessory: PlatformAccessory, device: irdevice & irDevicesConfig) {
54
- const Name = device.configDeviceName ?? device.deviceName ?? accessory.displayName;
55
- const NameOfName = device.configDeviceName ? 'configDeviceName' : device.deviceName ? 'deviceName' : 'displayName';
56
- const validName = this.validateAndCleanString(Name, NameOfName, Name);
57
- return validName;
49
+ .setCharacteristic(this.hap.Characteristic.ProductData, device.deviceId)
50
+ .setCharacteristic(this.hap.Characteristic.SerialNumber, device.deviceId);
58
51
  }
59
52
 
60
53
  async getDeviceLogSettings(device: irdevice & irDevicesConfig): Promise<void> {
@@ -353,39 +346,6 @@ export abstract class irdeviceBase {
353
346
  }
354
347
  }
355
348
 
356
- /**
357
- * Validate and clean a string value for a Name Characteristic.
358
- * @param displayName
359
- * @param name
360
- * @param value
361
- * @returns string value
362
- */
363
- validateAndCleanString(displayName: string, name: string, value: string): string {
364
- const validPattern = /^[a-zA-Z0-9][a-zA-Z0-9 ']*[a-zA-Z0-9]$/;
365
- const invalidCharsPattern = /[^a-zA-Z0-9 ']/g;
366
- const invalidStartEndPattern = /^[^a-zA-Z0-9]+|[^a-zA-Z0-9]+$/g;
367
-
368
- if (!validPattern.test(value)) {
369
- this.warnLog(`WARNING: The accessory '${displayName}' has an invalid '${name}' characteristic ('${value}'). Please use only alphanumeric,`
370
- + ' space, and apostrophe characters. Ensure it starts and ends with an alphabetic or numeric character, and avoid emojis. This may'
371
- + ' prevent the accessory from being added in the Home App or cause unresponsiveness.');
372
-
373
- // Remove invalid characters
374
- if (invalidCharsPattern.test(value)) {
375
- this.warnLog(`Removing invalid characters from '${name}' characteristic`);
376
- value = value.replace(invalidCharsPattern, '');
377
- }
378
-
379
- // Ensure it starts and ends with an alphanumeric character
380
- if (invalidStartEndPattern.test(value)) {
381
- this.warnLog(`Removing invalid starting or ending characters from '${name}' characteristic`);
382
- value = value.replace(invalidStartEndPattern, '');
383
- }
384
- }
385
-
386
- return value;
387
- }
388
-
389
349
  /**
390
350
  * Logging for Device
391
351
  */
@@ -403,7 +363,7 @@ export abstract class irdeviceBase {
403
363
 
404
364
  async debugSuccessLog(...log: any[]): Promise<void> {
405
365
  if (await this.enablingDeviceLogging()) {
406
- if (this.deviceLogging?.includes('debug')) {
366
+ if (await this.loggingIsDebug()) {
407
367
  this.log.success(`[DEBUG] ${this.device.remoteType}: ${this.accessory.displayName}`, String(...log));
408
368
  }
409
369
  }
@@ -417,7 +377,7 @@ export abstract class irdeviceBase {
417
377
 
418
378
  async debugWarnLog(...log: any[]): Promise<void> {
419
379
  if (await this.enablingDeviceLogging()) {
420
- if (this.deviceLogging?.includes('debug')) {
380
+ if (await this.loggingIsDebug()) {
421
381
  this.log.warn(`[DEBUG] ${this.device.remoteType}: ${this.accessory.displayName}`, String(...log));
422
382
  }
423
383
  }
@@ -431,7 +391,7 @@ export abstract class irdeviceBase {
431
391
 
432
392
  async debugErrorLog(...log: any[]): Promise<void> {
433
393
  if (await this.enablingDeviceLogging()) {
434
- if (this.deviceLogging?.includes('debug')) {
394
+ if (await this.loggingIsDebug()) {
435
395
  this.log.error(`[DEBUG] ${this.device.remoteType}: ${this.accessory.displayName}`, String(...log));
436
396
  }
437
397
  }
@@ -441,13 +401,17 @@ export abstract class irdeviceBase {
441
401
  if (await this.enablingDeviceLogging()) {
442
402
  if (this.deviceLogging === 'debug') {
443
403
  this.log.info(`[DEBUG] ${this.device.remoteType}: ${this.accessory.displayName}`, String(...log));
444
- } else {
404
+ } else if (this.deviceLogging === 'debugMode') {
445
405
  this.log.debug(`${this.device.remoteType}: ${this.accessory.displayName}`, String(...log));
446
406
  }
447
407
  }
448
408
  }
449
409
 
410
+ async loggingIsDebug(): Promise<boolean> {
411
+ return this.deviceLogging === 'debugMode' || this.deviceLogging === 'debug';
412
+ }
413
+
450
414
  async enablingDeviceLogging(): Promise<boolean> {
451
- return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
415
+ return this.deviceLogging === 'debugMode' || this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
452
416
  }
453
417
  }
@@ -48,12 +48,8 @@ export class Light extends irdeviceBase {
48
48
  if (!device.irlight?.stateless) {
49
49
  // Initialize LightBulb Service
50
50
  accessory.context.LightBulb = accessory.context.LightBulb ?? {};
51
- if (accessory.context.LightBulb.Name) {
52
- accessory.context.LightBulb.Name = this.validateAndCleanString(accessory.context.LightBulb.Name,
53
- 'LightBulb Name', accessory.context.LightBulb.Name);
54
- }
55
51
  this.LightBulb = {
56
- Name: accessory.context.LightBulb.Name ?? `${accessory.displayName} ${device.remoteType}`,
52
+ Name: accessory.displayName,
57
53
  Service: accessory.getService(this.hap.Service.Lightbulb) ?? accessory.addService(this.hap.Service.Lightbulb) as Service,
58
54
  On: accessory.context.On || false,
59
55
  };
@@ -69,12 +65,8 @@ export class Light extends irdeviceBase {
69
65
  } else {
70
66
  // Initialize ProgrammableSwitchOn Service
71
67
  accessory.context.ProgrammableSwitchOn = accessory.context.ProgrammableSwitchOn ?? {};
72
- if (accessory.context.ProgrammableSwitchOn.Name) {
73
- accessory.context.ProgrammableSwitchOn.Name = this.validateAndCleanString(accessory.context.ProgrammableSwitchOn.Name,
74
- 'ProgrammableSwitchOn Name', accessory.context.ProgrammableSwitchOn.Name);
75
- }
76
68
  this.ProgrammableSwitchOn = {
77
- Name: accessory.context.ProgrammableSwitchOn.Name ?? `${accessory.displayName} ${device.remoteType} On`,
69
+ Name: `${accessory.displayName} On`,
78
70
  Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch)
79
71
  ?? accessory.addService(this.hap.Service.StatefulProgrammableSwitch) as Service,
80
72
  ProgrammableSwitchEvent: accessory.context.ProgrammableSwitchEvent ?? this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS,
@@ -104,12 +96,8 @@ export class Light extends irdeviceBase {
104
96
 
105
97
  // Initialize ProgrammableSwitchOff Service
106
98
  accessory.context.ProgrammableSwitchOff = accessory.context.ProgrammableSwitchOff ?? {};
107
- if (accessory.context.ProgrammableSwitchOff.Name) {
108
- accessory.context.ProgrammableSwitchOff.Name = this.validateAndCleanString(accessory.context.ProgrammableSwitchOff.Name,
109
- 'ProgrammableSwitchOff Name', accessory.context.ProgrammableSwitchOff.Name);
110
- }
111
99
  this.ProgrammableSwitchOff = {
112
- Name: accessory.context.ProgrammableSwitchOff.Name ?? `${accessory.displayName} ${device.remoteType} Off`,
100
+ Name: `${accessory.displayName} Off`,
113
101
  Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch)
114
102
  ?? accessory.addService(this.hap.Service.StatefulProgrammableSwitch) as Service,
115
103
  ProgrammableSwitchEvent: accessory.context.ProgrammableSwitchEvent ?? this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS,