@switchbot/homebridge-switchbot 3.5.0-beta.57 → 3.5.0-beta.59
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/.vscode/settings.json +4 -1
- package/dist/device/blindtilt.d.ts +5 -5
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +103 -69
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +4 -4
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +201 -154
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +3 -3
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +41 -36
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +3 -3
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +36 -37
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +4 -4
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +76 -55
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +4 -4
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +99 -55
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +4 -4
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +11 -9
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts +3 -3
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +54 -24
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts +4 -4
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +40 -57
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +3 -3
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +39 -39
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +3 -3
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +41 -50
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +4 -4
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +36 -33
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +3 -3
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +68 -59
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +3 -3
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +42 -51
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +3 -3
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +42 -51
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +3 -3
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +52 -40
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +3 -3
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +13 -13
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +4 -4
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +81 -98
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts +3 -3
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +39 -31
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/homebridge-ui/public/index.html +20 -14
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +3 -3
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +9 -9
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +3 -3
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +1 -1
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +3 -3
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +2 -2
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +6 -6
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +37 -29
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +3 -3
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts +9 -14
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +67 -88
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +3 -3
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +1 -1
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +3 -3
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +3 -3
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +3 -3
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +2 -2
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +3 -3
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +2 -2
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +7 -7
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +20 -23
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +24 -10
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +16 -0
- package/dist/settings.js.map +1 -1
- package/eslint.config.js +89 -78
- package/package.json +3 -3
- package/src/device/blindtilt.ts +120 -87
- package/src/device/bot.ts +238 -175
- package/src/device/ceilinglight.ts +49 -46
- package/src/device/colorbulb.ts +40 -43
- package/src/device/contact.ts +91 -65
- package/src/device/curtain.ts +113 -66
- package/src/device/device.ts +12 -13
- package/src/device/fan.ts +66 -29
- package/src/device/hub.ts +53 -60
- package/src/device/humidifier.ts +54 -56
- package/src/device/iosensor.ts +57 -56
- package/src/device/lightstrip.ts +43 -39
- package/src/device/lock.ts +79 -68
- package/src/device/meter.ts +54 -54
- package/src/device/meterplus.ts +54 -54
- package/src/device/motion.ts +62 -46
- package/src/device/plug.ts +19 -18
- package/src/device/robotvacuumcleaner.ts +89 -104
- package/src/device/waterdetector.ts +46 -34
- package/src/homebridge-ui/public/index.html +20 -14
- package/src/index.ts +3 -2
- package/src/irdevice/airconditioner.ts +13 -11
- package/src/irdevice/airpurifier.ts +5 -3
- package/src/irdevice/camera.ts +6 -4
- package/src/irdevice/fan.ts +42 -29
- package/src/irdevice/irdevice.ts +4 -5
- package/src/irdevice/light.ts +83 -103
- package/src/irdevice/other.ts +5 -3
- package/src/irdevice/tv.ts +7 -5
- package/src/irdevice/vacuumcleaner.ts +6 -4
- package/src/irdevice/waterheater.ts +6 -4
- package/src/platform.ts +59 -66
- package/src/settings.ts +73 -58
package/src/irdevice/light.ts
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
* light.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
5
|
import { request } from 'undici';
|
|
6
|
+
import { Devices } from '../settings.js';
|
|
6
7
|
import { irdeviceBase } from './irdevice.js';
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
|
|
9
|
+
import type { SwitchBotPlatform } from '../platform.js';
|
|
10
|
+
import type { irDevicesConfig, irdevice } from '../settings.js';
|
|
11
|
+
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Platform Accessory
|
|
@@ -15,20 +17,22 @@ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
|
15
17
|
*/
|
|
16
18
|
export class Light extends irdeviceBase {
|
|
17
19
|
// Services
|
|
18
|
-
private LightBulb
|
|
20
|
+
private LightBulb?: {
|
|
19
21
|
Service: Service;
|
|
20
22
|
On: CharacteristicValue;
|
|
21
23
|
};
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
private ProgrammableSwitchOn?: {
|
|
26
|
+
Service: Service;
|
|
27
|
+
ProgrammableSwitchEvent: CharacteristicValue;
|
|
28
|
+
ProgrammableSwitchOutputState: CharacteristicValue;
|
|
29
|
+
};
|
|
25
30
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
ProgrammableSwitchOutputStateOff?: CharacteristicValue;
|
|
31
|
+
private ProgrammableSwitchOff?: {
|
|
32
|
+
Service: Service;
|
|
33
|
+
ProgrammableSwitchEvent: CharacteristicValue;
|
|
34
|
+
ProgrammableSwitchOutputState: CharacteristicValue;
|
|
35
|
+
};
|
|
32
36
|
|
|
33
37
|
constructor(
|
|
34
38
|
readonly platform: SwitchBotPlatform,
|
|
@@ -40,7 +44,7 @@ export class Light extends irdeviceBase {
|
|
|
40
44
|
if (!device.irlight?.stateless) {
|
|
41
45
|
// Initialize LightBulb property
|
|
42
46
|
this.LightBulb = {
|
|
43
|
-
Service: accessory.getService(this.hap.Service.Lightbulb) as Service,
|
|
47
|
+
Service: accessory.getService(this.hap.Service.Lightbulb)! as Service,
|
|
44
48
|
On: accessory.context.On || false,
|
|
45
49
|
};
|
|
46
50
|
// get the Light service if it exists, otherwise create a new Light service
|
|
@@ -57,47 +61,47 @@ export class Light extends irdeviceBase {
|
|
|
57
61
|
} else {
|
|
58
62
|
|
|
59
63
|
// create a new Stateful Programmable Switch On service
|
|
60
|
-
const
|
|
61
|
-
(this.
|
|
62
|
-
|| accessory.addService(this.hap.Service.StatefulProgrammableSwitch)),
|
|
64
|
+
const ProgrammableSwitchOn = `${accessory.displayName} ${device.remoteType} On`;
|
|
65
|
+
(this.ProgrammableSwitchOn!.Service = accessory.getService(this.hap.Service.StatefulProgrammableSwitch)
|
|
66
|
+
|| accessory.addService(this.hap.Service.StatefulProgrammableSwitch)), ProgrammableSwitchOn;
|
|
63
67
|
|
|
64
68
|
|
|
65
|
-
this.
|
|
69
|
+
this.ProgrammableSwitchOn?.Service.setCharacteristic(this.hap.Characteristic.Name, `${accessory.displayName} On`);
|
|
66
70
|
|
|
67
|
-
this.
|
|
71
|
+
this.ProgrammableSwitchOn?.Service.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent).setProps({
|
|
68
72
|
validValueRanges: [0, 0],
|
|
69
73
|
minValue: 0,
|
|
70
74
|
maxValue: 0,
|
|
71
75
|
validValues: [0],
|
|
72
76
|
})
|
|
73
77
|
.onGet(() => {
|
|
74
|
-
return this.
|
|
78
|
+
return this.ProgrammableSwitchOn!.ProgrammableSwitchEvent;
|
|
75
79
|
});
|
|
76
80
|
|
|
77
|
-
this.
|
|
81
|
+
this.ProgrammableSwitchOn?.Service.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState)
|
|
78
82
|
.onSet(this.ProgrammableSwitchOutputStateSetOn.bind(this));
|
|
79
83
|
|
|
80
84
|
|
|
81
85
|
|
|
82
86
|
// create a new Stateful Programmable Switch Off service
|
|
83
|
-
const
|
|
84
|
-
(this.
|
|
85
|
-
|| accessory.addService(this.hap.Service.StatefulProgrammableSwitch)),
|
|
87
|
+
const ProgrammableSwitchOff = `${accessory.displayName} ${device.remoteType} Off`;
|
|
88
|
+
(this.ProgrammableSwitchOff!.Service = accessory.getService(this.hap.Service.StatefulProgrammableSwitch)
|
|
89
|
+
|| accessory.addService(this.hap.Service.StatefulProgrammableSwitch)), ProgrammableSwitchOff;
|
|
86
90
|
|
|
87
91
|
|
|
88
|
-
this.
|
|
92
|
+
this.ProgrammableSwitchOff?.Service.setCharacteristic(this.hap.Characteristic.Name, `${accessory.displayName} Off`);
|
|
89
93
|
|
|
90
|
-
this.
|
|
94
|
+
this.ProgrammableSwitchOff?.Service.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent).setProps({
|
|
91
95
|
validValueRanges: [0, 0],
|
|
92
96
|
minValue: 0,
|
|
93
97
|
maxValue: 0,
|
|
94
98
|
validValues: [0],
|
|
95
99
|
})
|
|
96
100
|
.onGet(() => {
|
|
97
|
-
return this.
|
|
101
|
+
return this.ProgrammableSwitchOff!.ProgrammableSwitchEvent;
|
|
98
102
|
});
|
|
99
103
|
|
|
100
|
-
this.
|
|
104
|
+
this.ProgrammableSwitchOff?.Service.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState)
|
|
101
105
|
.onSet(this.ProgrammableSwitchOutputStateSetOff.bind(this));
|
|
102
106
|
}
|
|
103
107
|
|
|
@@ -106,11 +110,13 @@ export class Light extends irdeviceBase {
|
|
|
106
110
|
async OnSet(value: CharacteristicValue): Promise<void> {
|
|
107
111
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${value}`);
|
|
108
112
|
|
|
109
|
-
this.On = value;
|
|
110
|
-
if (this.On) {
|
|
111
|
-
|
|
113
|
+
this.LightBulb!.On = value;
|
|
114
|
+
if (this.LightBulb?.On) {
|
|
115
|
+
const On = true;
|
|
116
|
+
await this.pushLightOnChanges(On);
|
|
112
117
|
} else {
|
|
113
|
-
|
|
118
|
+
const On = false;
|
|
119
|
+
await this.pushLightOffChanges(On);
|
|
114
120
|
}
|
|
115
121
|
/**
|
|
116
122
|
* pushLightOnChanges and pushLightOffChanges above assume they are measuring the state of the accessory BEFORE
|
|
@@ -121,10 +127,10 @@ export class Light extends irdeviceBase {
|
|
|
121
127
|
async ProgrammableSwitchOutputStateSetOn(value: CharacteristicValue): Promise<void> {
|
|
122
128
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${value}`);
|
|
123
129
|
|
|
124
|
-
this.
|
|
125
|
-
if (this.
|
|
126
|
-
|
|
127
|
-
await this.pushLightOnChanges();
|
|
130
|
+
this.ProgrammableSwitchOn!.ProgrammableSwitchOutputState = value;
|
|
131
|
+
if (this.ProgrammableSwitchOn?.ProgrammableSwitchOutputState === 1) {
|
|
132
|
+
const On = true;
|
|
133
|
+
await this.pushLightOnChanges(On);
|
|
128
134
|
}
|
|
129
135
|
/**
|
|
130
136
|
* pushLightOnChanges and pushLightOffChanges above assume they are measuring the state of the accessory BEFORE
|
|
@@ -135,10 +141,10 @@ export class Light extends irdeviceBase {
|
|
|
135
141
|
async ProgrammableSwitchOutputStateSetOff(value: CharacteristicValue): Promise<void> {
|
|
136
142
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${value}`);
|
|
137
143
|
|
|
138
|
-
this.
|
|
139
|
-
if (this.
|
|
140
|
-
|
|
141
|
-
await this.pushLightOffChanges();
|
|
144
|
+
this.ProgrammableSwitchOff!.ProgrammableSwitchOutputState = value;
|
|
145
|
+
if (this.ProgrammableSwitchOff?.ProgrammableSwitchOutputState === 1) {
|
|
146
|
+
const On = false;
|
|
147
|
+
await this.pushLightOffChanges(On);
|
|
142
148
|
}
|
|
143
149
|
/**
|
|
144
150
|
* pushLightOnChanges and pushLightOffChanges above assume they are measuring the state of the accessory BEFORE
|
|
@@ -158,11 +164,9 @@ export class Light extends irdeviceBase {
|
|
|
158
164
|
* Light - "command" "channelAdd" "default" = next channel
|
|
159
165
|
* Light - "command" "channelSub" "default" = previous channel
|
|
160
166
|
*/
|
|
161
|
-
async pushLightOnChanges(): Promise<void> {
|
|
162
|
-
this.debugLog(
|
|
163
|
-
|
|
164
|
-
);
|
|
165
|
-
if (this.On && !this.disablePushOn) {
|
|
167
|
+
async pushLightOnChanges(On: boolean): Promise<void> {
|
|
168
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushLightOnChanges On: ${On}, disablePushOn: ${this.disablePushOn}`);
|
|
169
|
+
if (On === true && this.disablePushOn === false) {
|
|
166
170
|
const commandType: string = await this.commandType();
|
|
167
171
|
const command: string = await this.commandOn();
|
|
168
172
|
const bodyChange = JSON.stringify({
|
|
@@ -170,15 +174,13 @@ export class Light extends irdeviceBase {
|
|
|
170
174
|
parameter: 'default',
|
|
171
175
|
commandType: commandType,
|
|
172
176
|
});
|
|
173
|
-
await this.pushChanges(bodyChange);
|
|
177
|
+
await this.pushChanges(bodyChange, On);
|
|
174
178
|
}
|
|
175
179
|
}
|
|
176
180
|
|
|
177
|
-
async pushLightOffChanges(): Promise<void> {
|
|
178
|
-
this.debugLog(
|
|
179
|
-
|
|
180
|
-
);
|
|
181
|
-
if (!this.On && !this.disablePushOff) {
|
|
181
|
+
async pushLightOffChanges(On: boolean): Promise<void> {
|
|
182
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushLightOffChanges On: ${On}, disablePushOff: ${this.disablePushOff}`);
|
|
183
|
+
if (On === false && this.disablePushOff === false) {
|
|
182
184
|
const commandType: string = await this.commandType();
|
|
183
185
|
const command: string = await this.commandOff();
|
|
184
186
|
const bodyChange = JSON.stringify({
|
|
@@ -186,29 +188,11 @@ export class Light extends irdeviceBase {
|
|
|
186
188
|
parameter: 'default',
|
|
187
189
|
commandType: commandType,
|
|
188
190
|
});
|
|
189
|
-
await this.pushChanges(bodyChange);
|
|
191
|
+
await this.pushChanges(bodyChange, On);
|
|
190
192
|
}
|
|
191
193
|
}
|
|
192
194
|
|
|
193
|
-
|
|
194
|
-
const bodyChange = JSON.stringify({
|
|
195
|
-
command: 'brightnessUp',
|
|
196
|
-
parameter: 'default',
|
|
197
|
-
commandType: 'command',
|
|
198
|
-
});
|
|
199
|
-
await this.pushChanges(bodyChange);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
async pushLightBrightnessDownChanges(): Promise<void> {
|
|
203
|
-
const bodyChange = JSON.stringify({
|
|
204
|
-
command: 'brightnessDown',
|
|
205
|
-
parameter: 'default',
|
|
206
|
-
commandType: 'command',
|
|
207
|
-
});
|
|
208
|
-
await this.pushChanges(bodyChange);
|
|
209
|
-
}*/
|
|
210
|
-
|
|
211
|
-
async pushChanges(bodyChange: any): Promise<void> {
|
|
195
|
+
async pushChanges(bodyChange: any, On: boolean): Promise<void> {
|
|
212
196
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
|
|
213
197
|
if (this.device.connectionType === 'OpenAPI') {
|
|
214
198
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
@@ -227,7 +211,7 @@ export class Light extends irdeviceBase {
|
|
|
227
211
|
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
228
212
|
this.successLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
229
213
|
+ ` request to SwitchBot API, body: ${JSON.stringify(bodyChange)} sent successfully`);
|
|
230
|
-
this.accessory.context.On =
|
|
214
|
+
this.accessory.context.On = On;
|
|
231
215
|
this.updateHomeKitCharacteristics();
|
|
232
216
|
} else {
|
|
233
217
|
this.statusCode(statusCode);
|
|
@@ -235,63 +219,59 @@ export class Light extends irdeviceBase {
|
|
|
235
219
|
}
|
|
236
220
|
} catch (e: any) {
|
|
237
221
|
this.apiError(e);
|
|
238
|
-
this.errorLog(
|
|
239
|
-
|
|
240
|
-
` Connection, Error Message: ${JSON.stringify(e.message)}`,
|
|
241
|
-
);
|
|
222
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}`
|
|
223
|
+
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
242
224
|
}
|
|
243
225
|
} else {
|
|
244
|
-
this.warnLog(
|
|
245
|
-
|
|
246
|
-
` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`,
|
|
247
|
-
);
|
|
226
|
+
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName} Connection Type: `
|
|
227
|
+
+ `${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
248
228
|
}
|
|
249
229
|
}
|
|
250
230
|
|
|
251
231
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
252
|
-
if (this.device.irlight?.stateless) {
|
|
232
|
+
if (!this.device.irlight?.stateless) {
|
|
253
233
|
// On
|
|
254
|
-
if (this.On === undefined) {
|
|
255
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
234
|
+
if (this.LightBulb?.On === undefined) {
|
|
235
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.LightBulb?.On}`);
|
|
256
236
|
} else {
|
|
257
|
-
this.accessory.context.On = this.On;
|
|
258
|
-
this.LightBulb.
|
|
259
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
237
|
+
this.accessory.context.On = this.LightBulb.On;
|
|
238
|
+
this.LightBulb?.Service.updateCharacteristic(this.hap.Characteristic.On, this.LightBulb.On);
|
|
239
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.LightBulb.On}`);
|
|
260
240
|
}
|
|
261
241
|
} else {
|
|
262
242
|
// On Stateful Programmable Switch
|
|
263
|
-
if (this.
|
|
243
|
+
if (this.ProgrammableSwitchOn?.ProgrammableSwitchOutputState === undefined) {
|
|
264
244
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
265
|
-
+ ` ProgrammableSwitchOutputStateOn: ${this.
|
|
245
|
+
+ ` ProgrammableSwitchOutputStateOn: ${this.ProgrammableSwitchOn?.ProgrammableSwitchOutputState}`);
|
|
266
246
|
} else {
|
|
267
|
-
this.accessory.context.ProgrammableSwitchOutputStateOn = this.
|
|
268
|
-
this.
|
|
269
|
-
this.
|
|
247
|
+
this.accessory.context.ProgrammableSwitchOutputStateOn = this.ProgrammableSwitchOn.ProgrammableSwitchOutputState;
|
|
248
|
+
this.ProgrammableSwitchOn?.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState,
|
|
249
|
+
this.ProgrammableSwitchOn.ProgrammableSwitchOutputState);
|
|
270
250
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
271
|
-
+ ` ProgrammableSwitchOutputStateOn: ${this.
|
|
251
|
+
+ ` ProgrammableSwitchOutputStateOn: ${this.ProgrammableSwitchOn.ProgrammableSwitchOutputState}`);
|
|
272
252
|
}
|
|
273
253
|
// Off Stateful Programmable Switch
|
|
274
|
-
if (this.
|
|
254
|
+
if (this.ProgrammableSwitchOff?.ProgrammableSwitchOutputState === undefined) {
|
|
275
255
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
276
|
-
+ ` ProgrammableSwitchOutputStateOff: ${this.
|
|
256
|
+
+ ` ProgrammableSwitchOutputStateOff: ${this.ProgrammableSwitchOff?.ProgrammableSwitchOutputState}`);
|
|
277
257
|
} else {
|
|
278
|
-
this.accessory.context.ProgrammableSwitchOutputStateOff = this.
|
|
279
|
-
this.
|
|
280
|
-
this.
|
|
258
|
+
this.accessory.context.ProgrammableSwitchOutputStateOff = this.ProgrammableSwitchOff.ProgrammableSwitchOutputState;
|
|
259
|
+
this.ProgrammableSwitchOff.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState,
|
|
260
|
+
this.ProgrammableSwitchOff.ProgrammableSwitchOutputState);
|
|
281
261
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
282
|
-
+ ` ProgrammableSwitchOutputStateOff: ${this.
|
|
262
|
+
+ ` ProgrammableSwitchOutputStateOff: ${this.ProgrammableSwitchOff?.ProgrammableSwitchOutputState}`);
|
|
283
263
|
}
|
|
284
264
|
}
|
|
285
265
|
}
|
|
286
266
|
|
|
287
267
|
async apiError(e: any): Promise<void> {
|
|
288
|
-
if (this.device.irlight?.stateless) {
|
|
289
|
-
this.LightBulb.
|
|
268
|
+
if (!this.device.irlight?.stateless) {
|
|
269
|
+
this.LightBulb?.Service.updateCharacteristic(this.hap.Characteristic.On, e);
|
|
290
270
|
} else {
|
|
291
|
-
this.
|
|
292
|
-
this.
|
|
293
|
-
this.
|
|
294
|
-
this.
|
|
271
|
+
this.ProgrammableSwitchOn?.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, e);
|
|
272
|
+
this.ProgrammableSwitchOn?.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, e);
|
|
273
|
+
this.ProgrammableSwitchOff?.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, e);
|
|
274
|
+
this.ProgrammableSwitchOff?.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, e);
|
|
295
275
|
}
|
|
296
276
|
}
|
|
297
277
|
}
|
package/src/irdevice/other.ts
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
* other.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
5
|
import { request } from 'undici';
|
|
6
|
+
import { Devices } from '../settings.js';
|
|
6
7
|
import { irdeviceBase } from './irdevice.js';
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
|
|
9
|
+
import type { SwitchBotPlatform } from '../platform.js';
|
|
10
|
+
import type { irDevicesConfig, irdevice } from '../settings.js';
|
|
11
|
+
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Platform Accessory
|
package/src/irdevice/tv.ts
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
* tv.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
5
|
import { request } from 'undici';
|
|
6
|
+
import { Devices } from '../settings.js';
|
|
6
7
|
import { irdeviceBase } from './irdevice.js';
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
|
|
9
|
+
import type { SwitchBotPlatform } from '../platform.js';
|
|
10
|
+
import type { irDevicesConfig, irdevice } from '../settings.js';
|
|
11
|
+
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Platform Accessory
|
|
@@ -418,7 +420,7 @@ export class TV extends irdeviceBase {
|
|
|
418
420
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.Television.Active}`);
|
|
419
421
|
} else {
|
|
420
422
|
this.accessory.context.Active = this.Television.Active;
|
|
421
|
-
this.Television.Service
|
|
423
|
+
this.Television.Service.updateCharacteristic(this.hap.Characteristic.Active, this.Television.Active);
|
|
422
424
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Television.Active}`);
|
|
423
425
|
}
|
|
424
426
|
// ActiveIdentifier
|
|
@@ -426,7 +428,7 @@ export class TV extends irdeviceBase {
|
|
|
426
428
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} ActiveIdentifier: ${this.Television.ActiveIdentifier}`);
|
|
427
429
|
} else {
|
|
428
430
|
this.accessory.context.ActiveIdentifier = this.Television.ActiveIdentifier;
|
|
429
|
-
this.Television.Service
|
|
431
|
+
this.Television.Service.updateCharacteristic(this.hap.Characteristic.ActiveIdentifier, this.Television.ActiveIdentifier);
|
|
430
432
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
431
433
|
+ ` ActiveIdentifier: ${this.Television.ActiveIdentifier}`);
|
|
432
434
|
}
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
* vacuumcleaner.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
5
|
import { request } from 'undici';
|
|
6
|
+
import { Devices } from '../settings.js';
|
|
6
7
|
import { irdeviceBase } from './irdevice.js';
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
|
|
9
|
+
import type { SwitchBotPlatform } from '../platform.js';
|
|
10
|
+
import type { irDevicesConfig, irdevice } from '../settings.js';
|
|
11
|
+
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Platform Accessory
|
|
@@ -133,7 +135,7 @@ export class VacuumCleaner extends irdeviceBase {
|
|
|
133
135
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.Switch.On}`);
|
|
134
136
|
} else {
|
|
135
137
|
this.accessory.context.On = this.Switch.On;
|
|
136
|
-
this.Switch.Service
|
|
138
|
+
this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, this.Switch.On);
|
|
137
139
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.Switch.On}`);
|
|
138
140
|
}
|
|
139
141
|
}
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
* waterheater.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
5
|
import { request } from 'undici';
|
|
6
|
+
import { Devices } from '../settings.js';
|
|
6
7
|
import { irdeviceBase } from './irdevice.js';
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
|
|
9
|
+
import type { SwitchBotPlatform } from '../platform.js';
|
|
10
|
+
import type { irDevicesConfig, irdevice } from '../settings.js';
|
|
11
|
+
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Platform Accessory
|
|
@@ -138,7 +140,7 @@ export class WaterHeater extends irdeviceBase {
|
|
|
138
140
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.Valve.Active}`);
|
|
139
141
|
} else {
|
|
140
142
|
this.accessory.context.Active = this.Valve.Active;
|
|
141
|
-
this.Valve.Service
|
|
143
|
+
this.Valve.Service.updateCharacteristic(this.hap.Characteristic.Active, this.Valve.Active);
|
|
142
144
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Valve.Active}`);
|
|
143
145
|
}
|
|
144
146
|
}
|