@switchbot/homebridge-switchbot 3.6.1-beta.1 → 3.6.1-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +44 -17
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +1 -2
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +220 -397
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +3 -2
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +59 -31
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +3 -2
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +57 -29
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +47 -18
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +16 -5
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +9 -0
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +30 -3
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +44 -18
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +46 -18
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +45 -20
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +46 -18
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +4 -3
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +60 -31
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +48 -17
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +46 -18
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +46 -18
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +45 -17
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +40 -18
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +42 -17
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +41 -16
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +8 -1
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +6 -0
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +3 -0
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +3 -0
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +9 -0
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js +29 -2
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +9 -0
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +1 -0
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +216 -228
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +9 -0
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +3 -0
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.js +1 -1
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +11 -2
- package/dist/platform.js.map +1 -1
- package/dist/types/bledevicestatus.d.ts +1 -0
- package/dist/types/bledevicestatus.d.ts.map +1 -1
- package/dist/utils.d.ts +8 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +16 -0
- package/dist/utils.js.map +1 -1
- package/package.json +6 -6
- package/src/device/blindtilt.ts +44 -17
- package/src/device/bot.ts +224 -407
- package/src/device/ceilinglight.ts +57 -33
- package/src/device/colorbulb.ts +55 -31
- package/src/device/contact.ts +48 -19
- package/src/device/curtain.ts +19 -6
- package/src/device/device.ts +36 -3
- package/src/device/fan.ts +44 -19
- package/src/device/hub.ts +46 -18
- package/src/device/humidifier.ts +44 -20
- package/src/device/iosensor.ts +46 -18
- package/src/device/lightstrip.ts +60 -33
- package/src/device/lock.ts +49 -17
- package/src/device/meter.ts +46 -18
- package/src/device/meterplus.ts +46 -18
- package/src/device/motion.ts +46 -18
- package/src/device/plug.ts +38 -18
- package/src/device/robotvacuumcleaner.ts +41 -17
- package/src/device/waterdetector.ts +40 -16
- package/src/irdevice/airconditioner.ts +11 -2
- package/src/irdevice/airpurifier.ts +8 -0
- package/src/irdevice/camera.ts +4 -0
- package/src/irdevice/fan.ts +4 -0
- package/src/irdevice/irdevice.ts +35 -2
- package/src/irdevice/light.ts +12 -0
- package/src/irdevice/other.ts +254 -283
- package/src/irdevice/tv.ts +12 -0
- package/src/irdevice/vacuumcleaner.ts +4 -0
- package/src/irdevice/waterheater.ts +1 -1
- package/src/platform.ts +11 -2
- package/src/types/bledevicestatus.ts +1 -0
- package/src/utils.ts +15 -0
package/src/irdevice/irdevice.ts
CHANGED
|
@@ -43,13 +43,20 @@ 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,
|
|
47
|
-
.setCharacteristic(this.hap.Characteristic.ConfiguredName,
|
|
46
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.validName(accessory, device))
|
|
47
|
+
.setCharacteristic(this.hap.Characteristic.ConfiguredName, this.validName(accessory, device))
|
|
48
48
|
.setCharacteristic(this.hap.Characteristic.Model, accessory.context.model ?? 'Unknown')
|
|
49
49
|
.setCharacteristic(this.hap.Characteristic.ProductData, accessory.context.deviceId)
|
|
50
50
|
.setCharacteristic(this.hap.Characteristic.SerialNumber, accessory.context.deviceId);
|
|
51
51
|
}
|
|
52
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;
|
|
58
|
+
}
|
|
59
|
+
|
|
53
60
|
async getDeviceLogSettings(device: irdevice & irDevicesConfig): Promise<void> {
|
|
54
61
|
if (this.platform.debugMode) {
|
|
55
62
|
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
@@ -346,6 +353,32 @@ export abstract class irdeviceBase {
|
|
|
346
353
|
}
|
|
347
354
|
}
|
|
348
355
|
|
|
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
|
+
|
|
367
|
+
if (!validPattern.test(value)) {
|
|
368
|
+
this.warnLog(`WARNING: The accessory '${displayName}' has an invalid '${name}' characteristic ('${value}'). Please use only alphanumeric,`
|
|
369
|
+
+ ' space, and apostrophe characters. Ensure it starts and ends with an alphabetic or numeric character, and avoid emojis. This may'
|
|
370
|
+
+ ' prevent the accessory from being added in the Home App or cause unresponsiveness.');
|
|
371
|
+
|
|
372
|
+
// Remove invalid characters
|
|
373
|
+
value = value.replace(invalidCharsPattern, '');
|
|
374
|
+
|
|
375
|
+
// Ensure it starts and ends with an alphanumeric character
|
|
376
|
+
value = value.replace(/^[^a-zA-Z0-9]+|[^a-zA-Z0-9]+$/g, '');
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
return value;
|
|
380
|
+
}
|
|
381
|
+
|
|
349
382
|
/**
|
|
350
383
|
* Logging for Device
|
|
351
384
|
*/
|
package/src/irdevice/light.ts
CHANGED
|
@@ -48,6 +48,10 @@ 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
|
+
}
|
|
51
55
|
this.LightBulb = {
|
|
52
56
|
Name: accessory.context.LightBulb.Name ?? `${accessory.displayName} ${device.remoteType}`,
|
|
53
57
|
Service: accessory.getService(this.hap.Service.Lightbulb) ?? accessory.addService(this.hap.Service.Lightbulb) as Service,
|
|
@@ -65,6 +69,10 @@ export class Light extends irdeviceBase {
|
|
|
65
69
|
} else {
|
|
66
70
|
// Initialize ProgrammableSwitchOn Service
|
|
67
71
|
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
|
+
}
|
|
68
76
|
this.ProgrammableSwitchOn = {
|
|
69
77
|
Name: accessory.context.ProgrammableSwitchOn.Name ?? `${accessory.displayName} ${device.remoteType} On`,
|
|
70
78
|
Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch)
|
|
@@ -96,6 +104,10 @@ export class Light extends irdeviceBase {
|
|
|
96
104
|
|
|
97
105
|
// Initialize ProgrammableSwitchOff Service
|
|
98
106
|
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
|
+
}
|
|
99
111
|
this.ProgrammableSwitchOff = {
|
|
100
112
|
Name: accessory.context.ProgrammableSwitchOff.Name ?? `${accessory.displayName} ${device.remoteType} Off`,
|
|
101
113
|
Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch)
|