@switchbot/homebridge-switchbot 2.9.1-beta.4 → 2.9.2
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/.eslintrc +47 -14
- package/.github/ISSUE_TEMPLATE/feature-request.yml +4 -4
- package/.github/workflows/stale.yml +2 -0
- package/.vscode/settings.json +7 -1
- package/CHANGELOG.md +87 -70
- package/SECURITY.md +2 -2
- package/config.schema.json +348 -114
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +6 -4
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +42 -35
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +3 -2
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +3 -2
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +12 -11
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +9 -8
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.js +9 -9
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.js +6 -6
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +9 -8
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +3 -2
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +9 -7
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +9 -8
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +9 -8
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +9 -7
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +3 -2
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +6 -4
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +3 -2
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +3 -2
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +3 -2
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +3 -2
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +3 -2
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +38 -32
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +12 -11
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +3 -2
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +3 -2
- package/dist/irdevice/waterheater.js.map +1 -1
- package/nodemon.json +4 -2
- package/package.json +9 -14
- package/src/device/blindtilt.ts +7 -5
- package/src/device/bot.ts +44 -37
- package/src/device/ceilinglight.ts +7 -6
- package/src/device/colorbulb.ts +5 -4
- package/src/device/contact.ts +13 -11
- package/src/device/curtain.ts +10 -9
- package/src/device/hub.ts +9 -9
- package/src/device/humidifier.ts +8 -8
- package/src/device/iosensor.ts +10 -9
- package/src/device/lightstrip.ts +5 -4
- package/src/device/lock.ts +13 -11
- package/src/device/meter.ts +11 -10
- package/src/device/meterplus.ts +10 -9
- package/src/device/motion.ts +10 -8
- package/src/device/plug.ts +3 -2
- package/src/device/robotvacuumcleaner.ts +12 -10
- package/src/irdevice/airconditioner.ts +3 -2
- package/src/irdevice/airpurifier.ts +3 -2
- package/src/irdevice/camera.ts +3 -2
- package/src/irdevice/fan.ts +3 -2
- package/src/irdevice/light.ts +3 -2
- package/src/irdevice/other.ts +38 -32
- package/src/irdevice/tv.ts +12 -11
- package/src/irdevice/vacuumcleaner.ts +3 -2
- package/src/irdevice/waterheater.ts +3 -2
- package/tsconfig.json +16 -4
- package/.github/npm-version-script.js +0 -81
- package/.prettierrc +0 -9
package/src/device/meter.ts
CHANGED
|
@@ -87,9 +87,9 @@ export class Meter {
|
|
|
87
87
|
accessory.removeService(this.temperatureService!);
|
|
88
88
|
} else if (!this.temperatureService) {
|
|
89
89
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Temperature Sensor Service`);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
const temperatureService = `${accessory.displayName} Temperature Sensor`;
|
|
91
|
+
(this.temperatureService = this.accessory.getService(this.platform.Service.TemperatureSensor)
|
|
92
|
+
|| this.accessory.addService(this.platform.Service.TemperatureSensor)), temperatureService;
|
|
93
93
|
|
|
94
94
|
this.temperatureService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Temperature Sensor`);
|
|
95
95
|
if (!this.temperatureService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -118,9 +118,9 @@ export class Meter {
|
|
|
118
118
|
accessory.removeService(this.humidityService!);
|
|
119
119
|
} else if (!this.humidityService) {
|
|
120
120
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Humidity Sensor Service`);
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
const humidityService = `${accessory.displayName} Humidity Sensor`;
|
|
122
|
+
(this.humidityService = this.accessory.getService(this.platform.Service.HumiditySensor)
|
|
123
|
+
|| this.accessory.addService(this.platform.Service.HumiditySensor)), humidityService;
|
|
124
124
|
|
|
125
125
|
this.humidityService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Humidity Sensor`);
|
|
126
126
|
if (!this.humidityService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -139,8 +139,9 @@ export class Meter {
|
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
// Battery Service
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
const batteryService = `${accessory.displayName} Battery`;
|
|
143
|
+
(this.batteryService = this.accessory.getService(this.platform.Service.Battery)
|
|
144
|
+
|| accessory.addService(this.platform.Service.Battery)), batteryService;
|
|
144
145
|
|
|
145
146
|
this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
|
|
146
147
|
if (!this.batteryService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -237,7 +238,7 @@ export class Meter {
|
|
|
237
238
|
this.BatteryLevel = 100;
|
|
238
239
|
}
|
|
239
240
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel},`
|
|
240
|
-
|
|
241
|
+
+ ` StatusLowBattery: ${this.StatusLowBattery}`);
|
|
241
242
|
|
|
242
243
|
// FirmwareRevision
|
|
243
244
|
this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
|
|
@@ -387,7 +388,7 @@ export class Meter {
|
|
|
387
388
|
this.accessory.context.CurrentRelativeHumidity = this.CurrentRelativeHumidity;
|
|
388
389
|
this.humidityService?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.CurrentRelativeHumidity);
|
|
389
390
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
390
|
-
|
|
391
|
+
+ `updateCharacteristic CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
|
|
391
392
|
}
|
|
392
393
|
}
|
|
393
394
|
// CurrentTemperature
|
package/src/device/meterplus.ts
CHANGED
|
@@ -89,9 +89,9 @@ export class MeterPlus {
|
|
|
89
89
|
accessory.removeService(this.temperatureService!);
|
|
90
90
|
} else if (!this.temperatureService) {
|
|
91
91
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Temperature Sensor Service`);
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
const temperatureService = `${accessory.displayName} Temperature Sensor`;
|
|
93
|
+
(this.temperatureService = this.accessory.getService(this.platform.Service.TemperatureSensor)
|
|
94
|
+
|| this.accessory.addService(this.platform.Service.TemperatureSensor)), temperatureService;
|
|
95
95
|
|
|
96
96
|
this.temperatureService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Temperature Sensor`);
|
|
97
97
|
if (!this.temperatureService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -120,9 +120,9 @@ export class MeterPlus {
|
|
|
120
120
|
accessory.removeService(this.humidityService!);
|
|
121
121
|
} else if (!this.humidityService) {
|
|
122
122
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Humidity Sensor Service`);
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
const humidityService = `${accessory.displayName} Humidity Sensor`;
|
|
124
|
+
(this.humidityService = this.accessory.getService(this.platform.Service.HumiditySensor)
|
|
125
|
+
|| this.accessory.addService(this.platform.Service.HumiditySensor)), humidityService;
|
|
126
126
|
|
|
127
127
|
this.humidityService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Humidity Sensor`);
|
|
128
128
|
if (!this.humidityService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -141,8 +141,9 @@ export class MeterPlus {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
// Battery Service
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
const batteryService = `${accessory.displayName} Battery`;
|
|
145
|
+
(this.batteryService = this.accessory.getService(this.platform.Service.Battery)
|
|
146
|
+
|| accessory.addService(this.platform.Service.Battery)), batteryService;
|
|
146
147
|
|
|
147
148
|
this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
|
|
148
149
|
if (!this.batteryService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -239,7 +240,7 @@ export class MeterPlus {
|
|
|
239
240
|
this.BatteryLevel = 100;
|
|
240
241
|
}
|
|
241
242
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel},`
|
|
242
|
-
|
|
243
|
+
+ ` StatusLowBattery: ${this.StatusLowBattery}`);
|
|
243
244
|
|
|
244
245
|
// FirmwareRevision
|
|
245
246
|
this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
|
package/src/device/motion.ts
CHANGED
|
@@ -83,8 +83,9 @@ export class Motion {
|
|
|
83
83
|
|
|
84
84
|
// get the Battery service if it exists, otherwise create a new Motion service
|
|
85
85
|
// you can create multiple services for each accessory
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
const motionSensorService = `${accessory.displayName} Motion Sensor`;
|
|
87
|
+
(this.motionSensorService = accessory.getService(this.platform.Service.MotionSensor)
|
|
88
|
+
|| accessory.addService(this.platform.Service.MotionSensor)), motionSensorService;
|
|
88
89
|
|
|
89
90
|
this.motionSensorService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
90
91
|
if (!this.motionSensorService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -100,9 +101,9 @@ export class Motion {
|
|
|
100
101
|
accessory.removeService(this.lightSensorService!);
|
|
101
102
|
} else if (!this.lightSensorService) {
|
|
102
103
|
this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Light Sensor Service`);
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
const lightSensorService = `${accessory.displayName} Light Sensor`;
|
|
105
|
+
(this.lightSensorService = this.accessory.getService(this.platform.Service.LightSensor)
|
|
106
|
+
|| this.accessory.addService(this.platform.Service.LightSensor)), lightSensorService;
|
|
106
107
|
|
|
107
108
|
this.lightSensorService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Light Sensor`);
|
|
108
109
|
this.lightSensorService.setCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Light Sensor`);
|
|
@@ -111,8 +112,9 @@ export class Motion {
|
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
// Battery Service
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
const batteryService = `${accessory.displayName} Battery`;
|
|
116
|
+
(this.batteryService = this.accessory.getService(this.platform.Service.Battery)
|
|
117
|
+
|| accessory.addService(this.platform.Service.Battery)), batteryService;
|
|
116
118
|
|
|
117
119
|
this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
|
|
118
120
|
if (!this.batteryService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -223,7 +225,7 @@ export class Motion {
|
|
|
223
225
|
this.BatteryLevel = 100;
|
|
224
226
|
}
|
|
225
227
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel},`
|
|
226
|
-
|
|
228
|
+
+ ` StatusLowBattery: ${this.StatusLowBattery}`);
|
|
227
229
|
|
|
228
230
|
// FirmwareRevision
|
|
229
231
|
this.FirmwareRevision = this.OpenAPI_FirmwareRevision!;
|
package/src/device/plug.ts
CHANGED
|
@@ -64,8 +64,9 @@ export class Plug {
|
|
|
64
64
|
|
|
65
65
|
// get the Outlet service if it exists, otherwise create a new Outlet service
|
|
66
66
|
// you can create multiple services for each accessory
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
const outletService = `${accessory.displayName} ${device.deviceType}`;
|
|
68
|
+
(this.outletService = accessory.getService(this.platform.Service.Outlet)
|
|
69
|
+
|| accessory.addService(this.platform.Service.Outlet)), outletService;
|
|
69
70
|
|
|
70
71
|
this.outletService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
71
72
|
if (!this.outletService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -71,8 +71,9 @@ export class RobotVacuumCleaner {
|
|
|
71
71
|
|
|
72
72
|
// get the Lightbulb service if it exists, otherwise create a new Lightbulb service
|
|
73
73
|
// you can create multiple services for each accessory
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
const robotVacuumCleanerService = `${accessory.displayName} ${device.deviceType}`;
|
|
75
|
+
(this.robotVacuumCleanerService = accessory.getService(this.platform.Service.Lightbulb)
|
|
76
|
+
|| accessory.addService(this.platform.Service.Lightbulb)), robotVacuumCleanerService;
|
|
76
77
|
|
|
77
78
|
this.robotVacuumCleanerService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
78
79
|
if (!this.robotVacuumCleanerService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -100,8 +101,9 @@ export class RobotVacuumCleaner {
|
|
|
100
101
|
.onSet(this.BrightnessSet.bind(this));
|
|
101
102
|
|
|
102
103
|
// Battery Service
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
const batteryService = `${accessory.displayName} Battery`;
|
|
105
|
+
(this.batteryService = this.accessory.getService(this.platform.Service.Battery)
|
|
106
|
+
|| accessory.addService(this.platform.Service.Battery)), batteryService;
|
|
105
107
|
|
|
106
108
|
this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
|
|
107
109
|
if (!this.batteryService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -152,8 +154,8 @@ export class RobotVacuumCleaner {
|
|
|
152
154
|
async parseStatus(): Promise<void> {
|
|
153
155
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
154
156
|
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} parseStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
155
|
-
|
|
156
|
-
|
|
157
|
+
/*} else if (this.BLE) {
|
|
158
|
+
await this.BLEparseStatus();*/
|
|
157
159
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
158
160
|
await this.openAPIparseStatus();
|
|
159
161
|
} else {
|
|
@@ -208,8 +210,8 @@ export class RobotVacuumCleaner {
|
|
|
208
210
|
async refreshStatus(): Promise<void> {
|
|
209
211
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
210
212
|
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
211
|
-
|
|
212
|
-
|
|
213
|
+
/*} else if (this.BLE) {
|
|
214
|
+
await this.BLERefreshStatus();*/
|
|
213
215
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
214
216
|
await this.openAPIRefreshStatus();
|
|
215
217
|
} else {
|
|
@@ -328,8 +330,8 @@ export class RobotVacuumCleaner {
|
|
|
328
330
|
async pushChanges(): Promise<void> {
|
|
329
331
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
330
332
|
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges enableCloudService: ${this.device.enableCloudService}`);
|
|
331
|
-
|
|
332
|
-
|
|
333
|
+
/*} else if (this.BLE) {
|
|
334
|
+
await this.BLEpushChanges();*/
|
|
333
335
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
334
336
|
await this.openAPIpushChanges();
|
|
335
337
|
} else {
|
|
@@ -67,8 +67,9 @@ export class AirConditioner {
|
|
|
67
67
|
|
|
68
68
|
// get the Television service if it exists, otherwise create a new Television service
|
|
69
69
|
// you can create multiple services for each accessory
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
const coolerService = `${accessory.displayName} ${device.remoteType}`;
|
|
71
|
+
(this.coolerService = accessory.getService(this.platform.Service.HeaterCooler)
|
|
72
|
+
|| accessory.addService(this.platform.Service.HeaterCooler)), coolerService;
|
|
72
73
|
|
|
73
74
|
this.coolerService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
74
75
|
if (!this.coolerService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -61,8 +61,9 @@ export class AirPurifier {
|
|
|
61
61
|
|
|
62
62
|
// get the Television service if it exists, otherwise create a new Television service
|
|
63
63
|
// you can create multiple services for each accessory
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
const airPurifierService = `${accessory.displayName} Air Purifier`;
|
|
65
|
+
(this.airPurifierService = accessory.getService(this.platform.Service.AirPurifier)
|
|
66
|
+
|| accessory.addService(this.platform.Service.AirPurifier)), airPurifierService;
|
|
66
67
|
|
|
67
68
|
this.airPurifierService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
68
69
|
if (!this.airPurifierService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
package/src/irdevice/camera.ts
CHANGED
|
@@ -43,8 +43,9 @@ export class Camera {
|
|
|
43
43
|
|
|
44
44
|
// get the Television service if it exists, otherwise create a new Television service
|
|
45
45
|
// you can create multiple services for each accessory
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
const switchService = `${accessory.displayName} Camera`;
|
|
47
|
+
(this.switchService = accessory.getService(this.platform.Service.Switch)
|
|
48
|
+
|| accessory.addService(this.platform.Service.Switch)), switchService;
|
|
48
49
|
|
|
49
50
|
this.switchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
50
51
|
if (!this.switchService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
package/src/irdevice/fan.ts
CHANGED
|
@@ -50,8 +50,9 @@ export class Fan {
|
|
|
50
50
|
|
|
51
51
|
// get the Television service if it exists, otherwise create a new Television service
|
|
52
52
|
// you can create multiple services for each accessory
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
const fanService = `${accessory.displayName} Fan`;
|
|
54
|
+
(this.fanService = accessory.getService(this.platform.Service.Fanv2)
|
|
55
|
+
|| accessory.addService(this.platform.Service.Fanv2)), fanService;
|
|
55
56
|
|
|
56
57
|
this.fanService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
57
58
|
if (!this.fanService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
package/src/irdevice/light.ts
CHANGED
|
@@ -43,8 +43,9 @@ export class Light {
|
|
|
43
43
|
|
|
44
44
|
// get the Light service if it exists, otherwise create a new Light service
|
|
45
45
|
// you can create multiple services for each accessory
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
const lightBulbService = `${accessory.displayName} ${device.remoteType}`;
|
|
47
|
+
(this.lightBulbService = accessory.getService(this.platform.Service.Lightbulb)
|
|
48
|
+
|| accessory.addService(this.platform.Service.Lightbulb)), lightBulbService;
|
|
48
49
|
|
|
49
50
|
this.lightBulbService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
50
51
|
if (!this.lightBulbService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
package/src/irdevice/other.ts
CHANGED
|
@@ -65,8 +65,9 @@ export class Others {
|
|
|
65
65
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
66
66
|
|
|
67
67
|
// Add switchService
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
const switchService = `${accessory.displayName} Switch`;
|
|
69
|
+
(this.switchService = accessory.getService(this.platform.Service.Switch)
|
|
70
|
+
|| accessory.addService(this.platform.Service.Switch)), switchService;
|
|
70
71
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Switch`);
|
|
71
72
|
|
|
72
73
|
this.switchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -85,10 +86,10 @@ export class Others {
|
|
|
85
86
|
this.removeWindowCoveringService(accessory);
|
|
86
87
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
87
88
|
|
|
88
|
-
// Add
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
// Add garageDoorService
|
|
90
|
+
const garageDoorService = `${accessory.displayName} Garage Door Opener`;
|
|
91
|
+
(this.garageDoorService = accessory.getService(this.platform.Service.GarageDoorOpener)
|
|
92
|
+
|| accessory.addService(this.platform.Service.GarageDoorOpener)), garageDoorService;
|
|
92
93
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Garage Door Opener`);
|
|
93
94
|
|
|
94
95
|
this.garageDoorService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -108,9 +109,10 @@ export class Others {
|
|
|
108
109
|
this.removeWindowCoveringService(accessory);
|
|
109
110
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
110
111
|
|
|
111
|
-
// Add
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
// Add doorService
|
|
113
|
+
const doorService = `${accessory.displayName} Door`;
|
|
114
|
+
(this.doorService = accessory.getService(this.platform.Service.Door)
|
|
115
|
+
|| accessory.addService(this.platform.Service.Door)), doorService;
|
|
114
116
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Door`);
|
|
115
117
|
|
|
116
118
|
this.doorService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -138,9 +140,10 @@ export class Others {
|
|
|
138
140
|
this.removeWindowCoveringService(accessory);
|
|
139
141
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
140
142
|
|
|
141
|
-
// Add
|
|
142
|
-
|
|
143
|
-
|
|
143
|
+
// Add windowService
|
|
144
|
+
const windowService = `${accessory.displayName} Window`;
|
|
145
|
+
(this.windowService = accessory.getService(this.platform.Service.Window)
|
|
146
|
+
|| accessory.addService(this.platform.Service.Window)), windowService;
|
|
144
147
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Window`);
|
|
145
148
|
|
|
146
149
|
this.windowService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -168,10 +171,10 @@ export class Others {
|
|
|
168
171
|
this.removeGarageDoorService(accessory);
|
|
169
172
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
170
173
|
|
|
171
|
-
// Add
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
174
|
+
// Add windowCoveringService
|
|
175
|
+
const windowCoveringService = `${accessory.displayName} Window Covering`;
|
|
176
|
+
(this.windowCoveringService = accessory.getService(this.platform.Service.WindowCovering)
|
|
177
|
+
|| accessory.addService(this.platform.Service.WindowCovering)), windowCoveringService;
|
|
175
178
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Window Covering`);
|
|
176
179
|
|
|
177
180
|
this.windowCoveringService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -199,9 +202,10 @@ export class Others {
|
|
|
199
202
|
this.removeWindowCoveringService(accessory);
|
|
200
203
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
201
204
|
|
|
202
|
-
// Add
|
|
203
|
-
|
|
204
|
-
|
|
205
|
+
// Add lockService
|
|
206
|
+
const lockService = `${accessory.displayName} Lock`;
|
|
207
|
+
(this.lockService = accessory.getService(this.platform.Service.LockMechanism)
|
|
208
|
+
|| accessory.addService(this.platform.Service.LockMechanism)), lockService;
|
|
205
209
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Lock`);
|
|
206
210
|
|
|
207
211
|
this.lockService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -220,9 +224,10 @@ export class Others {
|
|
|
220
224
|
this.removeWindowCoveringService(accessory);
|
|
221
225
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
222
226
|
|
|
223
|
-
// Add
|
|
224
|
-
|
|
225
|
-
|
|
227
|
+
// Add faucetService
|
|
228
|
+
const faucetService = `${accessory.displayName} Faucet`;
|
|
229
|
+
(this.faucetService = accessory.getService(this.platform.Service.Faucet)
|
|
230
|
+
|| accessory.addService(this.platform.Service.Faucet)), faucetService;
|
|
226
231
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Faucet`);
|
|
227
232
|
|
|
228
233
|
this.faucetService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -241,9 +246,10 @@ export class Others {
|
|
|
241
246
|
this.removeWindowCoveringService(accessory);
|
|
242
247
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
243
248
|
|
|
244
|
-
// Add
|
|
245
|
-
|
|
246
|
-
|
|
249
|
+
// Add fanService
|
|
250
|
+
const fanService = `${accessory.displayName} Fan`;
|
|
251
|
+
(this.fanService = accessory.getService(this.platform.Service.Fan)
|
|
252
|
+
|| accessory.addService(this.platform.Service.Fan)), fanService;
|
|
247
253
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Fan`);
|
|
248
254
|
|
|
249
255
|
this.fanService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -262,11 +268,10 @@ export class Others {
|
|
|
262
268
|
this.removeGarageDoorService(accessory);
|
|
263
269
|
this.removeWindowCoveringService(accessory);
|
|
264
270
|
|
|
265
|
-
// Add
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
`${accessory.displayName} Stateful Programmable Switch`;
|
|
271
|
+
// Add statefulProgrammableSwitchService
|
|
272
|
+
const statefulProgrammableSwitchService = `${accessory.displayName} Stateful Programmable Switch`;
|
|
273
|
+
(this.statefulProgrammableSwitchService = accessory.getService(this.platform.Service.StatefulProgrammableSwitch)
|
|
274
|
+
|| accessory.addService(this.platform.Service.StatefulProgrammableSwitch)), statefulProgrammableSwitchService;
|
|
270
275
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Stateful Programmable Switch`);
|
|
271
276
|
|
|
272
277
|
this.statefulProgrammableSwitchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
@@ -288,8 +293,9 @@ export class Others {
|
|
|
288
293
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
289
294
|
|
|
290
295
|
// Add outletService
|
|
291
|
-
|
|
292
|
-
|
|
296
|
+
const outletService = `${accessory.displayName} Outlet`;
|
|
297
|
+
(this.outletService = accessory.getService(this.platform.Service.Outlet)
|
|
298
|
+
|| accessory.addService(this.platform.Service.Outlet)), outletService;
|
|
293
299
|
this.debugWarnLog(`${this.device.remoteType}: ${accessory.displayName} Displaying as Outlet`);
|
|
294
300
|
|
|
295
301
|
this.outletService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
package/src/irdevice/tv.ts
CHANGED
|
@@ -47,34 +47,35 @@ export class TV {
|
|
|
47
47
|
.setCharacteristic(this.platform.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision);
|
|
48
48
|
|
|
49
49
|
// set the accessory category
|
|
50
|
+
const tvServiceCategory = `${accessory.displayName} ${device.remoteType}`;
|
|
50
51
|
switch (device.remoteType) {
|
|
51
52
|
case 'Speaker':
|
|
52
53
|
case 'DIY Speaker':
|
|
53
54
|
accessory.category = this.platform.api.hap.Categories.SPEAKER;
|
|
54
|
-
(this.tvService = accessory.getService(this.platform.Service.Television)
|
|
55
|
-
|
|
55
|
+
(this.tvService = accessory.getService(this.platform.Service.Television)
|
|
56
|
+
|| accessory.addService(this.platform.Service.Television)), tvServiceCategory;
|
|
56
57
|
break;
|
|
57
58
|
case 'IPTV':
|
|
58
59
|
case 'DIY IPTV':
|
|
59
60
|
accessory.category = this.platform.api.hap.Categories.TV_STREAMING_STICK;
|
|
60
|
-
(this.tvService = accessory.getService(this.platform.Service.Television)
|
|
61
|
-
|
|
61
|
+
(this.tvService = accessory.getService(this.platform.Service.Television)
|
|
62
|
+
|| accessory.addService(this.platform.Service.Television)), tvServiceCategory;
|
|
62
63
|
break;
|
|
63
64
|
case 'DVD':
|
|
64
65
|
case 'DIY DVD':
|
|
65
66
|
case 'Set Top Box':
|
|
66
67
|
case 'DIY Set Top Box':
|
|
67
68
|
accessory.category = this.platform.api.hap.Categories.TV_SET_TOP_BOX;
|
|
68
|
-
(this.tvService = accessory.getService(this.platform.Service.Television)
|
|
69
|
-
|
|
69
|
+
(this.tvService = accessory.getService(this.platform.Service.Television)
|
|
70
|
+
|| accessory.addService(this.platform.Service.Television)), tvServiceCategory;
|
|
70
71
|
break;
|
|
71
72
|
default:
|
|
72
73
|
accessory.category = this.platform.api.hap.Categories.TELEVISION;
|
|
73
74
|
|
|
74
75
|
// get the Television service if it exists, otherwise create a new Television service
|
|
75
76
|
// you can create multiple services for each accessory
|
|
76
|
-
(this.tvService = accessory.getService(this.platform.Service.Television)
|
|
77
|
-
|
|
77
|
+
(this.tvService = accessory.getService(this.platform.Service.Television)
|
|
78
|
+
|| accessory.addService(this.platform.Service.Television)), tvServiceCategory;
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
this.tvService.getCharacteristic(this.platform.Characteristic.ConfiguredName);
|
|
@@ -100,9 +101,9 @@ export class TV {
|
|
|
100
101
|
* Create a speaker service to allow volume control
|
|
101
102
|
*/
|
|
102
103
|
// create a new Television Speaker service
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
const speakerService = `${accessory.displayName} Speaker`;
|
|
105
|
+
(this.speakerService = accessory.getService(this.platform.Service.TelevisionSpeaker)
|
|
106
|
+
|| accessory.addService(this.platform.Service.TelevisionSpeaker)), speakerService;
|
|
106
107
|
|
|
107
108
|
this.speakerService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Speaker`);
|
|
108
109
|
if (!this.speakerService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -43,8 +43,9 @@ export class VacuumCleaner {
|
|
|
43
43
|
|
|
44
44
|
// get the Television service if it exists, otherwise create a new Television service
|
|
45
45
|
// you can create multiple services for each accessory
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
const switchService = `${accessory.displayName} ${device.remoteType}`;
|
|
47
|
+
(this.switchService = accessory.getService(this.platform.Service.Switch)
|
|
48
|
+
|| accessory.addService(this.platform.Service.Switch)), switchService;
|
|
48
49
|
|
|
49
50
|
this.switchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
50
51
|
if (!this.switchService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
@@ -43,8 +43,9 @@ export class WaterHeater {
|
|
|
43
43
|
|
|
44
44
|
// get the Television service if it exists, otherwise create a new Television service
|
|
45
45
|
// you can create multiple services for each accessory
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
const valveService = `${accessory.displayName} ${device.remoteType}`;
|
|
47
|
+
(this.valveService = accessory.getService(this.platform.Service.Valve)
|
|
48
|
+
|| accessory.addService(this.platform.Service.Valve)), valveService;
|
|
48
49
|
|
|
49
50
|
this.valveService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
50
51
|
if (!this.valveService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
package/tsconfig.json
CHANGED
|
@@ -2,7 +2,15 @@
|
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"target": "ES2021",
|
|
4
4
|
"module": "commonjs",
|
|
5
|
-
"lib": [
|
|
5
|
+
"lib": [
|
|
6
|
+
"ES2015",
|
|
7
|
+
"ES2016",
|
|
8
|
+
"ES2017",
|
|
9
|
+
"ES2018",
|
|
10
|
+
"ES2019",
|
|
11
|
+
"ES2020",
|
|
12
|
+
"ES2021"
|
|
13
|
+
],
|
|
6
14
|
"declaration": true,
|
|
7
15
|
"declarationMap": true,
|
|
8
16
|
"sourceMap": true,
|
|
@@ -12,6 +20,10 @@
|
|
|
12
20
|
"esModuleInterop": true,
|
|
13
21
|
"noImplicitAny": false
|
|
14
22
|
},
|
|
15
|
-
"include": [
|
|
16
|
-
|
|
17
|
-
|
|
23
|
+
"include": [
|
|
24
|
+
"src/"
|
|
25
|
+
],
|
|
26
|
+
"exclude": [
|
|
27
|
+
"**/*.spec.ts"
|
|
28
|
+
]
|
|
29
|
+
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
#!/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This scripts queries the npm registry to pull out the latest version for a given tag.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const fs = require("fs");
|
|
8
|
-
const semver = require("semver");
|
|
9
|
-
const child_process = require("child_process");
|
|
10
|
-
const assert = require("assert");
|
|
11
|
-
|
|
12
|
-
const BRANCH_VERSION_PATTERN = /^([A-Za-z]*)-(\d+.\d+.\d+)$/
|
|
13
|
-
|
|
14
|
-
// Load the contents of the package.json file
|
|
15
|
-
const packageJSON = JSON.parse(fs.readFileSync("package.json", "utf8"));
|
|
16
|
-
|
|
17
|
-
let refArgument = process.argv[2];
|
|
18
|
-
let tagArgument = process.argv[3] || "latest";
|
|
19
|
-
|
|
20
|
-
if (refArgument == null) {
|
|
21
|
-
console.error("ref argument is missing");
|
|
22
|
-
console.error("Usage: npm-version-script.js <ref> [tag]");
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Queries the NPM registry for the latest version for the provided tag.
|
|
28
|
-
* @param tag The tag to query for.
|
|
29
|
-
* @returns {string} Returns the version.
|
|
30
|
-
*/
|
|
31
|
-
function getTagVersionFromNpm(tag) {
|
|
32
|
-
try {
|
|
33
|
-
return child_process.execSync(`npm info ${packageJSON.name} version --tag="${tag}"`).toString("utf8").trim();
|
|
34
|
-
} catch (e) {
|
|
35
|
-
throw e;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function desiredTargetVersion(ref) {
|
|
40
|
-
// ref is a GitHub action ref string
|
|
41
|
-
if (ref.startsWith("refs/pull/")) {
|
|
42
|
-
throw Error("The version script was executed inside a PR!");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
assert(ref.startsWith("refs/heads/"))
|
|
46
|
-
let branchName = ref.slice("refs/heads/".length);
|
|
47
|
-
|
|
48
|
-
let results = branchName.match(BRANCH_VERSION_PATTERN);
|
|
49
|
-
if (results != null) {
|
|
50
|
-
if (results[1] !== tagArgument) {
|
|
51
|
-
console.warn(`The base branch name (${results[1]}) differs from the tag name ${tagArgument}`);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return results[2];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// legacy mode were we use the `betaVersion` property in the package.json
|
|
58
|
-
if (branchName === "beta" && packageJSON.betaVersion) {
|
|
59
|
-
return packageJSON.betaVersion
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
throw new Error("Malformed branch name for ref: " + ref + ". Can't derive the base version. Use a branch name like: beta-x.x.x!");
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// derive the base version from the branch ref
|
|
66
|
-
const baseVersion = desiredTargetVersion(refArgument);
|
|
67
|
-
|
|
68
|
-
// query the npm registry for the latest version of the provided tag name
|
|
69
|
-
const latestReleasedVersion = getTagVersionFromNpm(tagArgument); // e.g. 0.7.0-beta.12
|
|
70
|
-
const latestReleaseBase = semver.inc(latestReleasedVersion, "patch"); // will produce 0.7.0 (removing the preid, needed for the equality check below)
|
|
71
|
-
|
|
72
|
-
let publishTag;
|
|
73
|
-
if (semver.eq(baseVersion, latestReleaseBase)) { // check if we are releasing another version for the latest beta
|
|
74
|
-
publishTag = latestReleasedVersion; // set the current latest beta to be incremented
|
|
75
|
-
} else {
|
|
76
|
-
publishTag = baseVersion; // start of with a new beta version
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// save the package.json
|
|
80
|
-
packageJSON.version = publishTag;
|
|
81
|
-
fs.writeFileSync("package.json", JSON.stringify(packageJSON, null, 2));
|