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