@switchbot/homebridge-switchbot 3.5.0-beta.9 → 3.5.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/.vscode/settings.json +4 -1
- package/CHANGELOG.md +4 -1
- package/config.schema.json +164 -22
- package/dist/device/blindtilt.d.ts +21 -96
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +457 -866
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +27 -72
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +851 -913
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +15 -69
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +316 -742
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +15 -76
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +380 -833
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +14 -66
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +267 -602
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +18 -89
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +469 -897
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +76 -0
- package/dist/device/device.d.ts.map +1 -0
- package/dist/device/device.js +846 -0
- package/dist/device/device.js.map +1 -0
- package/dist/device/fan.d.ts +63 -0
- package/dist/device/fan.d.ts.map +1 -0
- package/dist/device/fan.js +645 -0
- package/dist/device/fan.js.map +1 -0
- package/dist/device/hub.d.ts +19 -58
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +304 -640
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +11 -66
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +300 -710
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +12 -64
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +225 -643
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +12 -70
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +371 -742
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +17 -63
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +309 -642
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +15 -64
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +223 -638
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +15 -65
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +216 -644
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +12 -69
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +209 -588
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +10 -57
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +141 -532
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +13 -63
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +252 -609
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts +11 -63
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +179 -521
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/homebridge-ui/public/index.html +22 -16
- package/dist/homebridge-ui/server.js +1 -1
- package/dist/homebridge-ui/server.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +10 -50
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +337 -482
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +8 -39
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +108 -333
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +7 -36
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +47 -299
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +7 -43
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +95 -364
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +46 -0
- package/dist/irdevice/irdevice.d.ts.map +1 -0
- package/dist/irdevice/irdevice.js +393 -0
- package/dist/irdevice/irdevice.js.map +1 -0
- package/dist/irdevice/light.d.ts +12 -45
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +121 -376
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +19 -48
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +441 -584
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +8 -40
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +94 -353
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +7 -36
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +48 -299
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +7 -36
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +50 -305
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +22 -8
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +342 -191
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +66 -18
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +16 -552
- package/dist/settings.js.map +1 -1
- package/dist/utils.d.ts +95 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +657 -1
- package/dist/utils.js.map +1 -1
- package/eslint.config.js +96 -0
- package/package.json +20 -16
- package/src/custom.d.ts +2 -1
- package/src/device/blindtilt.ts +488 -937
- package/src/device/bot.ts +907 -1016
- package/src/device/ceilinglight.ts +330 -798
- package/src/device/colorbulb.ts +394 -904
- package/src/device/contact.ts +298 -637
- package/src/device/curtain.ts +496 -954
- package/src/device/device.ts +872 -0
- package/src/device/fan.ts +692 -0
- package/src/device/hub.ts +338 -671
- package/src/device/humidifier.ts +330 -777
- package/src/device/iosensor.ts +258 -671
- package/src/device/lightstrip.ts +394 -809
- package/src/device/lock.ts +345 -700
- package/src/device/meter.ts +256 -666
- package/src/device/meterplus.ts +248 -672
- package/src/device/motion.ts +234 -622
- package/src/device/plug.ts +152 -572
- package/src/device/robotvacuumcleaner.ts +273 -653
- package/src/device/waterdetector.ts +198 -549
- package/src/homebridge-ui/public/index.html +22 -16
- package/src/homebridge-ui/server.ts +1 -1
- package/src/index.ts +4 -3
- package/src/irdevice/airconditioner.ts +368 -540
- package/src/irdevice/airpurifier.ts +134 -369
- package/src/irdevice/camera.ts +60 -324
- package/src/irdevice/fan.ts +111 -392
- package/src/irdevice/irdevice.ts +406 -0
- package/src/irdevice/light.ts +159 -425
- package/src/irdevice/other.ts +509 -661
- package/src/irdevice/tv.ts +123 -388
- package/src/irdevice/vacuumcleaner.ts +61 -324
- package/src/irdevice/waterheater.ts +63 -333
- package/src/platform.ts +395 -259
- package/src/settings.ts +120 -610
- package/src/utils.ts +661 -1
- package/src/device/waterdetector.json +0 -11
|
@@ -1,29 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/* Copyright(C) 2021-2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
|
|
2
|
+
*
|
|
3
|
+
* airconditioners.ts: @switchbot/homebridge-switchbot.
|
|
4
|
+
*/
|
|
5
|
+
import { irdeviceBase } from './irdevice.js';
|
|
3
6
|
/**
|
|
4
7
|
* Platform Accessory
|
|
5
8
|
* An instance of this class is created for each accessory your platform registers
|
|
6
9
|
* Each accessory may expose multiple services of different service types.
|
|
7
10
|
*/
|
|
8
|
-
export class AirConditioner {
|
|
11
|
+
export class AirConditioner extends irdeviceBase {
|
|
9
12
|
platform;
|
|
10
|
-
accessory;
|
|
11
|
-
device;
|
|
12
|
-
api;
|
|
13
|
-
log;
|
|
14
|
-
config;
|
|
15
|
-
hap;
|
|
16
13
|
// Services
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
RotationSpeed;
|
|
21
|
-
FirmwareRevision;
|
|
22
|
-
CurrentTemperature;
|
|
23
|
-
ThresholdTemperature;
|
|
24
|
-
CurrentRelativeHumidity;
|
|
25
|
-
TargetHeaterCoolerState;
|
|
26
|
-
CurrentHeaterCoolerState;
|
|
14
|
+
HeaterCooler;
|
|
15
|
+
meter;
|
|
16
|
+
HumiditySensor;
|
|
27
17
|
// Others
|
|
28
18
|
state;
|
|
29
19
|
Busy;
|
|
@@ -31,91 +21,80 @@ export class AirConditioner {
|
|
|
31
21
|
CurrentMode;
|
|
32
22
|
ValidValues;
|
|
33
23
|
CurrentFanSpeed;
|
|
34
|
-
static MODE_AUTO;
|
|
35
|
-
static MODE_COOL;
|
|
36
|
-
static MODE_HEAT;
|
|
37
24
|
// Config
|
|
38
|
-
deviceLogging;
|
|
39
25
|
hide_automode;
|
|
40
26
|
set_max_heat;
|
|
41
27
|
set_min_heat;
|
|
42
28
|
set_max_cool;
|
|
43
29
|
set_min_cool;
|
|
44
|
-
disablePushOn;
|
|
45
|
-
disablePushOff;
|
|
46
|
-
meter;
|
|
47
|
-
disablePushDetail;
|
|
48
|
-
valid12 = [1, 2];
|
|
49
|
-
valid012 = [0, 1, 2];
|
|
50
30
|
constructor(platform, accessory, device) {
|
|
31
|
+
super(platform, accessory, device);
|
|
51
32
|
this.platform = platform;
|
|
52
|
-
this.accessory = accessory;
|
|
53
|
-
this.device = device;
|
|
54
|
-
this.api = this.platform.api;
|
|
55
|
-
this.log = this.platform.log;
|
|
56
|
-
this.config = this.platform.config;
|
|
57
|
-
this.hap = this.api.hap;
|
|
58
33
|
// default placeholders
|
|
59
|
-
this.
|
|
60
|
-
this.deviceContext();
|
|
61
|
-
this.disablePushOnChanges(device);
|
|
62
|
-
this.disablePushOffChanges(device);
|
|
63
|
-
this.disablePushDetailChanges(device);
|
|
64
|
-
this.deviceConfig(device);
|
|
65
|
-
// set accessory information
|
|
66
|
-
accessory
|
|
67
|
-
.getService(this.hap.Service.AccessoryInformation)
|
|
68
|
-
.setCharacteristic(this.hap.Characteristic.Manufacturer, 'SwitchBot')
|
|
69
|
-
.setCharacteristic(this.hap.Characteristic.Model, device.remoteType)
|
|
70
|
-
.setCharacteristic(this.hap.Characteristic.SerialNumber, device.deviceId)
|
|
71
|
-
.setCharacteristic(this.hap.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision);
|
|
72
|
-
// get the Television service if it exists, otherwise create a new Television service
|
|
73
|
-
// you can create multiple services for each accessory
|
|
74
|
-
const coolerService = `${accessory.displayName} ${device.remoteType}`;
|
|
75
|
-
(this.coolerService = accessory.getService(this.hap.Service.HeaterCooler)
|
|
76
|
-
|| accessory.addService(this.hap.Service.HeaterCooler)), coolerService;
|
|
77
|
-
this.coolerService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
78
|
-
if (!this.coolerService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
79
|
-
this.coolerService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
80
|
-
}
|
|
81
|
-
// handle on / off events using the Active characteristic
|
|
82
|
-
this.coolerService.getCharacteristic(this.hap.Characteristic.Active).onSet(this.ActiveSet.bind(this));
|
|
83
|
-
this.coolerService.getCharacteristic(this.hap.Characteristic.CurrentTemperature).onGet(this.CurrentTemperatureGet.bind(this));
|
|
34
|
+
this.getAirConditionerConfigSettings(accessory, device);
|
|
84
35
|
this.ValidValues = this.hide_automode ? [1, 2] : [0, 1, 2];
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
36
|
+
// Initialize HeaterCooler Service
|
|
37
|
+
accessory.context.HeaterCooler = accessory.context.HeaterCooler ?? {};
|
|
38
|
+
this.HeaterCooler = {
|
|
39
|
+
Name: accessory.context.HeaterCooler.Name ?? `${accessory.displayName} ${device.remoteType}`,
|
|
40
|
+
Service: accessory.getService(this.hap.Service.HeaterCooler) ?? accessory.addService(this.hap.Service.HeaterCooler),
|
|
41
|
+
Active: accessory.context.Active ?? this.hap.Characteristic.Active.INACTIVE,
|
|
42
|
+
CurrentHeaterCoolerState: accessory.context.CurrentHeaterCoolerState ?? this.hap.Characteristic.CurrentHeaterCoolerState.IDLE,
|
|
43
|
+
TargetHeaterCoolerState: accessory.context.TargetHeaterCoolerState ?? this.hap.Characteristic.TargetHeaterCoolerState.AUTO,
|
|
44
|
+
CurrentTemperature: accessory.context.CurrentTemperature ?? 24,
|
|
45
|
+
ThresholdTemperature: accessory.context.ThresholdTemperature ?? 24,
|
|
46
|
+
RotationSpeed: accessory.context.RotationSpeed ?? 4,
|
|
47
|
+
};
|
|
48
|
+
accessory.context.HeaterCooler = this.HeaterCooler;
|
|
49
|
+
this.HeaterCooler.Service
|
|
50
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.HeaterCooler.Name)
|
|
51
|
+
.getCharacteristic(this.hap.Characteristic.Active)
|
|
52
|
+
.onGet(() => {
|
|
53
|
+
return this.HeaterCooler.Active;
|
|
54
|
+
})
|
|
55
|
+
.onSet(this.ActiveSet.bind(this));
|
|
56
|
+
this.HeaterCooler.Service
|
|
57
|
+
.getCharacteristic(this.hap.Characteristic.CurrentTemperature)
|
|
58
|
+
.onGet(async () => {
|
|
59
|
+
return await this.CurrentTemperatureGet();
|
|
60
|
+
});
|
|
61
|
+
this.HeaterCooler.Service
|
|
93
62
|
.getCharacteristic(this.hap.Characteristic.TargetHeaterCoolerState)
|
|
94
63
|
.setProps({
|
|
95
64
|
validValues: this.ValidValues,
|
|
96
65
|
})
|
|
97
|
-
.onGet(
|
|
66
|
+
.onGet(async () => {
|
|
67
|
+
return await this.TargetHeaterCoolerStateGet();
|
|
68
|
+
})
|
|
98
69
|
.onSet(this.TargetHeaterCoolerStateSet.bind(this));
|
|
99
|
-
this.
|
|
100
|
-
|
|
70
|
+
this.HeaterCooler.Service
|
|
71
|
+
.getCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState)
|
|
72
|
+
.onGet(async () => {
|
|
73
|
+
return await this.CurrentHeaterCoolerStateGet();
|
|
74
|
+
});
|
|
75
|
+
this.HeaterCooler.Service
|
|
101
76
|
.getCharacteristic(this.hap.Characteristic.HeatingThresholdTemperature)
|
|
102
77
|
.setProps({
|
|
103
78
|
minValue: this.set_min_heat,
|
|
104
79
|
maxValue: this.set_max_heat,
|
|
105
80
|
minStep: 0.5,
|
|
106
81
|
})
|
|
107
|
-
.onGet(
|
|
82
|
+
.onGet(async () => {
|
|
83
|
+
return await this.ThresholdTemperatureGet();
|
|
84
|
+
})
|
|
108
85
|
.onSet(this.ThresholdTemperatureSet.bind(this));
|
|
109
|
-
this.
|
|
86
|
+
this.HeaterCooler.Service
|
|
110
87
|
.getCharacteristic(this.hap.Characteristic.CoolingThresholdTemperature)
|
|
111
88
|
.setProps({
|
|
112
89
|
minValue: this.set_min_cool,
|
|
113
90
|
maxValue: this.set_max_cool,
|
|
114
91
|
minStep: 0.5,
|
|
115
92
|
})
|
|
116
|
-
.onGet(
|
|
93
|
+
.onGet(async () => {
|
|
94
|
+
return await this.ThresholdTemperatureGet();
|
|
95
|
+
})
|
|
117
96
|
.onSet(this.ThresholdTemperatureSet.bind(this));
|
|
118
|
-
this.
|
|
97
|
+
this.HeaterCooler.Service
|
|
119
98
|
.getCharacteristic(this.hap.Characteristic.RotationSpeed)
|
|
120
99
|
.setProps({
|
|
121
100
|
format: 'int',
|
|
@@ -123,8 +102,33 @@ export class AirConditioner {
|
|
|
123
102
|
minValue: 1,
|
|
124
103
|
maxValue: 4,
|
|
125
104
|
})
|
|
126
|
-
.onGet(
|
|
105
|
+
.onGet(async () => {
|
|
106
|
+
return await this.RotationSpeedGet();
|
|
107
|
+
})
|
|
127
108
|
.onSet(this.RotationSpeedSet.bind(this));
|
|
109
|
+
// Initialize HumiditySensor property
|
|
110
|
+
if (this.device.irair?.meterType && this.device.irair?.meterId) {
|
|
111
|
+
const meterUuid = this.platform.api.hap.uuid.generate(`${this.device.irair.meterId}-${this.device.irair.meterType}`);
|
|
112
|
+
this.meter = this.platform.accessories.find((accessory) => accessory.UUID === meterUuid);
|
|
113
|
+
accessory.context.HumiditySensor = accessory.context.HumiditySensor ?? {};
|
|
114
|
+
this.HumiditySensor = {
|
|
115
|
+
Name: accessory.context.HumiditySensor ?? this.meter.displayName,
|
|
116
|
+
Service: this.meter.getService(this.hap.Service.HumiditySensor) ?? this.meter.addService(this.hap.Service.HumiditySensor),
|
|
117
|
+
CurrentRelativeHumidity: this.meter.context.CurrentRelativeHumidity || 0,
|
|
118
|
+
};
|
|
119
|
+
accessory.context.HumiditySensor = this.HumiditySensor;
|
|
120
|
+
}
|
|
121
|
+
if (this.device.irair?.meterType && this.device.irair?.meterId) {
|
|
122
|
+
const meterUuid = this.platform.api.hap.uuid.generate(`${this.device.irair.meterId}-${this.device.irair.meterType}`);
|
|
123
|
+
this.meter = this.platform.accessories.find((accessory) => accessory.UUID === meterUuid);
|
|
124
|
+
}
|
|
125
|
+
if (this.meter) {
|
|
126
|
+
this.HumiditySensor.Service
|
|
127
|
+
.getCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity)
|
|
128
|
+
.onGet(async () => {
|
|
129
|
+
return await this.CurrentRelativeHumidityGet();
|
|
130
|
+
});
|
|
131
|
+
}
|
|
128
132
|
}
|
|
129
133
|
/**
|
|
130
134
|
* Pushes the requested changes to the SwitchBot API
|
|
@@ -136,9 +140,9 @@ export class AirConditioner {
|
|
|
136
140
|
* AirConditioner: "command" "highSpeed" "default" = fan speed to high
|
|
137
141
|
*/
|
|
138
142
|
async pushAirConditionerOnChanges() {
|
|
139
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOnChanges Active: ${this.Active},`
|
|
140
|
-
` disablePushOn: ${this.disablePushOn}`);
|
|
141
|
-
if (this.Active === this.hap.Characteristic.Active.ACTIVE && !this.disablePushOn) {
|
|
143
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOnChanges Active: ${this.HeaterCooler.Active},`
|
|
144
|
+
+ ` disablePushOn: ${this.disablePushOn}`);
|
|
145
|
+
if (this.HeaterCooler.Active === this.hap.Characteristic.Active.ACTIVE && !this.disablePushOn) {
|
|
142
146
|
const commandType = await this.commandType();
|
|
143
147
|
const command = await this.commandOn();
|
|
144
148
|
const bodyChange = JSON.stringify({
|
|
@@ -150,9 +154,9 @@ export class AirConditioner {
|
|
|
150
154
|
}
|
|
151
155
|
}
|
|
152
156
|
async pushAirConditionerOffChanges() {
|
|
153
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges Active: ${this.Active},`
|
|
154
|
-
` disablePushOff: ${this.disablePushOff}`);
|
|
155
|
-
if (this.Active === this.hap.Characteristic.Active.INACTIVE && !this.disablePushOff) {
|
|
157
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges Active: ${this.HeaterCooler.Active},`
|
|
158
|
+
+ ` disablePushOff: ${this.disablePushOff}`);
|
|
159
|
+
if (this.HeaterCooler.Active === this.hap.Characteristic.Active.INACTIVE && !this.disablePushOff) {
|
|
156
160
|
const commandType = await this.commandType();
|
|
157
161
|
const command = await this.commandOff();
|
|
158
162
|
const bodyChange = JSON.stringify({
|
|
@@ -164,19 +168,19 @@ export class AirConditioner {
|
|
|
164
168
|
}
|
|
165
169
|
}
|
|
166
170
|
async pushAirConditionerStatusChanges() {
|
|
167
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerStatusChanges Active: ${this.Active},`
|
|
168
|
-
` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`);
|
|
171
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerStatusChanges Active: ${this.HeaterCooler.Active},`
|
|
172
|
+
+ ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`);
|
|
169
173
|
if (!this.Busy) {
|
|
170
174
|
this.Busy = true;
|
|
171
|
-
this.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.IDLE;
|
|
175
|
+
this.HeaterCooler.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.IDLE;
|
|
172
176
|
}
|
|
173
177
|
clearTimeout(this.Timeout);
|
|
174
178
|
// Make a new Timeout set to go off in 1000ms (1 second)
|
|
175
179
|
this.Timeout = setTimeout(this.pushAirConditionerDetailsChanges.bind(this), 1500);
|
|
176
180
|
}
|
|
177
181
|
async pushAirConditionerDetailsChanges() {
|
|
178
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerDetailsChanges Active: ${this.Active},`
|
|
179
|
-
` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`);
|
|
182
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerDetailsChanges Active: ${this.HeaterCooler.Active},`
|
|
183
|
+
+ ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`);
|
|
180
184
|
//await this.deviceContext();
|
|
181
185
|
if (this.CurrentMode === undefined) {
|
|
182
186
|
this.CurrentMode = 1;
|
|
@@ -184,7 +188,7 @@ export class AirConditioner {
|
|
|
184
188
|
if (this.CurrentFanSpeed === undefined) {
|
|
185
189
|
this.CurrentFanSpeed = 1;
|
|
186
190
|
}
|
|
187
|
-
if (this.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
191
|
+
if (this.HeaterCooler.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
188
192
|
this.state = 'on';
|
|
189
193
|
}
|
|
190
194
|
else {
|
|
@@ -192,11 +196,11 @@ export class AirConditioner {
|
|
|
192
196
|
}
|
|
193
197
|
if (this.CurrentMode === 1) {
|
|
194
198
|
// Remove or make configurable?
|
|
195
|
-
this.ThresholdTemperature = 25;
|
|
196
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentMode: ${this.CurrentMode},`
|
|
197
|
-
` ThresholdTemperature: ${this.ThresholdTemperature}`);
|
|
199
|
+
this.HeaterCooler.ThresholdTemperature = 25;
|
|
200
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentMode: ${this.CurrentMode},`
|
|
201
|
+
+ ` ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
|
|
198
202
|
}
|
|
199
|
-
const parameter = `${this.ThresholdTemperature},${this.CurrentMode},${this.CurrentFanSpeed},${this.state}`;
|
|
203
|
+
const parameter = `${this.HeaterCooler.ThresholdTemperature},${this.CurrentMode},${this.CurrentFanSpeed},${this.state}`;
|
|
200
204
|
await this.UpdateCurrentHeaterCoolerState();
|
|
201
205
|
const bodyChange = JSON.stringify({
|
|
202
206
|
command: 'setAll',
|
|
@@ -206,22 +210,94 @@ export class AirConditioner {
|
|
|
206
210
|
await this.pushChanges(bodyChange);
|
|
207
211
|
}
|
|
208
212
|
async UpdateCurrentHeaterCoolerState() {
|
|
209
|
-
if (this.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
213
|
+
if (this.HeaterCooler.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
214
|
+
if (this.HeaterCooler.Active === undefined) {
|
|
215
|
+
this.HeaterCooler.Active = this.hap.Characteristic.Active.INACTIVE;
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
this.HeaterCooler.Active = this.HeaterCooler.Active ? this.HeaterCooler.Active : this.accessory.context.Active;
|
|
219
|
+
}
|
|
220
|
+
if (this.HeaterCooler.CurrentTemperature === undefined && this.accessory.context.CurrentTemperature === undefined) {
|
|
221
|
+
this.HeaterCooler.CurrentTemperature = 24;
|
|
214
222
|
}
|
|
215
|
-
else
|
|
216
|
-
this.
|
|
217
|
-
|
|
223
|
+
else {
|
|
224
|
+
this.HeaterCooler.CurrentTemperature = this.HeaterCooler.CurrentTemperature || this.accessory.context.CurrentTemperature;
|
|
225
|
+
}
|
|
226
|
+
if (this.HeaterCooler.ThresholdTemperature === undefined && this.accessory.context.ThresholdTemperature === undefined) {
|
|
227
|
+
this.HeaterCooler.ThresholdTemperature = 24;
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
this.HeaterCooler.ThresholdTemperature = this.HeaterCooler.ThresholdTemperature || this.accessory.context.ThresholdTemperature;
|
|
231
|
+
}
|
|
232
|
+
if (this.HeaterCooler.RotationSpeed === undefined && this.accessory.context.RotationSpeed === undefined) {
|
|
233
|
+
this.HeaterCooler.RotationSpeed = 4;
|
|
218
234
|
}
|
|
219
235
|
else {
|
|
220
|
-
this.
|
|
236
|
+
this.HeaterCooler.RotationSpeed = this.HeaterCooler.RotationSpeed || this.accessory.context.RotationSpeed;
|
|
237
|
+
}
|
|
238
|
+
if (this.device.irair?.hide_automode) {
|
|
239
|
+
this.hide_automode = this.device.irair?.hide_automode;
|
|
240
|
+
this.accessory.context.hide_automode = this.hide_automode;
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
this.hide_automode = this.device.irair?.hide_automode;
|
|
244
|
+
this.accessory.context.hide_automode = this.hide_automode;
|
|
245
|
+
}
|
|
246
|
+
if (this.device.irair?.set_max_heat) {
|
|
247
|
+
this.set_max_heat = this.device.irair?.set_max_heat;
|
|
248
|
+
this.accessory.context.set_max_heat = this.set_max_heat;
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
this.set_max_heat = 35;
|
|
252
|
+
this.accessory.context.set_max_heat = this.set_max_heat;
|
|
253
|
+
}
|
|
254
|
+
if (this.device.irair?.set_min_heat) {
|
|
255
|
+
this.set_min_heat = this.device.irair?.set_min_heat;
|
|
256
|
+
this.accessory.context.set_min_heat = this.set_min_heat;
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
this.set_min_heat = 0;
|
|
260
|
+
this.accessory.context.set_min_heat = this.set_min_heat;
|
|
261
|
+
}
|
|
262
|
+
if (this.device.irair?.set_max_cool) {
|
|
263
|
+
this.set_max_cool = this.device.irair?.set_max_cool;
|
|
264
|
+
this.accessory.context.set_max_cool = this.set_max_cool;
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
this.set_max_cool = 35;
|
|
268
|
+
this.accessory.context.set_max_cool = this.set_max_cool;
|
|
269
|
+
}
|
|
270
|
+
if (this.device.irair?.set_min_cool) {
|
|
271
|
+
this.set_min_cool = this.device.irair?.set_min_cool;
|
|
272
|
+
this.accessory.context.set_min_cool = this.set_min_cool;
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
this.set_min_cool = 0;
|
|
276
|
+
this.accessory.context.set_min_cool = this.set_min_cool;
|
|
277
|
+
}
|
|
278
|
+
if (this.meter) {
|
|
279
|
+
if (this.HumiditySensor.CurrentRelativeHumidity === undefined && this.accessory.context.CurrentRelativeHumidity === undefined) {
|
|
280
|
+
this.HumiditySensor.CurrentRelativeHumidity = 0;
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
this.HumiditySensor.CurrentRelativeHumidity = this.HumiditySensor.CurrentRelativeHumidity
|
|
284
|
+
|| this.accessory.context.CurrentRelativeHumidity;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
if (this.HeaterCooler.ThresholdTemperature < this.HeaterCooler.CurrentTemperature &&
|
|
288
|
+
this.HeaterCooler.TargetHeaterCoolerState !== this.hap.Characteristic.TargetHeaterCoolerState.HEAT) {
|
|
289
|
+
this.HeaterCooler.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
290
|
+
}
|
|
291
|
+
else if (this.HeaterCooler.ThresholdTemperature > this.HeaterCooler.CurrentTemperature &&
|
|
292
|
+
this.HeaterCooler.TargetHeaterCoolerState !== this.hap.Characteristic.TargetHeaterCoolerState.COOL) {
|
|
293
|
+
this.HeaterCooler.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
this.HeaterCooler.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.IDLE;
|
|
221
297
|
}
|
|
222
298
|
}
|
|
223
299
|
else {
|
|
224
|
-
this.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
300
|
+
this.HeaterCooler.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
225
301
|
}
|
|
226
302
|
}
|
|
227
303
|
async pushChanges(bodyChange) {
|
|
@@ -229,36 +305,29 @@ export class AirConditioner {
|
|
|
229
305
|
if (this.device.connectionType === 'OpenAPI' && !this.disablePushDetail) {
|
|
230
306
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
231
307
|
try {
|
|
232
|
-
const { body, statusCode } = await
|
|
233
|
-
body: bodyChange,
|
|
234
|
-
method: 'POST',
|
|
235
|
-
headers: this.platform.generateHeaders(),
|
|
236
|
-
});
|
|
237
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
308
|
+
const { body, statusCode } = await this.pushChangeRequest(bodyChange);
|
|
238
309
|
const deviceStatus = await body.json();
|
|
239
|
-
this.
|
|
240
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
310
|
+
await this.pushStatusCodes(statusCode, deviceStatus);
|
|
241
311
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
242
|
-
this.
|
|
243
|
-
|
|
244
|
-
this.updateHomeKitCharacteristics();
|
|
312
|
+
await this.successfulPushChange(statusCode, deviceStatus, bodyChange);
|
|
313
|
+
await this.updateHomeKitCharacteristics();
|
|
245
314
|
}
|
|
246
315
|
else {
|
|
247
|
-
this.statusCode(statusCode);
|
|
248
|
-
this.statusCode(deviceStatus.statusCode);
|
|
316
|
+
await this.statusCode(statusCode);
|
|
317
|
+
await this.statusCode(deviceStatus.statusCode);
|
|
249
318
|
}
|
|
250
319
|
}
|
|
251
320
|
catch (e) {
|
|
252
321
|
this.apiError(e);
|
|
253
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}`
|
|
254
|
-
` Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
322
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}`
|
|
323
|
+
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`);
|
|
255
324
|
}
|
|
256
325
|
}
|
|
257
326
|
else {
|
|
258
|
-
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
259
|
-
` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
260
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
261
|
-
` Connection Type: ${this.device.connectionType}, disablePushDetails: ${this.disablePushDetail}`);
|
|
327
|
+
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
328
|
+
+ ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
|
|
329
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
330
|
+
+ ` Connection Type: ${this.device.connectionType}, disablePushDetails: ${this.disablePushDetail}`);
|
|
262
331
|
this.updateHomeKitCharacteristics();
|
|
263
332
|
}
|
|
264
333
|
}
|
|
@@ -268,9 +337,9 @@ export class AirConditioner {
|
|
|
268
337
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
269
338
|
+ `Using CurrentTemperature from ${this.meter.context.deviceType} (${this.meter.context.deviceID})`);
|
|
270
339
|
}
|
|
271
|
-
this.CurrentTemperature = this.accessory.context.CurrentTemperature || 24;
|
|
272
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CurrentTemperature: ${this.CurrentTemperature}`);
|
|
273
|
-
return this.CurrentTemperature;
|
|
340
|
+
this.HeaterCooler.CurrentTemperature = this.accessory.context.CurrentTemperature || 24;
|
|
341
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CurrentTemperature: ${this.HeaterCooler.CurrentTemperature}`);
|
|
342
|
+
return this.HeaterCooler.CurrentTemperature;
|
|
274
343
|
}
|
|
275
344
|
async CurrentRelativeHumidityGet() {
|
|
276
345
|
if (this.meter?.context?.CurrentRelativeHumidity) {
|
|
@@ -278,19 +347,20 @@ export class AirConditioner {
|
|
|
278
347
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
279
348
|
+ `Using CurrentRelativeHumidity from ${this.meter.context.deviceType} (${this.meter.context.deviceID})`);
|
|
280
349
|
}
|
|
281
|
-
this.CurrentRelativeHumidity = this.accessory.context.CurrentRelativeHumidity || 0;
|
|
282
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get
|
|
283
|
-
|
|
350
|
+
this.HumiditySensor.CurrentRelativeHumidity = this.accessory.context.CurrentRelativeHumidity || 0;
|
|
351
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get`
|
|
352
|
+
+ ` CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}`);
|
|
353
|
+
return this.HumiditySensor.CurrentRelativeHumidity;
|
|
284
354
|
}
|
|
285
355
|
async RotationSpeedGet() {
|
|
286
356
|
if (!this.CurrentFanSpeed || this.CurrentFanSpeed === 1) {
|
|
287
|
-
this.RotationSpeed = 4;
|
|
357
|
+
this.HeaterCooler.RotationSpeed = 4;
|
|
288
358
|
}
|
|
289
359
|
else {
|
|
290
|
-
this.RotationSpeed = this.CurrentFanSpeed - 1;
|
|
360
|
+
this.HeaterCooler.RotationSpeed = this.CurrentFanSpeed - 1;
|
|
291
361
|
}
|
|
292
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get RotationSpeed: ${this.RotationSpeed}`);
|
|
293
|
-
return this.RotationSpeed;
|
|
362
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get RotationSpeed: ${this.HeaterCooler.RotationSpeed}`);
|
|
363
|
+
return this.HeaterCooler.RotationSpeed;
|
|
294
364
|
}
|
|
295
365
|
async RotationSpeedSet(value) {
|
|
296
366
|
if (value === 4) {
|
|
@@ -299,16 +369,16 @@ export class AirConditioner {
|
|
|
299
369
|
else {
|
|
300
370
|
this.CurrentFanSpeed = Number(value) + 1;
|
|
301
371
|
}
|
|
302
|
-
this.RotationSpeed = value;
|
|
303
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
304
|
-
`Set RotationSpeed: ${this.RotationSpeed}, CurrentFanSpeed: ${this.CurrentFanSpeed}`);
|
|
372
|
+
this.HeaterCooler.RotationSpeed = value;
|
|
373
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
374
|
+
+ `Set RotationSpeed: ${this.HeaterCooler.RotationSpeed}, CurrentFanSpeed: ${this.CurrentFanSpeed}`);
|
|
305
375
|
this.pushAirConditionerStatusChanges();
|
|
306
376
|
}
|
|
307
377
|
async ActiveSet(value) {
|
|
308
378
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Active: ${value}`);
|
|
309
|
-
this.Active = value;
|
|
310
|
-
if (this.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
311
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOnChanges, Active: ${this.Active}`);
|
|
379
|
+
this.HeaterCooler.Active = value;
|
|
380
|
+
if (this.HeaterCooler.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
381
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOnChanges, Active: ${this.HeaterCooler.Active}`);
|
|
312
382
|
if (this.disablePushOn) {
|
|
313
383
|
this.pushAirConditionerStatusChanges();
|
|
314
384
|
}
|
|
@@ -317,16 +387,16 @@ export class AirConditioner {
|
|
|
317
387
|
}
|
|
318
388
|
}
|
|
319
389
|
else {
|
|
320
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.Active}`);
|
|
390
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.HeaterCooler.Active}`);
|
|
321
391
|
this.pushAirConditionerOffChanges();
|
|
322
392
|
}
|
|
323
393
|
}
|
|
324
394
|
async TargetHeaterCoolerStateGet() {
|
|
325
|
-
const targetState = this.TargetHeaterCoolerState || this.accessory.context.TargetHeaterCoolerState;
|
|
326
|
-
this.TargetHeaterCoolerState = this.ValidValues.includes(targetState) ? targetState : this.ValidValues[0];
|
|
327
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get (${this.getTargetHeaterCoolerStateName()})
|
|
328
|
-
`
|
|
329
|
-
return this.TargetHeaterCoolerState;
|
|
395
|
+
const targetState = this.HeaterCooler.TargetHeaterCoolerState || this.accessory.context.TargetHeaterCoolerState;
|
|
396
|
+
this.HeaterCooler.TargetHeaterCoolerState = this.ValidValues.includes(targetState) ? targetState : this.ValidValues[0];
|
|
397
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get (${this.getTargetHeaterCoolerStateName()}) TargetHeaterCoolerState:`
|
|
398
|
+
+ ` ${this.HeaterCooler.TargetHeaterCoolerState}, ValidValues: ${this.ValidValues}, hide_automode: ${this.hide_automode}`);
|
|
399
|
+
return this.HeaterCooler.TargetHeaterCoolerState;
|
|
330
400
|
}
|
|
331
401
|
async TargetHeaterCoolerStateSet(value) {
|
|
332
402
|
if (!this.hide_automode && value === this.hap.Characteristic.TargetHeaterCoolerState.AUTO) {
|
|
@@ -339,37 +409,40 @@ export class AirConditioner {
|
|
|
339
409
|
this.TargetHeaterCoolerStateCOOL();
|
|
340
410
|
}
|
|
341
411
|
else {
|
|
342
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Set TargetHeaterCoolerState:
|
|
343
|
-
|
|
412
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Set TargetHeaterCoolerState: `
|
|
413
|
+
+ `${this.HeaterCooler.TargetHeaterCoolerState}, hide_automode: ${this.hide_automode} `);
|
|
344
414
|
}
|
|
345
415
|
this.pushAirConditionerStatusChanges();
|
|
346
416
|
}
|
|
347
417
|
async TargetHeaterCoolerStateAUTO() {
|
|
348
|
-
this.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
418
|
+
this.HeaterCooler.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
349
419
|
this.CurrentMode = 1;
|
|
350
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (AUTO)
|
|
420
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (AUTO)`
|
|
421
|
+
+ ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
351
422
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
352
423
|
}
|
|
353
424
|
async TargetHeaterCoolerStateCOOL() {
|
|
354
|
-
this.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.COOL;
|
|
425
|
+
this.HeaterCooler.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.COOL;
|
|
355
426
|
this.CurrentMode = 2;
|
|
356
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (COOL)
|
|
427
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (COOL)`
|
|
428
|
+
+ ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
357
429
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
358
430
|
}
|
|
359
431
|
async TargetHeaterCoolerStateHEAT() {
|
|
360
|
-
this.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
432
|
+
this.HeaterCooler.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
361
433
|
this.CurrentMode = 5;
|
|
362
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (HEAT)
|
|
434
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (HEAT)`
|
|
435
|
+
+ ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
363
436
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
364
437
|
}
|
|
365
438
|
async CurrentHeaterCoolerStateGet() {
|
|
366
439
|
await this.UpdateCurrentHeaterCoolerState();
|
|
367
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
368
|
-
` Get (${this.getTargetHeaterCoolerStateName()}) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
369
|
-
return this.CurrentHeaterCoolerState;
|
|
440
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
441
|
+
+ ` Get (${this.getTargetHeaterCoolerStateName()}) CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`);
|
|
442
|
+
return this.HeaterCooler.CurrentHeaterCoolerState;
|
|
370
443
|
}
|
|
371
444
|
getTargetHeaterCoolerStateName() {
|
|
372
|
-
switch (this.TargetHeaterCoolerState) {
|
|
445
|
+
switch (this.HeaterCooler.TargetHeaterCoolerState) {
|
|
373
446
|
case this.hap.Characteristic.TargetHeaterCoolerState.AUTO:
|
|
374
447
|
return 'AUTO';
|
|
375
448
|
case this.hap.Characteristic.TargetHeaterCoolerState.HEAT:
|
|
@@ -377,397 +450,179 @@ export class AirConditioner {
|
|
|
377
450
|
case this.hap.Characteristic.TargetHeaterCoolerState.COOL:
|
|
378
451
|
return 'COOL';
|
|
379
452
|
default:
|
|
380
|
-
return this.TargetHeaterCoolerState.toString();
|
|
453
|
+
return this.HeaterCooler.TargetHeaterCoolerState.toString();
|
|
381
454
|
}
|
|
382
455
|
}
|
|
383
456
|
async ThresholdTemperatureGet() {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
457
|
+
if (this.HeaterCooler.Active === undefined) {
|
|
458
|
+
this.HeaterCooler.Active = this.hap.Characteristic.Active.INACTIVE;
|
|
459
|
+
}
|
|
460
|
+
else {
|
|
461
|
+
this.HeaterCooler.Active = this.HeaterCooler.Active ? this.HeaterCooler.Active : this.accessory.context.Active;
|
|
462
|
+
}
|
|
463
|
+
if (this.HeaterCooler.CurrentTemperature === undefined && this.accessory.context.CurrentTemperature === undefined) {
|
|
464
|
+
this.HeaterCooler.CurrentTemperature = 24;
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
this.HeaterCooler.CurrentTemperature = this.HeaterCooler.CurrentTemperature || this.accessory.context.CurrentTemperature;
|
|
468
|
+
}
|
|
469
|
+
if (this.HeaterCooler.ThresholdTemperature === undefined && this.accessory.context.ThresholdTemperature === undefined) {
|
|
470
|
+
this.HeaterCooler.ThresholdTemperature = 24;
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
this.HeaterCooler.ThresholdTemperature = this.HeaterCooler.ThresholdTemperature || this.accessory.context.ThresholdTemperature;
|
|
474
|
+
}
|
|
475
|
+
if (this.HeaterCooler.RotationSpeed === undefined && this.accessory.context.RotationSpeed === undefined) {
|
|
476
|
+
this.HeaterCooler.RotationSpeed = 4;
|
|
477
|
+
}
|
|
478
|
+
else {
|
|
479
|
+
this.HeaterCooler.RotationSpeed = this.HeaterCooler.RotationSpeed || this.accessory.context.RotationSpeed;
|
|
480
|
+
}
|
|
481
|
+
await this.getAirConditionerConfigSettings(this.accessory, this.device);
|
|
482
|
+
if (this.meter) {
|
|
483
|
+
if (this.HumiditySensor.CurrentRelativeHumidity === undefined && this.accessory.context.CurrentRelativeHumidity === undefined) {
|
|
484
|
+
this.HumiditySensor.CurrentRelativeHumidity = 0;
|
|
485
|
+
}
|
|
486
|
+
else {
|
|
487
|
+
this.HumiditySensor.CurrentRelativeHumidity = this.HumiditySensor.CurrentRelativeHumidity || this.accessory.context.CurrentRelativeHumidity;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
|
|
491
|
+
return this.HeaterCooler.ThresholdTemperature;
|
|
387
492
|
}
|
|
388
493
|
async ThresholdTemperatureSet(value) {
|
|
389
|
-
this.ThresholdTemperature = value;
|
|
390
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set ThresholdTemperature: ${this.ThresholdTemperature},`
|
|
391
|
-
` ThresholdTemperatureCached: ${this.accessory.context.ThresholdTemperature}`);
|
|
494
|
+
this.HeaterCooler.ThresholdTemperature = value;
|
|
495
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature},`
|
|
496
|
+
+ ` ThresholdTemperatureCached: ${this.accessory.context.ThresholdTemperature}`);
|
|
392
497
|
this.pushAirConditionerStatusChanges();
|
|
393
498
|
}
|
|
394
499
|
async updateHomeKitCharacteristics() {
|
|
395
500
|
// Active
|
|
396
|
-
if (this.Active === undefined) {
|
|
397
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.Active}`);
|
|
501
|
+
if (this.HeaterCooler.Active === undefined) {
|
|
502
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.HeaterCooler.Active}`);
|
|
398
503
|
}
|
|
399
504
|
else {
|
|
400
|
-
this.accessory.context.Active = this.Active;
|
|
401
|
-
this.
|
|
402
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
|
|
505
|
+
this.accessory.context.Active = this.HeaterCooler.Active;
|
|
506
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.Active, this.HeaterCooler.Active);
|
|
507
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.HeaterCooler.Active}`);
|
|
403
508
|
}
|
|
404
509
|
// RotationSpeed
|
|
405
|
-
if (this.RotationSpeed === undefined) {
|
|
406
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} RotationSpeed: ${this.RotationSpeed}`);
|
|
510
|
+
if (this.HeaterCooler.RotationSpeed === undefined) {
|
|
511
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} RotationSpeed: ${this.HeaterCooler.RotationSpeed}`);
|
|
407
512
|
}
|
|
408
513
|
else {
|
|
409
|
-
this.accessory.context.RotationSpeed = this.RotationSpeed;
|
|
410
|
-
this.
|
|
411
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic
|
|
514
|
+
this.accessory.context.RotationSpeed = this.HeaterCooler.RotationSpeed;
|
|
515
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.RotationSpeed, this.HeaterCooler.RotationSpeed);
|
|
516
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
517
|
+
+ ` RotationSpeed: ${this.HeaterCooler.RotationSpeed}`);
|
|
412
518
|
}
|
|
413
519
|
// CurrentTemperature
|
|
414
|
-
if (this.CurrentTemperature === undefined) {
|
|
415
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentTemperature: ${this.CurrentTemperature}`);
|
|
520
|
+
if (this.HeaterCooler.CurrentTemperature === undefined) {
|
|
521
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentTemperature: ${this.HeaterCooler.CurrentTemperature}`);
|
|
416
522
|
}
|
|
417
523
|
else {
|
|
418
|
-
this.accessory.context.CurrentTemperature = this.CurrentTemperature;
|
|
419
|
-
this.
|
|
420
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic
|
|
524
|
+
this.accessory.context.CurrentTemperature = this.HeaterCooler.CurrentTemperature;
|
|
525
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, this.HeaterCooler.CurrentTemperature);
|
|
526
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
527
|
+
+ ` CurrentTemperature: ${this.HeaterCooler.CurrentTemperature}`);
|
|
421
528
|
}
|
|
422
529
|
// CurrentRelativeHumidity
|
|
423
530
|
if (this.meter) {
|
|
424
|
-
if (this.CurrentRelativeHumidity === undefined) {
|
|
425
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}
|
|
531
|
+
if (this.HumiditySensor.CurrentRelativeHumidity === undefined) {
|
|
532
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
533
|
+
+ ` CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}`);
|
|
426
534
|
}
|
|
427
535
|
else {
|
|
428
|
-
this.accessory.context.CurrentRelativeHumidity = this.CurrentRelativeHumidity;
|
|
429
|
-
this.
|
|
430
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic
|
|
536
|
+
this.accessory.context.CurrentRelativeHumidity = this.HumiditySensor.CurrentRelativeHumidity;
|
|
537
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity, this.HumiditySensor.CurrentRelativeHumidity);
|
|
538
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
539
|
+
+ ` CurrentRelativeHumidity: ${this.HumiditySensor.CurrentRelativeHumidity}`);
|
|
431
540
|
}
|
|
432
541
|
}
|
|
433
542
|
// TargetHeaterCoolerState
|
|
434
|
-
if (this.TargetHeaterCoolerState === undefined) {
|
|
435
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.TargetHeaterCoolerState}`);
|
|
543
|
+
if (this.HeaterCooler.TargetHeaterCoolerState === undefined) {
|
|
544
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
436
545
|
}
|
|
437
546
|
else {
|
|
438
|
-
this.accessory.context.TargetHeaterCoolerState = this.TargetHeaterCoolerState;
|
|
439
|
-
this.
|
|
440
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}
|
|
547
|
+
this.accessory.context.TargetHeaterCoolerState = this.HeaterCooler.TargetHeaterCoolerState;
|
|
548
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.TargetHeaterCoolerState, this.HeaterCooler.TargetHeaterCoolerState);
|
|
549
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
550
|
+
+ ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
441
551
|
}
|
|
442
552
|
// CurrentHeaterCoolerState
|
|
443
|
-
if (this.CurrentHeaterCoolerState === undefined) {
|
|
444
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}
|
|
553
|
+
if (this.HeaterCooler.CurrentHeaterCoolerState === undefined) {
|
|
554
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
555
|
+
+ ` CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`);
|
|
445
556
|
}
|
|
446
557
|
else {
|
|
447
|
-
this.accessory.context.CurrentHeaterCoolerState = this.CurrentHeaterCoolerState;
|
|
448
|
-
this.
|
|
449
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
450
|
-
` updateCharacteristic CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
|
|
558
|
+
this.accessory.context.CurrentHeaterCoolerState = this.HeaterCooler.CurrentHeaterCoolerState;
|
|
559
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState, this.HeaterCooler.CurrentHeaterCoolerState);
|
|
560
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
561
|
+
+ ` updateCharacteristic CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`);
|
|
451
562
|
}
|
|
452
563
|
// ThresholdTemperature
|
|
453
|
-
if (this.ThresholdTemperature === undefined) {
|
|
454
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} ThresholdTemperature: ${this.ThresholdTemperature}`);
|
|
455
|
-
}
|
|
456
|
-
else {
|
|
457
|
-
this.accessory.context.ThresholdTemperature = this.ThresholdTemperature;
|
|
458
|
-
this.coolerService?.updateCharacteristic(this.hap.Characteristic.HeatingThresholdTemperature, this.ThresholdTemperature);
|
|
459
|
-
this.coolerService?.updateCharacteristic(this.hap.Characteristic.CoolingThresholdTemperature, this.ThresholdTemperature);
|
|
460
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}` + ` updateCharacteristic ThresholdTemperature: ${this.ThresholdTemperature}`);
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
async disablePushOnChanges(device) {
|
|
464
|
-
if (device.disablePushOn === undefined) {
|
|
465
|
-
this.disablePushOn = false;
|
|
564
|
+
if (this.HeaterCooler.ThresholdTemperature === undefined) {
|
|
565
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
|
|
466
566
|
}
|
|
467
567
|
else {
|
|
468
|
-
this.
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
this.disablePushOff = false;
|
|
474
|
-
}
|
|
475
|
-
else {
|
|
476
|
-
this.disablePushOff = device.disablePushOff;
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
async disablePushDetailChanges(device) {
|
|
480
|
-
if (device.disablePushDetail === undefined) {
|
|
481
|
-
this.disablePushDetail = false;
|
|
482
|
-
}
|
|
483
|
-
else {
|
|
484
|
-
this.disablePushDetail = device.disablePushDetail;
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
async commandType() {
|
|
488
|
-
let commandType;
|
|
489
|
-
if (this.device.customize) {
|
|
490
|
-
commandType = 'customize';
|
|
491
|
-
}
|
|
492
|
-
else {
|
|
493
|
-
commandType = 'command';
|
|
494
|
-
}
|
|
495
|
-
return commandType;
|
|
496
|
-
}
|
|
497
|
-
async commandOn() {
|
|
498
|
-
let command;
|
|
499
|
-
if (this.device.customize && this.device.customOn) {
|
|
500
|
-
command = this.device.customOn;
|
|
501
|
-
}
|
|
502
|
-
else {
|
|
503
|
-
command = 'turnOn';
|
|
504
|
-
}
|
|
505
|
-
return command;
|
|
506
|
-
}
|
|
507
|
-
async commandOff() {
|
|
508
|
-
let command;
|
|
509
|
-
if (this.device.customize && this.device.customOff) {
|
|
510
|
-
command = this.device.customOff;
|
|
511
|
-
}
|
|
512
|
-
else {
|
|
513
|
-
command = 'turnOff';
|
|
514
|
-
}
|
|
515
|
-
return command;
|
|
516
|
-
}
|
|
517
|
-
async statusCode(statusCode) {
|
|
518
|
-
switch (statusCode) {
|
|
519
|
-
case 151:
|
|
520
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command not supported by this deviceType, statusCode: ${statusCode}`);
|
|
521
|
-
break;
|
|
522
|
-
case 152:
|
|
523
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device not found, statusCode: ${statusCode}`);
|
|
524
|
-
break;
|
|
525
|
-
case 160:
|
|
526
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command is not supported, statusCode: ${statusCode}`);
|
|
527
|
-
break;
|
|
528
|
-
case 161:
|
|
529
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline, statusCode: ${statusCode}`);
|
|
530
|
-
break;
|
|
531
|
-
case 171:
|
|
532
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
|
|
533
|
-
`Hub: ${this.device.hubDeviceId}`);
|
|
534
|
-
break;
|
|
535
|
-
case 190:
|
|
536
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` +
|
|
537
|
-
` Or command format is invalid, statusCode: ${statusCode}`);
|
|
538
|
-
break;
|
|
539
|
-
case 100:
|
|
540
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Command successfully sent, statusCode: ${statusCode}`);
|
|
541
|
-
break;
|
|
542
|
-
case 200:
|
|
543
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
|
|
544
|
-
break;
|
|
545
|
-
case 400:
|
|
546
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Bad Request, The client has issued an invalid request. `
|
|
547
|
-
+ `This is commonly used to specify validation errors in a request payload, statusCode: ${statusCode}`);
|
|
548
|
-
break;
|
|
549
|
-
case 401:
|
|
550
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Unauthorized, Authorization for the API is required, `
|
|
551
|
-
+ `but the request has not been authenticated, statusCode: ${statusCode}`);
|
|
552
|
-
break;
|
|
553
|
-
case 403:
|
|
554
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Forbidden, The request has been authenticated but does not `
|
|
555
|
-
+ `have appropriate permissions, or a requested resource is not found, statusCode: ${statusCode}`);
|
|
556
|
-
break;
|
|
557
|
-
case 404:
|
|
558
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Not Found, Specifies the requested path does not exist, `
|
|
559
|
-
+ `statusCode: ${statusCode}`);
|
|
560
|
-
break;
|
|
561
|
-
case 406:
|
|
562
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Not Acceptable, The client has requested a MIME type via `
|
|
563
|
-
+ `the Accept header for a value not supported by the server, statusCode: ${statusCode}`);
|
|
564
|
-
break;
|
|
565
|
-
case 415:
|
|
566
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Unsupported Media Type, The client has defined a contentType `
|
|
567
|
-
+ `header that is not supported by the server, statusCode: ${statusCode}`);
|
|
568
|
-
break;
|
|
569
|
-
case 422:
|
|
570
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Unprocessable Entity, The client has made a valid request, but `
|
|
571
|
-
+ `the server cannot process it. This is often used for APIs for which certain limits have been exceeded, statusCode: ${statusCode}`);
|
|
572
|
-
break;
|
|
573
|
-
case 429:
|
|
574
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Too Many Requests, The client has exceeded the number of `
|
|
575
|
-
+ `requests allowed for a given time window, statusCode: ${statusCode}`);
|
|
576
|
-
break;
|
|
577
|
-
case 500:
|
|
578
|
-
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Internal Server Error, An unexpected error on the SmartThings `
|
|
579
|
-
+ `servers has occurred. These errors should be rare, statusCode: ${statusCode}`);
|
|
580
|
-
break;
|
|
581
|
-
default:
|
|
582
|
-
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode: ` +
|
|
583
|
-
`${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
|
|
568
|
+
this.accessory.context.ThresholdTemperature = this.HeaterCooler.ThresholdTemperature;
|
|
569
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.HeatingThresholdTemperature, this.HeaterCooler.ThresholdTemperature);
|
|
570
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CoolingThresholdTemperature, this.HeaterCooler.ThresholdTemperature);
|
|
571
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
572
|
+
+ ` ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
|
|
584
573
|
}
|
|
585
574
|
}
|
|
586
575
|
async apiError({ e }) {
|
|
587
|
-
this.
|
|
588
|
-
this.
|
|
589
|
-
this.
|
|
590
|
-
this.
|
|
591
|
-
this.
|
|
592
|
-
this.
|
|
593
|
-
this.
|
|
594
|
-
this.
|
|
595
|
-
}
|
|
596
|
-
async
|
|
597
|
-
if (this.Active === undefined) {
|
|
598
|
-
this.Active = this.hap.Characteristic.Active.INACTIVE;
|
|
599
|
-
}
|
|
600
|
-
else if (this.Active) {
|
|
601
|
-
this.Active;
|
|
602
|
-
}
|
|
603
|
-
else {
|
|
604
|
-
this.Active = this.accessory.context.Active;
|
|
605
|
-
}
|
|
606
|
-
if (this.CurrentTemperature === undefined && this.accessory.context.CurrentTemperature === undefined) {
|
|
607
|
-
this.CurrentTemperature = 24;
|
|
608
|
-
}
|
|
609
|
-
else {
|
|
610
|
-
this.CurrentTemperature = this.CurrentTemperature || this.accessory.context.CurrentTemperature;
|
|
611
|
-
}
|
|
612
|
-
if (this.ThresholdTemperature === undefined && this.accessory.context.ThresholdTemperature === undefined) {
|
|
613
|
-
this.ThresholdTemperature = 24;
|
|
614
|
-
}
|
|
615
|
-
else {
|
|
616
|
-
this.ThresholdTemperature = this.ThresholdTemperature || this.accessory.context.ThresholdTemperature;
|
|
617
|
-
}
|
|
618
|
-
if (this.RotationSpeed === undefined && this.accessory.context.RotationSpeed === undefined) {
|
|
619
|
-
this.RotationSpeed = 4;
|
|
620
|
-
}
|
|
621
|
-
else {
|
|
622
|
-
this.RotationSpeed = this.RotationSpeed || this.accessory.context.RotationSpeed;
|
|
623
|
-
}
|
|
576
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.Active, e);
|
|
577
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.RotationSpeed, e);
|
|
578
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, e);
|
|
579
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity, e);
|
|
580
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.TargetHeaterCoolerState, e);
|
|
581
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState, e);
|
|
582
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.HeatingThresholdTemperature, e);
|
|
583
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CoolingThresholdTemperature, e);
|
|
584
|
+
}
|
|
585
|
+
async getAirConditionerConfigSettings(accessory, device) {
|
|
624
586
|
if (this.device.irair?.hide_automode) {
|
|
625
|
-
this.hide_automode =
|
|
626
|
-
|
|
587
|
+
this.hide_automode = device.irair?.hide_automode;
|
|
588
|
+
accessory.context.hide_automode = this.hide_automode;
|
|
627
589
|
}
|
|
628
590
|
else {
|
|
629
|
-
this.hide_automode =
|
|
630
|
-
|
|
591
|
+
this.hide_automode = device.irair?.hide_automode;
|
|
592
|
+
accessory.context.hide_automode = this.hide_automode;
|
|
631
593
|
}
|
|
632
594
|
if (this.device.irair?.set_max_heat) {
|
|
633
|
-
this.set_max_heat =
|
|
634
|
-
|
|
595
|
+
this.set_max_heat = device.irair?.set_max_heat;
|
|
596
|
+
accessory.context.set_max_heat = this.set_max_heat;
|
|
635
597
|
}
|
|
636
598
|
else {
|
|
637
599
|
this.set_max_heat = 35;
|
|
638
|
-
|
|
600
|
+
accessory.context.set_max_heat = this.set_max_heat;
|
|
639
601
|
}
|
|
640
602
|
if (this.device.irair?.set_min_heat) {
|
|
641
|
-
this.set_min_heat =
|
|
642
|
-
|
|
603
|
+
this.set_min_heat = device.irair?.set_min_heat;
|
|
604
|
+
accessory.context.set_min_heat = this.set_min_heat;
|
|
643
605
|
}
|
|
644
606
|
else {
|
|
645
607
|
this.set_min_heat = 0;
|
|
646
|
-
|
|
608
|
+
accessory.context.set_min_heat = this.set_min_heat;
|
|
647
609
|
}
|
|
648
610
|
if (this.device.irair?.set_max_cool) {
|
|
649
|
-
this.set_max_cool =
|
|
650
|
-
|
|
611
|
+
this.set_max_cool = device.irair?.set_max_cool;
|
|
612
|
+
accessory.context.set_max_cool = this.set_max_cool;
|
|
651
613
|
}
|
|
652
614
|
else {
|
|
653
615
|
this.set_max_cool = 35;
|
|
654
|
-
|
|
616
|
+
accessory.context.set_max_cool = this.set_max_cool;
|
|
655
617
|
}
|
|
656
618
|
if (this.device.irair?.set_min_cool) {
|
|
657
|
-
this.set_min_cool =
|
|
658
|
-
|
|
619
|
+
this.set_min_cool = device.irair?.set_min_cool;
|
|
620
|
+
accessory.context.set_min_cool = this.set_min_cool;
|
|
659
621
|
}
|
|
660
622
|
else {
|
|
661
623
|
this.set_min_cool = 0;
|
|
662
|
-
|
|
624
|
+
accessory.context.set_min_cool = this.set_min_cool;
|
|
663
625
|
}
|
|
664
|
-
if (this.meter) {
|
|
665
|
-
if (this.CurrentRelativeHumidity === undefined && this.accessory.context.CurrentRelativeHumidity === undefined) {
|
|
666
|
-
this.CurrentRelativeHumidity = 0;
|
|
667
|
-
}
|
|
668
|
-
else {
|
|
669
|
-
this.CurrentRelativeHumidity = this.CurrentRelativeHumidity || this.accessory.context.CurrentRelativeHumidity;
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
if (this.FirmwareRevision === undefined) {
|
|
673
|
-
this.FirmwareRevision = this.platform.version;
|
|
674
|
-
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
async deviceConfig(device) {
|
|
678
|
-
let config = {};
|
|
679
|
-
if (device.irair) {
|
|
680
|
-
config = device.irair;
|
|
681
|
-
}
|
|
682
|
-
if (device.logging !== undefined) {
|
|
683
|
-
config['logging'] = device.logging;
|
|
684
|
-
}
|
|
685
|
-
if (device.connectionType !== undefined) {
|
|
686
|
-
config['connectionType'] = device.connectionType;
|
|
687
|
-
}
|
|
688
|
-
if (device.external !== undefined) {
|
|
689
|
-
config['external'] = device.external;
|
|
690
|
-
}
|
|
691
|
-
if (device.customOn !== undefined) {
|
|
692
|
-
config['customOn'] = device.customOn;
|
|
693
|
-
}
|
|
694
|
-
if (device.customOff !== undefined) {
|
|
695
|
-
config['customOff'] = device.customOff;
|
|
696
|
-
}
|
|
697
|
-
if (device.customize !== undefined) {
|
|
698
|
-
config['customize'] = device.customize;
|
|
699
|
-
}
|
|
700
|
-
if (device.disablePushOn !== undefined) {
|
|
701
|
-
config['disablePushOn'] = device.disablePushOn;
|
|
702
|
-
}
|
|
703
|
-
if (device.disablePushOff !== undefined) {
|
|
704
|
-
config['disablePushOff'] = device.disablePushOff;
|
|
705
|
-
}
|
|
706
|
-
if (device.disablePushDetail !== undefined) {
|
|
707
|
-
config['disablePushDetail'] = device.disablePushDetail;
|
|
708
|
-
}
|
|
709
|
-
if (Object.entries(config).length !== 0) {
|
|
710
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
async deviceLogs(device) {
|
|
714
|
-
if (this.platform.debugMode) {
|
|
715
|
-
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
716
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
717
|
-
}
|
|
718
|
-
else if (device.logging) {
|
|
719
|
-
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
720
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
721
|
-
}
|
|
722
|
-
else if (this.platform.config.options?.logging) {
|
|
723
|
-
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
724
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
725
|
-
}
|
|
726
|
-
else {
|
|
727
|
-
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
728
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
/**
|
|
732
|
-
* Logging for Device
|
|
733
|
-
*/
|
|
734
|
-
infoLog(...log) {
|
|
735
|
-
if (this.enablingDeviceLogging()) {
|
|
736
|
-
this.platform.log.info(String(...log));
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
warnLog(...log) {
|
|
740
|
-
if (this.enablingDeviceLogging()) {
|
|
741
|
-
this.platform.log.warn(String(...log));
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
debugWarnLog(...log) {
|
|
745
|
-
if (this.enablingDeviceLogging() && this.deviceLogging?.includes('debug')) {
|
|
746
|
-
this.platform.log.warn('[DEBUG]', String(...log));
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
errorLog(...log) {
|
|
750
|
-
if (this.enablingDeviceLogging()) {
|
|
751
|
-
this.platform.log.error(String(...log));
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
debugErrorLog(...log) {
|
|
755
|
-
if (this.enablingDeviceLogging() && this.deviceLogging?.includes('debug')) {
|
|
756
|
-
this.platform.log.error('[DEBUG]', String(...log));
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
debugLog(...log) {
|
|
760
|
-
if (this.enablingDeviceLogging()) {
|
|
761
|
-
if (this.deviceLogging === 'debug') {
|
|
762
|
-
this.platform.log.info('[DEBUG]', String(...log));
|
|
763
|
-
}
|
|
764
|
-
else {
|
|
765
|
-
this.platform.log.debug(String(...log));
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
enablingDeviceLogging() {
|
|
770
|
-
return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
|
|
771
626
|
}
|
|
772
627
|
}
|
|
773
628
|
//# sourceMappingURL=airconditioner.js.map
|