@switchbot/homebridge-switchbot 3.5.0-beta.57 → 3.5.0-beta.59
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/dist/device/blindtilt.d.ts +5 -5
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +103 -69
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +4 -4
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +201 -154
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +3 -3
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +41 -36
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +3 -3
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +36 -37
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +4 -4
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +76 -55
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +4 -4
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +99 -55
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +4 -4
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +11 -9
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts +3 -3
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +54 -24
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts +4 -4
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +40 -57
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +3 -3
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +39 -39
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +3 -3
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +41 -50
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +4 -4
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +36 -33
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +3 -3
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +68 -59
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +3 -3
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +42 -51
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +3 -3
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +42 -51
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +3 -3
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +52 -40
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +3 -3
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +13 -13
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +4 -4
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +81 -98
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts +3 -3
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +39 -31
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/homebridge-ui/public/index.html +20 -14
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +3 -3
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +9 -9
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +3 -3
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +1 -1
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +3 -3
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +2 -2
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +6 -6
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +37 -29
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +3 -3
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts +9 -14
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +67 -88
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +3 -3
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +1 -1
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +3 -3
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +3 -3
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +3 -3
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +2 -2
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +3 -3
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +2 -2
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +7 -7
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +20 -23
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +24 -10
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +16 -0
- package/dist/settings.js.map +1 -1
- package/eslint.config.js +89 -78
- package/package.json +3 -3
- package/src/device/blindtilt.ts +120 -87
- package/src/device/bot.ts +238 -175
- package/src/device/ceilinglight.ts +49 -46
- package/src/device/colorbulb.ts +40 -43
- package/src/device/contact.ts +91 -65
- package/src/device/curtain.ts +113 -66
- package/src/device/device.ts +12 -13
- package/src/device/fan.ts +66 -29
- package/src/device/hub.ts +53 -60
- package/src/device/humidifier.ts +54 -56
- package/src/device/iosensor.ts +57 -56
- package/src/device/lightstrip.ts +43 -39
- package/src/device/lock.ts +79 -68
- package/src/device/meter.ts +54 -54
- package/src/device/meterplus.ts +54 -54
- package/src/device/motion.ts +62 -46
- package/src/device/plug.ts +19 -18
- package/src/device/robotvacuumcleaner.ts +89 -104
- package/src/device/waterdetector.ts +46 -34
- package/src/homebridge-ui/public/index.html +20 -14
- package/src/index.ts +3 -2
- package/src/irdevice/airconditioner.ts +13 -11
- package/src/irdevice/airpurifier.ts +5 -3
- package/src/irdevice/camera.ts +6 -4
- package/src/irdevice/fan.ts +42 -29
- package/src/irdevice/irdevice.ts +4 -5
- package/src/irdevice/light.ts +83 -103
- package/src/irdevice/other.ts +5 -3
- package/src/irdevice/tv.ts +7 -5
- package/src/irdevice/vacuumcleaner.ts +6 -4
- package/src/irdevice/waterheater.ts +6 -4
- package/src/platform.ts +59 -66
- package/src/settings.ts +73 -58
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
<p class="text-center">
|
|
2
2
|
<img
|
|
3
3
|
src="https://raw.githubusercontent.com/OpenWonderLabs/homebridge-switchbot/latest/branding/Homebridge_x_SwitchBot.svg"
|
|
4
|
-
alt="homebridge-switchbot logo"
|
|
5
|
-
style="width: 50%" />
|
|
4
|
+
alt="homebridge-switchbot logo" style="width: 50%" />
|
|
6
5
|
</p>
|
|
7
6
|
<div id="pageIntro" style="display: none">
|
|
8
7
|
<p class="lead text-center">Thank you for installing <strong>homebridge-switchbot</strong></p>
|
|
@@ -10,10 +9,10 @@
|
|
|
10
9
|
<ol>
|
|
11
10
|
<li class="mb-3">
|
|
12
11
|
Download the SwitchBot App from either the
|
|
13
|
-
<a href="https://apps.apple.com/us/app/switchbot/id1087374760" target="_blank" rel="noreferrer noopener">App
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
<a href="https://apps.apple.com/us/app/switchbot/id1087374760" target="_blank" rel="noreferrer noopener">App
|
|
13
|
+
Store</a> or the
|
|
14
|
+
<a href="https://play.google.com/store/apps/details?id=com.theswitchbot.switchbot&hl=en_US&gl=US" target="_blank"
|
|
15
|
+
rel="noreferrer noopener">Play Store</a>.
|
|
17
16
|
</li>
|
|
18
17
|
<li class="mb-3">Select <strong>Profile</strong>.</li>
|
|
19
18
|
<li class="mb-3">Select <strong>Preferences</strong>.</li>
|
|
@@ -84,31 +83,38 @@
|
|
|
84
83
|
<a href="https://github.com/OpenWonderLabs/homebridge-switchbot/wiki" target="_blank">Wiki Home</a>
|
|
85
84
|
</li>
|
|
86
85
|
<li>
|
|
87
|
-
<a href="https://github.com/OpenWonderLabs/homebridge-switchbot/wiki/Configuration"
|
|
86
|
+
<a href="https://github.com/OpenWonderLabs/homebridge-switchbot/wiki/Configuration"
|
|
87
|
+
target="_blank">Configuration</a>
|
|
88
88
|
</li>
|
|
89
89
|
<li>
|
|
90
|
-
<a href="https://github.com/OpenWonderLabs/homebridge-switchbot/wiki/Beta-Version" target="_blank">Beta
|
|
90
|
+
<a href="https://github.com/OpenWonderLabs/homebridge-switchbot/wiki/Beta-Version" target="_blank">Beta
|
|
91
|
+
Version</a>
|
|
91
92
|
</li>
|
|
92
93
|
<li>
|
|
93
|
-
<a href="https://github.com/OpenWonderLabs/homebridge-switchbot/wiki/Node-Version" target="_blank">Node
|
|
94
|
+
<a href="https://github.com/OpenWonderLabs/homebridge-switchbot/wiki/Node-Version" target="_blank">Node
|
|
95
|
+
Version</a>
|
|
94
96
|
</li>
|
|
95
97
|
<li>
|
|
96
|
-
<a href="https://github.com/OpenWonderLabs/homebridge-switchbot/wiki/Uninstallation"
|
|
98
|
+
<a href="https://github.com/OpenWonderLabs/homebridge-switchbot/wiki/Uninstallation"
|
|
99
|
+
target="_blank">Uninstallation</a>
|
|
97
100
|
</li>
|
|
98
101
|
</ul>
|
|
99
102
|
<h5>Features</h5>
|
|
100
103
|
<ul>
|
|
101
104
|
<li>
|
|
102
|
-
<a href="https://github.com/OpenWonderLabs/homebridge-switchbot/wiki/Supported-Devices" target="_blank">Supported
|
|
105
|
+
<a href="https://github.com/OpenWonderLabs/homebridge-switchbot/wiki/Supported-Devices" target="_blank">Supported
|
|
106
|
+
Devices</a>
|
|
103
107
|
</li>
|
|
104
108
|
</ul>
|
|
105
109
|
<h5>Help/About</h5>
|
|
106
110
|
<ul>
|
|
107
111
|
<li>
|
|
108
|
-
<a href="https://github.com/OpenWonderLabs/homebridge-switchbot/issues/new/choose" target="_blank">Support
|
|
112
|
+
<a href="https://github.com/OpenWonderLabs/homebridge-switchbot/issues/new/choose" target="_blank">Support
|
|
113
|
+
Request</a>
|
|
109
114
|
</li>
|
|
110
115
|
<li>
|
|
111
|
-
<a href="https://github.com/OpenWonderLabs/homebridge-switchbot/blob/latest/CHANGELOG.md"
|
|
116
|
+
<a href="https://github.com/OpenWonderLabs/homebridge-switchbot/blob/latest/CHANGELOG.md"
|
|
117
|
+
target="_blank">Changelog</a>
|
|
112
118
|
</li>
|
|
113
119
|
</ul>
|
|
114
120
|
</div>
|
|
@@ -237,4 +243,4 @@
|
|
|
237
243
|
homebridge.hideSpinner();
|
|
238
244
|
}
|
|
239
245
|
})();
|
|
240
|
-
</script>
|
|
246
|
+
</script>
|
package/src/index.ts
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
*
|
|
3
3
|
* index.ts: @switchbot/homebridge-switchbot plugin registration.
|
|
4
4
|
*/
|
|
5
|
-
import { PLATFORM_NAME, PLUGIN_NAME } from './settings.js';
|
|
6
|
-
import { API } from 'homebridge';
|
|
7
5
|
import { SwitchBotPlatform } from './platform.js';
|
|
6
|
+
import { PLATFORM_NAME, PLUGIN_NAME } from './settings.js';
|
|
7
|
+
|
|
8
|
+
import type { API } from 'homebridge';
|
|
8
9
|
|
|
9
10
|
// Register our platform with homebridge.
|
|
10
11
|
export default (api: API): void => {
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
* airconditioners.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
5
|
import { request } from 'undici';
|
|
6
|
+
import { Devices } from '../settings.js';
|
|
6
7
|
import { irdeviceBase } from './irdevice.js';
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
|
|
9
|
+
import type { SwitchBotPlatform } from '../platform.js';
|
|
10
|
+
import type { irDevicesConfig, irdevice } from '../settings.js';
|
|
11
|
+
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Platform Accessory
|
|
@@ -607,7 +609,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
607
609
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.HeaterCooler.Active}`);
|
|
608
610
|
} else {
|
|
609
611
|
this.accessory.context.Active = this.HeaterCooler.Active;
|
|
610
|
-
this.HeaterCooler.Service
|
|
612
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.Active, this.HeaterCooler.Active);
|
|
611
613
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.HeaterCooler.Active}`);
|
|
612
614
|
}
|
|
613
615
|
// RotationSpeed
|
|
@@ -615,7 +617,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
615
617
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} RotationSpeed: ${this.HeaterCooler.RotationSpeed}`);
|
|
616
618
|
} else {
|
|
617
619
|
this.accessory.context.RotationSpeed = this.HeaterCooler.RotationSpeed;
|
|
618
|
-
this.HeaterCooler.Service
|
|
620
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.RotationSpeed, this.HeaterCooler.RotationSpeed);
|
|
619
621
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
620
622
|
+ ` RotationSpeed: ${this.HeaterCooler.RotationSpeed}`);
|
|
621
623
|
}
|
|
@@ -624,7 +626,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
624
626
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentTemperature: ${this.HeaterCooler.CurrentTemperature}`);
|
|
625
627
|
} else {
|
|
626
628
|
this.accessory.context.CurrentTemperature = this.HeaterCooler.CurrentTemperature;
|
|
627
|
-
this.HeaterCooler.Service
|
|
629
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, this.HeaterCooler.CurrentTemperature);
|
|
628
630
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
629
631
|
+ ` CurrentTemperature: ${this.HeaterCooler.CurrentTemperature}`);
|
|
630
632
|
}
|
|
@@ -635,7 +637,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
635
637
|
+ ` CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`);
|
|
636
638
|
} else {
|
|
637
639
|
this.accessory.context.CurrentRelativeHumidity = this.HumiditySensor!.CurrentRelativeHumidity;
|
|
638
|
-
this.HeaterCooler.Service
|
|
640
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity,
|
|
639
641
|
this.HumiditySensor!.CurrentRelativeHumidity);
|
|
640
642
|
this.debugLog(
|
|
641
643
|
`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
@@ -648,7 +650,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
648
650
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
649
651
|
} else {
|
|
650
652
|
this.accessory.context.TargetHeaterCoolerState = this.HeaterCooler.TargetHeaterCoolerState;
|
|
651
|
-
this.HeaterCooler.Service
|
|
653
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.TargetHeaterCoolerState, this.HeaterCooler.TargetHeaterCoolerState);
|
|
652
654
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
653
655
|
+ ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
|
|
654
656
|
}
|
|
@@ -658,7 +660,7 @@ export class AirConditioner extends irdeviceBase {
|
|
|
658
660
|
+ ` CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`);
|
|
659
661
|
} else {
|
|
660
662
|
this.accessory.context.CurrentHeaterCoolerState = this.HeaterCooler.CurrentHeaterCoolerState;
|
|
661
|
-
this.HeaterCooler.Service
|
|
663
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState, this.HeaterCooler.CurrentHeaterCoolerState);
|
|
662
664
|
this.debugLog(
|
|
663
665
|
`${this.device.remoteType}: ${this.accessory.displayName}` +
|
|
664
666
|
` updateCharacteristic CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`,
|
|
@@ -669,8 +671,8 @@ export class AirConditioner extends irdeviceBase {
|
|
|
669
671
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
|
|
670
672
|
} else {
|
|
671
673
|
this.accessory.context.ThresholdTemperature = this.HeaterCooler.ThresholdTemperature;
|
|
672
|
-
this.HeaterCooler.Service
|
|
673
|
-
this.HeaterCooler.Service
|
|
674
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.HeatingThresholdTemperature, this.HeaterCooler.ThresholdTemperature);
|
|
675
|
+
this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CoolingThresholdTemperature, this.HeaterCooler.ThresholdTemperature);
|
|
674
676
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
|
|
675
677
|
+ ` ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
|
|
676
678
|
}
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
* airpurifier.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
5
|
import { request } from 'undici';
|
|
6
|
+
import { Devices } from '../settings.js';
|
|
6
7
|
import { irdeviceBase } from './irdevice.js';
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
|
|
9
|
+
import type { SwitchBotPlatform } from '../platform.js';
|
|
10
|
+
import type { irDevicesConfig, irdevice } from '../settings.js';
|
|
11
|
+
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Platform Accessory
|
package/src/irdevice/camera.ts
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
* camera.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
5
|
import { request } from 'undici';
|
|
6
|
+
import { Devices } from '../settings.js';
|
|
6
7
|
import { irdeviceBase } from './irdevice.js';
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
|
|
9
|
+
import type { SwitchBotPlatform } from '../platform.js';
|
|
10
|
+
import type { irDevicesConfig, irdevice } from '../settings.js';
|
|
11
|
+
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Platform Accessory
|
|
@@ -142,7 +144,7 @@ export class Camera extends irdeviceBase {
|
|
|
142
144
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.Switch.On}`);
|
|
143
145
|
} else {
|
|
144
146
|
this.accessory.context.On = this.Switch.On;
|
|
145
|
-
this.Switch.Service
|
|
147
|
+
this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, this.Switch.On);
|
|
146
148
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.Switch.On}`);
|
|
147
149
|
}
|
|
148
150
|
}
|
package/src/irdevice/fan.ts
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
* fan.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
5
|
import { request } from 'undici';
|
|
6
|
+
import { Devices } from '../settings.js';
|
|
6
7
|
import { irdeviceBase } from './irdevice.js';
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
|
|
9
|
+
import type { SwitchBotPlatform } from '../platform.js';
|
|
10
|
+
import type { irDevicesConfig, irdevice } from '../settings.js';
|
|
11
|
+
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Platform Accessory
|
|
@@ -23,11 +25,6 @@ export class IRFan extends irdeviceBase {
|
|
|
23
25
|
RotationDirection: CharacteristicValue;
|
|
24
26
|
};
|
|
25
27
|
|
|
26
|
-
// Config
|
|
27
|
-
minStep?: number;
|
|
28
|
-
minValue?: number;
|
|
29
|
-
maxValue?: number;
|
|
30
|
-
|
|
31
28
|
constructor(
|
|
32
29
|
readonly platform: SwitchBotPlatform,
|
|
33
30
|
accessory: PlatformAccessory,
|
|
@@ -55,29 +52,15 @@ export class IRFan extends irdeviceBase {
|
|
|
55
52
|
// handle on / off events using the Active characteristic
|
|
56
53
|
this.Fan.Service.getCharacteristic(this.hap.Characteristic.Active).onSet(this.ActiveSet.bind(this));
|
|
57
54
|
|
|
55
|
+
|
|
58
56
|
if (device.irfan?.rotation_speed) {
|
|
59
|
-
if (device.irfan?.set_minStep) {
|
|
60
|
-
this.minStep = device.irfan?.set_minStep;
|
|
61
|
-
} else {
|
|
62
|
-
this.minStep = 1;
|
|
63
|
-
}
|
|
64
|
-
if (device.irfan?.set_min) {
|
|
65
|
-
this.minValue = device.irfan?.set_min;
|
|
66
|
-
} else {
|
|
67
|
-
this.minValue = 1;
|
|
68
|
-
}
|
|
69
|
-
if (device.irfan?.set_max) {
|
|
70
|
-
this.maxValue = device.irfan?.set_max;
|
|
71
|
-
} else {
|
|
72
|
-
this.maxValue = 100;
|
|
73
|
-
}
|
|
74
57
|
// handle Rotation Speed events using the RotationSpeed characteristic
|
|
75
58
|
this.Fan.Service
|
|
76
59
|
.getCharacteristic(this.hap.Characteristic.RotationSpeed)
|
|
77
60
|
.setProps({
|
|
78
|
-
minStep: this.minStep,
|
|
79
|
-
minValue: this.minValue,
|
|
80
|
-
maxValue: this.maxValue,
|
|
61
|
+
minStep: Number(this.minStep(device)),
|
|
62
|
+
minValue: Number(this.minValue(device)),
|
|
63
|
+
maxValue: Number(this.maxValue(device)),
|
|
81
64
|
})
|
|
82
65
|
.onSet(this.RotationSpeedSet.bind(this));
|
|
83
66
|
} else if (this.Fan.Service.testCharacteristic(this.hap.Characteristic.RotationSpeed) && !device.irfan?.swing_mode) {
|
|
@@ -106,6 +89,36 @@ export class IRFan extends irdeviceBase {
|
|
|
106
89
|
}
|
|
107
90
|
}
|
|
108
91
|
|
|
92
|
+
async minStep(device: irdevice & irDevicesConfig): Promise<number> {
|
|
93
|
+
let minStep: number;
|
|
94
|
+
if (device.irfan?.set_minStep) {
|
|
95
|
+
minStep = device.irfan?.set_minStep;
|
|
96
|
+
} else {
|
|
97
|
+
minStep = 1;
|
|
98
|
+
}
|
|
99
|
+
return minStep;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async minValue(device: irdevice & irDevicesConfig): Promise<number> {
|
|
103
|
+
let minValue: number;
|
|
104
|
+
if (device.irfan?.set_min) {
|
|
105
|
+
minValue = device.irfan?.set_min;
|
|
106
|
+
} else {
|
|
107
|
+
minValue = 1;
|
|
108
|
+
}
|
|
109
|
+
return minValue;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async maxValue(device: irdevice & irDevicesConfig): Promise<number> {
|
|
113
|
+
let maxValue: number;
|
|
114
|
+
if (device.irfan?.set_max) {
|
|
115
|
+
maxValue = device.irfan?.set_max;
|
|
116
|
+
} else {
|
|
117
|
+
maxValue = 100;
|
|
118
|
+
}
|
|
119
|
+
return maxValue;
|
|
120
|
+
}
|
|
121
|
+
|
|
109
122
|
async SwingModeSet(value: CharacteristicValue): Promise<void> {
|
|
110
123
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} SwingMode: ${value}`);
|
|
111
124
|
if (value > this.Fan.SwingMode) {
|
|
@@ -258,21 +271,21 @@ export class IRFan extends irdeviceBase {
|
|
|
258
271
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.Fan.Active}`);
|
|
259
272
|
} else {
|
|
260
273
|
this.accessory.context.Active = this.Fan.Active;
|
|
261
|
-
this.Fan.Service
|
|
274
|
+
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.Active, this.Fan.Active);
|
|
262
275
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Fan.Active}`);
|
|
263
276
|
}
|
|
264
277
|
if (this.Fan.SwingMode === undefined) {
|
|
265
278
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} SwingMode: ${this.Fan.SwingMode}`);
|
|
266
279
|
} else {
|
|
267
280
|
this.accessory.context.SwingMode = this.Fan.SwingMode;
|
|
268
|
-
this.Fan.Service
|
|
281
|
+
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.SwingMode, this.Fan.SwingMode);
|
|
269
282
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic SwingMode: ${this.Fan.SwingMode}`);
|
|
270
283
|
}
|
|
271
284
|
if (this.Fan.RotationSpeed === undefined) {
|
|
272
285
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} RotationSpeed: ${this.Fan.RotationSpeed}`);
|
|
273
286
|
} else {
|
|
274
287
|
this.accessory.context.RotationSpeed = this.Fan.RotationSpeed;
|
|
275
|
-
this.Fan.Service
|
|
288
|
+
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.RotationSpeed, this.Fan.RotationSpeed);
|
|
276
289
|
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.Fan.RotationSpeed}`);
|
|
277
290
|
}
|
|
278
291
|
}
|
package/src/irdevice/irdevice.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/* Copyright(C) 2021-2024, donavanbecker (https://github.com/donavanbecker). All rights reserved.
|
|
2
2
|
*
|
|
3
|
-
* device.ts: homebridge-
|
|
3
|
+
* device.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
import { SwitchBotPlatformConfig, irDevicesConfig, irdevice } from '../settings.js';
|
|
5
|
+
import type { SwitchBotPlatform } from '../platform.js';
|
|
6
|
+
import type { API, HAP, Logging, PlatformAccessory } from 'homebridge';
|
|
7
|
+
import type { SwitchBotPlatformConfig, irDevicesConfig, irdevice } from '../settings.js';
|
|
9
8
|
|
|
10
9
|
export abstract class irdeviceBase {
|
|
11
10
|
public readonly api: API;
|