@switchbot/homebridge-switchbot 3.5.0-beta.6 → 3.5.0-beta.61
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 +120 -17
- package/dist/device/blindtilt.d.ts +23 -96
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +408 -779
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +26 -72
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +696 -822
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +14 -68
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +237 -606
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +14 -75
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +280 -658
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +15 -66
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +242 -544
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +19 -88
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +402 -805
- 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 +684 -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 +535 -0
- package/dist/device/fan.js.map +1 -0
- package/dist/device/hub.d.ts +16 -60
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +246 -613
- 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 +232 -593
- 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 +185 -600
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +11 -69
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +277 -586
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +16 -63
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +241 -560
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +14 -64
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +181 -593
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +14 -65
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +170 -593
- 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 +178 -531
- 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 +92 -458
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +12 -63
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +197 -521
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts +10 -65
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +139 -495
- 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 +9 -49
- 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 +8 -39
- 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 +7 -36
- 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 +10 -43
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +100 -338
- 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 +330 -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 +87 -357
- 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 +352 -546
- 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 +82 -321
- 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 +41 -284
- 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 +42 -287
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +19 -6
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +310 -169
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +62 -19
- 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 +77 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +638 -1
- package/dist/utils.js.map +1 -1
- package/eslint.config.js +96 -0
- package/package.json +19 -15
- package/src/custom.d.ts +2 -1
- package/src/device/blindtilt.ts +442 -814
- package/src/device/bot.ts +754 -915
- package/src/device/ceilinglight.ts +255 -633
- package/src/device/colorbulb.ts +295 -685
- package/src/device/contact.ts +277 -571
- package/src/device/curtain.ts +431 -835
- package/src/device/device.ts +709 -0
- package/src/device/fan.ts +591 -0
- package/src/device/hub.ts +286 -644
- package/src/device/humidifier.ts +266 -646
- package/src/device/iosensor.ts +220 -625
- package/src/device/lightstrip.ts +305 -620
- package/src/device/lock.ts +280 -600
- package/src/device/meter.ts +216 -617
- package/src/device/meterplus.ts +205 -619
- package/src/device/motion.ts +206 -556
- package/src/device/plug.ts +107 -490
- package/src/device/robotvacuumcleaner.ts +223 -550
- package/src/device/waterdetector.ts +160 -519
- 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 +333 -447
- package/src/irdevice/airpurifier.ts +92 -322
- package/src/irdevice/camera.ts +45 -294
- package/src/irdevice/fan.ts +115 -353
- package/src/irdevice/irdevice.ts +346 -0
- package/src/irdevice/light.ts +110 -385
- package/src/irdevice/other.ts +399 -616
- package/src/irdevice/tv.ts +103 -340
- package/src/irdevice/vacuumcleaner.ts +52 -306
- package/src/irdevice/waterheater.ts +53 -311
- package/src/platform.ts +355 -216
- package/src/settings.ts +116 -611
- package/src/utils.ts +642 -1
- package/src/device/waterdetector.json +0 -11
|
@@ -1,30 +1,36 @@
|
|
|
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';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
6
|
+
import { Devices } from '../settings.js';
|
|
7
|
+
import { irdeviceBase } from './irdevice.js';
|
|
8
|
+
|
|
9
|
+
import type { SwitchBotPlatform } from '../platform.js';
|
|
10
|
+
import type { irDevicesConfig, irdevice } from '../settings.js';
|
|
11
|
+
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
5
12
|
|
|
6
13
|
/**
|
|
7
14
|
* Platform Accessory
|
|
8
15
|
* An instance of this class is created for each accessory your platform registers
|
|
9
16
|
* Each accessory may expose multiple services of different service types.
|
|
10
17
|
*/
|
|
11
|
-
export class AirConditioner {
|
|
12
|
-
public readonly api: API;
|
|
13
|
-
public readonly log: Logging;
|
|
14
|
-
public readonly config!: SwitchBotPlatformConfig;
|
|
15
|
-
protected readonly hap: HAP;
|
|
18
|
+
export class AirConditioner extends irdeviceBase {
|
|
16
19
|
// Services
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
private HeaterCooler: {
|
|
21
|
+
Service: Service;
|
|
22
|
+
Active: CharacteristicValue;
|
|
23
|
+
CurrentHeaterCoolerState: CharacteristicValue;
|
|
24
|
+
TargetHeaterCoolerState: CharacteristicValue;
|
|
25
|
+
CurrentTemperature: CharacteristicValue;
|
|
26
|
+
ThresholdTemperature: CharacteristicValue;
|
|
27
|
+
RotationSpeed: CharacteristicValue;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
private HumiditySensor?: {
|
|
31
|
+
Service: Service;
|
|
32
|
+
CurrentRelativeHumidity: CharacteristicValue;
|
|
33
|
+
};
|
|
28
34
|
|
|
29
35
|
// Others
|
|
30
36
|
state!: string;
|
|
@@ -33,65 +39,60 @@ export class AirConditioner {
|
|
|
33
39
|
CurrentMode!: number;
|
|
34
40
|
ValidValues: number[];
|
|
35
41
|
CurrentFanSpeed!: number;
|
|
36
|
-
static MODE_AUTO: number;
|
|
37
|
-
static MODE_COOL: number;
|
|
38
|
-
static MODE_HEAT: number;
|
|
39
42
|
|
|
40
43
|
// Config
|
|
41
|
-
deviceLogging!: string;
|
|
42
44
|
hide_automode?: boolean;
|
|
43
45
|
set_max_heat?: number;
|
|
44
46
|
set_min_heat?: number;
|
|
45
47
|
set_max_cool?: number;
|
|
46
48
|
set_min_cool?: number;
|
|
47
|
-
disablePushOn?: boolean;
|
|
48
|
-
disablePushOff?: boolean;
|
|
49
49
|
meter?: PlatformAccessory;
|
|
50
|
-
disablePushDetail?: boolean;
|
|
51
|
-
|
|
52
|
-
private readonly valid12 = [1, 2];
|
|
53
|
-
private readonly valid012 = [0, 1, 2];
|
|
54
50
|
|
|
55
51
|
constructor(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
readonly platform: SwitchBotPlatform,
|
|
53
|
+
accessory: PlatformAccessory,
|
|
54
|
+
device: irdevice & irDevicesConfig,
|
|
59
55
|
) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
this.config = this.platform.config;
|
|
63
|
-
this.hap = this.api.hap;
|
|
56
|
+
super(platform, accessory, device);
|
|
57
|
+
|
|
64
58
|
// default placeholders
|
|
65
|
-
this.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
this.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
.
|
|
75
|
-
.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
59
|
+
this.getAirConditionerConfigSettings(accessory, device);
|
|
60
|
+
|
|
61
|
+
// Initialize HeaterCooler property
|
|
62
|
+
this.HeaterCooler = {
|
|
63
|
+
Service: accessory.getService(this.hap.Service.Switch) as Service,
|
|
64
|
+
Active: accessory.context.Active || this.hap.Characteristic.Active.INACTIVE,
|
|
65
|
+
CurrentHeaterCoolerState: accessory.context.CurrentHeaterCoolerState || this.hap.Characteristic.CurrentHeaterCoolerState.IDLE,
|
|
66
|
+
TargetHeaterCoolerState: accessory.context.TargetHeaterCoolerState || this.hap.Characteristic.TargetHeaterCoolerState.AUTO,
|
|
67
|
+
CurrentTemperature: accessory.context.CurrentTemperature || 24,
|
|
68
|
+
ThresholdTemperature: accessory.context.ThresholdTemperature || 24,
|
|
69
|
+
RotationSpeed: accessory.context.RotationSpeed || 4,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// Initialize HumiditySensor property
|
|
73
|
+
if (this.device.irair?.meterType && this.device.irair?.meterId) {
|
|
74
|
+
const meterUuid = this.platform.api.hap.uuid.generate(`${this.device.irair.meterId}-${this.device.irair.meterType}`);
|
|
75
|
+
this.meter = this.platform.accessories.find((accessory) => accessory.UUID === meterUuid);
|
|
76
|
+
this.HumiditySensor = {
|
|
77
|
+
Service: this.meter!.getService(this.hap.Service.HumiditySensor) as Service,
|
|
78
|
+
CurrentRelativeHumidity: this.meter!.context.CurrentRelativeHumidity || 0,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
79
81
|
|
|
80
82
|
// get the Television service if it exists, otherwise create a new Television service
|
|
81
83
|
// you can create multiple services for each accessory
|
|
82
|
-
const
|
|
83
|
-
(this.
|
|
84
|
-
|| accessory.addService(this.hap.Service.HeaterCooler)),
|
|
84
|
+
const HeaterCoolerService = `${accessory.displayName} ${device.remoteType}`;
|
|
85
|
+
(this.HeaterCooler.Service = accessory.getService(this.hap.Service.HeaterCooler)
|
|
86
|
+
|| accessory.addService(this.hap.Service.HeaterCooler)), HeaterCoolerService;
|
|
85
87
|
|
|
86
|
-
this.
|
|
87
|
-
if (!this.coolerService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
88
|
-
this.coolerService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
89
|
-
}
|
|
88
|
+
this.HeaterCooler.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
90
89
|
|
|
91
90
|
// handle on / off events using the Active characteristic
|
|
92
|
-
this.
|
|
91
|
+
this.HeaterCooler.Service.getCharacteristic(this.hap.Characteristic.Active)
|
|
92
|
+
.onSet(this.ActiveSet.bind(this));
|
|
93
93
|
|
|
94
|
-
this.
|
|
94
|
+
this.HeaterCooler.Service.getCharacteristic(this.hap.Characteristic.CurrentTemperature)
|
|
95
|
+
.onGet(this.CurrentTemperatureGet.bind(this));
|
|
95
96
|
|
|
96
97
|
this.ValidValues = this.hide_automode ? [1, 2] : [0, 1, 2];
|
|
97
98
|
|
|
@@ -101,10 +102,11 @@ export class AirConditioner {
|
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
if (this.meter) {
|
|
104
|
-
this.
|
|
105
|
+
this.HumiditySensor!.Service.getCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity)
|
|
106
|
+
.onGet(this.CurrentRelativeHumidityGet.bind(this));
|
|
105
107
|
}
|
|
106
108
|
|
|
107
|
-
this.
|
|
109
|
+
this.HeaterCooler.Service
|
|
108
110
|
.getCharacteristic(this.hap.Characteristic.TargetHeaterCoolerState)
|
|
109
111
|
.setProps({
|
|
110
112
|
validValues: this.ValidValues,
|
|
@@ -112,9 +114,10 @@ export class AirConditioner {
|
|
|
112
114
|
.onGet(this.TargetHeaterCoolerStateGet.bind(this))
|
|
113
115
|
.onSet(this.TargetHeaterCoolerStateSet.bind(this));
|
|
114
116
|
|
|
115
|
-
this.
|
|
117
|
+
this.HeaterCooler.Service.getCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState)
|
|
118
|
+
.onGet(this.CurrentHeaterCoolerStateGet.bind(this));
|
|
116
119
|
|
|
117
|
-
this.
|
|
120
|
+
this.HeaterCooler.Service
|
|
118
121
|
.getCharacteristic(this.hap.Characteristic.HeatingThresholdTemperature)
|
|
119
122
|
.setProps({
|
|
120
123
|
minValue: this.set_min_heat,
|
|
@@ -124,7 +127,7 @@ export class AirConditioner {
|
|
|
124
127
|
.onGet(this.ThresholdTemperatureGet.bind(this))
|
|
125
128
|
.onSet(this.ThresholdTemperatureSet.bind(this));
|
|
126
129
|
|
|
127
|
-
this.
|
|
130
|
+
this.HeaterCooler.Service
|
|
128
131
|
.getCharacteristic(this.hap.Characteristic.CoolingThresholdTemperature)
|
|
129
132
|
.setProps({
|
|
130
133
|
minValue: this.set_min_cool,
|
|
@@ -134,7 +137,7 @@ export class AirConditioner {
|
|
|
134
137
|
.onGet(this.ThresholdTemperatureGet.bind(this))
|
|
135
138
|
.onSet(this.ThresholdTemperatureSet.bind(this));
|
|
136
139
|
|
|
137
|
-
this.
|
|
140
|
+
this.HeaterCooler.Service
|
|
138
141
|
.getCharacteristic(this.hap.Characteristic.RotationSpeed)
|
|
139
142
|
.setProps({
|
|
140
143
|
format: 'int',
|
|
@@ -157,10 +160,10 @@ export class AirConditioner {
|
|
|
157
160
|
*/
|
|
158
161
|
async pushAirConditionerOnChanges(): Promise<void> {
|
|
159
162
|
this.debugLog(
|
|
160
|
-
`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOnChanges Active: ${this.Active},` +
|
|
163
|
+
`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOnChanges Active: ${this.HeaterCooler.Active},` +
|
|
161
164
|
` disablePushOn: ${this.disablePushOn}`,
|
|
162
165
|
);
|
|
163
|
-
if (this.Active === this.hap.Characteristic.Active.ACTIVE && !this.disablePushOn) {
|
|
166
|
+
if (this.HeaterCooler.Active === this.hap.Characteristic.Active.ACTIVE && !this.disablePushOn) {
|
|
164
167
|
const commandType: string = await this.commandType();
|
|
165
168
|
const command: string = await this.commandOn();
|
|
166
169
|
const bodyChange = JSON.stringify({
|
|
@@ -174,10 +177,10 @@ export class AirConditioner {
|
|
|
174
177
|
|
|
175
178
|
async pushAirConditionerOffChanges(): Promise<void> {
|
|
176
179
|
this.debugLog(
|
|
177
|
-
`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges Active: ${this.Active},` +
|
|
180
|
+
`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges Active: ${this.HeaterCooler.Active},` +
|
|
178
181
|
` disablePushOff: ${this.disablePushOff}`,
|
|
179
182
|
);
|
|
180
|
-
if (this.Active === this.hap.Characteristic.Active.INACTIVE && !this.disablePushOff) {
|
|
183
|
+
if (this.HeaterCooler.Active === this.hap.Characteristic.Active.INACTIVE && !this.disablePushOff) {
|
|
181
184
|
const commandType: string = await this.commandType();
|
|
182
185
|
const command: string = await this.commandOff();
|
|
183
186
|
const bodyChange = JSON.stringify({
|
|
@@ -191,12 +194,12 @@ export class AirConditioner {
|
|
|
191
194
|
|
|
192
195
|
async pushAirConditionerStatusChanges(): Promise<void> {
|
|
193
196
|
this.debugLog(
|
|
194
|
-
`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerStatusChanges Active: ${this.Active},` +
|
|
197
|
+
`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerStatusChanges Active: ${this.HeaterCooler.Active},` +
|
|
195
198
|
` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`,
|
|
196
199
|
);
|
|
197
200
|
if (!this.Busy) {
|
|
198
201
|
this.Busy = true;
|
|
199
|
-
this.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.IDLE;
|
|
202
|
+
this.HeaterCooler.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.IDLE;
|
|
200
203
|
}
|
|
201
204
|
clearTimeout(this.Timeout);
|
|
202
205
|
|
|
@@ -206,7 +209,7 @@ export class AirConditioner {
|
|
|
206
209
|
|
|
207
210
|
async pushAirConditionerDetailsChanges(): Promise<void> {
|
|
208
211
|
this.debugLog(
|
|
209
|
-
`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerDetailsChanges Active: ${this.Active},` +
|
|
212
|
+
`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerDetailsChanges Active: ${this.HeaterCooler.Active},` +
|
|
210
213
|
` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`,
|
|
211
214
|
);
|
|
212
215
|
//await this.deviceContext();
|
|
@@ -216,20 +219,20 @@ export class AirConditioner {
|
|
|
216
219
|
if (this.CurrentFanSpeed === undefined) {
|
|
217
220
|
this.CurrentFanSpeed = 1;
|
|
218
221
|
}
|
|
219
|
-
if (this.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
222
|
+
if (this.HeaterCooler.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
220
223
|
this.state = 'on';
|
|
221
224
|
} else {
|
|
222
225
|
this.state = 'off';
|
|
223
226
|
}
|
|
224
227
|
if (this.CurrentMode === 1) {
|
|
225
228
|
// Remove or make configurable?
|
|
226
|
-
this.ThresholdTemperature = 25;
|
|
229
|
+
this.HeaterCooler.ThresholdTemperature = 25;
|
|
227
230
|
this.debugLog(
|
|
228
231
|
`${this.device.remoteType}: ${this.accessory.displayName} CurrentMode: ${this.CurrentMode},` +
|
|
229
|
-
` ThresholdTemperature: ${this.ThresholdTemperature}`,
|
|
232
|
+
` ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`,
|
|
230
233
|
);
|
|
231
234
|
}
|
|
232
|
-
const parameter = `${this.ThresholdTemperature},${this.CurrentMode},${this.CurrentFanSpeed},${this.state}`;
|
|
235
|
+
const parameter = `${this.HeaterCooler.ThresholdTemperature},${this.CurrentMode},${this.CurrentFanSpeed},${this.state}`;
|
|
233
236
|
|
|
234
237
|
await this.UpdateCurrentHeaterCoolerState();
|
|
235
238
|
const bodyChange = JSON.stringify({
|
|
@@ -242,19 +245,91 @@ export class AirConditioner {
|
|
|
242
245
|
}
|
|
243
246
|
|
|
244
247
|
private async UpdateCurrentHeaterCoolerState() {
|
|
245
|
-
if (this.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
246
|
-
|
|
247
|
-
if (this.
|
|
248
|
-
this.
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
this.
|
|
248
|
+
if (this.HeaterCooler.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
249
|
+
|
|
250
|
+
if (this.HeaterCooler.Active === undefined) {
|
|
251
|
+
this.HeaterCooler.Active = this.hap.Characteristic.Active.INACTIVE;
|
|
252
|
+
} else if (this.HeaterCooler.Active) {
|
|
253
|
+
this.HeaterCooler.Active;
|
|
254
|
+
} else {
|
|
255
|
+
this.HeaterCooler.Active = this.accessory.context.Active;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (this.HeaterCooler.CurrentTemperature === undefined && this.accessory.context.CurrentTemperature === undefined) {
|
|
259
|
+
this.HeaterCooler.CurrentTemperature = 24;
|
|
260
|
+
} else {
|
|
261
|
+
this.HeaterCooler.CurrentTemperature = this.HeaterCooler.CurrentTemperature || this.accessory.context.CurrentTemperature;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (this.HeaterCooler.ThresholdTemperature === undefined && this.accessory.context.ThresholdTemperature === undefined) {
|
|
265
|
+
this.HeaterCooler.ThresholdTemperature = 24;
|
|
266
|
+
} else {
|
|
267
|
+
this.HeaterCooler.ThresholdTemperature = this.HeaterCooler.ThresholdTemperature || this.accessory.context.ThresholdTemperature;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (this.HeaterCooler.RotationSpeed === undefined && this.accessory.context.RotationSpeed === undefined) {
|
|
271
|
+
this.HeaterCooler.RotationSpeed = 4;
|
|
272
|
+
} else {
|
|
273
|
+
this.HeaterCooler.RotationSpeed = this.HeaterCooler.RotationSpeed || this.accessory.context.RotationSpeed;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if (this.device.irair?.hide_automode) {
|
|
277
|
+
this.hide_automode = this.device.irair?.hide_automode;
|
|
278
|
+
this.accessory.context.hide_automode = this.hide_automode;
|
|
279
|
+
} else {
|
|
280
|
+
this.hide_automode = this.device.irair?.hide_automode;
|
|
281
|
+
this.accessory.context.hide_automode = this.hide_automode;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if (this.device.irair?.set_max_heat) {
|
|
285
|
+
this.set_max_heat = this.device.irair?.set_max_heat;
|
|
286
|
+
this.accessory.context.set_max_heat = this.set_max_heat;
|
|
287
|
+
} else {
|
|
288
|
+
this.set_max_heat = 35;
|
|
289
|
+
this.accessory.context.set_max_heat = this.set_max_heat;
|
|
290
|
+
}
|
|
291
|
+
if (this.device.irair?.set_min_heat) {
|
|
292
|
+
this.set_min_heat = this.device.irair?.set_min_heat;
|
|
293
|
+
this.accessory.context.set_min_heat = this.set_min_heat;
|
|
294
|
+
} else {
|
|
295
|
+
this.set_min_heat = 0;
|
|
296
|
+
this.accessory.context.set_min_heat = this.set_min_heat;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (this.device.irair?.set_max_cool) {
|
|
300
|
+
this.set_max_cool = this.device.irair?.set_max_cool;
|
|
301
|
+
this.accessory.context.set_max_cool = this.set_max_cool;
|
|
302
|
+
} else {
|
|
303
|
+
this.set_max_cool = 35;
|
|
304
|
+
this.accessory.context.set_max_cool = this.set_max_cool;
|
|
305
|
+
}
|
|
306
|
+
if (this.device.irair?.set_min_cool) {
|
|
307
|
+
this.set_min_cool = this.device.irair?.set_min_cool;
|
|
308
|
+
this.accessory.context.set_min_cool = this.set_min_cool;
|
|
253
309
|
} else {
|
|
254
|
-
this.
|
|
310
|
+
this.set_min_cool = 0;
|
|
311
|
+
this.accessory.context.set_min_cool = this.set_min_cool;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (this.meter) {
|
|
315
|
+
if (this.HumiditySensor!.CurrentRelativeHumidity === undefined && this.accessory.context.CurrentRelativeHumidity === undefined) {
|
|
316
|
+
this.HumiditySensor!.CurrentRelativeHumidity = 0;
|
|
317
|
+
} else {
|
|
318
|
+
this.HumiditySensor!.CurrentRelativeHumidity = this.HumiditySensor!.CurrentRelativeHumidity
|
|
319
|
+
|| this.accessory.context.CurrentRelativeHumidity;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
if (this.HeaterCooler.ThresholdTemperature < this.HeaterCooler.CurrentTemperature &&
|
|
323
|
+
this.HeaterCooler.TargetHeaterCoolerState !== this.hap.Characteristic.TargetHeaterCoolerState.HEAT) {
|
|
324
|
+
this.HeaterCooler.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.COOLING;
|
|
325
|
+
} else if (this.HeaterCooler.ThresholdTemperature > this.HeaterCooler.CurrentTemperature &&
|
|
326
|
+
this.HeaterCooler.TargetHeaterCoolerState !== this.hap.Characteristic.TargetHeaterCoolerState.COOL) {
|
|
327
|
+
this.HeaterCooler.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.HEATING;
|
|
328
|
+
} else {
|
|
329
|
+
this.HeaterCooler.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.IDLE;
|
|
255
330
|
}
|
|
256
331
|
} else {
|
|
257
|
-
this.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
332
|
+
this.HeaterCooler.CurrentHeaterCoolerState = this.hap.Characteristic.CurrentHeaterCoolerState.INACTIVE;
|
|
258
333
|
}
|
|
259
334
|
}
|
|
260
335
|
|
|
@@ -273,8 +348,10 @@ export class AirConditioner {
|
|
|
273
348
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
274
349
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
275
350
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
276
|
-
this.
|
|
351
|
+
this.debugSuccessLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
277
352
|
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
353
|
+
this.successLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
354
|
+
+ ` request to SwitchBot API, body: ${JSON.stringify(bodyChange)} sent successfully`);
|
|
278
355
|
this.updateHomeKitCharacteristics();
|
|
279
356
|
} else {
|
|
280
357
|
this.statusCode(statusCode);
|
|
@@ -309,9 +386,9 @@ export class AirConditioner {
|
|
|
309
386
|
);
|
|
310
387
|
}
|
|
311
388
|
|
|
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;
|
|
389
|
+
this.HeaterCooler.CurrentTemperature = this.accessory.context.CurrentTemperature || 24;
|
|
390
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CurrentTemperature: ${this.HeaterCooler.CurrentTemperature}`);
|
|
391
|
+
return this.HeaterCooler.CurrentTemperature;
|
|
315
392
|
}
|
|
316
393
|
|
|
317
394
|
async CurrentRelativeHumidityGet(): Promise<CharacteristicValue> {
|
|
@@ -323,19 +400,20 @@ export class AirConditioner {
|
|
|
323
400
|
);
|
|
324
401
|
}
|
|
325
402
|
|
|
326
|
-
this.CurrentRelativeHumidity = this.accessory.context.CurrentRelativeHumidity || 0;
|
|
327
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get
|
|
328
|
-
|
|
403
|
+
this.HumiditySensor!.CurrentRelativeHumidity = this.accessory.context.CurrentRelativeHumidity || 0;
|
|
404
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get`
|
|
405
|
+
+ ` CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`);
|
|
406
|
+
return this.HumiditySensor!.CurrentRelativeHumidity as CharacteristicValue;
|
|
329
407
|
}
|
|
330
408
|
|
|
331
409
|
async RotationSpeedGet(): Promise<number> {
|
|
332
410
|
if (!this.CurrentFanSpeed || this.CurrentFanSpeed === 1) {
|
|
333
|
-
this.RotationSpeed = 4;
|
|
411
|
+
this.HeaterCooler.RotationSpeed = 4;
|
|
334
412
|
} else {
|
|
335
|
-
this.RotationSpeed = this.CurrentFanSpeed - 1;
|
|
413
|
+
this.HeaterCooler.RotationSpeed = this.CurrentFanSpeed - 1;
|
|
336
414
|
}
|
|
337
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get RotationSpeed: ${this.RotationSpeed}`);
|
|
338
|
-
return this.RotationSpeed;
|
|
415
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get RotationSpeed: ${this.HeaterCooler.RotationSpeed}`);
|
|
416
|
+
return this.HeaterCooler.RotationSpeed;
|
|
339
417
|
}
|
|
340
418
|
|
|
341
419
|
async RotationSpeedSet(value: CharacteristicValue): Promise<void> {
|
|
@@ -344,37 +422,35 @@ export class AirConditioner {
|
|
|
344
422
|
} else {
|
|
345
423
|
this.CurrentFanSpeed = Number(value) + 1;
|
|
346
424
|
}
|
|
347
|
-
this.RotationSpeed = value;
|
|
425
|
+
this.HeaterCooler.RotationSpeed = value;
|
|
348
426
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}` +
|
|
349
|
-
`Set RotationSpeed: ${this.RotationSpeed}, CurrentFanSpeed: ${this.CurrentFanSpeed}`);
|
|
427
|
+
`Set RotationSpeed: ${this.HeaterCooler.RotationSpeed}, CurrentFanSpeed: ${this.CurrentFanSpeed}`);
|
|
350
428
|
this.pushAirConditionerStatusChanges();
|
|
351
429
|
}
|
|
352
430
|
|
|
353
431
|
async ActiveSet(value: CharacteristicValue): Promise<void> {
|
|
354
432
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Active: ${value}`);
|
|
355
433
|
|
|
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}`);
|
|
434
|
+
this.HeaterCooler.Active = value;
|
|
435
|
+
if (this.HeaterCooler.Active === this.hap.Characteristic.Active.ACTIVE) {
|
|
436
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOnChanges, Active: ${this.HeaterCooler.Active}`);
|
|
359
437
|
if (this.disablePushOn) {
|
|
360
438
|
this.pushAirConditionerStatusChanges();
|
|
361
439
|
} else {
|
|
362
440
|
this.pushAirConditionerOnChanges();
|
|
363
441
|
}
|
|
364
442
|
} else {
|
|
365
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.Active}`);
|
|
443
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.HeaterCooler.Active}`);
|
|
366
444
|
this.pushAirConditionerOffChanges();
|
|
367
445
|
}
|
|
368
446
|
}
|
|
369
447
|
|
|
370
448
|
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;
|
|
449
|
+
const targetState = this.HeaterCooler.TargetHeaterCoolerState || this.accessory.context.TargetHeaterCoolerState;
|
|
450
|
+
this.HeaterCooler.TargetHeaterCoolerState = this.ValidValues.includes(targetState) ? targetState : this.ValidValues[0];
|
|
451
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get (${this.getTargetHeaterCoolerStateName()}) TargetHeaterCoolerState:`
|
|
452
|
+
+ ` ${this.HeaterCooler.TargetHeaterCoolerState}, ValidValues: ${this.ValidValues}, hide_automode: ${this.hide_automode}`);
|
|
453
|
+
return this.HeaterCooler.TargetHeaterCoolerState;
|
|
378
454
|
}
|
|
379
455
|
|
|
380
456
|
async TargetHeaterCoolerStateSet(value: CharacteristicValue): Promise<void> {
|
|
@@ -386,7 +462,7 @@ export class AirConditioner {
|
|
|
386
462
|
this.TargetHeaterCoolerStateCOOL();
|
|
387
463
|
} else {
|
|
388
464
|
this.errorLog(
|
|
389
|
-
`${this.device.remoteType}: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.TargetHeaterCoolerState},` +
|
|
465
|
+
`${this.device.remoteType}: ${this.accessory.displayName} Set TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState},` +
|
|
390
466
|
` hide_automode: ${this.hide_automode} `,
|
|
391
467
|
);
|
|
392
468
|
}
|
|
@@ -394,23 +470,26 @@ export class AirConditioner {
|
|
|
394
470
|
}
|
|
395
471
|
|
|
396
472
|
async TargetHeaterCoolerStateAUTO(): Promise<void> {
|
|
397
|
-
this.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
473
|
+
this.HeaterCooler.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.AUTO;
|
|
398
474
|
this.CurrentMode = 1;
|
|
399
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (AUTO)
|
|
475
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (AUTO)`
|
|
476
|
+
+ ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
400
477
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
401
478
|
}
|
|
402
479
|
|
|
403
480
|
async TargetHeaterCoolerStateCOOL(): Promise<void> {
|
|
404
|
-
this.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.COOL;
|
|
481
|
+
this.HeaterCooler.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.COOL;
|
|
405
482
|
this.CurrentMode = 2;
|
|
406
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (COOL)
|
|
483
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (COOL)`
|
|
484
|
+
+ ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
407
485
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
408
486
|
}
|
|
409
487
|
|
|
410
488
|
async TargetHeaterCoolerStateHEAT(): Promise<void> {
|
|
411
|
-
this.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
489
|
+
this.HeaterCooler.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.HEAT;
|
|
412
490
|
this.CurrentMode = 5;
|
|
413
|
-
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (HEAT)
|
|
491
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (HEAT)`
|
|
492
|
+
+ ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
414
493
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
|
|
415
494
|
}
|
|
416
495
|
|
|
@@ -418,15 +497,15 @@ export class AirConditioner {
|
|
|
418
497
|
await this.UpdateCurrentHeaterCoolerState();
|
|
419
498
|
this.debugLog(
|
|
420
499
|
`${this.device.remoteType}: ${this.accessory.displayName}` +
|
|
421
|
-
` Get (${this.getTargetHeaterCoolerStateName()}) CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`,
|
|
500
|
+
` Get (${this.getTargetHeaterCoolerStateName()}) CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`,
|
|
422
501
|
);
|
|
423
502
|
|
|
424
|
-
return this.CurrentHeaterCoolerState;
|
|
503
|
+
return this.HeaterCooler.CurrentHeaterCoolerState;
|
|
425
504
|
}
|
|
426
505
|
|
|
427
506
|
|
|
428
507
|
private getTargetHeaterCoolerStateName(): string {
|
|
429
|
-
switch (this.TargetHeaterCoolerState) {
|
|
508
|
+
switch (this.HeaterCooler.TargetHeaterCoolerState) {
|
|
430
509
|
case this.hap.Characteristic.TargetHeaterCoolerState.AUTO:
|
|
431
510
|
return 'AUTO';
|
|
432
511
|
case this.hap.Characteristic.TargetHeaterCoolerState.HEAT:
|
|
@@ -434,262 +513,36 @@ export class AirConditioner {
|
|
|
434
513
|
case this.hap.Characteristic.TargetHeaterCoolerState.COOL:
|
|
435
514
|
return 'COOL';
|
|
436
515
|
default:
|
|
437
|
-
return this.TargetHeaterCoolerState.toString();
|
|
516
|
+
return this.HeaterCooler.TargetHeaterCoolerState.toString();
|
|
438
517
|
}
|
|
439
518
|
}
|
|
440
519
|
|
|
441
520
|
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
521
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
522
|
+
if (this.HeaterCooler.Active === undefined) {
|
|
523
|
+
this.HeaterCooler.Active = this.hap.Characteristic.Active.INACTIVE;
|
|
524
|
+
} else if (this.HeaterCooler.Active) {
|
|
525
|
+
this.HeaterCooler.Active;
|
|
530
526
|
} else {
|
|
531
|
-
this.
|
|
527
|
+
this.HeaterCooler.Active = this.accessory.context.Active;
|
|
532
528
|
}
|
|
533
|
-
}
|
|
534
529
|
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
this.disablePushOff = false;
|
|
530
|
+
if (this.HeaterCooler.CurrentTemperature === undefined && this.accessory.context.CurrentTemperature === undefined) {
|
|
531
|
+
this.HeaterCooler.CurrentTemperature = 24;
|
|
538
532
|
} else {
|
|
539
|
-
this.
|
|
533
|
+
this.HeaterCooler.CurrentTemperature = this.HeaterCooler.CurrentTemperature || this.accessory.context.CurrentTemperature;
|
|
540
534
|
}
|
|
541
|
-
}
|
|
542
535
|
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
this.disablePushDetail = false;
|
|
536
|
+
if (this.HeaterCooler.ThresholdTemperature === undefined && this.accessory.context.ThresholdTemperature === undefined) {
|
|
537
|
+
this.HeaterCooler.ThresholdTemperature = 24;
|
|
546
538
|
} else {
|
|
547
|
-
this.
|
|
539
|
+
this.HeaterCooler.ThresholdTemperature = this.HeaterCooler.ThresholdTemperature || this.accessory.context.ThresholdTemperature;
|
|
548
540
|
}
|
|
549
|
-
}
|
|
550
541
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
if (this.device.customize) {
|
|
554
|
-
commandType = 'customize';
|
|
542
|
+
if (this.HeaterCooler.RotationSpeed === undefined && this.accessory.context.RotationSpeed === undefined) {
|
|
543
|
+
this.HeaterCooler.RotationSpeed = 4;
|
|
555
544
|
} else {
|
|
556
|
-
|
|
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
|
-
|
|
668
|
-
async deviceContext(): Promise<void> {
|
|
669
|
-
if (this.Active === undefined) {
|
|
670
|
-
this.Active = this.hap.Characteristic.Active.INACTIVE;
|
|
671
|
-
} else if (this.Active) {
|
|
672
|
-
this.Active;
|
|
673
|
-
} else {
|
|
674
|
-
this.Active = this.accessory.context.Active;
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
if (this.CurrentTemperature === undefined && this.accessory.context.CurrentTemperature === undefined) {
|
|
678
|
-
this.CurrentTemperature = 24;
|
|
679
|
-
} else {
|
|
680
|
-
this.CurrentTemperature = this.CurrentTemperature || this.accessory.context.CurrentTemperature;
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
if (this.ThresholdTemperature === undefined && this.accessory.context.ThresholdTemperature === undefined) {
|
|
684
|
-
this.ThresholdTemperature = 24;
|
|
685
|
-
} else {
|
|
686
|
-
this.ThresholdTemperature = this.ThresholdTemperature || this.accessory.context.ThresholdTemperature;
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
if (this.RotationSpeed === undefined && this.accessory.context.RotationSpeed === undefined) {
|
|
690
|
-
this.RotationSpeed = 4;
|
|
691
|
-
} else {
|
|
692
|
-
this.RotationSpeed = this.RotationSpeed || this.accessory.context.RotationSpeed;
|
|
545
|
+
this.HeaterCooler.RotationSpeed = this.HeaterCooler.RotationSpeed || this.accessory.context.RotationSpeed;
|
|
693
546
|
}
|
|
694
547
|
|
|
695
548
|
if (this.device.irair?.hide_automode) {
|
|
@@ -731,115 +584,148 @@ export class AirConditioner {
|
|
|
731
584
|
}
|
|
732
585
|
|
|
733
586
|
if (this.meter) {
|
|
734
|
-
if (this.CurrentRelativeHumidity === undefined && this.accessory.context.CurrentRelativeHumidity === undefined) {
|
|
735
|
-
this.CurrentRelativeHumidity = 0;
|
|
587
|
+
if (this.HumiditySensor!.CurrentRelativeHumidity === undefined && this.accessory.context.CurrentRelativeHumidity === undefined) {
|
|
588
|
+
this.HumiditySensor!.CurrentRelativeHumidity = 0;
|
|
736
589
|
} else {
|
|
737
|
-
this.CurrentRelativeHumidity = this.CurrentRelativeHumidity || this.accessory.context.CurrentRelativeHumidity;
|
|
590
|
+
this.HumiditySensor!.CurrentRelativeHumidity = this.HumiditySensor!.CurrentRelativeHumidity || this.accessory.context.CurrentRelativeHumidity;
|
|
738
591
|
}
|
|
739
592
|
}
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
this.accessory.context.FirmwareRevision = this.FirmwareRevision;
|
|
743
|
-
}
|
|
593
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
|
|
594
|
+
return this.HeaterCooler.ThresholdTemperature;
|
|
744
595
|
}
|
|
745
596
|
|
|
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;
|
|
597
|
+
async ThresholdTemperatureSet(value: CharacteristicValue): Promise<void> {
|
|
598
|
+
this.HeaterCooler.ThresholdTemperature = value;
|
|
599
|
+
this.debugLog(
|
|
600
|
+
`${this.device.remoteType}: ${this.accessory.displayName} Set ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature},` +
|
|
601
|
+
` ThresholdTemperatureCached: ${this.accessory.context.ThresholdTemperature}`,
|
|
602
|
+
);
|
|
603
|
+
this.pushAirConditionerStatusChanges();
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
async updateHomeKitCharacteristics(): Promise<void> {
|
|
607
|
+
// Active
|
|
608
|
+
if (this.HeaterCooler.Active === undefined) {
|
|
609
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.HeaterCooler.Active}`);
|
|
610
|
+
} else {
|
|
611
|
+
this.accessory.context.Active = this.HeaterCooler.Active;
|
|
612
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.Active, this.HeaterCooler.Active);
|
|
613
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.HeaterCooler.Active}`);
|
|
765
614
|
}
|
|
766
|
-
|
|
767
|
-
|
|
615
|
+
// RotationSpeed
|
|
616
|
+
if (this.HeaterCooler.RotationSpeed === undefined) {
|
|
617
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} RotationSpeed: ${this.HeaterCooler.RotationSpeed}`);
|
|
618
|
+
} else {
|
|
619
|
+
this.accessory.context.RotationSpeed = this.HeaterCooler.RotationSpeed;
|
|
620
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.RotationSpeed, this.HeaterCooler.RotationSpeed);
|
|
621
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
622
|
+
+ ` RotationSpeed: ${this.HeaterCooler.RotationSpeed}`);
|
|
768
623
|
}
|
|
769
|
-
|
|
770
|
-
|
|
624
|
+
// CurrentTemperature
|
|
625
|
+
if (this.HeaterCooler.CurrentTemperature === undefined) {
|
|
626
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentTemperature: ${this.HeaterCooler.CurrentTemperature}`);
|
|
627
|
+
} else {
|
|
628
|
+
this.accessory.context.CurrentTemperature = this.HeaterCooler.CurrentTemperature;
|
|
629
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, this.HeaterCooler.CurrentTemperature);
|
|
630
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
631
|
+
+ ` CurrentTemperature: ${this.HeaterCooler.CurrentTemperature}`);
|
|
771
632
|
}
|
|
772
|
-
|
|
773
|
-
|
|
633
|
+
// CurrentRelativeHumidity
|
|
634
|
+
if (this.meter) {
|
|
635
|
+
if (this.HumiditySensor!.CurrentRelativeHumidity === undefined) {
|
|
636
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
637
|
+
+ ` CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`);
|
|
638
|
+
} else {
|
|
639
|
+
this.accessory.context.CurrentRelativeHumidity = this.HumiditySensor!.CurrentRelativeHumidity;
|
|
640
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity,
|
|
641
|
+
this.HumiditySensor!.CurrentRelativeHumidity);
|
|
642
|
+
this.debugLog(
|
|
643
|
+
`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
644
|
+
+ ` CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`,
|
|
645
|
+
);
|
|
646
|
+
}
|
|
774
647
|
}
|
|
775
|
-
|
|
776
|
-
|
|
648
|
+
// TargetHeaterCoolerState
|
|
649
|
+
if (this.HeaterCooler.TargetHeaterCoolerState === undefined) {
|
|
650
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
651
|
+
} else {
|
|
652
|
+
this.accessory.context.TargetHeaterCoolerState = this.HeaterCooler.TargetHeaterCoolerState;
|
|
653
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.TargetHeaterCoolerState, this.HeaterCooler.TargetHeaterCoolerState);
|
|
654
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
655
|
+
+ ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
777
656
|
}
|
|
778
|
-
|
|
779
|
-
|
|
657
|
+
// CurrentHeaterCoolerState
|
|
658
|
+
if (this.HeaterCooler.CurrentHeaterCoolerState === undefined) {
|
|
659
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
|
|
660
|
+
+ ` CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`);
|
|
661
|
+
} else {
|
|
662
|
+
this.accessory.context.CurrentHeaterCoolerState = this.HeaterCooler.CurrentHeaterCoolerState;
|
|
663
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState, this.HeaterCooler.CurrentHeaterCoolerState);
|
|
664
|
+
this.debugLog(
|
|
665
|
+
`${this.device.remoteType}: ${this.accessory.displayName}` +
|
|
666
|
+
` updateCharacteristic CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`,
|
|
667
|
+
);
|
|
780
668
|
}
|
|
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}`);
|
|
669
|
+
// ThresholdTemperature
|
|
670
|
+
if (this.HeaterCooler.ThresholdTemperature === undefined) {
|
|
671
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
|
|
793
672
|
} else {
|
|
794
|
-
this.
|
|
795
|
-
this.
|
|
673
|
+
this.accessory.context.ThresholdTemperature = this.HeaterCooler.ThresholdTemperature;
|
|
674
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.HeatingThresholdTemperature, this.HeaterCooler.ThresholdTemperature);
|
|
675
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CoolingThresholdTemperature, this.HeaterCooler.ThresholdTemperature);
|
|
676
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
677
|
+
+ ` ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
|
|
796
678
|
}
|
|
797
679
|
}
|
|
798
680
|
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
681
|
+
async apiError({ e }: { e: any }): Promise<void> {
|
|
682
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.Active, e);
|
|
683
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.RotationSpeed, e);
|
|
684
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, e);
|
|
685
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity, e);
|
|
686
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.TargetHeaterCoolerState, e);
|
|
687
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState, e);
|
|
688
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.HeatingThresholdTemperature, e);
|
|
689
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CoolingThresholdTemperature, e);
|
|
806
690
|
}
|
|
807
691
|
|
|
808
|
-
|
|
809
|
-
if (this.
|
|
810
|
-
this.
|
|
692
|
+
async getAirConditionerConfigSettings(accessory: PlatformAccessory, device: irdevice & irDevicesConfig): Promise<void> {
|
|
693
|
+
if (this.device.irair?.hide_automode) {
|
|
694
|
+
this.hide_automode = device.irair?.hide_automode;
|
|
695
|
+
accessory.context.hide_automode = this.hide_automode;
|
|
696
|
+
} else {
|
|
697
|
+
this.hide_automode = device.irair?.hide_automode;
|
|
698
|
+
accessory.context.hide_automode = this.hide_automode;
|
|
811
699
|
}
|
|
812
|
-
}
|
|
813
700
|
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
701
|
+
if (this.device.irair?.set_max_heat) {
|
|
702
|
+
this.set_max_heat = device.irair?.set_max_heat;
|
|
703
|
+
accessory.context.set_max_heat = this.set_max_heat;
|
|
704
|
+
} else {
|
|
705
|
+
this.set_max_heat = 35;
|
|
706
|
+
accessory.context.set_max_heat = this.set_max_heat;
|
|
817
707
|
}
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
this.
|
|
708
|
+
if (this.device.irair?.set_min_heat) {
|
|
709
|
+
this.set_min_heat = device.irair?.set_min_heat;
|
|
710
|
+
accessory.context.set_min_heat = this.set_min_heat;
|
|
711
|
+
} else {
|
|
712
|
+
this.set_min_heat = 0;
|
|
713
|
+
accessory.context.set_min_heat = this.set_min_heat;
|
|
823
714
|
}
|
|
824
|
-
}
|
|
825
715
|
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
716
|
+
if (this.device.irair?.set_max_cool) {
|
|
717
|
+
this.set_max_cool = device.irair?.set_max_cool;
|
|
718
|
+
accessory.context.set_max_cool = this.set_max_cool;
|
|
719
|
+
} else {
|
|
720
|
+
this.set_max_cool = 35;
|
|
721
|
+
accessory.context.set_max_cool = this.set_max_cool;
|
|
829
722
|
}
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
} else {
|
|
837
|
-
this.platform.log.debug(String(...log));
|
|
838
|
-
}
|
|
723
|
+
if (this.device.irair?.set_min_cool) {
|
|
724
|
+
this.set_min_cool = device.irair?.set_min_cool;
|
|
725
|
+
accessory.context.set_min_cool = this.set_min_cool;
|
|
726
|
+
} else {
|
|
727
|
+
this.set_min_cool = 0;
|
|
728
|
+
accessory.context.set_min_cool = this.set_min_cool;
|
|
839
729
|
}
|
|
840
730
|
}
|
|
841
|
-
|
|
842
|
-
enablingDeviceLogging(): boolean {
|
|
843
|
-
return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
|
|
844
|
-
}
|
|
845
731
|
}
|