@switchbot/homebridge-switchbot 2.14.1-beta.0 → 3.0.0-beta.1
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.js → npm-version-script.cjs} +1 -1
- package/.github/workflows/dependabot.yml +10 -11
- package/CHANGELOG.md +11 -2
- package/LICENSE +1 -1
- package/dist/device/blindtilt.d.ts +10 -6
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +152 -91
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +10 -6
- 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 +10 -6
- 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 +10 -6
- 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 +10 -6
- 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 +10 -6
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +165 -107
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts +10 -6
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +88 -51
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +10 -6
- 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 +10 -6
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +109 -66
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +10 -6
- 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 +11 -7
- 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 +10 -6
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +103 -63
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +10 -6
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +103 -63
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +10 -6
- 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 +10 -6
- 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 +10 -6
- 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.js +5 -10
- package/dist/homebridge-ui/server.js.map +1 -1
- 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 +9 -5
- 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 +9 -5
- 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 +9 -5
- 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 +9 -5
- 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 +9 -5
- 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 +9 -5
- 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 +9 -5
- 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 +9 -5
- 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 +9 -5
- 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 +151 -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 +20 -9
- package/src/device/blindtilt.ts +84 -72
- package/src/device/bot.ts +191 -180
- package/src/device/ceilinglight.ts +57 -44
- package/src/device/colorbulb.ts +53 -40
- package/src/device/contact.ts +71 -60
- package/src/device/curtain.ts +98 -86
- package/src/device/hub.ts +57 -45
- package/src/device/humidifier.ts +88 -77
- package/src/device/iosensor.ts +67 -55
- package/src/device/lightstrip.ts +56 -43
- package/src/device/lock.ts +91 -81
- package/src/device/meter.ts +63 -51
- package/src/device/meterplus.ts +67 -55
- package/src/device/motion.ts +58 -47
- package/src/device/plug.ts +38 -27
- package/src/device/robotvacuumcleaner.ts +49 -38
- package/src/index.ts +10 -7
- package/src/irdevice/airconditioner.ts +71 -63
- package/src/irdevice/airpurifier.ts +48 -40
- package/src/irdevice/camera.ts +28 -20
- package/src/irdevice/fan.ts +42 -34
- package/src/irdevice/light.ts +48 -40
- package/src/irdevice/other.ts +164 -156
- package/src/irdevice/tv.ts +66 -58
- package/src/irdevice/vacuumcleaner.ts +28 -20
- package/src/irdevice/waterheater.ts +35 -27
- package/src/platform.ts +65 -47
- package/tsconfig.json +11 -13
package/src/platform.ts
CHANGED
|
@@ -1,41 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import
|
|
1
|
+
/* Copyright(C) 2017-2023, donavanbecker (https://github.com/donavanbecker). All rights reserved.
|
|
2
|
+
*
|
|
3
|
+
* protect-platform.ts: homebridge-cloudflared-tunnel platform class.
|
|
4
|
+
*/
|
|
5
|
+
import { API, DynamicPlatformPlugin, Logging, PlatformAccessory } from 'homebridge';
|
|
6
|
+
import { PLATFORM_NAME, PLUGIN_NAME, irdevice, device, SwitchBotPlatformConfig, devicesConfig, irDevicesConfig, Devices } from './settings.js';
|
|
7
|
+
import { Bot } from './device/bot.js';
|
|
8
|
+
import { Plug } from './device/plug.js';
|
|
9
|
+
import { Lock } from './device/lock.js';
|
|
10
|
+
import { Meter } from './device/meter.js';
|
|
11
|
+
import { Motion } from './device/motion.js';
|
|
12
|
+
import { Hub } from './device/hub.js';
|
|
13
|
+
import { Contact } from './device/contact.js';
|
|
14
|
+
import { Curtain } from './device/curtain.js';
|
|
15
|
+
import { IOSensor } from './device/iosensor.js';
|
|
16
|
+
import { MeterPlus } from './device/meterplus.js';
|
|
17
|
+
import { ColorBulb } from './device/colorbulb.js';
|
|
18
|
+
import { CeilingLight } from './device/ceilinglight.js';
|
|
19
|
+
import { StripLight } from './device/lightstrip.js';
|
|
20
|
+
import { Humidifier } from './device/humidifier.js';
|
|
21
|
+
import { RobotVacuumCleaner } from './device/robotvacuumcleaner.js';
|
|
22
|
+
import { TV } from './irdevice/tv.js';
|
|
23
|
+
import { Fan } from './irdevice/fan.js';
|
|
24
|
+
import { Light } from './irdevice/light.js';
|
|
25
|
+
import { Others } from './irdevice/other.js';
|
|
26
|
+
import { Camera } from './irdevice/camera.js';
|
|
27
|
+
import { BlindTilt } from './device/blindtilt.js';
|
|
28
|
+
import { AirPurifier } from './irdevice/airpurifier.js';
|
|
29
|
+
import { WaterHeater } from './irdevice/waterheater.js';
|
|
30
|
+
import { VacuumCleaner } from './irdevice/vacuumcleaner.js';
|
|
31
|
+
import { AirConditioner } from './irdevice/airconditioner.js';
|
|
32
|
+
import * as http from 'http';
|
|
28
33
|
import { Buffer } from 'buffer';
|
|
34
|
+
import { request } from 'undici';
|
|
35
|
+
import { MqttClient } from 'mqtt';
|
|
29
36
|
import { queueScheduler } from 'rxjs';
|
|
30
37
|
import fakegato from 'fakegato-history';
|
|
31
|
-
import
|
|
32
|
-
import {
|
|
33
|
-
import { connectAsync } from 'async-mqtt';
|
|
34
|
-
import * as http from 'http';
|
|
35
|
-
|
|
38
|
+
import asyncmqtt from 'async-mqtt';
|
|
39
|
+
import crypto, { randomUUID } from 'crypto';
|
|
36
40
|
import { readFileSync, writeFileSync } from 'fs';
|
|
37
|
-
import
|
|
38
|
-
|
|
41
|
+
import hbLib from 'homebridge-lib';
|
|
42
|
+
|
|
39
43
|
|
|
40
44
|
/**
|
|
41
45
|
* HomebridgePlatform
|
|
@@ -43,15 +47,15 @@ import { PLATFORM_NAME, PLUGIN_NAME, irdevice, device, SwitchBotPlatformConfig,
|
|
|
43
47
|
* parse the user config and discover/register accessories with Homebridge.
|
|
44
48
|
*/
|
|
45
49
|
export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
46
|
-
public
|
|
47
|
-
public readonly
|
|
48
|
-
|
|
49
|
-
// this is used to track restored cached accessories
|
|
50
|
-
public readonly accessories: PlatformAccessory[] = [];
|
|
50
|
+
public accessories: PlatformAccessory[];
|
|
51
|
+
public readonly api: API;
|
|
52
|
+
public readonly log: Logging;
|
|
51
53
|
|
|
52
|
-
version = process.env.npm_package_version || '2.
|
|
54
|
+
version = process.env.npm_package_version || '2.13.0';
|
|
55
|
+
Logging?: string;
|
|
53
56
|
debugMode!: boolean;
|
|
54
57
|
platformLogging?: string;
|
|
58
|
+
config!: SwitchBotPlatformConfig;
|
|
55
59
|
webhookEventListener: http.Server | null = null;
|
|
56
60
|
mqttClient: MqttClient | null = null;
|
|
57
61
|
|
|
@@ -59,18 +63,30 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
59
63
|
public readonly eve: any;
|
|
60
64
|
public readonly webhookEventHandler: { [x: string]: (context: { [x: string]: any }) => void } = {};
|
|
61
65
|
|
|
62
|
-
constructor(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
) {
|
|
67
|
-
this.logs();
|
|
68
|
-
this.debugLog('Finished initializing platform:', this.config.name);
|
|
66
|
+
constructor(log: Logging, config: SwitchBotPlatformConfig, api: API) {
|
|
67
|
+
this.accessories = [];
|
|
68
|
+
this.api = api;
|
|
69
|
+
this.log = log;
|
|
69
70
|
// only load if configured
|
|
70
71
|
if (!this.config) {
|
|
71
72
|
return;
|
|
72
73
|
}
|
|
73
74
|
|
|
75
|
+
// Plugin options into our config variables.
|
|
76
|
+
this.config = {
|
|
77
|
+
platform: 'SwitchBotPlatform',
|
|
78
|
+
name: config.name,
|
|
79
|
+
credentials: config.credentials as object,
|
|
80
|
+
url: config.url as string,
|
|
81
|
+
port: config.port as number,
|
|
82
|
+
hostname: config.hostname as string,
|
|
83
|
+
protocol: config.protocol as string,
|
|
84
|
+
verifyTLS: config.verifyTLS as boolean,
|
|
85
|
+
logging: config.logging as string,
|
|
86
|
+
};
|
|
87
|
+
this.logs();
|
|
88
|
+
this.debugLog(`Finished initializing platform: ${config.name}`);
|
|
89
|
+
|
|
74
90
|
// HOOBS notice
|
|
75
91
|
if (__dirname.includes('hoobs')) {
|
|
76
92
|
this.warnLog(
|
|
@@ -90,6 +106,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
90
106
|
}
|
|
91
107
|
|
|
92
108
|
// import fakegato-history module and EVE characteristics
|
|
109
|
+
const { EveHomeKitTypes } = hbLib;
|
|
93
110
|
this.fakegatoAPI = fakegato(api);
|
|
94
111
|
this.eve = new EveHomeKitTypes(api);
|
|
95
112
|
|
|
@@ -122,6 +139,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
122
139
|
async setupMqtt(): Promise<void> {
|
|
123
140
|
if (this.config.options?.mqttURL) {
|
|
124
141
|
try {
|
|
142
|
+
const { connectAsync } = asyncmqtt;
|
|
125
143
|
this.mqttClient = await connectAsync(this.config.options?.mqttURL, this.config.options.mqttOptions || {});
|
|
126
144
|
this.debugLog('MQTT connection has been established successfully.');
|
|
127
145
|
this.mqttClient.on('error', (e: Error) => {
|
package/tsconfig.json
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
4
|
-
"module": "
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ES2022",
|
|
5
5
|
"lib": [
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"ES2017",
|
|
9
|
-
"ES2018",
|
|
10
|
-
"ES2019",
|
|
11
|
-
"ES2020",
|
|
12
|
-
"ES2021"
|
|
6
|
+
"DOM",
|
|
7
|
+
"ES2022"
|
|
13
8
|
],
|
|
14
9
|
"declaration": true,
|
|
15
10
|
"declarationMap": true,
|
|
16
11
|
"sourceMap": true,
|
|
17
|
-
"outDir": "
|
|
18
|
-
"rootDir": "
|
|
12
|
+
"outDir": "dist",
|
|
13
|
+
"rootDir": "src",
|
|
19
14
|
"strict": true,
|
|
20
15
|
"esModuleInterop": true,
|
|
21
|
-
"noImplicitAny": false
|
|
16
|
+
"noImplicitAny": false,
|
|
17
|
+
"allowSyntheticDefaultImports": true,
|
|
18
|
+
"forceConsistentCasingInFileNames": true,
|
|
19
|
+
"moduleResolution": "node",
|
|
22
20
|
},
|
|
23
21
|
"include": [
|
|
24
|
-
"src
|
|
22
|
+
"src"
|
|
25
23
|
],
|
|
26
24
|
"exclude": [
|
|
27
25
|
"**/*.spec.ts"
|