@switchbot/homebridge-switchbot 1.11.0 → 1.11.1
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/CHANGELOG.md +10 -0
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +15 -7
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +22 -22
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +44 -44
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +12 -9
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +20 -20
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +10 -7
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +11 -11
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +12 -9
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +29 -29
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts +10 -7
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +13 -13
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +12 -9
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +17 -17
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +13 -10
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +25 -25
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +10 -7
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +13 -13
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +10 -7
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +16 -16
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/device/colorbulb.ts +15 -9
- package/src/irdevice/airconditioner.ts +54 -54
- package/src/irdevice/airpurifier.ts +30 -30
- package/src/irdevice/camera.ts +19 -19
- package/src/irdevice/fan.ts +40 -40
- package/src/irdevice/light.ts +23 -23
- package/src/irdevice/other.ts +25 -25
- package/src/irdevice/tv.ts +42 -42
- package/src/irdevice/vacuumcleaner.ts +21 -21
- package/src/irdevice/waterheater.ts +24 -24
- package/src/platform.ts +4 -4
|
@@ -10,7 +10,7 @@ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
|
10
10
|
*/
|
|
11
11
|
export class WaterHeater {
|
|
12
12
|
// Services
|
|
13
|
-
|
|
13
|
+
valveService!: Service;
|
|
14
14
|
|
|
15
15
|
// Characteristic Values
|
|
16
16
|
Active!: CharacteristicValue;
|
|
@@ -38,7 +38,7 @@ export class WaterHeater {
|
|
|
38
38
|
|
|
39
39
|
// get the Television service if it exists, otherwise create a new Television service
|
|
40
40
|
// you can create multiple services for each accessory
|
|
41
|
-
(this.
|
|
41
|
+
(this.valveService = accessory.getService(this.platform.Service.Valve) || accessory.addService(this.platform.Service.Valve)),
|
|
42
42
|
`${accessory.displayName} Water Heater`;
|
|
43
43
|
|
|
44
44
|
// To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
|
|
@@ -47,34 +47,34 @@ export class WaterHeater {
|
|
|
47
47
|
|
|
48
48
|
// set the service name, this is what is displayed as the default name on the Home app
|
|
49
49
|
// in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
|
|
50
|
-
this.
|
|
50
|
+
this.valveService.setCharacteristic(this.platform.Characteristic.Name, `${device.deviceName} ${device.remoteType}`);
|
|
51
51
|
|
|
52
52
|
// set sleep discovery characteristic
|
|
53
|
-
this.
|
|
53
|
+
this.valveService.setCharacteristic(this.platform.Characteristic.ValveType, this.platform.Characteristic.ValveType.GENERIC_VALVE);
|
|
54
54
|
|
|
55
55
|
// handle on / off events using the Active characteristic
|
|
56
|
-
this.
|
|
56
|
+
this.valveService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
async ActiveSet(value: CharacteristicValue): Promise<void> {
|
|
60
60
|
this.debugLog(`Water Heater: ${this.accessory.displayName} Active: ${value}`);
|
|
61
61
|
if (value === this.platform.Characteristic.Active.INACTIVE) {
|
|
62
|
-
this.pushWaterHeaterOffChanges();
|
|
63
|
-
this.
|
|
62
|
+
await this.pushWaterHeaterOffChanges();
|
|
63
|
+
this.valveService.setCharacteristic(this.platform.Characteristic.InUse, this.platform.Characteristic.InUse.NOT_IN_USE);
|
|
64
64
|
} else {
|
|
65
|
-
this.pushWaterHeaterOnChanges();
|
|
66
|
-
this.
|
|
65
|
+
await this.pushWaterHeaterOnChanges();
|
|
66
|
+
this.valveService.setCharacteristic(this.platform.Characteristic.InUse, this.platform.Characteristic.InUse.IN_USE);
|
|
67
67
|
}
|
|
68
68
|
this.Active = value;
|
|
69
69
|
this.ActiveCached = this.Active;
|
|
70
70
|
this.accessory.context.Active = this.ActiveCached;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
async updateHomeKitCharacteristics(): Promise<void> {
|
|
74
74
|
if (this.Active === undefined) {
|
|
75
75
|
this.debugLog(`Water Heater: ${this.accessory.displayName} Active: ${this.Active}`);
|
|
76
76
|
} else {
|
|
77
|
-
this.
|
|
77
|
+
this.valveService?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
|
|
78
78
|
this.debugLog(`Water Heater: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
@@ -89,7 +89,7 @@ export class WaterHeater {
|
|
|
89
89
|
* WaterHeater: "command" "channelAdd" "default" = next channel
|
|
90
90
|
* WaterHeater: "command" "channelSub" "default" = previous channel
|
|
91
91
|
*/
|
|
92
|
-
async pushWaterHeaterOnChanges() {
|
|
92
|
+
async pushWaterHeaterOnChanges(): Promise<void> {
|
|
93
93
|
if (this.Active !== 1) {
|
|
94
94
|
const payload = {
|
|
95
95
|
commandType: 'command',
|
|
@@ -100,7 +100,7 @@ export class WaterHeater {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
async pushWaterHeaterOffChanges() {
|
|
103
|
+
async pushWaterHeaterOffChanges(): Promise<void> {
|
|
104
104
|
if (this.Active !== 0) {
|
|
105
105
|
const payload = {
|
|
106
106
|
commandType: 'command',
|
|
@@ -111,7 +111,7 @@ export class WaterHeater {
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
async pushChanges(payload: payload): Promise<void> {
|
|
115
115
|
try {
|
|
116
116
|
this.infoLog(
|
|
117
117
|
`Water Heater: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
|
|
@@ -137,7 +137,7 @@ export class WaterHeater {
|
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
async statusCode(push: AxiosResponse<{ statusCode: number }>): Promise<void>{
|
|
141
141
|
switch (push.data.statusCode) {
|
|
142
142
|
case 151:
|
|
143
143
|
this.errorLog(`Water Heater: ${this.accessory.displayName} Command not supported by this device type.`);
|
|
@@ -168,12 +168,12 @@ export class WaterHeater {
|
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
|
|
172
|
-
this.
|
|
171
|
+
async apiError(e: any): Promise<void> {
|
|
172
|
+
this.valveService.updateCharacteristic(this.platform.Characteristic.Active, e);
|
|
173
173
|
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
config(device: irdevice & irDevicesConfig) {
|
|
176
|
+
async config(device: irdevice & irDevicesConfig): Promise<void> {
|
|
177
177
|
let config = {};
|
|
178
178
|
if (device.irwh) {
|
|
179
179
|
config = device.irwh;
|
|
@@ -186,7 +186,7 @@ export class WaterHeater {
|
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
logs(device: irdevice & irDevicesConfig) {
|
|
189
|
+
async logs(device: irdevice & irDevicesConfig): Promise<void> {
|
|
190
190
|
if (this.platform.debugMode) {
|
|
191
191
|
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
192
192
|
this.debugLog(`Water Heater: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
@@ -205,25 +205,25 @@ export class WaterHeater {
|
|
|
205
205
|
/**
|
|
206
206
|
* Logging for Device
|
|
207
207
|
*/
|
|
208
|
-
infoLog(...log: any[]) {
|
|
208
|
+
infoLog(...log: any[]): void {
|
|
209
209
|
if (this.enablingDeviceLogging()) {
|
|
210
210
|
this.platform.log.info(String(...log));
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
warnLog(...log: any[]) {
|
|
214
|
+
warnLog(...log: any[]): void {
|
|
215
215
|
if (this.enablingDeviceLogging()) {
|
|
216
216
|
this.platform.log.warn(String(...log));
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
-
errorLog(...log: any[]) {
|
|
220
|
+
errorLog(...log: any[]): void {
|
|
221
221
|
if (this.enablingDeviceLogging()) {
|
|
222
222
|
this.platform.log.error(String(...log));
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
debugLog(...log: any[]) {
|
|
226
|
+
debugLog(...log: any[]): void {
|
|
227
227
|
if (this.enablingDeviceLogging()) {
|
|
228
228
|
if (this.deviceLogging === 'debug') {
|
|
229
229
|
this.platform.log.info('[DEBUG]', String(...log));
|
package/src/platform.ts
CHANGED
|
@@ -1582,25 +1582,25 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1582
1582
|
* If device level logging is turned on, log to log.warn
|
|
1583
1583
|
* Otherwise send debug logs to log.debug
|
|
1584
1584
|
*/
|
|
1585
|
-
infoLog(...log: any[]) {
|
|
1585
|
+
infoLog(...log: any[]): void {
|
|
1586
1586
|
if (this.enablingPlatfromLogging()) {
|
|
1587
1587
|
this.log.info(String(...log));
|
|
1588
1588
|
}
|
|
1589
1589
|
}
|
|
1590
1590
|
|
|
1591
|
-
warnLog(...log: any[]) {
|
|
1591
|
+
warnLog(...log: any[]): void {
|
|
1592
1592
|
if (this.enablingPlatfromLogging()) {
|
|
1593
1593
|
this.log.warn(String(...log));
|
|
1594
1594
|
}
|
|
1595
1595
|
}
|
|
1596
1596
|
|
|
1597
|
-
errorLog(...log: any[]) {
|
|
1597
|
+
errorLog(...log: any[]): void {
|
|
1598
1598
|
if (this.enablingPlatfromLogging()) {
|
|
1599
1599
|
this.log.error(String(...log));
|
|
1600
1600
|
}
|
|
1601
1601
|
}
|
|
1602
1602
|
|
|
1603
|
-
debugLog(...log: any[]) {
|
|
1603
|
+
debugLog(...log: any[]): void {
|
|
1604
1604
|
if (this.enablingPlatfromLogging()) {
|
|
1605
1605
|
if (this.platformLogging === 'debugMode') {
|
|
1606
1606
|
this.log.debug(String(...log));
|