@switchbot/homebridge-switchbot 1.4.1-beta.1 → 1.4.1-beta.2
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 +14 -0
- package/config.schema.json +82 -10
- package/dist/devices/bots.d.ts +12 -2
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +140 -89
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/colorbulb.d.ts +12 -2
- package/dist/devices/colorbulb.d.ts.map +1 -1
- package/dist/devices/colorbulb.js +138 -84
- package/dist/devices/colorbulb.js.map +1 -1
- package/dist/devices/contact.d.ts +12 -2
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +101 -52
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts +13 -4
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +173 -124
- package/dist/devices/curtains.js.map +1 -1
- package/dist/devices/humidifiers.d.ts +12 -2
- package/dist/devices/humidifiers.d.ts.map +1 -1
- package/dist/devices/humidifiers.js +156 -108
- package/dist/devices/humidifiers.js.map +1 -1
- package/dist/devices/meters.d.ts +12 -2
- package/dist/devices/meters.d.ts.map +1 -1
- package/dist/devices/meters.js +98 -49
- package/dist/devices/meters.js.map +1 -1
- package/dist/devices/motion.d.ts +12 -2
- package/dist/devices/motion.d.ts.map +1 -1
- package/dist/devices/motion.js +86 -37
- package/dist/devices/motion.js.map +1 -1
- package/dist/devices/plugs.d.ts +12 -2
- package/dist/devices/plugs.d.ts.map +1 -1
- package/dist/devices/plugs.js +80 -31
- package/dist/devices/plugs.js.map +1 -1
- package/dist/irdevices/airconditioners.d.ts +10 -2
- package/dist/irdevices/airconditioners.d.ts.map +1 -1
- package/dist/irdevices/airconditioners.js +77 -37
- package/dist/irdevices/airconditioners.js.map +1 -1
- package/dist/irdevices/airpurifiers.d.ts +10 -2
- package/dist/irdevices/airpurifiers.d.ts.map +1 -1
- package/dist/irdevices/airpurifiers.js +65 -25
- package/dist/irdevices/airpurifiers.js.map +1 -1
- package/dist/irdevices/cameras.d.ts +10 -2
- package/dist/irdevices/cameras.d.ts.map +1 -1
- package/dist/irdevices/cameras.js +61 -21
- package/dist/irdevices/cameras.js.map +1 -1
- package/dist/irdevices/fans.d.ts +10 -2
- package/dist/irdevices/fans.d.ts.map +1 -1
- package/dist/irdevices/fans.js +71 -30
- package/dist/irdevices/fans.js.map +1 -1
- package/dist/irdevices/lights.d.ts +10 -2
- package/dist/irdevices/lights.d.ts.map +1 -1
- package/dist/irdevices/lights.js +62 -22
- package/dist/irdevices/lights.js.map +1 -1
- package/dist/irdevices/others.d.ts +10 -2
- package/dist/irdevices/others.d.ts.map +1 -1
- package/dist/irdevices/others.js +68 -28
- package/dist/irdevices/others.js.map +1 -1
- package/dist/irdevices/tvs.d.ts +10 -2
- package/dist/irdevices/tvs.d.ts.map +1 -1
- package/dist/irdevices/tvs.js +78 -38
- package/dist/irdevices/tvs.js.map +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts +10 -2
- package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
- package/dist/irdevices/vacuumcleaners.js +61 -21
- package/dist/irdevices/vacuumcleaners.js.map +1 -1
- package/dist/irdevices/waterheaters.d.ts +10 -2
- package/dist/irdevices/waterheaters.d.ts.map +1 -1
- package/dist/irdevices/waterheaters.js +61 -21
- package/dist/irdevices/waterheaters.js.map +1 -1
- package/dist/platform.d.ts +9 -10
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +264 -285
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +4 -1
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/nodemon.json +1 -1
- package/package.json +1 -1
- package/src/devices/bots.ts +146 -89
- package/src/devices/colorbulb.ts +146 -86
- package/src/devices/contact.ts +107 -52
- package/src/devices/curtains.ts +182 -129
- package/src/devices/humidifiers.ts +162 -109
- package/src/devices/meters.ts +104 -49
- package/src/devices/motion.ts +91 -36
- package/src/devices/plugs.ts +84 -31
- package/src/irdevices/airconditioners.ts +81 -36
- package/src/irdevices/airpurifiers.ts +69 -24
- package/src/irdevices/cameras.ts +65 -20
- package/src/irdevices/fans.ts +75 -30
- package/src/irdevices/lights.ts +66 -21
- package/src/irdevices/others.ts +72 -27
- package/src/irdevices/tvs.ts +82 -37
- package/src/irdevices/vacuumcleaners.ts +65 -20
- package/src/irdevices/waterheaters.ts +65 -20
- package/src/platform.ts +267 -290
- package/src/settings.ts +4 -1
- package/dist/devices/indoorcam.d.ts +0 -64
- package/dist/devices/indoorcam.d.ts.map +0 -1
- package/dist/devices/indoorcam.js +0 -249
- package/dist/devices/indoorcam.js.map +0 -1
- package/src/devices/indoorcam.ts +0 -309
|
@@ -17,8 +17,7 @@ export class WaterHeater {
|
|
|
17
17
|
ActiveCached!: CharacteristicValue;
|
|
18
18
|
|
|
19
19
|
// Config
|
|
20
|
-
|
|
21
|
-
private readonly debugDebug = this.platform.config.options?.debug === 'debug' || this.platform.debugMode;
|
|
20
|
+
deviceLogging!: string;
|
|
22
21
|
|
|
23
22
|
constructor(
|
|
24
23
|
private readonly platform: SwitchBotPlatform,
|
|
@@ -26,6 +25,7 @@ export class WaterHeater {
|
|
|
26
25
|
public device: irdevice & irDevicesConfig,
|
|
27
26
|
) {
|
|
28
27
|
// default placeholders
|
|
28
|
+
this.logs();
|
|
29
29
|
if (this.Active === undefined) {
|
|
30
30
|
this.Active = this.platform.Characteristic.Active.INACTIVE;
|
|
31
31
|
} else {
|
|
@@ -66,8 +66,18 @@ export class WaterHeater {
|
|
|
66
66
|
this.service.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
logs() {
|
|
70
|
+
if (this.device.logging) {
|
|
71
|
+
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
72
|
+
} else if (this.platform.config.options?.logging) {
|
|
73
|
+
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
74
|
+
} else {
|
|
75
|
+
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
69
79
|
private ActiveSet(value: CharacteristicValue) {
|
|
70
|
-
this.
|
|
80
|
+
this.debugLog(`Water Heater: ${this.accessory.displayName} Active: ${value}`);
|
|
71
81
|
if (value === this.platform.Characteristic.Active.INACTIVE) {
|
|
72
82
|
this.pushWaterHeaterOffChanges();
|
|
73
83
|
this.service.setCharacteristic(
|
|
@@ -85,10 +95,10 @@ export class WaterHeater {
|
|
|
85
95
|
|
|
86
96
|
private updateHomeKitCharacteristics() {
|
|
87
97
|
if (this.Active === undefined) {
|
|
88
|
-
this.
|
|
98
|
+
this.debugLog(`Water Heater: ${this.accessory.displayName} Active: ${this.Active}`);
|
|
89
99
|
} else {
|
|
90
100
|
this.service?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
|
|
91
|
-
this.
|
|
101
|
+
this.debugLog(`Water Heater: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
|
|
92
102
|
}
|
|
93
103
|
}
|
|
94
104
|
|
|
@@ -126,22 +136,22 @@ export class WaterHeater {
|
|
|
126
136
|
|
|
127
137
|
public async pushChanges(payload: payload) {
|
|
128
138
|
try {
|
|
129
|
-
this.
|
|
139
|
+
this.infoLog(`Water Heater: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
|
|
130
140
|
+ ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`);
|
|
131
141
|
|
|
132
142
|
// Make the API request
|
|
133
143
|
const push = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
|
|
134
|
-
this.
|
|
144
|
+
this.debugLog(`Water Heater: ${this.accessory.displayName} pushChanges: ${push.data}`);
|
|
135
145
|
this.statusCode(push);
|
|
136
146
|
this.updateHomeKitCharacteristics();
|
|
137
147
|
} catch (e: any) {
|
|
138
|
-
this.
|
|
139
|
-
if (this.
|
|
140
|
-
this.
|
|
148
|
+
this.errorLog(`Water Heater: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
|
|
149
|
+
if (this.deviceLogging === 'debug') {
|
|
150
|
+
this.errorLog(`Water Heater: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
141
151
|
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
142
152
|
}
|
|
143
|
-
if (this.
|
|
144
|
-
this.
|
|
153
|
+
if (this.platform.debugMode) {
|
|
154
|
+
this.errorLog(`Water Heater: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
145
155
|
+ ` Error: ${JSON.stringify(e)}`);
|
|
146
156
|
}
|
|
147
157
|
this.apiError();
|
|
@@ -151,33 +161,68 @@ export class WaterHeater {
|
|
|
151
161
|
private statusCode(push: AxiosResponse<{ statusCode: number; }>) {
|
|
152
162
|
switch (push.data.statusCode) {
|
|
153
163
|
case 151:
|
|
154
|
-
this.
|
|
164
|
+
this.errorLog(`Water Heater: ${this.accessory.displayName} Command not supported by this device type.`);
|
|
155
165
|
break;
|
|
156
166
|
case 152:
|
|
157
|
-
this.
|
|
167
|
+
this.errorLog(`Water Heater: ${this.accessory.displayName} Device not found.`);
|
|
158
168
|
break;
|
|
159
169
|
case 160:
|
|
160
|
-
this.
|
|
170
|
+
this.errorLog(`Water Heater: ${this.accessory.displayName} Command is not supported.`);
|
|
161
171
|
break;
|
|
162
172
|
case 161:
|
|
163
|
-
this.
|
|
173
|
+
this.errorLog(`Water Heater: ${this.accessory.displayName} Device is offline.`);
|
|
164
174
|
break;
|
|
165
175
|
case 171:
|
|
166
|
-
this.
|
|
176
|
+
this.errorLog(`Water Heater: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
167
177
|
break;
|
|
168
178
|
case 190:
|
|
169
|
-
this.
|
|
179
|
+
this.errorLog(`Water Heater: ${this.accessory.displayName} Device internal error due to device states not synchronized`
|
|
170
180
|
+ ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`);
|
|
171
181
|
break;
|
|
172
182
|
case 100:
|
|
173
|
-
this.
|
|
183
|
+
this.debugLog(`Water Heater: ${this.accessory.displayName} Command successfully sent.`);
|
|
174
184
|
break;
|
|
175
185
|
default:
|
|
176
|
-
this.
|
|
186
|
+
this.debugLog(`Water Heater: ${this.accessory.displayName} Unknown statusCode.`);
|
|
177
187
|
}
|
|
178
188
|
}
|
|
179
189
|
|
|
180
190
|
public apiError() {
|
|
181
191
|
throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
182
192
|
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Logging for Device
|
|
196
|
+
*/
|
|
197
|
+
infoLog(...log: any[]) {
|
|
198
|
+
if (this.enablingDeviceLogging()) {
|
|
199
|
+
this.platform.log.info(String(...log));
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
warnLog(...log: any[]) {
|
|
204
|
+
if (this.enablingDeviceLogging()) {
|
|
205
|
+
this.platform.log.warn(String(...log));
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
errorLog(...log: any[]) {
|
|
210
|
+
if (this.enablingDeviceLogging()) {
|
|
211
|
+
this.platform.log.error(String(...log));
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
debugLog(...log: any[]) {
|
|
216
|
+
if (this.enablingDeviceLogging()) {
|
|
217
|
+
if (this.deviceLogging === 'debug') {
|
|
218
|
+
this.platform.log.info('[DEBUG]', String(...log));
|
|
219
|
+
} else {
|
|
220
|
+
this.platform.log.debug(String(...log));
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
enablingDeviceLogging(): boolean {
|
|
226
|
+
return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
|
|
227
|
+
}
|
|
183
228
|
}
|