@switchbot/homebridge-switchbot 1.8.3-beta.0 → 1.10.1-beta.0
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/.eslintrc +14 -45
- package/.github/ISSUE_TEMPLATE/bug-report.yml +3 -3
- package/.github/ISSUE_TEMPLATE/feature-request.yml +2 -2
- package/.github/ISSUE_TEMPLATE/support-request.yml +3 -3
- package/.github/labeler.yml +1 -1
- package/.github/workflows/codeql-analysis.yml +29 -29
- package/.github/workflows/nodejs-beta.yml +1 -1
- package/.github/workflows/prerelease-beta.js +1 -1
- package/.github/workflows/stale.yml +1 -1
- package/.prettierrc +9 -0
- package/.vscode/extensions.json +2 -4
- package/.vscode/settings.json +14 -2
- package/CHANGELOG.md +16 -0
- package/README.md +100 -99
- package/SECURITY.md +2 -2
- package/config.schema.json +17 -0
- package/dist/devices/bots.d.ts +35 -32
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +168 -210
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/colorbulb.d.ts +35 -35
- package/dist/devices/colorbulb.d.ts.map +1 -1
- package/dist/devices/colorbulb.js +83 -108
- package/dist/devices/colorbulb.js.map +1 -1
- package/dist/devices/contact.d.ts +27 -25
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +110 -131
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts +29 -27
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +147 -182
- package/dist/devices/curtains.js.map +1 -1
- package/dist/devices/humidifiers.d.ts +31 -31
- package/dist/devices/humidifiers.d.ts.map +1 -1
- package/dist/devices/humidifiers.js +154 -181
- package/dist/devices/humidifiers.js.map +1 -1
- package/dist/devices/meters.d.ts +29 -28
- package/dist/devices/meters.d.ts.map +1 -1
- package/dist/devices/meters.js +98 -120
- package/dist/devices/meters.js.map +1 -1
- package/dist/devices/motion.d.ts +24 -23
- package/dist/devices/motion.d.ts.map +1 -1
- package/dist/devices/motion.js +97 -113
- package/dist/devices/motion.js.map +1 -1
- package/dist/devices/plugs.d.ts +16 -16
- package/dist/devices/plugs.d.ts.map +1 -1
- package/dist/devices/plugs.js +48 -71
- package/dist/devices/plugs.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -22
- package/dist/index.js.map +1 -1
- package/dist/irdevices/airconditioners.d.ts +7 -4
- package/dist/irdevices/airconditioners.d.ts.map +1 -1
- package/dist/irdevices/airconditioners.js +72 -93
- package/dist/irdevices/airconditioners.js.map +1 -1
- package/dist/irdevices/airpurifiers.d.ts +3 -3
- package/dist/irdevices/airpurifiers.d.ts.map +1 -1
- package/dist/irdevices/airpurifiers.js +32 -51
- package/dist/irdevices/airpurifiers.js.map +1 -1
- package/dist/irdevices/cameras.d.ts +3 -3
- package/dist/irdevices/cameras.d.ts.map +1 -1
- package/dist/irdevices/cameras.js +19 -26
- package/dist/irdevices/cameras.js.map +1 -1
- package/dist/irdevices/fans.d.ts +3 -3
- package/dist/irdevices/fans.d.ts.map +1 -1
- package/dist/irdevices/fans.js +35 -44
- package/dist/irdevices/fans.js.map +1 -1
- package/dist/irdevices/lights.d.ts +3 -3
- package/dist/irdevices/lights.d.ts.map +1 -1
- package/dist/irdevices/lights.js +25 -32
- package/dist/irdevices/lights.js.map +1 -1
- package/dist/irdevices/others.d.ts +3 -3
- package/dist/irdevices/others.d.ts.map +1 -1
- package/dist/irdevices/others.js +21 -29
- package/dist/irdevices/others.js.map +1 -1
- package/dist/irdevices/tvs.d.ts +3 -3
- package/dist/irdevices/tvs.d.ts.map +1 -1
- package/dist/irdevices/tvs.js +66 -89
- package/dist/irdevices/tvs.js.map +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts +3 -3
- package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
- package/dist/irdevices/vacuumcleaners.js +18 -24
- package/dist/irdevices/vacuumcleaners.js.map +1 -1
- package/dist/irdevices/waterheaters.d.ts +3 -3
- package/dist/irdevices/waterheaters.d.ts.map +1 -1
- package/dist/irdevices/waterheaters.js +19 -26
- package/dist/irdevices/waterheaters.js.map +1 -1
- package/dist/platform.d.ts +10 -10
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +163 -233
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +3 -1
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +4 -4
- package/dist/settings.js.map +1 -1
- package/homebridge-ui/public/index.html +231 -245
- package/homebridge-ui/server.js +2 -4
- package/nodemon.json +2 -4
- package/package.json +17 -12
- package/src/devices/bots.ts +411 -854
- package/src/devices/colorbulb.ts +187 -408
- package/src/devices/contact.ts +210 -376
- package/src/devices/curtains.ts +288 -563
- package/src/devices/humidifiers.ts +291 -537
- package/src/devices/meters.ts +189 -331
- package/src/devices/motion.ts +188 -322
- package/src/devices/plugs.ts +88 -160
- package/src/index.ts +5 -5
- package/src/irdevices/airconditioners.ts +139 -318
- package/src/irdevices/airpurifiers.ts +71 -170
- package/src/irdevices/cameras.ts +44 -103
- package/src/irdevices/fans.ts +70 -165
- package/src/irdevices/lights.ts +49 -104
- package/src/irdevices/others.ts +55 -131
- package/src/irdevices/tvs.ts +114 -247
- package/src/irdevices/vacuumcleaners.ts +44 -104
- package/src/irdevices/waterheaters.ts +49 -121
- package/src/platform.ts +341 -753
- package/src/settings.ts +8 -11
- package/tsconfig.json +5 -14
- package/.github/PULL_REQUEST_TEMPLATE/pull_requests.md +0 -27
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AxiosResponse } from
|
|
2
|
-
import { SwitchBotPlatform } from
|
|
3
|
-
import { irDevicesConfig, DeviceURL, irdevice, payload } from
|
|
4
|
-
import { CharacteristicValue, PlatformAccessory, Service } from
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
|
+
import { SwitchBotPlatform } from '../platform';
|
|
3
|
+
import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
|
|
4
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -42,15 +42,13 @@ export class AirConditioner {
|
|
|
42
42
|
// Config
|
|
43
43
|
deviceLogging!: string;
|
|
44
44
|
hide_automode?: boolean;
|
|
45
|
+
pushOn?: boolean;
|
|
45
46
|
|
|
46
|
-
constructor(
|
|
47
|
-
private readonly platform: SwitchBotPlatform,
|
|
48
|
-
private accessory: PlatformAccessory,
|
|
49
|
-
public device: irdevice & irDevicesConfig,
|
|
50
|
-
) {
|
|
47
|
+
constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
|
|
51
48
|
// default placeholders
|
|
52
49
|
this.logs(device);
|
|
53
50
|
this.config(device);
|
|
51
|
+
this.pushOnChanges(device);
|
|
54
52
|
if (this.Active === undefined) {
|
|
55
53
|
this.Active = this.platform.Characteristic.Active.INACTIVE;
|
|
56
54
|
} else {
|
|
@@ -72,18 +70,13 @@ export class AirConditioner {
|
|
|
72
70
|
// set accessory information
|
|
73
71
|
accessory
|
|
74
72
|
.getService(this.platform.Service.AccessoryInformation)!
|
|
75
|
-
.setCharacteristic(this.platform.Characteristic.Manufacturer,
|
|
73
|
+
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
76
74
|
.setCharacteristic(this.platform.Characteristic.Model, device.remoteType)
|
|
77
|
-
.setCharacteristic(
|
|
78
|
-
this.platform.Characteristic.SerialNumber,
|
|
79
|
-
device.deviceId!,
|
|
80
|
-
);
|
|
75
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
|
|
81
76
|
|
|
82
77
|
// get the Television service if it exists, otherwise create a new Television service
|
|
83
78
|
// you can create multiple services for each accessory
|
|
84
|
-
(this.service =
|
|
85
|
-
accessory.getService(this.platform.Service.HeaterCooler) ||
|
|
86
|
-
accessory.addService(this.platform.Service.HeaterCooler)),
|
|
79
|
+
(this.service = accessory.getService(this.platform.Service.HeaterCooler) || accessory.addService(this.platform.Service.HeaterCooler)),
|
|
87
80
|
`${accessory.displayName} Air Conditioner`;
|
|
88
81
|
|
|
89
82
|
// To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
|
|
@@ -92,15 +85,10 @@ export class AirConditioner {
|
|
|
92
85
|
|
|
93
86
|
// set the service name, this is what is displayed as the default name on the Home app
|
|
94
87
|
// in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
|
|
95
|
-
this.service.setCharacteristic(
|
|
96
|
-
this.platform.Characteristic.Name,
|
|
97
|
-
accessory.displayName,
|
|
98
|
-
);
|
|
88
|
+
this.service.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
99
89
|
|
|
100
90
|
// handle on / off events using the Active characteristic
|
|
101
|
-
this.service
|
|
102
|
-
.getCharacteristic(this.platform.Characteristic.Active)
|
|
103
|
-
.onSet(this.ActiveSet.bind(this));
|
|
91
|
+
this.service.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
|
|
104
92
|
|
|
105
93
|
this.service
|
|
106
94
|
.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
|
|
@@ -117,18 +105,14 @@ export class AirConditioner {
|
|
|
117
105
|
this.TargetHeaterCoolerState = 1 || 2;
|
|
118
106
|
this.ValidValues = [1, 2];
|
|
119
107
|
this.debugLog(
|
|
120
|
-
`Air Conditioner: ${
|
|
121
|
-
this.accessory.displayName
|
|
122
|
-
} ValidValues: ${JSON.stringify(this.ValidValues)},` +
|
|
108
|
+
`Air Conditioner: ${this.accessory.displayName} ValidValues: ${JSON.stringify(this.ValidValues)},` +
|
|
123
109
|
` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
|
|
124
110
|
);
|
|
125
111
|
} else {
|
|
126
112
|
this.TargetHeaterCoolerState = 0 || 1 || 2;
|
|
127
113
|
this.ValidValues = [0, 1, 2];
|
|
128
114
|
this.debugLog(
|
|
129
|
-
`Air Conditioner: ${
|
|
130
|
-
this.accessory.displayName
|
|
131
|
-
} ValidValues: ${JSON.stringify(this.ValidValues)},` +
|
|
115
|
+
`Air Conditioner: ${this.accessory.displayName} ValidValues: ${JSON.stringify(this.ValidValues)},` +
|
|
132
116
|
` hide_automode: ${this.hide_automode}, TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
|
|
133
117
|
);
|
|
134
118
|
}
|
|
@@ -142,16 +126,12 @@ export class AirConditioner {
|
|
|
142
126
|
})
|
|
143
127
|
.onSet(this.TargetHeaterCoolerStateSet.bind(this));
|
|
144
128
|
|
|
145
|
-
this.service
|
|
146
|
-
.
|
|
147
|
-
|
|
148
|
-
return this.CurrentHeaterCoolerStateGet();
|
|
149
|
-
});
|
|
129
|
+
this.service.getCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState).onGet(async () => {
|
|
130
|
+
return this.CurrentHeaterCoolerStateGet();
|
|
131
|
+
});
|
|
150
132
|
|
|
151
133
|
this.service
|
|
152
|
-
.getCharacteristic(
|
|
153
|
-
this.platform.Characteristic.HeatingThresholdTemperature,
|
|
154
|
-
)
|
|
134
|
+
.getCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature)
|
|
155
135
|
.setProps({
|
|
156
136
|
minValue: 16,
|
|
157
137
|
maxValue: 30,
|
|
@@ -163,9 +143,7 @@ export class AirConditioner {
|
|
|
163
143
|
.onSet(this.HeatingThresholdTemperatureSet.bind(this));
|
|
164
144
|
|
|
165
145
|
this.service
|
|
166
|
-
.getCharacteristic(
|
|
167
|
-
this.platform.Characteristic.CoolingThresholdTemperature,
|
|
168
|
-
)
|
|
146
|
+
.getCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature)
|
|
169
147
|
.setProps({
|
|
170
148
|
minValue: 16,
|
|
171
149
|
maxValue: 30,
|
|
@@ -198,8 +176,8 @@ export class AirConditioner {
|
|
|
198
176
|
* AirConditioner: "command" "middleSpeed" "default" = fan speed to medium
|
|
199
177
|
* AirConditioner: "command" "highSpeed" "default" = fan speed to high
|
|
200
178
|
*/
|
|
201
|
-
|
|
202
|
-
if (this.Active !== this.platform.Characteristic.Active.ACTIVE) {
|
|
179
|
+
async pushAirConditionerOnChanges() {
|
|
180
|
+
if (this.Active !== this.platform.Characteristic.Active.ACTIVE || this.pushOn) {
|
|
203
181
|
const payload = {
|
|
204
182
|
commandType: 'command',
|
|
205
183
|
parameter: 'default',
|
|
@@ -207,13 +185,13 @@ export class AirConditioner {
|
|
|
207
185
|
} as any;
|
|
208
186
|
await this.pushChanges(payload);
|
|
209
187
|
}
|
|
210
|
-
}
|
|
188
|
+
}
|
|
211
189
|
|
|
212
190
|
async pushAirConditionerOffChanges() {
|
|
213
191
|
const payload = {
|
|
214
|
-
commandType:
|
|
215
|
-
parameter:
|
|
216
|
-
command:
|
|
192
|
+
commandType: 'command',
|
|
193
|
+
parameter: 'default',
|
|
194
|
+
command: 'turnOff',
|
|
217
195
|
} as any;
|
|
218
196
|
await this.pushChanges(payload);
|
|
219
197
|
}
|
|
@@ -221,22 +199,18 @@ export class AirConditioner {
|
|
|
221
199
|
async pushAirConditionerStatusChanges() {
|
|
222
200
|
if (!this.Busy) {
|
|
223
201
|
this.Busy = true;
|
|
224
|
-
this.CurrentHeaterCoolerState =
|
|
225
|
-
this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
|
|
202
|
+
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.IDLE;
|
|
226
203
|
}
|
|
227
204
|
clearTimeout(this.Timeout);
|
|
228
205
|
|
|
229
206
|
// Make a new Timeout set to go off in 1000ms (1 second)
|
|
230
|
-
this.Timeout = setTimeout(
|
|
231
|
-
this.pushAirConditionerDetailsChanges.bind(this),
|
|
232
|
-
1500,
|
|
233
|
-
);
|
|
207
|
+
this.Timeout = setTimeout(this.pushAirConditionerDetailsChanges.bind(this), 1500);
|
|
234
208
|
}
|
|
235
209
|
|
|
236
210
|
async pushAirConditionerDetailsChanges() {
|
|
237
211
|
const payload = {
|
|
238
|
-
commandType:
|
|
239
|
-
command:
|
|
212
|
+
commandType: 'command',
|
|
213
|
+
command: 'setAll',
|
|
240
214
|
} as any;
|
|
241
215
|
|
|
242
216
|
this.CurrentTemperatureUndefined();
|
|
@@ -247,15 +221,14 @@ export class AirConditioner {
|
|
|
247
221
|
this.CurrentFanSpeed = 1;
|
|
248
222
|
}
|
|
249
223
|
if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
|
|
250
|
-
this.state =
|
|
224
|
+
this.state = 'on';
|
|
251
225
|
} else {
|
|
252
|
-
this.state =
|
|
226
|
+
this.state = 'off';
|
|
253
227
|
}
|
|
254
228
|
if (this.CurrentMode === 1) {
|
|
255
229
|
this.CurrentTemperature = 25;
|
|
256
230
|
this.debugLog(
|
|
257
|
-
`Air Conditioner: ${this.accessory.displayName} CurrentMode: ${this.CurrentMode},` +
|
|
258
|
-
` CurrentTemperature: ${this.CurrentTemperature}`,
|
|
231
|
+
`Air Conditioner: ${this.accessory.displayName} CurrentMode: ${this.CurrentMode},` + ` CurrentTemperature: ${this.CurrentTemperature}`,
|
|
259
232
|
);
|
|
260
233
|
}
|
|
261
234
|
payload.parameter = `${this.CurrentTemperature},${this.CurrentMode},${this.CurrentFanSpeed},${this.state}`;
|
|
@@ -263,15 +236,12 @@ export class AirConditioner {
|
|
|
263
236
|
if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
|
|
264
237
|
this.CurrentTemperatureUndefined();
|
|
265
238
|
if (this.CurrentTemperature < this.CurrentTemperatureCached) {
|
|
266
|
-
this.CurrentHeaterCoolerState =
|
|
267
|
-
this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
239
|
+
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
268
240
|
} else if (this.CurrentTemperature > this.CurrentTemperatureCached) {
|
|
269
|
-
this.CurrentHeaterCoolerState =
|
|
270
|
-
this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
241
|
+
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
271
242
|
}
|
|
272
243
|
} else {
|
|
273
|
-
this.CurrentHeaterCoolerState =
|
|
274
|
-
this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
244
|
+
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
275
245
|
}
|
|
276
246
|
|
|
277
247
|
await this.pushChanges(payload);
|
|
@@ -285,42 +255,25 @@ export class AirConditioner {
|
|
|
285
255
|
);
|
|
286
256
|
|
|
287
257
|
// Make the API request
|
|
288
|
-
const push: any = await this.platform.axios.post(
|
|
289
|
-
|
|
290
|
-
payload,
|
|
291
|
-
);
|
|
292
|
-
this.debugLog(
|
|
293
|
-
`Air Conditioner: ${
|
|
294
|
-
this.accessory.displayName
|
|
295
|
-
} pushChanges: ${JSON.stringify(push.data)}`,
|
|
296
|
-
);
|
|
258
|
+
const push: any = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
|
|
259
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} pushChanges: ${JSON.stringify(push.data)}`);
|
|
297
260
|
this.statusCode(push);
|
|
298
261
|
this.CurrentTemperatureCached = this.CurrentTemperature;
|
|
299
262
|
this.accessory.context.CurrentTemperature = this.CurrentTemperatureCached;
|
|
300
263
|
this.HeatingThresholdTemperature = this.CurrentTemperatureCached;
|
|
301
264
|
this.HeatingThresholdTemperatureCached = this.CurrentTemperatureCached;
|
|
302
|
-
this.accessory.context.HeatingThresholdTemperature =
|
|
303
|
-
this.HeatingThresholdTemperatureCached;
|
|
265
|
+
this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperatureCached;
|
|
304
266
|
this.CoolingThresholdTemperature = this.CurrentTemperatureCached;
|
|
305
267
|
this.CoolingThresholdTemperatureCached = this.CurrentTemperatureCached;
|
|
306
|
-
this.accessory.context.CoolingThresholdTemperature =
|
|
307
|
-
this.CoolingThresholdTemperatureCached;
|
|
268
|
+
this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperatureCached;
|
|
308
269
|
this.updateHomeKitCharacteristics();
|
|
309
270
|
} catch (e: any) {
|
|
310
|
-
this.errorLog(
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
if (this.deviceLogging === "debug") {
|
|
314
|
-
this.errorLog(
|
|
315
|
-
`Air Conditioner: ${this.accessory.displayName} failed pushChanges,` +
|
|
316
|
-
` Error Message: ${JSON.stringify(e.message)}`,
|
|
317
|
-
);
|
|
271
|
+
this.errorLog(`Air Conditioner: ${this.accessory.displayName} failed pushChanges`);
|
|
272
|
+
if (this.deviceLogging === 'debug') {
|
|
273
|
+
this.errorLog(`Air Conditioner: ${this.accessory.displayName} failed pushChanges,` + ` Error Message: ${JSON.stringify(e.message)}`);
|
|
318
274
|
}
|
|
319
275
|
if (this.platform.debugMode) {
|
|
320
|
-
this.errorLog(
|
|
321
|
-
`Air Conditioner: ${this.accessory.displayName} failed pushChanges,` +
|
|
322
|
-
` Error: ${JSON.stringify(e)}`,
|
|
323
|
-
);
|
|
276
|
+
this.errorLog(`Air Conditioner: ${this.accessory.displayName} failed pushChanges,` + ` Error: ${JSON.stringify(e)}`);
|
|
324
277
|
}
|
|
325
278
|
this.apiError(e);
|
|
326
279
|
}
|
|
@@ -329,174 +282,95 @@ export class AirConditioner {
|
|
|
329
282
|
statusCode(push: AxiosResponse<{ statusCode: number }>) {
|
|
330
283
|
switch (push.data.statusCode) {
|
|
331
284
|
case 151:
|
|
332
|
-
this.errorLog(
|
|
333
|
-
`Air Conditioner: ${this.accessory.displayName} Command not supported by this device type.`,
|
|
334
|
-
);
|
|
285
|
+
this.errorLog(`Air Conditioner: ${this.accessory.displayName} Command not supported by this device type.`);
|
|
335
286
|
break;
|
|
336
287
|
case 152:
|
|
337
|
-
this.errorLog(
|
|
338
|
-
`Air Conditioner: ${this.accessory.displayName} Device not found.`,
|
|
339
|
-
);
|
|
288
|
+
this.errorLog(`Air Conditioner: ${this.accessory.displayName} Device not found.`);
|
|
340
289
|
break;
|
|
341
290
|
case 160:
|
|
342
|
-
this.errorLog(
|
|
343
|
-
`Air Conditioner: ${this.accessory.displayName} Command is not supported.`,
|
|
344
|
-
);
|
|
291
|
+
this.errorLog(`Air Conditioner: ${this.accessory.displayName} Command is not supported.`);
|
|
345
292
|
break;
|
|
346
293
|
case 161:
|
|
347
|
-
this.errorLog(
|
|
348
|
-
`Air Conditioner: ${this.accessory.displayName} Device is offline.`,
|
|
349
|
-
);
|
|
294
|
+
this.errorLog(`Air Conditioner: ${this.accessory.displayName} Device is offline.`);
|
|
350
295
|
break;
|
|
351
296
|
case 171:
|
|
352
|
-
this.errorLog(
|
|
353
|
-
`Air Conditioner: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`,
|
|
354
|
-
);
|
|
297
|
+
this.errorLog(`Air Conditioner: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
355
298
|
break;
|
|
356
299
|
case 190:
|
|
357
300
|
this.errorLog(
|
|
358
301
|
`Air Conditioner: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
|
|
359
|
-
` with server, Or command: ${JSON.stringify(
|
|
360
|
-
push.data,
|
|
361
|
-
)} format is invalid`,
|
|
302
|
+
` with server, Or command: ${JSON.stringify(push.data)} format is invalid`,
|
|
362
303
|
);
|
|
363
304
|
break;
|
|
364
305
|
case 100:
|
|
365
|
-
this.debugLog(
|
|
366
|
-
`Air Conditioner: ${this.accessory.displayName} Command successfully sent.`,
|
|
367
|
-
);
|
|
306
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Command successfully sent.`);
|
|
368
307
|
break;
|
|
369
308
|
default:
|
|
370
|
-
this.debugLog(
|
|
371
|
-
`Air Conditioner: ${this.accessory.displayName} Unknown statusCode.`,
|
|
372
|
-
);
|
|
309
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Unknown statusCode.`);
|
|
373
310
|
}
|
|
374
311
|
}
|
|
375
312
|
|
|
376
313
|
updateHomeKitCharacteristics() {
|
|
377
314
|
if (this.Active === undefined) {
|
|
378
|
-
this.debugLog(
|
|
379
|
-
`Air Conditioner: ${this.accessory.displayName} Active: ${this.Active}`,
|
|
380
|
-
);
|
|
315
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Active: ${this.Active}`);
|
|
381
316
|
} else {
|
|
382
|
-
this.service?.updateCharacteristic(
|
|
383
|
-
|
|
384
|
-
this.Active,
|
|
385
|
-
);
|
|
386
|
-
this.debugLog(
|
|
387
|
-
`Air Conditioner: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`,
|
|
388
|
-
);
|
|
317
|
+
this.service?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
|
|
318
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
|
|
389
319
|
}
|
|
390
320
|
if (this.RotationSpeed === undefined) {
|
|
391
|
-
this.debugLog(
|
|
392
|
-
`Air Conditioner: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`,
|
|
393
|
-
);
|
|
321
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`);
|
|
394
322
|
} else {
|
|
395
|
-
this.service?.updateCharacteristic(
|
|
396
|
-
|
|
397
|
-
this.RotationSpeed,
|
|
398
|
-
);
|
|
399
|
-
this.debugLog(
|
|
400
|
-
`Air Conditioner: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.RotationSpeed}`,
|
|
401
|
-
);
|
|
323
|
+
this.service?.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.RotationSpeed);
|
|
324
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.RotationSpeed}`);
|
|
402
325
|
}
|
|
403
326
|
if (this.CurrentTemperature === undefined) {
|
|
404
|
-
this.debugLog(
|
|
405
|
-
`Air Conditioner: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`,
|
|
406
|
-
);
|
|
327
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
|
|
407
328
|
} else {
|
|
408
|
-
this.service?.updateCharacteristic(
|
|
409
|
-
|
|
410
|
-
this.CurrentTemperature,
|
|
411
|
-
);
|
|
412
|
-
this.debugLog(
|
|
413
|
-
`Air Conditioner: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`,
|
|
414
|
-
);
|
|
329
|
+
this.service?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
|
|
330
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
|
|
415
331
|
}
|
|
416
332
|
if (this.TargetHeaterCoolerState === undefined) {
|
|
417
|
-
this.debugLog(
|
|
418
|
-
`Air Conditioner: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
|
|
419
|
-
);
|
|
333
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
420
334
|
} else {
|
|
421
|
-
this.service?.updateCharacteristic(
|
|
422
|
-
this.platform.Characteristic.TargetHeaterCoolerState,
|
|
423
|
-
this.TargetHeaterCoolerState,
|
|
424
|
-
);
|
|
335
|
+
this.service?.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, this.TargetHeaterCoolerState);
|
|
425
336
|
this.debugLog(
|
|
426
|
-
`Air Conditioner: ${this.accessory.displayName}` +
|
|
427
|
-
` updateCharacteristic TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
|
|
337
|
+
`Air Conditioner: ${this.accessory.displayName}` + ` updateCharacteristic TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`,
|
|
428
338
|
);
|
|
429
339
|
}
|
|
430
340
|
if (this.CurrentHeaterCoolerState === undefined) {
|
|
431
|
-
this.debugLog(
|
|
432
|
-
`Air Conditioner: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
433
|
-
);
|
|
341
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
434
342
|
} else {
|
|
435
|
-
this.service?.updateCharacteristic(
|
|
436
|
-
this.platform.Characteristic.CurrentHeaterCoolerState,
|
|
437
|
-
this.CurrentHeaterCoolerState,
|
|
438
|
-
);
|
|
343
|
+
this.service?.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState);
|
|
439
344
|
this.debugLog(
|
|
440
|
-
`Air Conditioner: ${this.accessory.displayName}` +
|
|
441
|
-
` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
345
|
+
`Air Conditioner: ${this.accessory.displayName}` + ` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
442
346
|
);
|
|
443
347
|
}
|
|
444
348
|
if (this.HeatingThresholdTemperature === undefined) {
|
|
445
|
-
this.debugLog(
|
|
446
|
-
`Air Conditioner: ${this.accessory.displayName} HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`,
|
|
447
|
-
);
|
|
349
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
448
350
|
} else {
|
|
449
|
-
this.service?.updateCharacteristic(
|
|
450
|
-
this.platform.Characteristic.HeatingThresholdTemperature,
|
|
451
|
-
this.HeatingThresholdTemperature,
|
|
452
|
-
);
|
|
351
|
+
this.service?.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, this.HeatingThresholdTemperature);
|
|
453
352
|
this.debugLog(
|
|
454
|
-
`Air Conditioner: ${this.accessory.displayName}` +
|
|
455
|
-
` updateCharacteristic HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`,
|
|
353
|
+
`Air Conditioner: ${this.accessory.displayName}` + ` updateCharacteristic HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`,
|
|
456
354
|
);
|
|
457
355
|
}
|
|
458
356
|
if (this.CoolingThresholdTemperature === undefined) {
|
|
459
|
-
this.debugLog(
|
|
460
|
-
`Air Conditioner: ${this.accessory.displayName} CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`,
|
|
461
|
-
);
|
|
357
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
|
|
462
358
|
} else {
|
|
463
|
-
this.service?.updateCharacteristic(
|
|
464
|
-
this.platform.Characteristic.CoolingThresholdTemperature,
|
|
465
|
-
this.CoolingThresholdTemperature,
|
|
466
|
-
);
|
|
359
|
+
this.service?.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, this.CoolingThresholdTemperature);
|
|
467
360
|
this.debugLog(
|
|
468
|
-
`Air Conditioner: ${this.accessory.displayName}` +
|
|
469
|
-
` updateCharacteristic CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`,
|
|
361
|
+
`Air Conditioner: ${this.accessory.displayName}` + ` updateCharacteristic CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`,
|
|
470
362
|
);
|
|
471
363
|
}
|
|
472
364
|
}
|
|
473
365
|
|
|
474
366
|
public apiError(e: any) {
|
|
475
367
|
this.service.updateCharacteristic(this.platform.Characteristic.Active, e);
|
|
476
|
-
this.service.updateCharacteristic(
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
);
|
|
480
|
-
this.service.updateCharacteristic(
|
|
481
|
-
|
|
482
|
-
e,
|
|
483
|
-
);
|
|
484
|
-
this.service.updateCharacteristic(
|
|
485
|
-
this.platform.Characteristic.TargetHeaterCoolerState,
|
|
486
|
-
e,
|
|
487
|
-
);
|
|
488
|
-
this.service.updateCharacteristic(
|
|
489
|
-
this.platform.Characteristic.CurrentHeaterCoolerState,
|
|
490
|
-
e,
|
|
491
|
-
);
|
|
492
|
-
this.service.updateCharacteristic(
|
|
493
|
-
this.platform.Characteristic.HeatingThresholdTemperature,
|
|
494
|
-
e,
|
|
495
|
-
);
|
|
496
|
-
this.service.updateCharacteristic(
|
|
497
|
-
this.platform.Characteristic.CoolingThresholdTemperature,
|
|
498
|
-
e,
|
|
499
|
-
);
|
|
368
|
+
this.service.updateCharacteristic(this.platform.Characteristic.RotationSpeed, e);
|
|
369
|
+
this.service.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
|
|
370
|
+
this.service.updateCharacteristic(this.platform.Characteristic.TargetHeaterCoolerState, e);
|
|
371
|
+
this.service.updateCharacteristic(this.platform.Characteristic.CurrentHeaterCoolerState, e);
|
|
372
|
+
this.service.updateCharacteristic(this.platform.Characteristic.HeatingThresholdTemperature, e);
|
|
373
|
+
this.service.updateCharacteristic(this.platform.Characteristic.CoolingThresholdTemperature, e);
|
|
500
374
|
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
501
375
|
}
|
|
502
376
|
|
|
@@ -507,9 +381,7 @@ export class AirConditioner {
|
|
|
507
381
|
} else {
|
|
508
382
|
this.CurrentTemperatureCached = this.CurrentTemperature;
|
|
509
383
|
}
|
|
510
|
-
this.debugLog(
|
|
511
|
-
`Air Conditioner: ${this.accessory.displayName} Get CurrentTemperature: ${this.CurrentTemperature}`,
|
|
512
|
-
);
|
|
384
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get CurrentTemperature: ${this.CurrentTemperature}`);
|
|
513
385
|
this.accessory.context.CurrentTemperature = this.CurrentTemperatureCached;
|
|
514
386
|
return this.CurrentTemperature;
|
|
515
387
|
}
|
|
@@ -522,9 +394,7 @@ export class AirConditioner {
|
|
|
522
394
|
} else {
|
|
523
395
|
this.RotationSpeed = this.CurrentFanSpeed - 1;
|
|
524
396
|
}
|
|
525
|
-
this.debugLog(
|
|
526
|
-
`Air Conditioner: ${this.accessory.displayName} Get RotationSpeed: ${this.RotationSpeed}`,
|
|
527
|
-
);
|
|
397
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get RotationSpeed: ${this.RotationSpeed}`);
|
|
528
398
|
this.RotationSpeedCached = this.RotationSpeed;
|
|
529
399
|
this.accessory.context.RotationSpeed = this.RotationSpeedCached;
|
|
530
400
|
return this.RotationSpeed;
|
|
@@ -542,40 +412,36 @@ export class AirConditioner {
|
|
|
542
412
|
this.pushAirConditionerStatusChanges();
|
|
543
413
|
}
|
|
544
414
|
|
|
545
|
-
ActiveSet(value: CharacteristicValue)
|
|
546
|
-
this.debugLog(
|
|
547
|
-
`Air Conditioner: ${this.accessory.displayName} Set Active: ${value}`,
|
|
548
|
-
);
|
|
415
|
+
ActiveSet(value: CharacteristicValue) {
|
|
416
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set Active: ${value}`);
|
|
549
417
|
|
|
550
418
|
this.Active = value;
|
|
551
419
|
this.ActiveCached = this.Active;
|
|
552
420
|
this.accessory.context.Active = this.ActiveCached;
|
|
553
421
|
|
|
554
422
|
if (value === this.platform.Characteristic.Active.INACTIVE) {
|
|
555
|
-
this.debugLog(
|
|
556
|
-
`Air Conditioner: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.Active}`,
|
|
557
|
-
);
|
|
423
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.Active}`);
|
|
558
424
|
this.pushAirConditionerOffChanges();
|
|
559
425
|
} else {
|
|
560
|
-
this.debugLog(
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
426
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} pushAirConditionerOnChanges, Active: ${this.Active}`);
|
|
427
|
+
if (this.pushOn) {
|
|
428
|
+
this.pushAirConditionerOnChanges();
|
|
429
|
+
} else {
|
|
430
|
+
this.pushAirConditionerStatusChanges();
|
|
431
|
+
}
|
|
564
432
|
}
|
|
565
433
|
}
|
|
566
434
|
|
|
567
435
|
TargetHeaterCoolerStateGet() {
|
|
568
436
|
if (this.ValidValues === [0, 1, 2]) {
|
|
569
|
-
this.TargetHeaterCoolerState =
|
|
570
|
-
this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
437
|
+
this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
571
438
|
this.debugLog(
|
|
572
439
|
`Air Conditioner: ${this.accessory.displayName} Get (AUTO) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
|
|
573
440
|
` ValidValues: ${this.ValidValues}`,
|
|
574
441
|
);
|
|
575
442
|
} else if (this.ValidValues === [1, 2]) {
|
|
576
443
|
this.TargetHeaterCoolerState =
|
|
577
|
-
this.platform.Characteristic.TargetHeaterCoolerState.COOL ||
|
|
578
|
-
this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
444
|
+
this.platform.Characteristic.TargetHeaterCoolerState.COOL || this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
579
445
|
this.debugLog(
|
|
580
446
|
`Air Conditioner: ${this.accessory.displayName} Get (COOL/HEAT) TargetHeaterCoolerState: ${this.CurrentHeaterCoolerState},` +
|
|
581
447
|
` ValidValues: ${this.ValidValues}`,
|
|
@@ -587,8 +453,7 @@ export class AirConditioner {
|
|
|
587
453
|
);
|
|
588
454
|
}
|
|
589
455
|
this.TargetHeaterCoolerStateCached = this.TargetHeaterCoolerState;
|
|
590
|
-
this.accessory.context.TargetHeaterCoolerState =
|
|
591
|
-
this.TargetHeaterCoolerStateCached;
|
|
456
|
+
this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerStateCached;
|
|
592
457
|
return this.TargetHeaterCoolerState;
|
|
593
458
|
}
|
|
594
459
|
|
|
@@ -596,9 +461,7 @@ export class AirConditioner {
|
|
|
596
461
|
if (this.hide_automode) {
|
|
597
462
|
if (value === this.platform.Characteristic.TargetHeaterCoolerState.HEAT) {
|
|
598
463
|
this.TargetHeaterCoolerStateHEAT();
|
|
599
|
-
} else if (
|
|
600
|
-
value === this.platform.Characteristic.TargetHeaterCoolerState.COOL
|
|
601
|
-
) {
|
|
464
|
+
} else if (value === this.platform.Characteristic.TargetHeaterCoolerState.COOL) {
|
|
602
465
|
this.TargetHeaterCoolerStateCOOL();
|
|
603
466
|
} else {
|
|
604
467
|
this.errorLog(
|
|
@@ -609,13 +472,9 @@ export class AirConditioner {
|
|
|
609
472
|
} else {
|
|
610
473
|
if (value === this.platform.Characteristic.TargetHeaterCoolerState.AUTO) {
|
|
611
474
|
this.TargetHeaterCoolerStateAUTO();
|
|
612
|
-
} else if (
|
|
613
|
-
value === this.platform.Characteristic.TargetHeaterCoolerState.HEAT
|
|
614
|
-
) {
|
|
475
|
+
} else if (value === this.platform.Characteristic.TargetHeaterCoolerState.HEAT) {
|
|
615
476
|
this.TargetHeaterCoolerStateHEAT();
|
|
616
|
-
} else if (
|
|
617
|
-
value === this.platform.Characteristic.TargetHeaterCoolerState.COOL
|
|
618
|
-
) {
|
|
477
|
+
} else if (value === this.platform.Characteristic.TargetHeaterCoolerState.COOL) {
|
|
619
478
|
this.TargetHeaterCoolerStateCOOL();
|
|
620
479
|
} else {
|
|
621
480
|
this.errorLog(
|
|
@@ -625,73 +484,47 @@ export class AirConditioner {
|
|
|
625
484
|
}
|
|
626
485
|
}
|
|
627
486
|
this.TargetHeaterCoolerStateCached = this.TargetHeaterCoolerState;
|
|
628
|
-
this.accessory.context.TargetHeaterCoolerState =
|
|
629
|
-
this.TargetHeaterCoolerStateCached;
|
|
487
|
+
this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerStateCached;
|
|
630
488
|
this.pushAirConditionerStatusChanges();
|
|
631
489
|
}
|
|
632
490
|
|
|
633
491
|
private TargetHeaterCoolerStateAUTO() {
|
|
634
|
-
this.TargetHeaterCoolerState =
|
|
635
|
-
this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
492
|
+
this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
636
493
|
this.CurrentMode = 1;
|
|
637
|
-
this.debugLog(
|
|
638
|
-
|
|
639
|
-
);
|
|
640
|
-
this.debugLog(
|
|
641
|
-
`Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`,
|
|
642
|
-
);
|
|
494
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set (AUTO) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
495
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
643
496
|
}
|
|
644
497
|
|
|
645
498
|
private TargetHeaterCoolerStateCOOL() {
|
|
646
|
-
this.TargetHeaterCoolerState =
|
|
647
|
-
this.platform.Characteristic.TargetHeaterCoolerState.COOL;
|
|
499
|
+
this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.COOL;
|
|
648
500
|
this.CurrentMode = 2;
|
|
649
|
-
this.debugLog(
|
|
650
|
-
|
|
651
|
-
);
|
|
652
|
-
this.debugLog(
|
|
653
|
-
`Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`,
|
|
654
|
-
);
|
|
501
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set (COOL) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
502
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
655
503
|
}
|
|
656
504
|
|
|
657
505
|
private TargetHeaterCoolerStateHEAT() {
|
|
658
|
-
this.TargetHeaterCoolerState =
|
|
659
|
-
this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
506
|
+
this.TargetHeaterCoolerState = this.platform.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
660
507
|
this.CurrentMode = 5;
|
|
661
|
-
this.debugLog(
|
|
662
|
-
|
|
663
|
-
);
|
|
664
|
-
this.debugLog(
|
|
665
|
-
`Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`,
|
|
666
|
-
);
|
|
508
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Set (HEAT) TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
509
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
667
510
|
}
|
|
668
511
|
|
|
669
512
|
CurrentHeaterCoolerStateGet() {
|
|
670
513
|
if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
|
|
671
514
|
this.CurrentTemperatureUndefined();
|
|
672
515
|
if (this.CurrentTemperature < this.CurrentTemperatureCached) {
|
|
673
|
-
this.CurrentHeaterCoolerState =
|
|
674
|
-
|
|
675
|
-
this.debugLog(
|
|
676
|
-
`Air Conditioner: ${this.accessory.displayName} Get (COOLLING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
677
|
-
);
|
|
516
|
+
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
517
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get (COOLLING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
678
518
|
} else if (this.CurrentTemperature > this.CurrentTemperatureCached) {
|
|
679
|
-
this.CurrentHeaterCoolerState =
|
|
680
|
-
|
|
681
|
-
this.debugLog(
|
|
682
|
-
`Air Conditioner: ${this.accessory.displayName} Get (HEATING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
683
|
-
);
|
|
519
|
+
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
520
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get (HEATING) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
684
521
|
}
|
|
685
522
|
} else {
|
|
686
|
-
this.CurrentHeaterCoolerState =
|
|
687
|
-
|
|
688
|
-
this.debugLog(
|
|
689
|
-
`Air Conditioner: ${this.accessory.displayName} Get (INACTIVE) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
690
|
-
);
|
|
523
|
+
this.CurrentHeaterCoolerState = this.platform.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
524
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get (INACTIVE) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
691
525
|
}
|
|
692
526
|
this.CurrentHeaterCoolerStateCached = this.CurrentHeaterCoolerState;
|
|
693
|
-
this.accessory.context.CurrentHeaterCoolerState =
|
|
694
|
-
this.CurrentHeaterCoolerStateCached;
|
|
527
|
+
this.accessory.context.CurrentHeaterCoolerState = this.CurrentHeaterCoolerStateCached;
|
|
695
528
|
return this.CurrentHeaterCoolerState;
|
|
696
529
|
}
|
|
697
530
|
|
|
@@ -700,11 +533,8 @@ export class AirConditioner {
|
|
|
700
533
|
this.CurrentTemperature = this.CurrentTemperatureCached;
|
|
701
534
|
this.HeatingThresholdTemperature = this.CurrentTemperatureCached;
|
|
702
535
|
this.HeatingThresholdTemperatureCached = this.HeatingThresholdTemperature;
|
|
703
|
-
this.accessory.context.HeatingThresholdTemperature =
|
|
704
|
-
|
|
705
|
-
this.debugLog(
|
|
706
|
-
`Air Conditioner: ${this.accessory.displayName} Get HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`,
|
|
707
|
-
);
|
|
536
|
+
this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperatureCached;
|
|
537
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get HeatingThresholdTemperature: ${this.HeatingThresholdTemperature}`);
|
|
708
538
|
return this.HeatingThresholdTemperature;
|
|
709
539
|
}
|
|
710
540
|
|
|
@@ -712,8 +542,7 @@ export class AirConditioner {
|
|
|
712
542
|
this.CurrentTemperatureCached = this.CurrentTemperature;
|
|
713
543
|
this.CurrentTemperature = value;
|
|
714
544
|
this.HeatingThresholdTemperatureCached = this.HeatingThresholdTemperature;
|
|
715
|
-
this.accessory.context.HeatingThresholdTemperature =
|
|
716
|
-
this.HeatingThresholdTemperatureCached;
|
|
545
|
+
this.accessory.context.HeatingThresholdTemperature = this.HeatingThresholdTemperatureCached;
|
|
717
546
|
this.debugLog(
|
|
718
547
|
`Air Conditioner: ${this.accessory.displayName} Set HeatingThresholdTemperature: ${this.HeatingThresholdTemperature},` +
|
|
719
548
|
` CurrentTemperatureCached: ${this.CurrentTemperatureCached}`,
|
|
@@ -726,11 +555,8 @@ export class AirConditioner {
|
|
|
726
555
|
this.CurrentTemperature = this.CurrentTemperatureCached;
|
|
727
556
|
this.CoolingThresholdTemperature = this.CurrentTemperatureCached;
|
|
728
557
|
this.CoolingThresholdTemperatureCached = this.CoolingThresholdTemperature;
|
|
729
|
-
this.accessory.context.CoolingThresholdTemperature =
|
|
730
|
-
|
|
731
|
-
this.debugLog(
|
|
732
|
-
`Air Conditioner: ${this.accessory.displayName} Get CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`,
|
|
733
|
-
);
|
|
558
|
+
this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperatureCached;
|
|
559
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Get CoolingThresholdTemperature: ${this.CoolingThresholdTemperature}`);
|
|
734
560
|
return this.CoolingThresholdTemperature;
|
|
735
561
|
}
|
|
736
562
|
|
|
@@ -738,8 +564,7 @@ export class AirConditioner {
|
|
|
738
564
|
this.CurrentTemperatureCached = this.CurrentTemperature;
|
|
739
565
|
this.CurrentTemperature = value;
|
|
740
566
|
this.CoolingThresholdTemperatureCached = this.CoolingThresholdTemperature;
|
|
741
|
-
this.accessory.context.CoolingThresholdTemperature =
|
|
742
|
-
this.CoolingThresholdTemperatureCached;
|
|
567
|
+
this.accessory.context.CoolingThresholdTemperature = this.CoolingThresholdTemperatureCached;
|
|
743
568
|
this.debugLog(
|
|
744
569
|
`Air Conditioner: ${this.accessory.displayName} Set CoolingThresholdTemperature: ${this.CoolingThresholdTemperature},` +
|
|
745
570
|
` CurrentTemperatureCached: ${this.CurrentTemperatureCached}`,
|
|
@@ -762,39 +587,35 @@ export class AirConditioner {
|
|
|
762
587
|
config = device.irair;
|
|
763
588
|
}
|
|
764
589
|
if (device.logging !== undefined) {
|
|
765
|
-
config[
|
|
590
|
+
config['logging'] = device.logging;
|
|
766
591
|
}
|
|
767
592
|
if (Object.entries(config).length !== 0) {
|
|
768
|
-
this.warnLog(
|
|
769
|
-
`Air Conditioner: ${
|
|
770
|
-
this.accessory.displayName
|
|
771
|
-
} Config: ${JSON.stringify(config)}`,
|
|
772
|
-
);
|
|
593
|
+
this.warnLog(`Air Conditioner: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
773
594
|
}
|
|
774
595
|
}
|
|
775
596
|
|
|
776
597
|
logs(device: irdevice & irDevicesConfig) {
|
|
777
598
|
if (this.platform.debugMode) {
|
|
778
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
779
|
-
this.debugLog(
|
|
780
|
-
`Air Conditioner: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`,
|
|
781
|
-
);
|
|
599
|
+
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
600
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
782
601
|
} else if (device.logging) {
|
|
783
602
|
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
784
|
-
this.debugLog(
|
|
785
|
-
`Air Conditioner: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`,
|
|
786
|
-
);
|
|
603
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
787
604
|
} else if (this.platform.config.options?.logging) {
|
|
788
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
789
|
-
|
|
790
|
-
this.debugLog(
|
|
791
|
-
`Air Conditioner: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`,
|
|
792
|
-
);
|
|
605
|
+
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
606
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
793
607
|
} else {
|
|
794
|
-
this.deviceLogging = this.accessory.context.logging =
|
|
795
|
-
this.debugLog(
|
|
796
|
-
|
|
797
|
-
|
|
608
|
+
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
609
|
+
this.debugLog(`Air Conditioner: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
pushOnChanges(device: irdevice & irDevicesConfig) {
|
|
615
|
+
if (device.irair?.pushOn) {
|
|
616
|
+
this.pushOn = true;
|
|
617
|
+
} else {
|
|
618
|
+
this.pushOn = false;
|
|
798
619
|
}
|
|
799
620
|
}
|
|
800
621
|
|
|
@@ -821,8 +642,8 @@ export class AirConditioner {
|
|
|
821
642
|
|
|
822
643
|
debugLog(...log: any[]) {
|
|
823
644
|
if (this.enablingDeviceLogging()) {
|
|
824
|
-
if (this.deviceLogging ===
|
|
825
|
-
this.platform.log.info(
|
|
645
|
+
if (this.deviceLogging === 'debug') {
|
|
646
|
+
this.platform.log.info('[DEBUG]', String(...log));
|
|
826
647
|
} else {
|
|
827
648
|
this.platform.log.debug(String(...log));
|
|
828
649
|
}
|
|
@@ -830,6 +651,6 @@ export class AirConditioner {
|
|
|
830
651
|
}
|
|
831
652
|
|
|
832
653
|
enablingDeviceLogging(): boolean {
|
|
833
|
-
return this.deviceLogging
|
|
654
|
+
return this.deviceLogging === 'debug' || this.deviceLogging === 'standard';
|
|
834
655
|
}
|
|
835
656
|
}
|