@switchbot/homebridge-switchbot 3.5.0-beta.62 → 3.5.0-beta.63
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 +4 -2
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +2 -1
- package/dist/device/bot.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +3 -1
- package/dist/device/colorbulb.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/motion.js +1 -1
- package/dist/device/motion.js.map +1 -1
- package/dist/device/waterdetector.js +4 -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 +39 -17
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +14 -10
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +27 -14
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +55 -23
- 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 +198 -135
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +54 -59
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +15 -10
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +16 -13
- package/dist/irdevice/waterheater.js.map +1 -1
- package/package.json +1 -1
- package/src/device/blindtilt.ts +4 -2
- package/src/device/bot.ts +2 -1
- package/src/device/colorbulb.ts +3 -2
- package/src/device/curtain.ts +11 -8
- package/src/device/motion.ts +1 -1
- package/src/device/waterdetector.ts +4 -4
- package/src/irdevice/airconditioner.ts +73 -85
- package/src/irdevice/airpurifier.ts +46 -21
- package/src/irdevice/camera.ts +15 -12
- package/src/irdevice/fan.ts +29 -17
- package/src/irdevice/light.ts +70 -42
- package/src/irdevice/other.ts +230 -153
- package/src/irdevice/tv.ts +61 -70
- package/src/irdevice/vacuumcleaner.ts +16 -12
- package/src/irdevice/waterheater.ts +17 -16
package/src/device/blindtilt.ts
CHANGED
|
@@ -66,9 +66,10 @@ export class BlindTilt extends deviceBase {
|
|
|
66
66
|
this.blindTiltUpdateInProgress = false;
|
|
67
67
|
this.setNewTarget = false;
|
|
68
68
|
|
|
69
|
+
accessory.context.WindowCovering = accessory.context.WindowCovering ?? {};
|
|
69
70
|
// Initialize WindowCovering Service
|
|
70
71
|
this.WindowCovering = {
|
|
71
|
-
Name: accessory.context.
|
|
72
|
+
Name: accessory.context.WindowCovering.Name ?? accessory.displayName,
|
|
72
73
|
Service: accessory.getService(this.hap.Service.WindowCovering) ?? accessory.addService(this.hap.Service.WindowCovering) as Service,
|
|
73
74
|
PositionState: accessory.context.PositionState ?? this.hap.Characteristic.PositionState.STOPPED,
|
|
74
75
|
TargetPosition: accessory.context.TargetPosition ?? 100,
|
|
@@ -76,6 +77,7 @@ export class BlindTilt extends deviceBase {
|
|
|
76
77
|
TargetHorizontalTiltAngle: accessory.context.TargetHorizontalTiltAngle ?? 90,
|
|
77
78
|
CurrentHorizontalTiltAngle: accessory.context.CurrentHorizontalTiltAngle ?? 90,
|
|
78
79
|
};
|
|
80
|
+
accessory.context.WindowCovering = this.WindowCovering as object;
|
|
79
81
|
|
|
80
82
|
// Initialize WindowCovering Characteristics
|
|
81
83
|
this.WindowCovering.Service
|
|
@@ -117,7 +119,7 @@ export class BlindTilt extends deviceBase {
|
|
|
117
119
|
return this.WindowCovering.TargetHorizontalTiltAngle;
|
|
118
120
|
})
|
|
119
121
|
.onSet(this.TargetHorizontalTiltAngleSet.bind(this));
|
|
120
|
-
accessory.context.
|
|
122
|
+
accessory.context.WindowCovering.Name = this.WindowCovering.Name;
|
|
121
123
|
|
|
122
124
|
// Initialize WindowCovering CurrentHorizontalTiltAngle Characteristic
|
|
123
125
|
this.WindowCovering.Service
|
package/src/device/bot.ts
CHANGED
|
@@ -111,9 +111,10 @@ export class Bot extends deviceBase {
|
|
|
111
111
|
this.doBotUpdate = new Subject();
|
|
112
112
|
this.botUpdateInProgress = false;
|
|
113
113
|
|
|
114
|
+
accessory.context.Battery = accessory.context.Battery ?? {};
|
|
114
115
|
// Initialize Battery property
|
|
115
116
|
this.Battery = {
|
|
116
|
-
Name: accessory.context.
|
|
117
|
+
Name: accessory.context.Battery.Name ?? `${accessory.displayName} Battery`,
|
|
117
118
|
Service: accessory.getService(this.hap.Service.Battery) ?? accessory.addService(this.hap.Service.Battery) as Service,
|
|
118
119
|
BatteryLevel: accessory.context.BatteryLevel ?? 100,
|
|
119
120
|
StatusLowBattery: accessory.context.StatusLowBattery ?? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
|
package/src/device/colorbulb.ts
CHANGED
|
@@ -51,8 +51,7 @@ export class ColorBulb extends deviceBase {
|
|
|
51
51
|
this.doColorBulbUpdate = new Subject();
|
|
52
52
|
this.colorBulbUpdateInProgress = false;
|
|
53
53
|
|
|
54
|
-
accessory.context.LightBulb = {};
|
|
55
|
-
|
|
54
|
+
accessory.context.LightBulb = accessory.context.LightBulb ?? {};
|
|
56
55
|
// Initialize LightBulb property
|
|
57
56
|
this.LightBulb = {
|
|
58
57
|
Name: accessory.context.LightBulb.Name ?? accessory.displayName,
|
|
@@ -63,6 +62,8 @@ export class ColorBulb extends deviceBase {
|
|
|
63
62
|
Brightness: accessory.context.Brightness ?? 0,
|
|
64
63
|
ColorTemperature: accessory.context.ColorTemperature ?? 140,
|
|
65
64
|
};
|
|
65
|
+
accessory.context.LightBulb = this.LightBulb as object;
|
|
66
|
+
this.errorLog(`${device.deviceType}: ${accessory.displayName} LightBulb Context: ${JSON.stringify(accessory.context.LightBulb)}`);
|
|
66
67
|
|
|
67
68
|
// Adaptive Lighting
|
|
68
69
|
if (this.adaptiveLightingShift === -1 && accessory.context.adaptiveLighting) {
|
package/src/device/curtain.ts
CHANGED
|
@@ -59,15 +59,17 @@ export class Curtain extends deviceBase {
|
|
|
59
59
|
this.curtainUpdateInProgress = false;
|
|
60
60
|
this.setNewTarget = false;
|
|
61
61
|
|
|
62
|
-
// Initialize
|
|
62
|
+
// Initialize WindowCovering Service
|
|
63
|
+
accessory.context.WindowCovering = accessory.context.WindowCovering ?? {};
|
|
63
64
|
this.WindowCovering = {
|
|
64
|
-
Name: accessory.context.
|
|
65
|
+
Name: accessory.context.WindowCovering.Name ?? accessory.displayName,
|
|
65
66
|
Service: accessory.getService(this.hap.Service.WindowCovering) ?? accessory.addService(this.hap.Service.WindowCovering) as Service,
|
|
66
67
|
PositionState: accessory.context.PositionState ?? this.hap.Characteristic.PositionState.STOPPED,
|
|
67
68
|
TargetPosition: accessory.context.TargetPosition ?? 100,
|
|
68
69
|
CurrentPosition: accessory.context.CurrentPosition ?? 100,
|
|
69
70
|
HoldPosition: accessory.context.HoldPosition ?? false,
|
|
70
71
|
};
|
|
72
|
+
accessory.context.WindowCovering = this.WindowCovering as object;
|
|
71
73
|
|
|
72
74
|
// Initialize WindowCovering Service
|
|
73
75
|
this.WindowCovering.Service.
|
|
@@ -77,7 +79,6 @@ export class Curtain extends deviceBase {
|
|
|
77
79
|
.onGet(() => {
|
|
78
80
|
return this.WindowCovering.PositionState;
|
|
79
81
|
});
|
|
80
|
-
accessory.context.WindowCoveringName = this.WindowCovering.Name;
|
|
81
82
|
|
|
82
83
|
// Initialize WindowCovering CurrentPosition
|
|
83
84
|
this.WindowCovering.Service
|
|
@@ -114,14 +115,16 @@ export class Curtain extends deviceBase {
|
|
|
114
115
|
})
|
|
115
116
|
.onSet(this.HoldPositionSet.bind(this));
|
|
116
117
|
|
|
117
|
-
// Initialize Battery
|
|
118
|
+
// Initialize Battery Service
|
|
119
|
+
accessory.context.Battery = accessory.context.Battery ?? {};
|
|
118
120
|
this.Battery = {
|
|
119
|
-
Name: accessory.context.
|
|
121
|
+
Name: accessory.context.Battery.Name ?? `${accessory.displayName} Battery`,
|
|
120
122
|
Service: accessory.getService(this.hap.Service.Battery) ?? accessory.addService(this.hap.Service.Battery) as Service,
|
|
121
123
|
BatteryLevel: accessory.context.BatteryLevel ?? 100,
|
|
122
124
|
StatusLowBattery: accessory.context.StatusLowBattery ?? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
|
|
123
125
|
ChargingState: accessory.context.ChargingState ?? this.hap.Characteristic.ChargingState.NOT_CHARGING,
|
|
124
126
|
};
|
|
127
|
+
accessory.context.Battery = this.Battery as object;
|
|
125
128
|
|
|
126
129
|
// Initialize Battery Service
|
|
127
130
|
this.Battery.Service
|
|
@@ -130,7 +133,6 @@ export class Curtain extends deviceBase {
|
|
|
130
133
|
.onGet(() => {
|
|
131
134
|
return this.Battery.BatteryLevel;
|
|
132
135
|
});
|
|
133
|
-
accessory.context.BatteryName = this.Battery.Name;
|
|
134
136
|
|
|
135
137
|
this.Battery.Service
|
|
136
138
|
.getCharacteristic(this.hap.Characteristic.StatusLowBattery)
|
|
@@ -150,11 +152,13 @@ export class Curtain extends deviceBase {
|
|
|
150
152
|
this.LightSensor!.Service = this.accessory.getService(this.hap.Service.LightSensor) as Service;
|
|
151
153
|
accessory.removeService(this.LightSensor!.Service);
|
|
152
154
|
} else {
|
|
155
|
+
accessory.context.LightSensor = accessory.context.LightSensor ?? {};
|
|
153
156
|
this.LightSensor = {
|
|
154
|
-
Name: accessory.context.
|
|
157
|
+
Name: accessory.context.LightSensor.Name ?? `${accessory.displayName} Light Sensor`,
|
|
155
158
|
Service: accessory.getService(this.hap.Service.LightSensor) ?? this.accessory.addService(this.hap.Service.LightSensor) as Service,
|
|
156
159
|
CurrentAmbientLightLevel: accessory.context.CurrentAmbientLightLevel ?? 0.0001,
|
|
157
160
|
};
|
|
161
|
+
accessory.context.LightSensor = this.LightSensor as object;
|
|
158
162
|
|
|
159
163
|
// Initialize LightSensor Characteristic
|
|
160
164
|
this.LightSensor.Service
|
|
@@ -164,7 +168,6 @@ export class Curtain extends deviceBase {
|
|
|
164
168
|
.onGet(() => {
|
|
165
169
|
return this.LightSensor!.CurrentAmbientLightLevel!;
|
|
166
170
|
});
|
|
167
|
-
accessory.context.LightSensorName = this.LightSensor.Name;
|
|
168
171
|
}
|
|
169
172
|
|
|
170
173
|
// Retrieve initial values and updateHomekit
|
package/src/device/motion.ts
CHANGED
|
@@ -102,7 +102,7 @@ export class Motion extends deviceBase {
|
|
|
102
102
|
this.LightSensor = {
|
|
103
103
|
Name: accessory.context.LightSensorName ?? `${accessory.displayName} Light Sensor`,
|
|
104
104
|
Service: accessory.getService(this.hap.Service.LightSensor) ?? this.accessory.addService(this.hap.Service.LightSensor) as Service,
|
|
105
|
-
CurrentAmbientLightLevel: accessory.context.CurrentAmbientLightLevel ?? 0,
|
|
105
|
+
CurrentAmbientLightLevel: accessory.context.CurrentAmbientLightLevel ?? 0.0001,
|
|
106
106
|
};
|
|
107
107
|
|
|
108
108
|
// Initialize LightSensor Characteristics
|
|
@@ -52,7 +52,7 @@ export class WaterDetector extends deviceBase {
|
|
|
52
52
|
|
|
53
53
|
// Initialize Battery Service
|
|
54
54
|
this.Battery = {
|
|
55
|
-
Name: accessory.context.
|
|
55
|
+
Name: accessory.context.Battery.Name ?? `${accessory.displayName} Battery`,
|
|
56
56
|
Service: accessory.getService(this.hap.Service.Battery) ?? accessory.addService(this.hap.Service.Battery) as Service,
|
|
57
57
|
BatteryLevel: accessory.context.BatteryLevel ?? 100,
|
|
58
58
|
StatusLowBattery: accessory.context.StatusLowBattery ?? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
|
|
@@ -73,7 +73,7 @@ export class WaterDetector extends deviceBase {
|
|
|
73
73
|
.onGet(() => {
|
|
74
74
|
return this.Battery.StatusLowBattery;
|
|
75
75
|
});
|
|
76
|
-
accessory.context.
|
|
76
|
+
accessory.context.Battery.Name = this.Battery.Name;
|
|
77
77
|
|
|
78
78
|
// Initialize Leak Sensor Service
|
|
79
79
|
if (device.waterdetector?.hide_leak) {
|
|
@@ -82,7 +82,7 @@ export class WaterDetector extends deviceBase {
|
|
|
82
82
|
accessory.removeService(this.LeakSensor!.Service);
|
|
83
83
|
} else {
|
|
84
84
|
this.LeakSensor = {
|
|
85
|
-
Name: accessory.context.
|
|
85
|
+
Name: accessory.context.LeakSensor.Name ?? `${accessory.displayName} Leak Sensor`,
|
|
86
86
|
Service: accessory.getService(this.hap.Service.LeakSensor) ?? this.accessory.addService(this.hap.Service.LeakSensor) as Service,
|
|
87
87
|
StatusActive: accessory.context.StatusActive ?? false,
|
|
88
88
|
LeakDetected: accessory.context.LeakDetected ?? this.hap.Characteristic.LeakDetected.LEAK_NOT_DETECTED,
|
|
@@ -96,7 +96,7 @@ export class WaterDetector extends deviceBase {
|
|
|
96
96
|
.onGet(() => {
|
|
97
97
|
return this.LeakSensor!.LeakDetected;
|
|
98
98
|
});
|
|
99
|
-
accessory.context.
|
|
99
|
+
accessory.context.LeakSensor.Name = this.LeakSensor.Name;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
// Retrieve initial values and updateHomekit
|
|
@@ -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,54 @@ 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
|
-
};
|
|
63
|
+
this.ValidValues = this.hide_automode ? [1, 2] : [0, 1, 2];
|
|
71
64
|
|
|
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
|
-
}
|
|
81
65
|
|
|
82
|
-
//
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
66
|
+
// Initialize HeaterCooler Service
|
|
67
|
+
if (!accessory.context.HeaterCooler) {
|
|
68
|
+
accessory.context.HeaterCooler = {};
|
|
69
|
+
}
|
|
70
|
+
this.HeaterCooler = {
|
|
71
|
+
Name: accessory.context.HeaterCooler.Name ?? `${accessory.displayName} ${device.remoteType}`,
|
|
72
|
+
Service: accessory.getService(this.hap.Service.HeaterCooler) ?? accessory.addService(this.hap.Service.HeaterCooler) as Service,
|
|
73
|
+
Active: accessory.context.Active ?? this.hap.Characteristic.Active.INACTIVE,
|
|
74
|
+
CurrentHeaterCoolerState: accessory.context.CurrentHeaterCoolerState ?? this.hap.Characteristic.CurrentHeaterCoolerState.IDLE,
|
|
75
|
+
TargetHeaterCoolerState: accessory.context.TargetHeaterCoolerState ?? this.hap.Characteristic.TargetHeaterCoolerState.AUTO,
|
|
76
|
+
CurrentTemperature: accessory.context.CurrentTemperature ?? 24,
|
|
77
|
+
ThresholdTemperature: accessory.context.ThresholdTemperature ?? 24,
|
|
78
|
+
RotationSpeed: accessory.context.RotationSpeed ?? 4,
|
|
79
|
+
};
|
|
87
80
|
|
|
88
|
-
this.HeaterCooler.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
89
81
|
|
|
90
|
-
|
|
91
|
-
|
|
82
|
+
this.HeaterCooler.Service
|
|
83
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.HeaterCooler.Name)
|
|
84
|
+
.getCharacteristic(this.hap.Characteristic.Active)
|
|
85
|
+
.onGet(() => {
|
|
86
|
+
return this.HeaterCooler.Active;
|
|
87
|
+
})
|
|
92
88
|
.onSet(this.ActiveSet.bind(this));
|
|
93
89
|
|
|
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
|
-
}
|
|
90
|
+
this.HeaterCooler.Service
|
|
91
|
+
.getCharacteristic(this.hap.Characteristic.CurrentTemperature)
|
|
92
|
+
.onGet(async () => {
|
|
93
|
+
return await this.CurrentTemperatureGet();
|
|
94
|
+
});
|
|
108
95
|
|
|
109
96
|
this.HeaterCooler.Service
|
|
110
97
|
.getCharacteristic(this.hap.Characteristic.TargetHeaterCoolerState)
|
|
111
98
|
.setProps({
|
|
112
99
|
validValues: this.ValidValues,
|
|
113
100
|
})
|
|
114
|
-
.onGet(
|
|
101
|
+
.onGet(async () => {
|
|
102
|
+
return await this.TargetHeaterCoolerStateGet();
|
|
103
|
+
})
|
|
115
104
|
.onSet(this.TargetHeaterCoolerStateSet.bind(this));
|
|
116
105
|
|
|
117
|
-
this.HeaterCooler.Service
|
|
118
|
-
.
|
|
106
|
+
this.HeaterCooler.Service
|
|
107
|
+
.getCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState)
|
|
108
|
+
.onGet(async () => {
|
|
109
|
+
return await this.CurrentHeaterCoolerStateGet();
|
|
110
|
+
});
|
|
119
111
|
|
|
120
112
|
this.HeaterCooler.Service
|
|
121
113
|
.getCharacteristic(this.hap.Characteristic.HeatingThresholdTemperature)
|
|
@@ -124,7 +116,9 @@ export class AirConditioner extends irdeviceBase {
|
|
|
124
116
|
maxValue: this.set_max_heat,
|
|
125
117
|
minStep: 0.5,
|
|
126
118
|
})
|
|
127
|
-
.onGet(
|
|
119
|
+
.onGet(async () => {
|
|
120
|
+
return await this.ThresholdTemperatureGet();
|
|
121
|
+
})
|
|
128
122
|
.onSet(this.ThresholdTemperatureSet.bind(this));
|
|
129
123
|
|
|
130
124
|
this.HeaterCooler.Service
|
|
@@ -134,7 +128,9 @@ export class AirConditioner extends irdeviceBase {
|
|
|
134
128
|
maxValue: this.set_max_cool,
|
|
135
129
|
minStep: 0.5,
|
|
136
130
|
})
|
|
137
|
-
.onGet(
|
|
131
|
+
.onGet(async () => {
|
|
132
|
+
return await this.ThresholdTemperatureGet();
|
|
133
|
+
})
|
|
138
134
|
.onSet(this.ThresholdTemperatureSet.bind(this));
|
|
139
135
|
|
|
140
136
|
this.HeaterCooler.Service
|
|
@@ -145,8 +141,36 @@ export class AirConditioner extends irdeviceBase {
|
|
|
145
141
|
minValue: 1,
|
|
146
142
|
maxValue: 4,
|
|
147
143
|
})
|
|
148
|
-
.onGet(
|
|
144
|
+
.onGet(async () => {
|
|
145
|
+
return await this.RotationSpeedGet();
|
|
146
|
+
})
|
|
149
147
|
.onSet(this.RotationSpeedSet.bind(this));
|
|
148
|
+
accessory.context.HeaterCooler.Name = this.HeaterCooler.Name;
|
|
149
|
+
|
|
150
|
+
// Initialize HumiditySensor property
|
|
151
|
+
|
|
152
|
+
if (this.device.irair?.meterType && this.device.irair?.meterId) {
|
|
153
|
+
const meterUuid = this.platform.api.hap.uuid.generate(`${this.device.irair.meterId}-${this.device.irair.meterType}`);
|
|
154
|
+
this.meter = this.platform.accessories.find((accessory) => accessory.UUID === meterUuid);
|
|
155
|
+
this.HumiditySensor = {
|
|
156
|
+
Name: this.meter!.displayName,
|
|
157
|
+
Service: this.meter!.getService(this.hap.Service.HumiditySensor) ?? this.meter!.addService(this.hap.Service.HumiditySensor) as Service,
|
|
158
|
+
CurrentRelativeHumidity: this.meter!.context.CurrentRelativeHumidity || 0,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (this.device.irair?.meterType && this.device.irair?.meterId) {
|
|
163
|
+
const meterUuid = this.platform.api.hap.uuid.generate(`${this.device.irair.meterId}-${this.device.irair.meterType}`);
|
|
164
|
+
this.meter = this.platform.accessories.find((accessory) => accessory.UUID === meterUuid);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (this.meter) {
|
|
168
|
+
this.HumiditySensor!.Service
|
|
169
|
+
.getCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity)
|
|
170
|
+
.onGet(async () => {
|
|
171
|
+
return await this.CurrentRelativeHumidityGet();
|
|
172
|
+
});
|
|
173
|
+
}
|
|
150
174
|
}
|
|
151
175
|
|
|
152
176
|
/**
|
|
@@ -545,43 +569,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
545
569
|
this.HeaterCooler.RotationSpeed = this.HeaterCooler.RotationSpeed || this.accessory.context.RotationSpeed;
|
|
546
570
|
}
|
|
547
571
|
|
|
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
|
-
}
|
|
572
|
+
await this.getAirConditionerConfigSettings(this.accessory, this.device);
|
|
585
573
|
|
|
586
574
|
if (this.meter) {
|
|
587
575
|
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,59 @@ export class AirPurifier extends irdeviceBase {
|
|
|
54
56
|
) {
|
|
55
57
|
super(platform, accessory, device);
|
|
56
58
|
|
|
59
|
+
if (!accessory.context.AirPurifier) {
|
|
60
|
+
accessory.context.AirPurifier = {};
|
|
61
|
+
}
|
|
62
|
+
|
|
57
63
|
// Initialize AirPurifier property
|
|
58
64
|
this.AirPurifier = {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
Name: accessory.context.AirPurifier.Name ?? `${accessory.displayName} Air Purifier`,
|
|
66
|
+
Service: accessory.getService(this.hap.Service.AirPurifier) ?? accessory.addService(this.hap.Service.AirPurifier) as Service,
|
|
67
|
+
Active: accessory.context.Active ?? this.hap.Characteristic.Active.INACTIVE,
|
|
68
|
+
RotationSpeed: accessory.context.RotationSpeed ?? 0,
|
|
69
|
+
CurrentAirPurifierState: accessory.context.CurrentAirPurifierState ?? this.hap.Characteristic.CurrentAirPurifierState.INACTIVE,
|
|
70
|
+
TargetAirPurifierState: accessory.context.TargetAirPurifierState ?? this.hap.Characteristic.TargetAirPurifierState.AUTO,
|
|
64
71
|
};
|
|
65
72
|
|
|
73
|
+
this.AirPurifier.Service
|
|
74
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.AirPurifier.Name)
|
|
75
|
+
.getCharacteristic(this.hap.Characteristic.Active)
|
|
76
|
+
.onGet(() => {
|
|
77
|
+
return this.AirPurifier.Active;
|
|
78
|
+
})
|
|
79
|
+
.onSet(this.ActiveSet.bind(this));
|
|
80
|
+
|
|
81
|
+
this.AirPurifier.Service
|
|
82
|
+
.getCharacteristic(this.hap.Characteristic.CurrentAirPurifierState)
|
|
83
|
+
.onGet(() => {
|
|
84
|
+
return this.CurrentAirPurifierStateGet();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
this.AirPurifier.Service
|
|
88
|
+
.getCharacteristic(this.hap.Characteristic.TargetAirPurifierState)
|
|
89
|
+
.onGet(() => {
|
|
90
|
+
return this.AirPurifier.TargetAirPurifierState;
|
|
91
|
+
})
|
|
92
|
+
.onSet(this.TargetAirPurifierStateSet.bind(this));
|
|
93
|
+
accessory.context.AirPurifier.Name = this.AirPurifier.Name;
|
|
94
|
+
|
|
95
|
+
if (!accessory.context.TemperatureSensor) {
|
|
96
|
+
accessory.context.TemperatureSensor = {};
|
|
97
|
+
}
|
|
66
98
|
// Initialize TemperatureSensor property
|
|
67
99
|
this.TemperatureSensor = {
|
|
68
|
-
|
|
100
|
+
Name: accessory.context.TemperatureSensor.Name ?? `${accessory.displayName} Temperature Sensor`,
|
|
101
|
+
Service: accessory.getService(this.hap.Service.TemperatureSensor) ?? accessory.addService(this.hap.Service.TemperatureSensor) as Service,
|
|
69
102
|
CurrentTemperature: accessory.context.CurrentTemperature || 24,
|
|
70
103
|
};
|
|
71
104
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
// handle on / off events using the Active characteristic
|
|
80
|
-
this.AirPurifier.Service.getCharacteristic(this.hap.Characteristic.Active).onSet(this.ActiveSet.bind(this));
|
|
81
|
-
|
|
82
|
-
this.AirPurifier.Service.getCharacteristic(this.hap.Characteristic.CurrentAirPurifierState).onGet(() => {
|
|
83
|
-
return this.CurrentAirPurifierStateGet();
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
this.AirPurifier.Service.getCharacteristic(this.hap.Characteristic.TargetAirPurifierState).onSet(this.TargetAirPurifierStateSet.bind(this));
|
|
105
|
+
this.TemperatureSensor.Service
|
|
106
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.TemperatureSensor.Name)
|
|
107
|
+
.getCharacteristic(this.hap.Characteristic.CurrentTemperature)
|
|
108
|
+
.onGet(() => {
|
|
109
|
+
return this.TemperatureSensor.CurrentTemperature;
|
|
110
|
+
});
|
|
111
|
+
accessory.context.TemperatureSensor.Name = this.TemperatureSensor.Name;
|
|
87
112
|
}
|
|
88
113
|
|
|
89
114
|
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,24 @@ export class Camera extends irdeviceBase {
|
|
|
29
30
|
) {
|
|
30
31
|
super(platform, accessory, device);
|
|
31
32
|
|
|
33
|
+
if (!accessory.context.Switch) {
|
|
34
|
+
accessory.context.Switch = {};
|
|
35
|
+
}
|
|
32
36
|
// Initialize Switch property
|
|
33
37
|
this.Switch = {
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
Name: accessory.context.Switch.Name ?? `${accessory.displayName} Camera`,
|
|
39
|
+
Service: accessory.getService(this.hap.Service.Switch) ?? accessory.addService(this.hap.Service.Switch) as Service,
|
|
40
|
+
On: accessory.context.On ?? false,
|
|
36
41
|
};
|
|
37
42
|
|
|
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));
|
|
43
|
+
this.Switch.Service
|
|
44
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.Switch.Name)
|
|
45
|
+
.getCharacteristic(this.hap.Characteristic.On)
|
|
46
|
+
.onGet(() => {
|
|
47
|
+
return this.Switch.On;
|
|
48
|
+
})
|
|
49
|
+
.onSet(this.OnSet.bind(this));
|
|
50
|
+
accessory.context.Switch.Name = this.Switch.Name;
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
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,28 @@ export class IRFan extends irdeviceBase {
|
|
|
32
33
|
) {
|
|
33
34
|
super(platform, accessory, device);
|
|
34
35
|
|
|
36
|
+
if (!accessory.context.Fan) {
|
|
37
|
+
accessory.context.Fan = {};
|
|
38
|
+
}
|
|
39
|
+
|
|
35
40
|
// Initialize Switch property
|
|
36
41
|
this.Fan = {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
Name: accessory.context.Fan.Name ?? `${accessory.displayName} Fan`,
|
|
43
|
+
Service: accessory.getService(this.hap.Service.Fanv2) ?? accessory.addService(this.hap.Service.Fanv2) as Service,
|
|
44
|
+
Active: accessory.context.Active ?? this.hap.Characteristic.Active.INACTIVE,
|
|
45
|
+
SwingMode: accessory.context.SwingMode ?? this.hap.Characteristic.SwingMode.SWING_DISABLED,
|
|
46
|
+
RotationSpeed: accessory.context.RotationSpeed ?? 0,
|
|
47
|
+
RotationDirection: accessory.context.RotationDirection ?? this.hap.Characteristic.RotationDirection.CLOCKWISE,
|
|
42
48
|
};
|
|
43
49
|
|
|
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
|
-
|
|
50
|
+
this.Fan.Service
|
|
51
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.Fan.Name)
|
|
52
|
+
.getCharacteristic(this.hap.Characteristic.Active)
|
|
53
|
+
.onGet(() => {
|
|
54
|
+
return this.Fan.Active;
|
|
55
|
+
})
|
|
56
|
+
.onSet(this.ActiveSet.bind(this));
|
|
57
|
+
accessory.context.Fan.Name = this.Fan.Name;
|
|
55
58
|
|
|
56
59
|
if (device.irfan?.rotation_speed) {
|
|
57
60
|
// handle Rotation Speed events using the RotationSpeed characteristic
|
|
@@ -62,6 +65,9 @@ export class IRFan extends irdeviceBase {
|
|
|
62
65
|
minValue: Number(this.minValue(device)),
|
|
63
66
|
maxValue: Number(this.maxValue(device)),
|
|
64
67
|
})
|
|
68
|
+
.onGet(() => {
|
|
69
|
+
return this.Fan.RotationSpeed;
|
|
70
|
+
})
|
|
65
71
|
.onSet(this.RotationSpeedSet.bind(this));
|
|
66
72
|
} else if (this.Fan.Service.testCharacteristic(this.hap.Characteristic.RotationSpeed) && !device.irfan?.swing_mode) {
|
|
67
73
|
const characteristic = this.Fan.Service.getCharacteristic(this.hap.Characteristic.RotationSpeed);
|
|
@@ -76,7 +82,12 @@ export class IRFan extends irdeviceBase {
|
|
|
76
82
|
|
|
77
83
|
if (device.irfan?.swing_mode) {
|
|
78
84
|
// handle Osolcation events using the SwingMode characteristic
|
|
79
|
-
this.Fan.Service
|
|
85
|
+
this.Fan.Service
|
|
86
|
+
.getCharacteristic(this.hap.Characteristic.SwingMode)
|
|
87
|
+
.onGet(() => {
|
|
88
|
+
return this.Fan.SwingMode;
|
|
89
|
+
})
|
|
90
|
+
.onSet(this.SwingModeSet.bind(this));
|
|
80
91
|
} else if (this.Fan.Service.testCharacteristic(this.hap.Characteristic.SwingMode) && !device.irfan?.swing_mode) {
|
|
81
92
|
const characteristic = this.Fan.Service.getCharacteristic(this.hap.Characteristic.SwingMode);
|
|
82
93
|
this.Fan.Service.removeCharacteristic(characteristic);
|
|
@@ -87,6 +98,7 @@ export class IRFan extends irdeviceBase {
|
|
|
87
98
|
`Clear Cache on ${this.accessory.displayName} To Remove Chracteristic`,
|
|
88
99
|
);
|
|
89
100
|
}
|
|
101
|
+
accessory.context.Fan.Name = this.Fan.Name;
|
|
90
102
|
}
|
|
91
103
|
|
|
92
104
|
async minStep(device: irdevice & irDevicesConfig): Promise<number> {
|