@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/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;
|
|
@@ -41,68 +44,93 @@ export class Light extends irdeviceBase {
|
|
|
41
44
|
) {
|
|
42
45
|
super(platform, accessory, device);
|
|
43
46
|
|
|
47
|
+
|
|
48
|
+
|
|
44
49
|
if (!device.irlight?.stateless) {
|
|
50
|
+
if (!accessory.context.LightBulb) {
|
|
51
|
+
accessory.context.LightBulb = {};
|
|
52
|
+
}
|
|
45
53
|
// Initialize LightBulb property
|
|
46
54
|
this.LightBulb = {
|
|
47
|
-
|
|
55
|
+
Name: accessory.context.LightBulb.Name ?? `${accessory.displayName} ${device.remoteType}`,
|
|
56
|
+
Service: accessory.getService(this.hap.Service.Lightbulb) ?? accessory.addService(this.hap.Service.Lightbulb) as Service,
|
|
48
57
|
On: accessory.context.On || false,
|
|
49
58
|
};
|
|
50
|
-
// get the Light service if it exists, otherwise create a new Light service
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
this.LightBulb.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
this.LightBulb.Service
|
|
61
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.LightBulb.Name)
|
|
62
|
+
.getCharacteristic(this.hap.Characteristic.On)
|
|
63
|
+
.onGet(() => {
|
|
64
|
+
return this.LightBulb!.On;
|
|
65
|
+
})
|
|
66
|
+
.onSet(this.OnSet.bind(this));
|
|
67
|
+
accessory.context.LightBulb.Name = this.LightBulb.Name;
|
|
61
68
|
} else {
|
|
69
|
+
// Initialize ProgrammableSwitchOn Service
|
|
70
|
+
if (!accessory.context.ProgrammableSwitchOn) {
|
|
71
|
+
accessory.context.ProgrammableSwitchOn = {};
|
|
72
|
+
}
|
|
73
|
+
this.ProgrammableSwitchOn = {
|
|
74
|
+
Name: accessory.context.ProgrammableSwitchOn.Name ?? `${accessory.displayName} ${device.remoteType} On`,
|
|
75
|
+
Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch)
|
|
76
|
+
?? accessory.addService(this.hap.Service.StatefulProgrammableSwitch) as Service,
|
|
77
|
+
ProgrammableSwitchEvent: accessory.context.ProgrammableSwitchEvent ?? this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS,
|
|
78
|
+
ProgrammableSwitchOutputState: accessory.context.ProgrammableSwitchOutputState ?? 0,
|
|
79
|
+
};
|
|
62
80
|
|
|
63
|
-
//
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
validValueRanges: [0, 0],
|
|
73
|
-
minValue: 0,
|
|
74
|
-
maxValue: 0,
|
|
75
|
-
validValues: [0],
|
|
76
|
-
})
|
|
81
|
+
// Initialize ProgrammableSwitchOn Characteristics
|
|
82
|
+
this.ProgrammableSwitchOn?.Service
|
|
83
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.ProgrammableSwitchOn.Name)
|
|
84
|
+
.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent).setProps({
|
|
85
|
+
validValueRanges: [0, 0],
|
|
86
|
+
minValue: 0,
|
|
87
|
+
maxValue: 0,
|
|
88
|
+
validValues: [0],
|
|
89
|
+
})
|
|
77
90
|
.onGet(() => {
|
|
78
91
|
return this.ProgrammableSwitchOn!.ProgrammableSwitchEvent;
|
|
79
92
|
});
|
|
80
93
|
|
|
81
|
-
this.ProgrammableSwitchOn?.Service
|
|
94
|
+
this.ProgrammableSwitchOn?.Service
|
|
95
|
+
.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState)
|
|
96
|
+
.onGet(() => {
|
|
97
|
+
return this.ProgrammableSwitchOn!.ProgrammableSwitchOutputState;
|
|
98
|
+
})
|
|
82
99
|
.onSet(this.ProgrammableSwitchOutputStateSetOn.bind(this));
|
|
100
|
+
accessory.context.ProgrammableSwitchOn.Name = this.ProgrammableSwitchOn.Name;
|
|
83
101
|
|
|
102
|
+
// Initialize ProgrammableSwitchOff Service
|
|
103
|
+
if (!accessory.context.ProgrammableSwitchOff) {
|
|
104
|
+
accessory.context.ProgrammableSwitchOff = {};
|
|
105
|
+
}
|
|
106
|
+
this.ProgrammableSwitchOff = {
|
|
107
|
+
Name: accessory.context.ProgrammableSwitchOff.Name ?? `${accessory.displayName} ${device.remoteType} Off`,
|
|
108
|
+
Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch)
|
|
109
|
+
?? accessory.addService(this.hap.Service.StatefulProgrammableSwitch) as Service,
|
|
110
|
+
ProgrammableSwitchEvent: accessory.context.ProgrammableSwitchEvent ?? this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS,
|
|
111
|
+
ProgrammableSwitchOutputState: accessory.context.ProgrammableSwitchOutputState ?? 0,
|
|
112
|
+
};
|
|
84
113
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
this.ProgrammableSwitchOff?.Service.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent).setProps({
|
|
95
|
-
validValueRanges: [0, 0],
|
|
96
|
-
minValue: 0,
|
|
97
|
-
maxValue: 0,
|
|
98
|
-
validValues: [0],
|
|
99
|
-
})
|
|
114
|
+
// Initialize ProgrammableSwitchOff Characteristics
|
|
115
|
+
this.ProgrammableSwitchOff?.Service
|
|
116
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.ProgrammableSwitchOff.Name)
|
|
117
|
+
.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent).setProps({
|
|
118
|
+
validValueRanges: [0, 0],
|
|
119
|
+
minValue: 0,
|
|
120
|
+
maxValue: 0,
|
|
121
|
+
validValues: [0],
|
|
122
|
+
})
|
|
100
123
|
.onGet(() => {
|
|
101
124
|
return this.ProgrammableSwitchOff!.ProgrammableSwitchEvent;
|
|
102
125
|
});
|
|
103
126
|
|
|
104
|
-
this.ProgrammableSwitchOff?.Service
|
|
127
|
+
this.ProgrammableSwitchOff?.Service
|
|
128
|
+
.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState)
|
|
129
|
+
.onGet(() => {
|
|
130
|
+
return this.ProgrammableSwitchOff!.ProgrammableSwitchOutputState;
|
|
131
|
+
})
|
|
105
132
|
.onSet(this.ProgrammableSwitchOutputStateSetOff.bind(this));
|
|
133
|
+
accessory.context.ProgrammableSwitchOff.Name = this.ProgrammableSwitchOff.Name;
|
|
106
134
|
}
|
|
107
135
|
|
|
108
136
|
}
|