@switchbot/homebridge-switchbot 3.6.1-beta.10 → 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/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +9 -0
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +34 -1
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +3 -0
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +12 -0
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +9 -0
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +9 -0
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +9 -0
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +6 -0
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +9 -0
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +3 -0
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +12 -0
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +9 -0
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +9 -0
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +10 -1
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +4 -1
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +7 -1
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +6 -0
- 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.map +1 -1
- package/dist/irdevice/other.js +30 -0
- 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/package.json +1 -1
- package/src/device/blindtilt.ts +12 -0
- package/src/device/bot.ts +45 -1
- package/src/device/ceilinglight.ts +4 -0
- package/src/device/contact.ts +16 -0
- package/src/device/curtain.ts +12 -0
- package/src/device/fan.ts +12 -0
- package/src/device/hub.ts +12 -0
- package/src/device/humidifier.ts +8 -0
- package/src/device/iosensor.ts +12 -0
- package/src/device/lightstrip.ts +4 -0
- package/src/device/lock.ts +16 -0
- package/src/device/meter.ts +12 -0
- package/src/device/meterplus.ts +12 -0
- package/src/device/motion.ts +14 -2
- package/src/device/plug.ts +5 -1
- package/src/device/robotvacuumcleaner.ts +9 -1
- package/src/device/waterdetector.ts +8 -0
- 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 +40 -0
- package/src/irdevice/tv.ts +12 -0
- package/src/irdevice/vacuumcleaner.ts +4 -0
- package/src/irdevice/waterheater.ts +1 -1
|
@@ -63,6 +63,10 @@ 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
|
+
}
|
|
66
70
|
this.LightBulb = {
|
|
67
71
|
Name: accessory.context.LightBulb.Name ?? accessory.displayName,
|
|
68
72
|
Service: accessory.getService(this.hap.Service.Lightbulb) ?? accessory.addService(this.hap.Service.Lightbulb) as Service,
|
|
@@ -73,7 +77,7 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
73
77
|
|
|
74
78
|
// Initialize LightBulb Characteristics
|
|
75
79
|
this.LightBulb.Service
|
|
76
|
-
.setCharacteristic(this.hap.Characteristic.Name,
|
|
80
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.LightBulb.Name)
|
|
77
81
|
.getCharacteristic(this.hap.Characteristic.On)
|
|
78
82
|
.onGet(() => {
|
|
79
83
|
return this.LightBulb.On;
|
|
@@ -97,6 +101,10 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
97
101
|
|
|
98
102
|
// Initialize Battery Service
|
|
99
103
|
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
|
+
}
|
|
100
108
|
this.Battery = {
|
|
101
109
|
Name: accessory.context.Battery.Name ?? `${accessory.displayName} Battery`,
|
|
102
110
|
Service: accessory.getService(this.hap.Service.Battery) ?? accessory.addService(this.hap.Service.Battery) as Service,
|
|
@@ -64,6 +64,10 @@ 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
|
+
}
|
|
67
71
|
this.Battery = {
|
|
68
72
|
Name: accessory.context.Battery.Name ?? `${accessory.displayName} Battery`,
|
|
69
73
|
Service: accessory.getService(this.hap.Service.Battery) ?? accessory.addService(this.hap.Service.Battery) as Service,
|
|
@@ -99,6 +103,10 @@ export class WaterDetector extends deviceBase {
|
|
|
99
103
|
}
|
|
100
104
|
} else {
|
|
101
105
|
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
|
+
}
|
|
102
110
|
this.LeakSensor = {
|
|
103
111
|
Name: accessory.context.LeakSensor.Name ?? `${accessory.displayName} Leak Sensor`,
|
|
104
112
|
Service: accessory.getService(this.hap.Service.LeakSensor) ?? this.accessory.addService(this.hap.Service.LeakSensor) as Service,
|
|
@@ -66,6 +66,10 @@ 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
|
+
}
|
|
69
73
|
this.HeaterCooler = {
|
|
70
74
|
Name: accessory.context.HeaterCooler.Name ?? `${accessory.displayName} ${device.remoteType}`,
|
|
71
75
|
Service: accessory.getService(this.hap.Service.HeaterCooler) ?? accessory.addService(this.hap.Service.HeaterCooler) as Service,
|
|
@@ -151,6 +155,10 @@ export class AirConditioner extends irdeviceBase {
|
|
|
151
155
|
const meterUuid = this.platform.api.hap.uuid.generate(`${this.device.irair.meterId}-${this.device.irair.meterType}`);
|
|
152
156
|
this.meter = this.platform.accessories.find((accessory) => accessory.UUID === meterUuid);
|
|
153
157
|
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
|
+
}
|
|
154
162
|
this.HumiditySensor = {
|
|
155
163
|
Name: accessory.context.HumiditySensor ?? this.meter!.displayName,
|
|
156
164
|
Service: this.meter!.getService(this.hap.Service.HumiditySensor) ?? this.meter!.addService(this.hap.Service.HumiditySensor) as Service,
|
|
@@ -164,8 +172,9 @@ export class AirConditioner extends irdeviceBase {
|
|
|
164
172
|
this.meter = this.platform.accessories.find((accessory) => accessory.UUID === meterUuid);
|
|
165
173
|
}
|
|
166
174
|
|
|
167
|
-
if (this.meter) {
|
|
168
|
-
this.HumiditySensor
|
|
175
|
+
if (this.meter && this.HumiditySensor) {
|
|
176
|
+
this.HumiditySensor.Service
|
|
177
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.HumiditySensor.Name)
|
|
169
178
|
.getCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity)
|
|
170
179
|
.onGet(async () => {
|
|
171
180
|
return await this.CurrentRelativeHumidityGet();
|
|
@@ -59,6 +59,10 @@ 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
|
+
}
|
|
62
66
|
this.AirPurifier = {
|
|
63
67
|
Name: accessory.context.AirPurifier.Name ?? `${accessory.displayName} Air Purifier`,
|
|
64
68
|
Service: accessory.getService(this.hap.Service.AirPurifier) ?? accessory.addService(this.hap.Service.AirPurifier) as Service,
|
|
@@ -93,6 +97,10 @@ export class AirPurifier extends irdeviceBase {
|
|
|
93
97
|
|
|
94
98
|
// Initialize TemperatureSensor Service
|
|
95
99
|
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
|
+
}
|
|
96
104
|
this.TemperatureSensor = {
|
|
97
105
|
Name: accessory.context.TemperatureSensor.Name ?? `${accessory.displayName} Temperature Sensor`,
|
|
98
106
|
Service: accessory.getService(this.hap.Service.TemperatureSensor) ?? accessory.addService(this.hap.Service.TemperatureSensor) as Service,
|
package/src/irdevice/camera.ts
CHANGED
|
@@ -33,6 +33,10 @@ 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
|
+
}
|
|
36
40
|
this.Switch = {
|
|
37
41
|
Name: accessory.context.Switch.Name ?? `${accessory.displayName} Camera`,
|
|
38
42
|
Service: accessory.getService(this.hap.Service.Switch) ?? accessory.addService(this.hap.Service.Switch) as Service,
|
package/src/irdevice/fan.ts
CHANGED
|
@@ -36,6 +36,10 @@ 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
|
+
}
|
|
39
43
|
this.Fan = {
|
|
40
44
|
Name: accessory.context.Fan.Name ?? `${accessory.displayName} Fan`,
|
|
41
45
|
Service: accessory.getService(this.hap.Service.Fanv2) ?? accessory.addService(this.hap.Service.Fanv2) as Service,
|
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)
|
package/src/irdevice/other.ts
CHANGED
|
@@ -87,6 +87,10 @@ export class Others extends irdeviceBase {
|
|
|
87
87
|
accessory.category = this.hap.Categories.SWITCH;
|
|
88
88
|
// Initialize Switch Service
|
|
89
89
|
accessory.context.Switch = accessory.context.Switch ?? {};
|
|
90
|
+
if (accessory.context.Switch.Name) {
|
|
91
|
+
accessory.context.Switch.Name = this.validateAndCleanString(accessory.context.Switch.Name,
|
|
92
|
+
'Switch Name', accessory.context.Switch.Name);
|
|
93
|
+
}
|
|
90
94
|
this.Switch = {
|
|
91
95
|
Name: accessory.context.Switch.Name ?? accessory.displayName,
|
|
92
96
|
Service: accessory.getService(this.hap.Service.Switch) ?? accessory.addService(this.hap.Service.Switch) as Service,
|
|
@@ -113,6 +117,10 @@ export class Others extends irdeviceBase {
|
|
|
113
117
|
accessory.category = this.hap.Categories.GARAGE_DOOR_OPENER;
|
|
114
118
|
// Initialize GarageDoor Service
|
|
115
119
|
accessory.context.GarageDoor = accessory.context.GarageDoor ?? {};
|
|
120
|
+
if (accessory.context.GarageDoor.Name) {
|
|
121
|
+
accessory.context.GarageDoor.Name = this.validateAndCleanString(accessory.context.GarageDoor.Name,
|
|
122
|
+
'GarageDoor Name', accessory.context.GarageDoor.Name);
|
|
123
|
+
}
|
|
116
124
|
this.GarageDoor = {
|
|
117
125
|
Name: accessory.context.GarageDoor.Name ?? accessory.displayName,
|
|
118
126
|
Service: accessory.getService(this.hap.Service.GarageDoorOpener) ?? accessory.addService(this.hap.Service.GarageDoorOpener) as Service,
|
|
@@ -146,6 +154,10 @@ export class Others extends irdeviceBase {
|
|
|
146
154
|
accessory.category = this.hap.Categories.DOOR;
|
|
147
155
|
// Initialize Door Service
|
|
148
156
|
accessory.context.Door = accessory.context.Door ?? {};
|
|
157
|
+
if (accessory.context.Door.Name) {
|
|
158
|
+
accessory.context.Door.Name = this.validateAndCleanString(accessory.context.Door.Name,
|
|
159
|
+
'Door Name', accessory.context.Door.Name);
|
|
160
|
+
}
|
|
149
161
|
this.Door = {
|
|
150
162
|
Name: accessory.context.Door.Name ?? accessory.displayName,
|
|
151
163
|
Service: accessory.getService(this.hap.Service.Door) ?? accessory.addService(this.hap.Service.Door) as Service,
|
|
@@ -178,6 +190,10 @@ export class Others extends irdeviceBase {
|
|
|
178
190
|
accessory.category = this.hap.Categories.WINDOW;
|
|
179
191
|
// Initialize Window Service
|
|
180
192
|
accessory.context.Window = accessory.context.Window ?? {};
|
|
193
|
+
if (accessory.context.Window.Name) {
|
|
194
|
+
accessory.context.Window.Name = this.validateAndCleanString(accessory.context.Window.Name,
|
|
195
|
+
'Window Name', accessory.context.Window.Name);
|
|
196
|
+
}
|
|
181
197
|
this.Window = {
|
|
182
198
|
Name: accessory.context.Window.Name ?? accessory.displayName,
|
|
183
199
|
Service: accessory.getService(this.hap.Service.Window) ?? accessory.addService(this.hap.Service.Window) as Service,
|
|
@@ -210,6 +226,10 @@ export class Others extends irdeviceBase {
|
|
|
210
226
|
accessory.category = this.hap.Categories.WINDOW_COVERING;
|
|
211
227
|
// Initialize WindowCovering Service
|
|
212
228
|
accessory.context.WindowCovering = accessory.context.WindowCovering ?? {};
|
|
229
|
+
if (accessory.context.WindowCovering.Name) {
|
|
230
|
+
accessory.context.WindowCovering.Name = this.validateAndCleanString(accessory.context.WindowCovering.Name,
|
|
231
|
+
'WindowCovering Name', accessory.context.WindowCovering.Name);
|
|
232
|
+
}
|
|
213
233
|
this.WindowCovering = {
|
|
214
234
|
Name: accessory.context.WindowCovering.Name ?? accessory.displayName,
|
|
215
235
|
Service: accessory.getService(this.hap.Service.WindowCovering) ?? accessory.addService(this.hap.Service.WindowCovering) as Service,
|
|
@@ -243,6 +263,10 @@ export class Others extends irdeviceBase {
|
|
|
243
263
|
accessory.category = this.hap.Categories.DOOR_LOCK;
|
|
244
264
|
// Initialize Lock Service
|
|
245
265
|
accessory.context.LockMechanism = accessory.context.LockMechanism ?? {};
|
|
266
|
+
if (accessory.context.LockMechanism.Name) {
|
|
267
|
+
accessory.context.LockMechanism.Name = this.validateAndCleanString(accessory.context.LockMechanism.Name,
|
|
268
|
+
'LockMechanism Name', accessory.context.LockMechanism.Name);
|
|
269
|
+
}
|
|
246
270
|
this.LockMechanism = {
|
|
247
271
|
Name: accessory.context.LockMechanism.Name ?? accessory.displayName,
|
|
248
272
|
Service: accessory.getService(this.hap.Service.LockMechanism) ?? accessory.addService(this.hap.Service.LockMechanism) as Service,
|
|
@@ -270,6 +294,10 @@ export class Others extends irdeviceBase {
|
|
|
270
294
|
accessory.category = this.hap.Categories.FAUCET;
|
|
271
295
|
// Initialize Faucet Service
|
|
272
296
|
accessory.context.Faucet = accessory.context.Faucet ?? {};
|
|
297
|
+
if (accessory.context.Faucet.Name) {
|
|
298
|
+
accessory.context.Faucet.Name = this.validateAndCleanString(accessory.context.Faucet.Name,
|
|
299
|
+
'Faucet Name', accessory.context.Faucet.Name);
|
|
300
|
+
}
|
|
273
301
|
this.Faucet = {
|
|
274
302
|
Name: accessory.context.Faucet.Name ?? accessory.displayName,
|
|
275
303
|
Service: accessory.getService(this.hap.Service.Faucet) ?? accessory.addService(this.hap.Service.Faucet) as Service,
|
|
@@ -296,6 +324,10 @@ export class Others extends irdeviceBase {
|
|
|
296
324
|
accessory.category = this.hap.Categories.FAN;
|
|
297
325
|
// Initialize Fan Service
|
|
298
326
|
accessory.context.Fan = accessory.context.Fan ?? {};
|
|
327
|
+
if (accessory.context.Fan.Name) {
|
|
328
|
+
accessory.context.Fan.Name = this.validateAndCleanString(accessory.context.Fan.Name,
|
|
329
|
+
'Fan Name', accessory.context.Fan.Name);
|
|
330
|
+
}
|
|
299
331
|
this.Fan = {
|
|
300
332
|
Name: accessory.context.Fan.Name ?? accessory.displayName,
|
|
301
333
|
Service: accessory.getService(this.hap.Service.Fanv2) ?? accessory.addService(this.hap.Service.Fanv2) as Service,
|
|
@@ -322,6 +354,10 @@ export class Others extends irdeviceBase {
|
|
|
322
354
|
accessory.category = this.hap.Categories.PROGRAMMABLE_SWITCH;
|
|
323
355
|
// Initialize StatefulProgrammableSwitch Service
|
|
324
356
|
accessory.context.StatefulProgrammableSwitch = accessory.context.StatefulProgrammableSwitch ?? {};
|
|
357
|
+
if (accessory.context.StatefulProgrammableSwitch.Name) {
|
|
358
|
+
accessory.context.StatefulProgrammableSwitch.Name = this.validateAndCleanString(accessory.context.StatefulProgrammableSwitch.Name,
|
|
359
|
+
'StatefulProgrammableSwitch Name', accessory.context.StatefulProgrammableSwitch.Name);
|
|
360
|
+
}
|
|
325
361
|
this.StatefulProgrammableSwitch = {
|
|
326
362
|
Name: accessory.context.StatefulProgrammableSwitch.Name ?? accessory.displayName,
|
|
327
363
|
Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch)
|
|
@@ -349,6 +385,10 @@ export class Others extends irdeviceBase {
|
|
|
349
385
|
accessory.category = this.hap.Categories.OUTLET;
|
|
350
386
|
// Initialize Switch property
|
|
351
387
|
accessory.context.Outlet = accessory.context.Outlet ?? {};
|
|
388
|
+
if (accessory.context.Outlet.Name) {
|
|
389
|
+
accessory.context.Outlet.Name = this.validateAndCleanString(accessory.context.Outlet.Name,
|
|
390
|
+
'Outlet Name', accessory.context.Outlet.Name);
|
|
391
|
+
}
|
|
352
392
|
this.Outlet = {
|
|
353
393
|
Name: accessory.context.Outlet.Name ?? accessory.displayName,
|
|
354
394
|
Service: accessory.getService(this.hap.Service.Outlet) ?? accessory.addService(this.hap.Service.Outlet) as Service,
|
package/src/irdevice/tv.ts
CHANGED
|
@@ -45,6 +45,14 @@ export class TV extends irdeviceBase {
|
|
|
45
45
|
|
|
46
46
|
// Initialize Television Service
|
|
47
47
|
accessory.context.Television = accessory.context.Television ?? {};
|
|
48
|
+
if (accessory.context.Television.Name) {
|
|
49
|
+
accessory.context.Television.Name = this.validateAndCleanString(accessory.context.Television.Name,
|
|
50
|
+
'Television Name', accessory.context.Television.Name);
|
|
51
|
+
}
|
|
52
|
+
if (accessory.context.Television.ConfiguredName) {
|
|
53
|
+
accessory.context.Television.ConfiguredName = this.validateAndCleanString(accessory.context.Television.ConfiguredName,
|
|
54
|
+
'Television ConfiguredName', accessory.context.Television.ConfiguredName);
|
|
55
|
+
}
|
|
48
56
|
this.Television = {
|
|
49
57
|
Name: accessory.context.Television.Name ?? `${accessory.displayName} ${device.remoteType}`,
|
|
50
58
|
ConfiguredName: accessory.context.Television.ConfiguredName ?? `${accessory.displayName} ${device.remoteType}`,
|
|
@@ -104,6 +112,10 @@ export class TV extends irdeviceBase {
|
|
|
104
112
|
|
|
105
113
|
// Initialize TelevisionSpeaker Service
|
|
106
114
|
accessory.context.TelevisionSpeaker = accessory.context.TelevisionSpeaker ?? {};
|
|
115
|
+
if (accessory.context.TelevisionSpeaker.Name) {
|
|
116
|
+
accessory.context.TelevisionSpeaker.Name = this.validateAndCleanString(accessory.context.TelevisionSpeaker.Name,
|
|
117
|
+
'TelevisionSpeaker Name', accessory.context.TelevisionSpeaker.Name);
|
|
118
|
+
}
|
|
107
119
|
this.TelevisionSpeaker = {
|
|
108
120
|
Name: accessory.context.TelevisionSpeaker.Name ?? `${accessory.displayName} ${device.remoteType} Speaker`,
|
|
109
121
|
Service: accessory.getService(this.hap.Service.TelevisionSpeaker) ?? accessory.addService(this.hap.Service.TelevisionSpeaker) as Service,
|
|
@@ -33,6 +33,10 @@ export class VacuumCleaner 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
|
+
}
|
|
36
40
|
this.Switch = {
|
|
37
41
|
Name: accessory.context.Switch.Name ?? `${accessory.displayName} ${device.remoteType}`,
|
|
38
42
|
Service: accessory.getService(this.hap.Service.Switch) ?? accessory.addService(this.hap.Service.Switch) as Service,
|
|
@@ -41,7 +41,7 @@ export class WaterHeater extends irdeviceBase {
|
|
|
41
41
|
accessory.context.Valve = this.Valve as object;
|
|
42
42
|
|
|
43
43
|
this.Valve.Service
|
|
44
|
-
.setCharacteristic(this.hap.Characteristic.Name,
|
|
44
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.Valve.Name)
|
|
45
45
|
.setCharacteristic(this.hap.Characteristic.ValveType, this.hap.Characteristic.ValveType.GENERIC_VALVE)
|
|
46
46
|
.getCharacteristic(this.hap.Characteristic.Active)
|
|
47
47
|
.onGet(() => {
|