@switchbot/homebridge-switchbot 3.5.0-beta.8 → 3.5.0

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