@switchbot/homebridge-switchbot 2.14.0 → 3.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/npm-version-script.cjs +81 -0
- package/.github/workflows/dependabot.yml +10 -11
- package/CHANGELOG.md +11 -2
- package/LICENSE +1 -1
- package/config.schema.json +1 -0
- package/dist/device/blindtilt.d.ts +9 -5
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +151 -91
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +9 -5
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +234 -184
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +9 -5
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +110 -64
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +9 -5
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +121 -69
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +9 -5
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +111 -66
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +9 -5
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +164 -107
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts +9 -5
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +87 -51
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +9 -5
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +133 -90
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +9 -5
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +108 -66
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +9 -5
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +110 -65
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +10 -6
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +125 -84
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +9 -5
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +102 -63
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +9 -5
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +102 -63
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +9 -5
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +95 -54
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +9 -5
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +68 -40
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +9 -5
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +86 -52
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/homebridge-ui/server.d.ts +2 -0
- package/dist/homebridge-ui/server.d.ts.map +1 -0
- package/dist/homebridge-ui/server.js +44 -0
- package/dist/homebridge-ui/server.js.map +1 -0
- package/dist/index.d.ts +1 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +8 -4
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +105 -71
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +8 -4
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +78 -46
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +8 -4
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +41 -25
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +8 -4
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +62 -39
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts +8 -4
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +67 -45
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +8 -4
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +176 -150
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +8 -4
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +81 -62
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +8 -4
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +41 -25
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +8 -4
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +48 -32
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +8 -9
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +147 -162
- package/dist/platform.js.map +1 -1
- package/dist/settings.js +7 -14
- package/dist/settings.js.map +1 -1
- package/dist/utils.js +1 -5
- package/dist/utils.js.map +1 -1
- package/package.json +28 -16
- package/src/device/blindtilt.ts +80 -69
- package/src/device/bot.ts +189 -178
- package/src/device/ceilinglight.ts +55 -42
- package/src/device/colorbulb.ts +51 -38
- package/src/device/contact.ts +69 -58
- package/src/device/curtain.ts +94 -83
- package/src/device/hub.ts +54 -43
- package/src/device/humidifier.ts +86 -75
- package/src/device/iosensor.ts +63 -52
- package/src/device/lightstrip.ts +54 -41
- package/src/device/lock.ts +89 -79
- package/src/device/meter.ts +59 -48
- package/src/device/meterplus.ts +63 -52
- package/src/device/motion.ts +56 -45
- package/src/device/plug.ts +36 -25
- package/src/device/robotvacuumcleaner.ts +47 -36
- package/src/homebridge-ui/public/index.html +240 -0
- package/src/homebridge-ui/server.ts +48 -0
- package/src/index.ts +10 -7
- package/src/irdevice/airconditioner.ts +70 -62
- package/src/irdevice/airpurifier.ts +47 -39
- package/src/irdevice/camera.ts +27 -19
- package/src/irdevice/fan.ts +41 -33
- package/src/irdevice/light.ts +47 -39
- package/src/irdevice/other.ts +163 -155
- package/src/irdevice/tv.ts +65 -57
- package/src/irdevice/vacuumcleaner.ts +27 -19
- package/src/irdevice/waterheater.ts +34 -26
- package/src/platform.ts +35 -21
- package/tsconfig.json +11 -13
- package/homebridge-ui/server.js +0 -50
- /package/{homebridge-ui → dist/homebridge-ui}/public/index.html +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Subject } from 'rxjs';
|
|
2
2
|
import { SwitchBotPlatform } from '../platform';
|
|
3
|
-
import { device, devicesConfig, deviceStatus, serviceData } from '../settings';
|
|
4
|
-
import { Service, PlatformAccessory, CharacteristicValue, ControllerConstructor, Controller, ControllerServiceMap } from 'homebridge';
|
|
3
|
+
import { device, devicesConfig, deviceStatus, serviceData, SwitchBotPlatformConfig } from '../settings';
|
|
4
|
+
import { Service, PlatformAccessory, CharacteristicValue, ControllerConstructor, Controller, ControllerServiceMap, API, Logging, HAP } from 'homebridge';
|
|
5
5
|
/**
|
|
6
6
|
* Platform Accessory
|
|
7
7
|
* An instance of this class is created for each accessory your platform registers
|
|
@@ -11,6 +11,10 @@ export declare class ColorBulb {
|
|
|
11
11
|
private readonly platform;
|
|
12
12
|
private accessory;
|
|
13
13
|
device: device & devicesConfig;
|
|
14
|
+
readonly api: API;
|
|
15
|
+
readonly log: Logging;
|
|
16
|
+
readonly config: SwitchBotPlatformConfig;
|
|
17
|
+
protected readonly hap: HAP;
|
|
14
18
|
lightBulbService: Service;
|
|
15
19
|
On: CharacteristicValue;
|
|
16
20
|
Hue: CharacteristicValue;
|
|
@@ -44,8 +48,8 @@ export declare class ColorBulb {
|
|
|
44
48
|
cacheKelvin: number;
|
|
45
49
|
colorBulbUpdateInProgress: boolean;
|
|
46
50
|
doColorBulbUpdate: Subject<void>;
|
|
47
|
-
private readonly BLE;
|
|
48
51
|
private readonly OpenAPI;
|
|
52
|
+
private readonly BLE;
|
|
49
53
|
constructor(platform: SwitchBotPlatform, accessory: PlatformAccessory, device: device & devicesConfig);
|
|
50
54
|
/**
|
|
51
55
|
* Parse the device status from the SwitchBot api
|
|
@@ -120,8 +124,8 @@ export declare class ColorBulb {
|
|
|
120
124
|
apiError(e: any): void;
|
|
121
125
|
context(): Promise<void>;
|
|
122
126
|
refreshRate(device: device & devicesConfig): Promise<void>;
|
|
123
|
-
|
|
124
|
-
|
|
127
|
+
deviceConfig(device: device & devicesConfig): Promise<void>;
|
|
128
|
+
deviceLogs(device: device & devicesConfig): Promise<void>;
|
|
125
129
|
/**
|
|
126
130
|
* Logging for Device
|
|
127
131
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colorbulb.d.ts","sourceRoot":"","sources":["../../src/device/colorbulb.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,OAAO,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAwB,WAAW,EAAe,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"colorbulb.d.ts","sourceRoot":"","sources":["../../src/device/colorbulb.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,OAAO,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAwB,WAAW,EAAe,uBAAuB,EAAE,MAAM,aAAa,CAAC;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EAAE,MAAM,GAAG,aAAa,GAAG,MAAM;IASzC,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAcnD,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA0C7C,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAOjC,QAAQ,CAAC,CAAC,EAAE,GAAG,GAAG,IAAI;IAQhB,OAAO;IAkCP,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAU1D,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IA+B3D,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB/D;;OAEG;IACH,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAM5B,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAM5B,YAAY,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAQjC,QAAQ,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAM7B,aAAa,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAQlC,QAAQ,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAU7B,qBAAqB,IAAI,OAAO;CAGjC"}
|
package/dist/device/colorbulb.js
CHANGED
|
@@ -1,63 +1,116 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const rxjs_1 = require("rxjs");
|
|
7
|
-
const operators_1 = require("rxjs/operators");
|
|
8
|
-
const settings_1 = require("../settings");
|
|
1
|
+
import { request } from 'undici';
|
|
2
|
+
import { sleep } from '../utils';
|
|
3
|
+
import { interval, Subject } from 'rxjs';
|
|
4
|
+
import { debounceTime, skipWhile, take, tap } from 'rxjs/operators';
|
|
5
|
+
import { hs2rgb, rgb2hs, m2hs, Devices } from '../settings';
|
|
9
6
|
/**
|
|
10
7
|
* Platform Accessory
|
|
11
8
|
* An instance of this class is created for each accessory your platform registers
|
|
12
9
|
* Each accessory may expose multiple services of different service types.
|
|
13
10
|
*/
|
|
14
|
-
class ColorBulb {
|
|
11
|
+
export class ColorBulb {
|
|
12
|
+
platform;
|
|
13
|
+
accessory;
|
|
14
|
+
device;
|
|
15
|
+
api;
|
|
16
|
+
log;
|
|
17
|
+
config;
|
|
18
|
+
hap;
|
|
19
|
+
// Services
|
|
20
|
+
lightBulbService;
|
|
21
|
+
// Characteristic Values
|
|
22
|
+
On;
|
|
23
|
+
Hue;
|
|
24
|
+
Saturation;
|
|
25
|
+
Brightness;
|
|
26
|
+
FirmwareRevision;
|
|
27
|
+
ColorTemperature;
|
|
28
|
+
// OpenAPI Status
|
|
29
|
+
OpenAPI_On;
|
|
30
|
+
OpenAPI_RGB;
|
|
31
|
+
OpenAPI_Brightness;
|
|
32
|
+
OpenAPI_FirmwareRevision;
|
|
33
|
+
OpenAPI_ColorTemperature;
|
|
34
|
+
// BLE Status
|
|
35
|
+
BLE_Red;
|
|
36
|
+
BLE_On;
|
|
37
|
+
BLE_Blue;
|
|
38
|
+
BLE_Power;
|
|
39
|
+
BLE_Green;
|
|
40
|
+
BLE_Delay;
|
|
41
|
+
BLE_WifiRssi;
|
|
42
|
+
BLE_Brightness;
|
|
43
|
+
BLE_ColorTemperature;
|
|
44
|
+
// BLE Others
|
|
45
|
+
BLE_IsConnected;
|
|
46
|
+
// Config
|
|
47
|
+
set_minStep;
|
|
48
|
+
scanDuration;
|
|
49
|
+
deviceLogging;
|
|
50
|
+
deviceRefreshRate;
|
|
51
|
+
adaptiveLightingShift;
|
|
52
|
+
// Adaptive Lighting
|
|
53
|
+
AdaptiveLightingController;
|
|
54
|
+
minKelvin;
|
|
55
|
+
maxKelvin;
|
|
56
|
+
// Others
|
|
57
|
+
cacheKelvin;
|
|
58
|
+
// Updates
|
|
59
|
+
colorBulbUpdateInProgress;
|
|
60
|
+
doColorBulbUpdate;
|
|
61
|
+
// Connection
|
|
62
|
+
OpenAPI;
|
|
63
|
+
BLE;
|
|
15
64
|
constructor(platform, accessory, device) {
|
|
16
65
|
this.platform = platform;
|
|
17
66
|
this.accessory = accessory;
|
|
18
67
|
this.device = device;
|
|
68
|
+
this.api = this.platform.api;
|
|
69
|
+
this.log = this.platform.log;
|
|
70
|
+
this.config = this.platform.config;
|
|
71
|
+
this.hap = this.api.hap;
|
|
19
72
|
// Connection
|
|
20
73
|
this.BLE = this.device.connectionType === 'BLE' || this.device.connectionType === 'BLE/OpenAPI';
|
|
21
74
|
this.OpenAPI = this.device.connectionType === 'OpenAPI' || this.device.connectionType === 'BLE/OpenAPI';
|
|
22
75
|
// default placeholders
|
|
23
|
-
this.
|
|
76
|
+
this.deviceLogs(device);
|
|
24
77
|
this.scan(device);
|
|
25
78
|
this.refreshRate(device);
|
|
26
79
|
this.adaptiveLighting(device);
|
|
27
80
|
this.context();
|
|
28
|
-
this.
|
|
81
|
+
this.deviceConfig(device);
|
|
29
82
|
// this is subject we use to track when we need to POST changes to the SwitchBot API
|
|
30
|
-
this.doColorBulbUpdate = new
|
|
83
|
+
this.doColorBulbUpdate = new Subject();
|
|
31
84
|
this.colorBulbUpdateInProgress = false;
|
|
32
85
|
// Retrieve initial values and updateHomekit
|
|
33
86
|
this.refreshStatus();
|
|
34
87
|
// set accessory information
|
|
35
88
|
accessory
|
|
36
|
-
.getService(this.
|
|
37
|
-
.setCharacteristic(this.
|
|
38
|
-
.setCharacteristic(this.
|
|
39
|
-
.setCharacteristic(this.
|
|
40
|
-
.setCharacteristic(this.
|
|
89
|
+
.getService(this.hap.Service.AccessoryInformation)
|
|
90
|
+
.setCharacteristic(this.hap.Characteristic.Manufacturer, 'SwitchBot')
|
|
91
|
+
.setCharacteristic(this.hap.Characteristic.Model, 'W1401400')
|
|
92
|
+
.setCharacteristic(this.hap.Characteristic.SerialNumber, device.deviceId)
|
|
93
|
+
.setCharacteristic(this.hap.Characteristic.FirmwareRevision, accessory.context.FirmwareRevision);
|
|
41
94
|
// get the Lightbulb service if it exists, otherwise create a new Lightbulb service
|
|
42
95
|
// you can create multiple services for each accessory
|
|
43
96
|
const lightBulbService = `${accessory.displayName} ${device.deviceType}`;
|
|
44
|
-
(this.lightBulbService = accessory.getService(this.
|
|
45
|
-
|| accessory.addService(this.
|
|
97
|
+
(this.lightBulbService = accessory.getService(this.hap.Service.Lightbulb)
|
|
98
|
+
|| accessory.addService(this.hap.Service.Lightbulb)), lightBulbService;
|
|
46
99
|
if (this.adaptiveLightingShift === -1 && this.accessory.context.adaptiveLighting) {
|
|
47
100
|
this.accessory.removeService(this.lightBulbService);
|
|
48
|
-
this.lightBulbService = this.accessory.addService(this.
|
|
101
|
+
this.lightBulbService = this.accessory.addService(this.hap.Service.Lightbulb);
|
|
49
102
|
this.accessory.context.adaptiveLighting = false;
|
|
50
103
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} adaptiveLighting: ${this.accessory.context.adaptiveLighting}`);
|
|
51
104
|
}
|
|
52
|
-
this.lightBulbService.setCharacteristic(this.
|
|
53
|
-
if (!this.lightBulbService.testCharacteristic(this.
|
|
54
|
-
this.lightBulbService.addCharacteristic(this.
|
|
105
|
+
this.lightBulbService.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
106
|
+
if (!this.lightBulbService.testCharacteristic(this.hap.Characteristic.ConfiguredName)) {
|
|
107
|
+
this.lightBulbService.addCharacteristic(this.hap.Characteristic.ConfiguredName, accessory.displayName);
|
|
55
108
|
}
|
|
56
109
|
// handle on / off events using the On characteristic
|
|
57
|
-
this.lightBulbService.getCharacteristic(this.
|
|
110
|
+
this.lightBulbService.getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
58
111
|
// handle Brightness events using the Brightness characteristic
|
|
59
112
|
this.lightBulbService
|
|
60
|
-
.getCharacteristic(this.
|
|
113
|
+
.getCharacteristic(this.hap.Characteristic.Brightness)
|
|
61
114
|
.setProps({
|
|
62
115
|
minStep: this.minStep(device),
|
|
63
116
|
minValue: 0,
|
|
@@ -70,7 +123,7 @@ class ColorBulb {
|
|
|
70
123
|
.onSet(this.BrightnessSet.bind(this));
|
|
71
124
|
// handle ColorTemperature events using the ColorTemperature characteristic
|
|
72
125
|
this.lightBulbService
|
|
73
|
-
.getCharacteristic(this.
|
|
126
|
+
.getCharacteristic(this.hap.Characteristic.ColorTemperature)
|
|
74
127
|
.setProps({
|
|
75
128
|
minValue: 140,
|
|
76
129
|
maxValue: 500,
|
|
@@ -82,7 +135,7 @@ class ColorBulb {
|
|
|
82
135
|
.onSet(this.ColorTemperatureSet.bind(this));
|
|
83
136
|
// handle Hue events using the Hue characteristic
|
|
84
137
|
this.lightBulbService
|
|
85
|
-
.getCharacteristic(this.
|
|
138
|
+
.getCharacteristic(this.hap.Characteristic.Hue)
|
|
86
139
|
.setProps({
|
|
87
140
|
minValue: 0,
|
|
88
141
|
maxValue: 360,
|
|
@@ -94,7 +147,7 @@ class ColorBulb {
|
|
|
94
147
|
.onSet(this.HueSet.bind(this));
|
|
95
148
|
// handle Hue events using the Hue characteristic
|
|
96
149
|
this.lightBulbService
|
|
97
|
-
.getCharacteristic(this.
|
|
150
|
+
.getCharacteristic(this.hap.Characteristic.Saturation)
|
|
98
151
|
.setProps({
|
|
99
152
|
minValue: 0,
|
|
100
153
|
maxValue: 100,
|
|
@@ -117,8 +170,8 @@ class ColorBulb {
|
|
|
117
170
|
// Update Homekit
|
|
118
171
|
this.updateHomeKitCharacteristics();
|
|
119
172
|
// Start an update interval
|
|
120
|
-
|
|
121
|
-
.pipe(
|
|
173
|
+
interval(this.deviceRefreshRate * 1000)
|
|
174
|
+
.pipe(skipWhile(() => this.colorBulbUpdateInProgress))
|
|
122
175
|
.subscribe(async () => {
|
|
123
176
|
await this.refreshStatus();
|
|
124
177
|
});
|
|
@@ -141,8 +194,8 @@ class ColorBulb {
|
|
|
141
194
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} red: ${JSON.stringify(red)}`);
|
|
142
195
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} green: ${JSON.stringify(green)}`);
|
|
143
196
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} blue: ${JSON.stringify(blue)}`);
|
|
144
|
-
const [hue, saturation] =
|
|
145
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}` + ` hs: ${JSON.stringify(
|
|
197
|
+
const [hue, saturation] = rgb2hs(Number(red), Number(green), Number(blue));
|
|
198
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}` + ` hs: ${JSON.stringify(rgb2hs(Number(red), Number(green), Number(blue)))}`);
|
|
146
199
|
// Hue
|
|
147
200
|
this.Hue = hue;
|
|
148
201
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Hue: ${this.Hue}`);
|
|
@@ -161,9 +214,9 @@ class ColorBulb {
|
|
|
161
214
|
// Watch for Bulb change events
|
|
162
215
|
// We put in a debounce of 100ms so we don't make duplicate calls
|
|
163
216
|
this.doColorBulbUpdate
|
|
164
|
-
.pipe(
|
|
217
|
+
.pipe(tap(() => {
|
|
165
218
|
this.colorBulbUpdateInProgress = true;
|
|
166
|
-
}),
|
|
219
|
+
}), debounceTime(this.platform.config.options.pushRate * 1000))
|
|
167
220
|
.subscribe(async () => {
|
|
168
221
|
try {
|
|
169
222
|
await this.pushChanges();
|
|
@@ -212,9 +265,9 @@ class ColorBulb {
|
|
|
212
265
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} red: ${this.BLE_Red}`);
|
|
213
266
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} green: ${this.BLE_Green}`);
|
|
214
267
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} blue: ${this.BLE_Blue}`);
|
|
215
|
-
const [hue, saturation] =
|
|
268
|
+
const [hue, saturation] = rgb2hs(Number(this.BLE_Red), Number(this.BLE_Green), Number(this.BLE_Blue));
|
|
216
269
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}` +
|
|
217
|
-
` hs: ${JSON.stringify(
|
|
270
|
+
` hs: ${JSON.stringify(rgb2hs(Number(this.BLE_Red), Number(this.BLE_Green), Number(this.BLE_Blue)))}`);
|
|
218
271
|
// Hue
|
|
219
272
|
this.Hue = hue;
|
|
220
273
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Hue: ${this.Hue}`);
|
|
@@ -249,8 +302,8 @@ class ColorBulb {
|
|
|
249
302
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} red: ${JSON.stringify(red)}`);
|
|
250
303
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} green: ${JSON.stringify(green)}`);
|
|
251
304
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} blue: ${JSON.stringify(blue)}`);
|
|
252
|
-
const [hue, saturation] =
|
|
253
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}` + ` hs: ${JSON.stringify(
|
|
305
|
+
const [hue, saturation] = rgb2hs(Number(red), Number(green), Number(blue));
|
|
306
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}` + ` hs: ${JSON.stringify(rgb2hs(Number(red), Number(green), Number(blue)))}`);
|
|
254
307
|
// Hue
|
|
255
308
|
this.Hue = hue;
|
|
256
309
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Hue: ${this.Hue}`);
|
|
@@ -337,7 +390,7 @@ class ColorBulb {
|
|
|
337
390
|
}
|
|
338
391
|
};
|
|
339
392
|
// Wait
|
|
340
|
-
return await
|
|
393
|
+
return await sleep(this.scanDuration * 1000);
|
|
341
394
|
})
|
|
342
395
|
.then(async () => {
|
|
343
396
|
// Stop to monitor
|
|
@@ -357,7 +410,7 @@ class ColorBulb {
|
|
|
357
410
|
async openAPIRefreshStatus() {
|
|
358
411
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIRefreshStatus`);
|
|
359
412
|
try {
|
|
360
|
-
const { body, statusCode, headers } = await
|
|
413
|
+
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/status`, {
|
|
361
414
|
headers: this.platform.generateHeaders(),
|
|
362
415
|
});
|
|
363
416
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
@@ -414,9 +467,9 @@ class ColorBulb {
|
|
|
414
467
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:` + ` ${this.device.connectionType}, pushChanges will not happen.`);
|
|
415
468
|
}
|
|
416
469
|
// Refresh the status from the API
|
|
417
|
-
|
|
418
|
-
.pipe(
|
|
419
|
-
.pipe(
|
|
470
|
+
interval(15000)
|
|
471
|
+
.pipe(skipWhile(() => this.colorBulbUpdateInProgress))
|
|
472
|
+
.pipe(take(1))
|
|
420
473
|
.subscribe(async () => {
|
|
421
474
|
await this.refreshStatus();
|
|
422
475
|
});
|
|
@@ -554,7 +607,7 @@ class ColorBulb {
|
|
|
554
607
|
if (this.Hue !== this.accessory.context.Hue || this.Saturation !== this.accessory.context.Saturation) {
|
|
555
608
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Hue: ${JSON.stringify(this.Hue)}`);
|
|
556
609
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Saturation: ${JSON.stringify(this.Saturation)}`);
|
|
557
|
-
const [red, green, blue] =
|
|
610
|
+
const [red, green, blue] = hs2rgb(Number(this.Hue), Number(this.Saturation));
|
|
558
611
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} rgb: ${JSON.stringify([red, green, blue])}`);
|
|
559
612
|
const switchbot = await this.platform.connectBLE();
|
|
560
613
|
// Convert to BLE Address
|
|
@@ -605,7 +658,7 @@ class ColorBulb {
|
|
|
605
658
|
});
|
|
606
659
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
607
660
|
try {
|
|
608
|
-
const { body, statusCode, headers } = await
|
|
661
|
+
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
609
662
|
body: bodyChange,
|
|
610
663
|
method: 'POST',
|
|
611
664
|
headers: this.platform.generateHeaders(),
|
|
@@ -655,7 +708,7 @@ class ColorBulb {
|
|
|
655
708
|
if (this.Hue !== this.accessory.context.Hue || this.Saturation !== this.accessory.context.Saturation) {
|
|
656
709
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Hue: ${JSON.stringify(this.Hue)}`);
|
|
657
710
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Saturation: ${JSON.stringify(this.Saturation)}`);
|
|
658
|
-
const [red, green, blue] =
|
|
711
|
+
const [red, green, blue] = hs2rgb(Number(this.Hue), Number(this.Saturation));
|
|
659
712
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} rgb: ${JSON.stringify([red, green, blue])}`);
|
|
660
713
|
const bodyChange = JSON.stringify({
|
|
661
714
|
command: 'setColor',
|
|
@@ -664,7 +717,7 @@ class ColorBulb {
|
|
|
664
717
|
});
|
|
665
718
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
666
719
|
try {
|
|
667
|
-
const { body, statusCode, headers } = await
|
|
720
|
+
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
668
721
|
body: bodyChange,
|
|
669
722
|
method: 'POST',
|
|
670
723
|
headers: this.platform.generateHeaders(),
|
|
@@ -708,7 +761,7 @@ class ColorBulb {
|
|
|
708
761
|
});
|
|
709
762
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
710
763
|
try {
|
|
711
|
-
const { body, statusCode, headers } = await
|
|
764
|
+
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
712
765
|
body: bodyChange,
|
|
713
766
|
method: 'POST',
|
|
714
767
|
headers: this.platform.generateHeaders(),
|
|
@@ -750,7 +803,7 @@ class ColorBulb {
|
|
|
750
803
|
});
|
|
751
804
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
752
805
|
try {
|
|
753
|
-
const { body, statusCode, headers } = await
|
|
806
|
+
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
754
807
|
body: bodyChange,
|
|
755
808
|
method: 'POST',
|
|
756
809
|
headers: this.platform.generateHeaders(),
|
|
@@ -833,9 +886,9 @@ class ColorBulb {
|
|
|
833
886
|
return;
|
|
834
887
|
}
|
|
835
888
|
// Updating the hue/sat to the corresponding values mimics native adaptive lighting
|
|
836
|
-
const hs =
|
|
837
|
-
this.lightBulbService.updateCharacteristic(this.
|
|
838
|
-
this.lightBulbService.updateCharacteristic(this.
|
|
889
|
+
const hs = m2hs(value);
|
|
890
|
+
this.lightBulbService.updateCharacteristic(this.hap.Characteristic.Hue, hs[0]);
|
|
891
|
+
this.lightBulbService.updateCharacteristic(this.hap.Characteristic.Saturation, hs[1]);
|
|
839
892
|
this.ColorTemperature = value;
|
|
840
893
|
this.doColorBulbUpdate.next();
|
|
841
894
|
}
|
|
@@ -852,7 +905,7 @@ class ColorBulb {
|
|
|
852
905
|
else {
|
|
853
906
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Hue: ${value}`);
|
|
854
907
|
}
|
|
855
|
-
this.lightBulbService.updateCharacteristic(this.
|
|
908
|
+
this.lightBulbService.updateCharacteristic(this.hap.Characteristic.ColorTemperature, 140);
|
|
856
909
|
this.Hue = value;
|
|
857
910
|
this.doColorBulbUpdate.next();
|
|
858
911
|
}
|
|
@@ -869,7 +922,7 @@ class ColorBulb {
|
|
|
869
922
|
else {
|
|
870
923
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Saturation: ${value}`);
|
|
871
924
|
}
|
|
872
|
-
this.lightBulbService.updateCharacteristic(this.
|
|
925
|
+
this.lightBulbService.updateCharacteristic(this.hap.Characteristic.ColorTemperature, 140);
|
|
873
926
|
this.Saturation = value;
|
|
874
927
|
this.doColorBulbUpdate.next();
|
|
875
928
|
}
|
|
@@ -880,7 +933,7 @@ class ColorBulb {
|
|
|
880
933
|
}
|
|
881
934
|
else {
|
|
882
935
|
this.accessory.context.On = this.On;
|
|
883
|
-
this.lightBulbService.updateCharacteristic(this.
|
|
936
|
+
this.lightBulbService.updateCharacteristic(this.hap.Characteristic.On, this.On);
|
|
884
937
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
885
938
|
}
|
|
886
939
|
// Brightness
|
|
@@ -889,7 +942,7 @@ class ColorBulb {
|
|
|
889
942
|
}
|
|
890
943
|
else {
|
|
891
944
|
this.accessory.context.Brightness = this.Brightness;
|
|
892
|
-
this.lightBulbService.updateCharacteristic(this.
|
|
945
|
+
this.lightBulbService.updateCharacteristic(this.hap.Characteristic.Brightness, this.Brightness);
|
|
893
946
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Brightness: ${this.Brightness}`);
|
|
894
947
|
}
|
|
895
948
|
// ColorTemperature
|
|
@@ -898,7 +951,7 @@ class ColorBulb {
|
|
|
898
951
|
}
|
|
899
952
|
else {
|
|
900
953
|
this.accessory.context.ColorTemperature = this.ColorTemperature;
|
|
901
|
-
this.lightBulbService.updateCharacteristic(this.
|
|
954
|
+
this.lightBulbService.updateCharacteristic(this.hap.Characteristic.ColorTemperature, this.ColorTemperature);
|
|
902
955
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic ColorTemperature: ${this.ColorTemperature}`);
|
|
903
956
|
}
|
|
904
957
|
// Hue
|
|
@@ -907,7 +960,7 @@ class ColorBulb {
|
|
|
907
960
|
}
|
|
908
961
|
else {
|
|
909
962
|
this.accessory.context.Hue = this.Hue;
|
|
910
|
-
this.lightBulbService.updateCharacteristic(this.
|
|
963
|
+
this.lightBulbService.updateCharacteristic(this.hap.Characteristic.Hue, this.Hue);
|
|
911
964
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Hue: ${this.Hue}`);
|
|
912
965
|
}
|
|
913
966
|
// Saturation
|
|
@@ -916,7 +969,7 @@ class ColorBulb {
|
|
|
916
969
|
}
|
|
917
970
|
else {
|
|
918
971
|
this.accessory.context.Saturation = this.Saturation;
|
|
919
|
-
this.lightBulbService.updateCharacteristic(this.
|
|
972
|
+
this.lightBulbService.updateCharacteristic(this.hap.Characteristic.Saturation, this.Saturation);
|
|
920
973
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Saturation: ${this.Saturation}`);
|
|
921
974
|
}
|
|
922
975
|
}
|
|
@@ -952,7 +1005,7 @@ class ColorBulb {
|
|
|
952
1005
|
switchbot.onadvertisement = (ad) => {
|
|
953
1006
|
this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} ad: ${JSON.stringify(ad, null, ' ')}`);
|
|
954
1007
|
};
|
|
955
|
-
await
|
|
1008
|
+
await sleep(10000);
|
|
956
1009
|
// Stop to monitor
|
|
957
1010
|
await switchbot.stopScan();
|
|
958
1011
|
})();
|
|
@@ -978,7 +1031,7 @@ class ColorBulb {
|
|
|
978
1031
|
}
|
|
979
1032
|
this.infoLog(e);
|
|
980
1033
|
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Retrying`);
|
|
981
|
-
await
|
|
1034
|
+
await sleep(1000);
|
|
982
1035
|
return this.retry({ max: max - 1, fn });
|
|
983
1036
|
});
|
|
984
1037
|
}
|
|
@@ -1055,11 +1108,11 @@ class ColorBulb {
|
|
|
1055
1108
|
}
|
|
1056
1109
|
}
|
|
1057
1110
|
apiError(e) {
|
|
1058
|
-
this.lightBulbService.updateCharacteristic(this.
|
|
1059
|
-
this.lightBulbService.updateCharacteristic(this.
|
|
1060
|
-
this.lightBulbService.updateCharacteristic(this.
|
|
1061
|
-
this.lightBulbService.updateCharacteristic(this.
|
|
1062
|
-
this.lightBulbService.updateCharacteristic(this.
|
|
1111
|
+
this.lightBulbService.updateCharacteristic(this.hap.Characteristic.On, e);
|
|
1112
|
+
this.lightBulbService.updateCharacteristic(this.hap.Characteristic.Hue, e);
|
|
1113
|
+
this.lightBulbService.updateCharacteristic(this.hap.Characteristic.Brightness, e);
|
|
1114
|
+
this.lightBulbService.updateCharacteristic(this.hap.Characteristic.Saturation, e);
|
|
1115
|
+
this.lightBulbService.updateCharacteristic(this.hap.Characteristic.ColorTemperature, e);
|
|
1063
1116
|
}
|
|
1064
1117
|
async context() {
|
|
1065
1118
|
if (this.On === undefined) {
|
|
@@ -1109,7 +1162,7 @@ class ColorBulb {
|
|
|
1109
1162
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
1110
1163
|
}
|
|
1111
1164
|
}
|
|
1112
|
-
async
|
|
1165
|
+
async deviceConfig(device) {
|
|
1113
1166
|
let config = {};
|
|
1114
1167
|
if (device.colorbulb) {
|
|
1115
1168
|
config = device.colorbulb;
|
|
@@ -1139,7 +1192,7 @@ class ColorBulb {
|
|
|
1139
1192
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
1140
1193
|
}
|
|
1141
1194
|
}
|
|
1142
|
-
async
|
|
1195
|
+
async deviceLogs(device) {
|
|
1143
1196
|
if (this.platform.debugMode) {
|
|
1144
1197
|
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
1145
1198
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
@@ -1203,5 +1256,4 @@ class ColorBulb {
|
|
|
1203
1256
|
return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
|
|
1204
1257
|
}
|
|
1205
1258
|
}
|
|
1206
|
-
exports.ColorBulb = ColorBulb;
|
|
1207
1259
|
//# sourceMappingURL=colorbulb.js.map
|