@switchbot/homebridge-switchbot 3.5.0-beta.62 → 3.5.0-beta.64
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 -6
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +33 -22
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +4 -3
- package/dist/device/ceilinglight.js.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 +14 -10
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +11 -8
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.js +11 -10
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +7 -5
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +9 -6
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +6 -4
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +10 -6
- 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 +12 -8
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +8 -5
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +9 -6
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +10 -6
- 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/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +6 -4
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +65 -83
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +37 -19
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +13 -11
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +25 -15
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +50 -24
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +180 -138
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +50 -59
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +13 -10
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +14 -13
- package/dist/irdevice/waterheater.js.map +1 -1
- package/package.json +1 -1
- package/src/device/blindtilt.ts +9 -6
- package/src/device/bot.ts +33 -22
- package/src/device/ceilinglight.ts +4 -3
- package/src/device/colorbulb.ts +3 -3
- package/src/device/contact.ts +14 -10
- package/src/device/curtain.ts +11 -8
- package/src/device/device.ts +11 -11
- package/src/device/fan.ts +7 -5
- package/src/device/hub.ts +9 -6
- package/src/device/humidifier.ts +6 -4
- package/src/device/iosensor.ts +10 -6
- package/src/device/lightstrip.ts +3 -2
- package/src/device/lock.ts +12 -8
- package/src/device/meter.ts +8 -5
- package/src/device/meterplus.ts +9 -6
- package/src/device/motion.ts +10 -6
- package/src/device/plug.ts +3 -2
- package/src/device/robotvacuumcleaner.ts +6 -4
- package/src/device/waterdetector.ts +6 -4
- package/src/irdevice/airconditioner.ts +73 -86
- package/src/irdevice/airpurifier.ts +43 -23
- package/src/irdevice/camera.ts +14 -13
- package/src/irdevice/fan.ts +26 -18
- package/src/irdevice/light.ts +65 -45
- package/src/irdevice/other.ts +210 -154
- package/src/irdevice/tv.ts +57 -70
- package/src/irdevice/vacuumcleaner.ts +14 -12
- package/src/irdevice/waterheater.ts +15 -16
|
@@ -18,6 +18,7 @@ import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge
|
|
|
18
18
|
export class AirConditioner extends irdeviceBase {
|
|
19
19
|
// Services
|
|
20
20
|
private HeaterCooler: {
|
|
21
|
+
Name: CharacteristicValue;
|
|
21
22
|
Service: Service;
|
|
22
23
|
Active: CharacteristicValue;
|
|
23
24
|
CurrentHeaterCoolerState: CharacteristicValue;
|
|
@@ -27,7 +28,9 @@ export class AirConditioner extends irdeviceBase {
|
|
|
27
28
|
RotationSpeed: CharacteristicValue;
|
|
28
29
|
};
|
|
29
30
|
|
|
31
|
+
meter?: PlatformAccessory;
|
|
30
32
|
private HumiditySensor?: {
|
|
33
|
+
Name: CharacteristicValue;
|
|
31
34
|
Service: Service;
|
|
32
35
|
CurrentRelativeHumidity: CharacteristicValue;
|
|
33
36
|
};
|
|
@@ -46,7 +49,6 @@ export class AirConditioner extends irdeviceBase {
|
|
|
46
49
|
set_min_heat?: number;
|
|
47
50
|
set_max_cool?: number;
|
|
48
51
|
set_min_cool?: number;
|
|
49
|
-
meter?: PlatformAccessory;
|
|
50
52
|
|
|
51
53
|
constructor(
|
|
52
54
|
readonly platform: SwitchBotPlatform,
|
|
@@ -58,64 +60,52 @@ export class AirConditioner extends irdeviceBase {
|
|
|
58
60
|
// default placeholders
|
|
59
61
|
this.getAirConditionerConfigSettings(accessory, device);
|
|
60
62
|
|
|
61
|
-
|
|
62
|
-
this.HeaterCooler = {
|
|
63
|
-
Service: accessory.getService(this.hap.Service.Switch) as Service,
|
|
64
|
-
Active: accessory.context.Active || this.hap.Characteristic.Active.INACTIVE,
|
|
65
|
-
CurrentHeaterCoolerState: accessory.context.CurrentHeaterCoolerState || this.hap.Characteristic.CurrentHeaterCoolerState.IDLE,
|
|
66
|
-
TargetHeaterCoolerState: accessory.context.TargetHeaterCoolerState || this.hap.Characteristic.TargetHeaterCoolerState.AUTO,
|
|
67
|
-
CurrentTemperature: accessory.context.CurrentTemperature || 24,
|
|
68
|
-
ThresholdTemperature: accessory.context.ThresholdTemperature || 24,
|
|
69
|
-
RotationSpeed: accessory.context.RotationSpeed || 4,
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
// Initialize HumiditySensor property
|
|
73
|
-
if (this.device.irair?.meterType && this.device.irair?.meterId) {
|
|
74
|
-
const meterUuid = this.platform.api.hap.uuid.generate(`${this.device.irair.meterId}-${this.device.irair.meterType}`);
|
|
75
|
-
this.meter = this.platform.accessories.find((accessory) => accessory.UUID === meterUuid);
|
|
76
|
-
this.HumiditySensor = {
|
|
77
|
-
Service: this.meter!.getService(this.hap.Service.HumiditySensor) as Service,
|
|
78
|
-
CurrentRelativeHumidity: this.meter!.context.CurrentRelativeHumidity || 0,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
63
|
+
this.ValidValues = this.hide_automode ? [1, 2] : [0, 1, 2];
|
|
81
64
|
|
|
82
|
-
// get the Television service if it exists, otherwise create a new Television service
|
|
83
|
-
// you can create multiple services for each accessory
|
|
84
|
-
const HeaterCoolerService = `${accessory.displayName} ${device.remoteType}`;
|
|
85
|
-
(this.HeaterCooler.Service = accessory.getService(this.hap.Service.HeaterCooler)
|
|
86
|
-
|| accessory.addService(this.hap.Service.HeaterCooler)), HeaterCoolerService;
|
|
87
65
|
|
|
88
|
-
|
|
66
|
+
// Initialize HeaterCooler Service
|
|
67
|
+
accessory.context.HeaterCooler = accessory.context.HeaterCooler ?? {};
|
|
68
|
+
this.HeaterCooler = {
|
|
69
|
+
Name: accessory.context.HeaterCooler.Name ?? `${accessory.displayName} ${device.remoteType}`,
|
|
70
|
+
Service: accessory.getService(this.hap.Service.HeaterCooler) ?? accessory.addService(this.hap.Service.HeaterCooler) as Service,
|
|
71
|
+
Active: accessory.context.Active ?? this.hap.Characteristic.Active.INACTIVE,
|
|
72
|
+
CurrentHeaterCoolerState: accessory.context.CurrentHeaterCoolerState ?? this.hap.Characteristic.CurrentHeaterCoolerState.IDLE,
|
|
73
|
+
TargetHeaterCoolerState: accessory.context.TargetHeaterCoolerState ?? this.hap.Characteristic.TargetHeaterCoolerState.AUTO,
|
|
74
|
+
CurrentTemperature: accessory.context.CurrentTemperature ?? 24,
|
|
75
|
+
ThresholdTemperature: accessory.context.ThresholdTemperature ?? 24,
|
|
76
|
+
RotationSpeed: accessory.context.RotationSpeed ?? 4,
|
|
77
|
+
};
|
|
78
|
+
accessory.context.HeaterCooler = this.HeaterCooler as object;
|
|
89
79
|
|
|
90
|
-
|
|
91
|
-
|
|
80
|
+
this.HeaterCooler.Service
|
|
81
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.HeaterCooler.Name)
|
|
82
|
+
.getCharacteristic(this.hap.Characteristic.Active)
|
|
83
|
+
.onGet(() => {
|
|
84
|
+
return this.HeaterCooler.Active;
|
|
85
|
+
})
|
|
92
86
|
.onSet(this.ActiveSet.bind(this));
|
|
93
87
|
|
|
94
|
-
this.HeaterCooler.Service
|
|
95
|
-
.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (this.device.irair?.meterType && this.device.irair?.meterId) {
|
|
100
|
-
const meterUuid = this.platform.api.hap.uuid.generate(`${this.device.irair.meterId}-${this.device.irair.meterType}`);
|
|
101
|
-
this.meter = this.platform.accessories.find((accessory) => accessory.UUID === meterUuid);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (this.meter) {
|
|
105
|
-
this.HumiditySensor!.Service.getCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity)
|
|
106
|
-
.onGet(this.CurrentRelativeHumidityGet.bind(this));
|
|
107
|
-
}
|
|
88
|
+
this.HeaterCooler.Service
|
|
89
|
+
.getCharacteristic(this.hap.Characteristic.CurrentTemperature)
|
|
90
|
+
.onGet(async () => {
|
|
91
|
+
return await this.CurrentTemperatureGet();
|
|
92
|
+
});
|
|
108
93
|
|
|
109
94
|
this.HeaterCooler.Service
|
|
110
95
|
.getCharacteristic(this.hap.Characteristic.TargetHeaterCoolerState)
|
|
111
96
|
.setProps({
|
|
112
97
|
validValues: this.ValidValues,
|
|
113
98
|
})
|
|
114
|
-
.onGet(
|
|
99
|
+
.onGet(async () => {
|
|
100
|
+
return await this.TargetHeaterCoolerStateGet();
|
|
101
|
+
})
|
|
115
102
|
.onSet(this.TargetHeaterCoolerStateSet.bind(this));
|
|
116
103
|
|
|
117
|
-
this.HeaterCooler.Service
|
|
118
|
-
.
|
|
104
|
+
this.HeaterCooler.Service
|
|
105
|
+
.getCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState)
|
|
106
|
+
.onGet(async () => {
|
|
107
|
+
return await this.CurrentHeaterCoolerStateGet();
|
|
108
|
+
});
|
|
119
109
|
|
|
120
110
|
this.HeaterCooler.Service
|
|
121
111
|
.getCharacteristic(this.hap.Characteristic.HeatingThresholdTemperature)
|
|
@@ -124,7 +114,9 @@ export class AirConditioner extends irdeviceBase {
|
|
|
124
114
|
maxValue: this.set_max_heat,
|
|
125
115
|
minStep: 0.5,
|
|
126
116
|
})
|
|
127
|
-
.onGet(
|
|
117
|
+
.onGet(async () => {
|
|
118
|
+
return await this.ThresholdTemperatureGet();
|
|
119
|
+
})
|
|
128
120
|
.onSet(this.ThresholdTemperatureSet.bind(this));
|
|
129
121
|
|
|
130
122
|
this.HeaterCooler.Service
|
|
@@ -134,7 +126,9 @@ export class AirConditioner extends irdeviceBase {
|
|
|
134
126
|
maxValue: this.set_max_cool,
|
|
135
127
|
minStep: 0.5,
|
|
136
128
|
})
|
|
137
|
-
.onGet(
|
|
129
|
+
.onGet(async () => {
|
|
130
|
+
return await this.ThresholdTemperatureGet();
|
|
131
|
+
})
|
|
138
132
|
.onSet(this.ThresholdTemperatureSet.bind(this));
|
|
139
133
|
|
|
140
134
|
this.HeaterCooler.Service
|
|
@@ -145,8 +139,37 @@ export class AirConditioner extends irdeviceBase {
|
|
|
145
139
|
minValue: 1,
|
|
146
140
|
maxValue: 4,
|
|
147
141
|
})
|
|
148
|
-
.onGet(
|
|
142
|
+
.onGet(async () => {
|
|
143
|
+
return await this.RotationSpeedGet();
|
|
144
|
+
})
|
|
149
145
|
.onSet(this.RotationSpeedSet.bind(this));
|
|
146
|
+
|
|
147
|
+
// Initialize HumiditySensor property
|
|
148
|
+
|
|
149
|
+
if (this.device.irair?.meterType && this.device.irair?.meterId) {
|
|
150
|
+
const meterUuid = this.platform.api.hap.uuid.generate(`${this.device.irair.meterId}-${this.device.irair.meterType}`);
|
|
151
|
+
this.meter = this.platform.accessories.find((accessory) => accessory.UUID === meterUuid);
|
|
152
|
+
accessory.context.HumiditySensor = accessory.context.HumiditySensor ?? {};
|
|
153
|
+
this.HumiditySensor = {
|
|
154
|
+
Name: accessory.context.HumiditySensor ?? this.meter!.displayName,
|
|
155
|
+
Service: this.meter!.getService(this.hap.Service.HumiditySensor) ?? this.meter!.addService(this.hap.Service.HumiditySensor) as Service,
|
|
156
|
+
CurrentRelativeHumidity: this.meter!.context.CurrentRelativeHumidity || 0,
|
|
157
|
+
};
|
|
158
|
+
accessory.context.HumiditySensor = this.HumiditySensor as object;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (this.device.irair?.meterType && this.device.irair?.meterId) {
|
|
162
|
+
const meterUuid = this.platform.api.hap.uuid.generate(`${this.device.irair.meterId}-${this.device.irair.meterType}`);
|
|
163
|
+
this.meter = this.platform.accessories.find((accessory) => accessory.UUID === meterUuid);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (this.meter) {
|
|
167
|
+
this.HumiditySensor!.Service
|
|
168
|
+
.getCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity)
|
|
169
|
+
.onGet(async () => {
|
|
170
|
+
return await this.CurrentRelativeHumidityGet();
|
|
171
|
+
});
|
|
172
|
+
}
|
|
150
173
|
}
|
|
151
174
|
|
|
152
175
|
/**
|
|
@@ -545,43 +568,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
545
568
|
this.HeaterCooler.RotationSpeed = this.HeaterCooler.RotationSpeed || this.accessory.context.RotationSpeed;
|
|
546
569
|
}
|
|
547
570
|
|
|
548
|
-
|
|
549
|
-
this.hide_automode = this.device.irair?.hide_automode;
|
|
550
|
-
this.accessory.context.hide_automode = this.hide_automode;
|
|
551
|
-
} else {
|
|
552
|
-
this.hide_automode = this.device.irair?.hide_automode;
|
|
553
|
-
this.accessory.context.hide_automode = this.hide_automode;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
if (this.device.irair?.set_max_heat) {
|
|
557
|
-
this.set_max_heat = this.device.irair?.set_max_heat;
|
|
558
|
-
this.accessory.context.set_max_heat = this.set_max_heat;
|
|
559
|
-
} else {
|
|
560
|
-
this.set_max_heat = 35;
|
|
561
|
-
this.accessory.context.set_max_heat = this.set_max_heat;
|
|
562
|
-
}
|
|
563
|
-
if (this.device.irair?.set_min_heat) {
|
|
564
|
-
this.set_min_heat = this.device.irair?.set_min_heat;
|
|
565
|
-
this.accessory.context.set_min_heat = this.set_min_heat;
|
|
566
|
-
} else {
|
|
567
|
-
this.set_min_heat = 0;
|
|
568
|
-
this.accessory.context.set_min_heat = this.set_min_heat;
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
if (this.device.irair?.set_max_cool) {
|
|
572
|
-
this.set_max_cool = this.device.irair?.set_max_cool;
|
|
573
|
-
this.accessory.context.set_max_cool = this.set_max_cool;
|
|
574
|
-
} else {
|
|
575
|
-
this.set_max_cool = 35;
|
|
576
|
-
this.accessory.context.set_max_cool = this.set_max_cool;
|
|
577
|
-
}
|
|
578
|
-
if (this.device.irair?.set_min_cool) {
|
|
579
|
-
this.set_min_cool = this.device.irair?.set_min_cool;
|
|
580
|
-
this.accessory.context.set_min_cool = this.set_min_cool;
|
|
581
|
-
} else {
|
|
582
|
-
this.set_min_cool = 0;
|
|
583
|
-
this.accessory.context.set_min_cool = this.set_min_cool;
|
|
584
|
-
}
|
|
571
|
+
await this.getAirConditionerConfigSettings(this.accessory, this.device);
|
|
585
572
|
|
|
586
573
|
if (this.meter) {
|
|
587
574
|
if (this.HumiditySensor!.CurrentRelativeHumidity === undefined && this.accessory.context.CurrentRelativeHumidity === undefined) {
|
|
@@ -18,6 +18,7 @@ import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge
|
|
|
18
18
|
export class AirPurifier extends irdeviceBase {
|
|
19
19
|
// Services
|
|
20
20
|
private AirPurifier: {
|
|
21
|
+
Name: CharacteristicValue;
|
|
21
22
|
Service: Service;
|
|
22
23
|
Active: CharacteristicValue;
|
|
23
24
|
RotationSpeed: CharacteristicValue;
|
|
@@ -26,6 +27,7 @@ export class AirPurifier extends irdeviceBase {
|
|
|
26
27
|
};
|
|
27
28
|
|
|
28
29
|
private TemperatureSensor: {
|
|
30
|
+
Name: CharacteristicValue;
|
|
29
31
|
Service: Service;
|
|
30
32
|
CurrentTemperature: CharacteristicValue;
|
|
31
33
|
};
|
|
@@ -54,36 +56,54 @@ export class AirPurifier extends irdeviceBase {
|
|
|
54
56
|
) {
|
|
55
57
|
super(platform, accessory, device);
|
|
56
58
|
|
|
57
|
-
// Initialize AirPurifier
|
|
59
|
+
// Initialize AirPurifier Service
|
|
60
|
+
accessory.context.AirPurifier = accessory.context.AirPurifier ?? {};
|
|
58
61
|
this.AirPurifier = {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
Name: accessory.context.AirPurifier.Name ?? `${accessory.displayName} Air Purifier`,
|
|
63
|
+
Service: accessory.getService(this.hap.Service.AirPurifier) ?? accessory.addService(this.hap.Service.AirPurifier) as Service,
|
|
64
|
+
Active: accessory.context.Active ?? this.hap.Characteristic.Active.INACTIVE,
|
|
65
|
+
RotationSpeed: accessory.context.RotationSpeed ?? 0,
|
|
66
|
+
CurrentAirPurifierState: accessory.context.CurrentAirPurifierState ?? this.hap.Characteristic.CurrentAirPurifierState.INACTIVE,
|
|
67
|
+
TargetAirPurifierState: accessory.context.TargetAirPurifierState ?? this.hap.Characteristic.TargetAirPurifierState.AUTO,
|
|
64
68
|
};
|
|
69
|
+
accessory.context.AirPurifier = this.AirPurifier as object;
|
|
65
70
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
this.AirPurifier.Service
|
|
72
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.AirPurifier.Name)
|
|
73
|
+
.getCharacteristic(this.hap.Characteristic.Active)
|
|
74
|
+
.onGet(() => {
|
|
75
|
+
return this.AirPurifier.Active;
|
|
76
|
+
})
|
|
77
|
+
.onSet(this.ActiveSet.bind(this));
|
|
71
78
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
79
|
+
this.AirPurifier.Service
|
|
80
|
+
.getCharacteristic(this.hap.Characteristic.CurrentAirPurifierState)
|
|
81
|
+
.onGet(() => {
|
|
82
|
+
return this.CurrentAirPurifierStateGet();
|
|
83
|
+
});
|
|
77
84
|
|
|
78
|
-
this.AirPurifier.Service
|
|
79
|
-
|
|
80
|
-
|
|
85
|
+
this.AirPurifier.Service
|
|
86
|
+
.getCharacteristic(this.hap.Characteristic.TargetAirPurifierState)
|
|
87
|
+
.onGet(() => {
|
|
88
|
+
return this.AirPurifier.TargetAirPurifierState;
|
|
89
|
+
})
|
|
90
|
+
.onSet(this.TargetAirPurifierStateSet.bind(this));
|
|
81
91
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
92
|
+
// Initialize TemperatureSensor Service
|
|
93
|
+
accessory.context.TemperatureSensor = accessory.context.TemperatureSensor ?? {};
|
|
94
|
+
this.TemperatureSensor = {
|
|
95
|
+
Name: accessory.context.TemperatureSensor.Name ?? `${accessory.displayName} Temperature Sensor`,
|
|
96
|
+
Service: accessory.getService(this.hap.Service.TemperatureSensor) ?? accessory.addService(this.hap.Service.TemperatureSensor) as Service,
|
|
97
|
+
CurrentTemperature: accessory.context.CurrentTemperature || 24,
|
|
98
|
+
};
|
|
99
|
+
accessory.context.TemperatureSensor = this.TemperatureSensor as object;
|
|
85
100
|
|
|
86
|
-
this.
|
|
101
|
+
this.TemperatureSensor.Service
|
|
102
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.TemperatureSensor.Name)
|
|
103
|
+
.getCharacteristic(this.hap.Characteristic.CurrentTemperature)
|
|
104
|
+
.onGet(() => {
|
|
105
|
+
return this.TemperatureSensor.CurrentTemperature;
|
|
106
|
+
});
|
|
87
107
|
}
|
|
88
108
|
|
|
89
109
|
async ActiveSet(value: CharacteristicValue): Promise<void> {
|
package/src/irdevice/camera.ts
CHANGED
|
@@ -18,6 +18,7 @@ import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge
|
|
|
18
18
|
export class Camera extends irdeviceBase {
|
|
19
19
|
// Services
|
|
20
20
|
private Switch: {
|
|
21
|
+
Name: CharacteristicValue;
|
|
21
22
|
Service: Service;
|
|
22
23
|
On: CharacteristicValue;
|
|
23
24
|
};
|
|
@@ -29,22 +30,22 @@ export class Camera extends irdeviceBase {
|
|
|
29
30
|
) {
|
|
30
31
|
super(platform, accessory, device);
|
|
31
32
|
|
|
32
|
-
// Initialize Switch
|
|
33
|
+
// Initialize Switch Service
|
|
34
|
+
accessory.context.Switch = accessory.context.Switch ?? {};
|
|
33
35
|
this.Switch = {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
Name: accessory.context.Switch.Name ?? `${accessory.displayName} Camera`,
|
|
37
|
+
Service: accessory.getService(this.hap.Service.Switch) ?? accessory.addService(this.hap.Service.Switch) as Service,
|
|
38
|
+
On: accessory.context.On ?? false,
|
|
36
39
|
};
|
|
40
|
+
accessory.context.Switch = this.Switch as object;
|
|
37
41
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// handle on / off events using the On characteristic
|
|
47
|
-
this.Switch.Service.getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
42
|
+
this.Switch.Service
|
|
43
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.Switch.Name)
|
|
44
|
+
.getCharacteristic(this.hap.Characteristic.On)
|
|
45
|
+
.onGet(() => {
|
|
46
|
+
return this.Switch.On;
|
|
47
|
+
})
|
|
48
|
+
.onSet(this.OnSet.bind(this));
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
async OnSet(value: CharacteristicValue): Promise<void> {
|
package/src/irdevice/fan.ts
CHANGED
|
@@ -18,6 +18,7 @@ import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge
|
|
|
18
18
|
export class IRFan extends irdeviceBase {
|
|
19
19
|
// Services
|
|
20
20
|
private Fan: {
|
|
21
|
+
Name: CharacteristicValue;
|
|
21
22
|
Service: Service;
|
|
22
23
|
Active: CharacteristicValue;
|
|
23
24
|
SwingMode: CharacteristicValue;
|
|
@@ -32,26 +33,25 @@ export class IRFan extends irdeviceBase {
|
|
|
32
33
|
) {
|
|
33
34
|
super(platform, accessory, device);
|
|
34
35
|
|
|
35
|
-
// Initialize Switch
|
|
36
|
+
// Initialize Switch Service
|
|
37
|
+
accessory.context.Fan = accessory.context.Fan ?? {};
|
|
36
38
|
this.Fan = {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
Name: accessory.context.Fan.Name ?? `${accessory.displayName} Fan`,
|
|
40
|
+
Service: accessory.getService(this.hap.Service.Fanv2) ?? accessory.addService(this.hap.Service.Fanv2) as Service,
|
|
41
|
+
Active: accessory.context.Active ?? this.hap.Characteristic.Active.INACTIVE,
|
|
42
|
+
SwingMode: accessory.context.SwingMode ?? this.hap.Characteristic.SwingMode.SWING_DISABLED,
|
|
43
|
+
RotationSpeed: accessory.context.RotationSpeed ?? 0,
|
|
44
|
+
RotationDirection: accessory.context.RotationDirection ?? this.hap.Characteristic.RotationDirection.CLOCKWISE,
|
|
42
45
|
};
|
|
46
|
+
accessory.context.Fan = this.Fan as object;
|
|
43
47
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
// handle on / off events using the Active characteristic
|
|
53
|
-
this.Fan.Service.getCharacteristic(this.hap.Characteristic.Active).onSet(this.ActiveSet.bind(this));
|
|
54
|
-
|
|
48
|
+
this.Fan.Service
|
|
49
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.Fan.Name)
|
|
50
|
+
.getCharacteristic(this.hap.Characteristic.Active)
|
|
51
|
+
.onGet(() => {
|
|
52
|
+
return this.Fan.Active;
|
|
53
|
+
})
|
|
54
|
+
.onSet(this.ActiveSet.bind(this));
|
|
55
55
|
|
|
56
56
|
if (device.irfan?.rotation_speed) {
|
|
57
57
|
// handle Rotation Speed events using the RotationSpeed characteristic
|
|
@@ -62,6 +62,9 @@ export class IRFan extends irdeviceBase {
|
|
|
62
62
|
minValue: Number(this.minValue(device)),
|
|
63
63
|
maxValue: Number(this.maxValue(device)),
|
|
64
64
|
})
|
|
65
|
+
.onGet(() => {
|
|
66
|
+
return this.Fan.RotationSpeed;
|
|
67
|
+
})
|
|
65
68
|
.onSet(this.RotationSpeedSet.bind(this));
|
|
66
69
|
} else if (this.Fan.Service.testCharacteristic(this.hap.Characteristic.RotationSpeed) && !device.irfan?.swing_mode) {
|
|
67
70
|
const characteristic = this.Fan.Service.getCharacteristic(this.hap.Characteristic.RotationSpeed);
|
|
@@ -76,7 +79,12 @@ export class IRFan extends irdeviceBase {
|
|
|
76
79
|
|
|
77
80
|
if (device.irfan?.swing_mode) {
|
|
78
81
|
// handle Osolcation events using the SwingMode characteristic
|
|
79
|
-
this.Fan.Service
|
|
82
|
+
this.Fan.Service
|
|
83
|
+
.getCharacteristic(this.hap.Characteristic.SwingMode)
|
|
84
|
+
.onGet(() => {
|
|
85
|
+
return this.Fan.SwingMode;
|
|
86
|
+
})
|
|
87
|
+
.onSet(this.SwingModeSet.bind(this));
|
|
80
88
|
} else if (this.Fan.Service.testCharacteristic(this.hap.Characteristic.SwingMode) && !device.irfan?.swing_mode) {
|
|
81
89
|
const characteristic = this.Fan.Service.getCharacteristic(this.hap.Characteristic.SwingMode);
|
|
82
90
|
this.Fan.Service.removeCharacteristic(characteristic);
|
package/src/irdevice/light.ts
CHANGED
|
@@ -18,17 +18,20 @@ import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge
|
|
|
18
18
|
export class Light extends irdeviceBase {
|
|
19
19
|
// Services
|
|
20
20
|
private LightBulb?: {
|
|
21
|
+
Name: CharacteristicValue;
|
|
21
22
|
Service: Service;
|
|
22
23
|
On: CharacteristicValue;
|
|
23
24
|
};
|
|
24
25
|
|
|
25
26
|
private ProgrammableSwitchOn?: {
|
|
27
|
+
Name: CharacteristicValue;
|
|
26
28
|
Service: Service;
|
|
27
29
|
ProgrammableSwitchEvent: CharacteristicValue;
|
|
28
30
|
ProgrammableSwitchOutputState: CharacteristicValue;
|
|
29
31
|
};
|
|
30
32
|
|
|
31
33
|
private ProgrammableSwitchOff?: {
|
|
34
|
+
Name: CharacteristicValue;
|
|
32
35
|
Service: Service;
|
|
33
36
|
ProgrammableSwitchEvent: CharacteristicValue;
|
|
34
37
|
ProgrammableSwitchOutputState: CharacteristicValue;
|
|
@@ -42,66 +45,83 @@ export class Light extends irdeviceBase {
|
|
|
42
45
|
super(platform, accessory, device);
|
|
43
46
|
|
|
44
47
|
if (!device.irlight?.stateless) {
|
|
45
|
-
// Initialize LightBulb
|
|
48
|
+
// Initialize LightBulb Service
|
|
49
|
+
accessory.context.LightBulb = accessory.context.LightBulb ?? {};
|
|
46
50
|
this.LightBulb = {
|
|
47
|
-
|
|
51
|
+
Name: accessory.context.LightBulb.Name ?? `${accessory.displayName} ${device.remoteType}`,
|
|
52
|
+
Service: accessory.getService(this.hap.Service.Lightbulb) ?? accessory.addService(this.hap.Service.Lightbulb) as Service,
|
|
48
53
|
On: accessory.context.On || false,
|
|
49
54
|
};
|
|
50
|
-
|
|
51
|
-
// you can create multiple services for each accessory
|
|
52
|
-
const LightBulbService = `${accessory.displayName} ${device.remoteType}`;
|
|
53
|
-
(this.LightBulb.Service = accessory.getService(this.hap.Service.Lightbulb)
|
|
54
|
-
|| accessory.addService(this.hap.Service.Lightbulb)), LightBulbService;
|
|
55
|
+
accessory.context.LightBulb = this.LightBulb as object;
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
this.LightBulb.Service
|
|
58
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.LightBulb.Name)
|
|
59
|
+
.getCharacteristic(this.hap.Characteristic.On)
|
|
60
|
+
.onGet(() => {
|
|
61
|
+
return this.LightBulb!.On;
|
|
62
|
+
})
|
|
63
|
+
.onSet(this.OnSet.bind(this));
|
|
61
64
|
} else {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
65
|
+
// Initialize ProgrammableSwitchOn Service
|
|
66
|
+
accessory.context.ProgrammableSwitchOn = accessory.context.ProgrammableSwitchOn ?? {};
|
|
67
|
+
this.ProgrammableSwitchOn = {
|
|
68
|
+
Name: accessory.context.ProgrammableSwitchOn.Name ?? `${accessory.displayName} ${device.remoteType} On`,
|
|
69
|
+
Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch)
|
|
70
|
+
?? accessory.addService(this.hap.Service.StatefulProgrammableSwitch) as Service,
|
|
71
|
+
ProgrammableSwitchEvent: accessory.context.ProgrammableSwitchEvent ?? this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS,
|
|
72
|
+
ProgrammableSwitchOutputState: accessory.context.ProgrammableSwitchOutputState ?? 0,
|
|
73
|
+
};
|
|
74
|
+
accessory.context.ProgrammableSwitchOn = this.ProgrammableSwitchOn as object;
|
|
75
|
+
|
|
76
|
+
// Initialize ProgrammableSwitchOn Characteristics
|
|
77
|
+
this.ProgrammableSwitchOn?.Service
|
|
78
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.ProgrammableSwitchOn.Name)
|
|
79
|
+
.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent).setProps({
|
|
80
|
+
validValueRanges: [0, 0],
|
|
81
|
+
minValue: 0,
|
|
82
|
+
maxValue: 0,
|
|
83
|
+
validValues: [0],
|
|
84
|
+
})
|
|
77
85
|
.onGet(() => {
|
|
78
86
|
return this.ProgrammableSwitchOn!.ProgrammableSwitchEvent;
|
|
79
87
|
});
|
|
80
88
|
|
|
81
|
-
this.ProgrammableSwitchOn?.Service
|
|
89
|
+
this.ProgrammableSwitchOn?.Service
|
|
90
|
+
.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState)
|
|
91
|
+
.onGet(() => {
|
|
92
|
+
return this.ProgrammableSwitchOn!.ProgrammableSwitchOutputState;
|
|
93
|
+
})
|
|
82
94
|
.onSet(this.ProgrammableSwitchOutputStateSetOn.bind(this));
|
|
83
95
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
// Initialize ProgrammableSwitchOff Service
|
|
97
|
+
accessory.context.ProgrammableSwitchOff = accessory.context.ProgrammableSwitchOff ?? {};
|
|
98
|
+
this.ProgrammableSwitchOff = {
|
|
99
|
+
Name: accessory.context.ProgrammableSwitchOff.Name ?? `${accessory.displayName} ${device.remoteType} Off`,
|
|
100
|
+
Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch)
|
|
101
|
+
?? accessory.addService(this.hap.Service.StatefulProgrammableSwitch) as Service,
|
|
102
|
+
ProgrammableSwitchEvent: accessory.context.ProgrammableSwitchEvent ?? this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS,
|
|
103
|
+
ProgrammableSwitchOutputState: accessory.context.ProgrammableSwitchOutputState ?? 0,
|
|
104
|
+
};
|
|
105
|
+
accessory.context.ProgrammableSwitchOff = this.ProgrammableSwitchOff as object;
|
|
106
|
+
|
|
107
|
+
// Initialize ProgrammableSwitchOff Characteristics
|
|
108
|
+
this.ProgrammableSwitchOff?.Service
|
|
109
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.ProgrammableSwitchOff.Name)
|
|
110
|
+
.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent).setProps({
|
|
111
|
+
validValueRanges: [0, 0],
|
|
112
|
+
minValue: 0,
|
|
113
|
+
maxValue: 0,
|
|
114
|
+
validValues: [0],
|
|
115
|
+
})
|
|
100
116
|
.onGet(() => {
|
|
101
117
|
return this.ProgrammableSwitchOff!.ProgrammableSwitchEvent;
|
|
102
118
|
});
|
|
103
119
|
|
|
104
|
-
this.ProgrammableSwitchOff?.Service
|
|
120
|
+
this.ProgrammableSwitchOff?.Service
|
|
121
|
+
.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState)
|
|
122
|
+
.onGet(() => {
|
|
123
|
+
return this.ProgrammableSwitchOff!.ProgrammableSwitchOutputState;
|
|
124
|
+
})
|
|
105
125
|
.onSet(this.ProgrammableSwitchOutputStateSetOff.bind(this));
|
|
106
126
|
}
|
|
107
127
|
|