@switchbot/homebridge-switchbot 3.7.1-beta.8 → 3.8.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/CHANGELOG.md +8 -2
- package/README.md +14 -0
- package/assets/security-privacy-bluetooth.png +0 -0
- package/config.schema.json +78 -3
- package/dist/device/blindtilt.d.ts +18 -8
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +108 -70
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +9 -9
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +143 -170
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +13 -13
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +38 -73
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +12 -12
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +41 -79
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +5 -5
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +20 -42
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +15 -5
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +127 -81
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +18 -18
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +33 -36
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts +8 -8
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +43 -75
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts +5 -5
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +18 -39
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +5 -5
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +38 -78
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +5 -5
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +21 -40
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +6 -6
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +34 -73
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +9 -9
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +37 -52
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +5 -5
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +21 -39
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +5 -5
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +21 -38
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +5 -5
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +14 -32
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +12 -12
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +16 -25
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +11 -11
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +42 -56
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts +5 -5
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +47 -44
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/homebridge-ui/server.js +2 -2
- package/dist/homebridge-ui/server.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -4
- package/dist/index.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +8 -8
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +61 -105
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +10 -10
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +22 -42
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +9 -9
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +15 -25
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +8 -8
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +21 -40
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +11 -11
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js +14 -22
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts +9 -9
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +24 -47
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +9 -9
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +40 -83
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +9 -9
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +29 -54
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +5 -5
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +11 -21
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +5 -5
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +11 -22
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +24 -23
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +471 -715
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +6 -3
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/dist/types/bledevicestatus.d.ts +9 -9
- package/dist/types/bledevicestatus.d.ts.map +1 -1
- package/dist/types/devicelist.d.ts +6 -6
- package/dist/types/devicelist.d.ts.map +1 -1
- package/dist/types/deviceresponse.d.ts +4 -4
- package/dist/types/deviceresponse.d.ts.map +1 -1
- package/dist/types/devicestatus.d.ts +2 -2
- package/dist/types/devicestatus.d.ts.map +1 -1
- package/dist/types/devicewebhookstatus.d.ts +5 -5
- package/dist/types/devicewebhookstatus.d.ts.map +1 -1
- package/dist/types/irdevicelist.d.ts +4 -4
- package/dist/types/irdevicelist.d.ts.map +1 -1
- package/dist/types/pushbody.d.ts +2 -2
- package/dist/types/pushbody.d.ts.map +1 -1
- package/dist/utils.d.ts +4 -4
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +9 -13
- package/dist/utils.js.map +1 -1
- package/eslint.config.js +48 -93
- package/package.json +62 -55
- package/src/device/blindtilt.ts +509 -460
- package/src/device/bot.ts +696 -718
- package/src/device/ceilinglight.ts +331 -364
- package/src/device/colorbulb.ts +412 -448
- package/src/device/contact.ts +200 -221
- package/src/device/curtain.ts +506 -444
- package/src/device/device.ts +206 -208
- package/src/device/fan.ts +307 -340
- package/src/device/hub.ts +184 -209
- package/src/device/humidifier.ts +297 -342
- package/src/device/iosensor.ts +182 -204
- package/src/device/lightstrip.ts +362 -399
- package/src/device/lock.ts +262 -276
- package/src/device/meter.ts +183 -205
- package/src/device/meterplus.ts +183 -204
- package/src/device/motion.ts +169 -185
- package/src/device/plug.ts +174 -177
- package/src/device/robotvacuumcleaner.ts +256 -269
- package/src/device/waterdetector.ts +185 -185
- package/src/homebridge-ui/server.ts +16 -15
- package/src/index.ts +5 -6
- package/src/irdevice/airconditioner.ts +277 -326
- package/src/irdevice/airpurifier.ts +124 -143
- package/src/irdevice/camera.ts +58 -64
- package/src/irdevice/fan.ts +106 -123
- package/src/irdevice/irdevice.ts +116 -119
- package/src/irdevice/light.ts +119 -143
- package/src/irdevice/other.ts +417 -461
- package/src/irdevice/tv.ts +155 -177
- package/src/irdevice/vacuumcleaner.ts +54 -60
- package/src/irdevice/waterheater.ts +56 -63
- package/src/platform.ts +1467 -1683
- package/src/settings.ts +173 -170
- package/src/types/bledevicestatus.ts +252 -256
- package/src/types/devicelist.ts +79 -79
- package/src/types/deviceresponse.ts +12 -13
- package/src/types/devicestatus.ts +124 -124
- package/src/types/devicewebhookstatus.ts +126 -131
- package/src/types/irdevicelist.ts +10 -10
- package/src/types/pushbody.ts +5 -5
- package/src/utils.ts +64 -65
- package/tsconfig.json +10 -9
- package/.github/npm-version-script.cjs +0 -81
|
@@ -2,195 +2,190 @@
|
|
|
2
2
|
*
|
|
3
3
|
* devicestatus.ts: @switchbot/homebridge-switchbot platform class.
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
eventType: string,
|
|
9
|
-
eventVersion: string,
|
|
5
|
+
interface deviceWebhook {
|
|
6
|
+
eventType: string
|
|
7
|
+
eventVersion: string
|
|
10
8
|
context: deviceWebhookContext
|
|
11
|
-
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { deviceWebhook }
|
|
12
12
|
|
|
13
|
-
export
|
|
14
|
-
//properties on all devices
|
|
15
|
-
deviceMac: string
|
|
16
|
-
deviceType: string
|
|
13
|
+
export interface deviceWebhookContext {
|
|
14
|
+
// properties on all devices
|
|
15
|
+
deviceMac: string
|
|
16
|
+
deviceType: string
|
|
17
17
|
timeOfSample: number
|
|
18
|
-
}
|
|
18
|
+
}
|
|
19
19
|
|
|
20
20
|
export type botWebhookContext = deviceWebhookContext & {
|
|
21
|
-
power: string
|
|
22
|
-
battery: number
|
|
23
|
-
deviceMode: 'pressMode' | 'switchMode' | 'customizeMode'
|
|
24
|
-
}
|
|
21
|
+
power: string // "on"or"off"
|
|
22
|
+
battery: number
|
|
23
|
+
deviceMode: 'pressMode' | 'switchMode' | 'customizeMode'
|
|
24
|
+
}
|
|
25
25
|
|
|
26
26
|
export type curtainWebhookContext = deviceWebhookContext & {
|
|
27
|
-
calibrate: boolean
|
|
28
|
-
group: boolean
|
|
29
|
-
slidePosition: number
|
|
30
|
-
battery: number
|
|
31
|
-
}
|
|
27
|
+
calibrate: boolean
|
|
28
|
+
group: boolean
|
|
29
|
+
slidePosition: number // 0~100
|
|
30
|
+
battery: number
|
|
31
|
+
}
|
|
32
32
|
|
|
33
33
|
export type curtain3WebhookContext = deviceWebhookContext & {
|
|
34
|
-
calibrate: boolean
|
|
35
|
-
group: boolean
|
|
36
|
-
slidePosition: number
|
|
37
|
-
battery: number
|
|
38
|
-
}
|
|
34
|
+
calibrate: boolean
|
|
35
|
+
group: boolean
|
|
36
|
+
slidePosition: number // 0~100
|
|
37
|
+
battery: number
|
|
38
|
+
}
|
|
39
39
|
|
|
40
40
|
export type motionSensorWebhookContext = deviceWebhookContext & {
|
|
41
|
-
detectionState: 'NOT_DETECTED' | 'DETECTED'
|
|
42
|
-
}
|
|
41
|
+
detectionState: 'NOT_DETECTED' | 'DETECTED'
|
|
42
|
+
}
|
|
43
43
|
|
|
44
44
|
export type contactSensorWebhookContext = deviceWebhookContext & {
|
|
45
|
-
detectionState: 'NOT_DETECTED' | 'DETECTED'
|
|
46
|
-
doorMode: 'IN_DOOR' | 'OUT_DOOR'
|
|
47
|
-
brightness: 'dim' | 'bright'
|
|
48
|
-
openState: 'open' | 'close' | 'timeOutNotClose'
|
|
49
|
-
}
|
|
45
|
+
detectionState: 'NOT_DETECTED' | 'DETECTED'
|
|
46
|
+
doorMode: 'IN_DOOR' | 'OUT_DOOR'
|
|
47
|
+
brightness: 'dim' | 'bright'
|
|
48
|
+
openState: 'open' | 'close' | 'timeOutNotClose'
|
|
49
|
+
}
|
|
50
50
|
|
|
51
51
|
export type waterLeakDetectorWebhookContext = deviceWebhookContext & {
|
|
52
|
-
detectionState: 0 | 1
|
|
53
|
-
battery: number
|
|
54
|
-
}
|
|
52
|
+
detectionState: 0 | 1
|
|
53
|
+
battery: number // 0~100
|
|
54
|
+
}
|
|
55
55
|
|
|
56
56
|
export type meterWebhookContext = deviceWebhookContext & {
|
|
57
|
-
temperature: number
|
|
58
|
-
scale: 'CELSIUS' | 'FAHRENHEIT'
|
|
59
|
-
humidity: number
|
|
60
|
-
}
|
|
57
|
+
temperature: number
|
|
58
|
+
scale: 'CELSIUS' | 'FAHRENHEIT'
|
|
59
|
+
humidity: number
|
|
60
|
+
}
|
|
61
61
|
|
|
62
62
|
export type meterPlusWebhookContext = deviceWebhookContext & {
|
|
63
|
-
temperature: number
|
|
64
|
-
scale: 'CELSIUS' | 'FAHRENHEIT'
|
|
65
|
-
humidity: number
|
|
66
|
-
}
|
|
63
|
+
temperature: number
|
|
64
|
+
scale: 'CELSIUS' | 'FAHRENHEIT'
|
|
65
|
+
humidity: number
|
|
66
|
+
}
|
|
67
67
|
|
|
68
68
|
export type outdoorMeterWebhookContext = deviceWebhookContext & {
|
|
69
|
-
temperature: number
|
|
70
|
-
scale: 'CELSIUS' | 'FAHRENHEIT'
|
|
71
|
-
humidity: number
|
|
72
|
-
}
|
|
69
|
+
temperature: number
|
|
70
|
+
scale: 'CELSIUS' | 'FAHRENHEIT'
|
|
71
|
+
humidity: number
|
|
72
|
+
}
|
|
73
73
|
|
|
74
74
|
export type lockWebhookContext = deviceWebhookContext & {
|
|
75
|
-
lockState: 'UNLOCKED' | 'LOCKED' | 'JAMMED'
|
|
76
|
-
}
|
|
75
|
+
lockState: 'UNLOCKED' | 'LOCKED' | 'JAMMED'
|
|
76
|
+
}
|
|
77
77
|
|
|
78
78
|
export type lockProWebhookContext = deviceWebhookContext & {
|
|
79
|
-
lockState: 'UNLOCKED' | 'LOCKED' | 'JAMMED'
|
|
80
|
-
}
|
|
79
|
+
lockState: 'UNLOCKED' | 'LOCKED' | 'JAMMED'
|
|
80
|
+
}
|
|
81
81
|
|
|
82
82
|
export type indoorCameraWebhookContext = deviceWebhookContext & {
|
|
83
|
-
detectionState: 'DETECTED'
|
|
84
|
-
}
|
|
83
|
+
detectionState: 'DETECTED'
|
|
84
|
+
}
|
|
85
85
|
|
|
86
86
|
export type panTiltCamWebhookContext = deviceWebhookContext & {
|
|
87
|
-
detectionState: 'DETECTED'
|
|
88
|
-
}
|
|
87
|
+
detectionState: 'DETECTED'
|
|
88
|
+
}
|
|
89
89
|
|
|
90
90
|
export type colorBulbWebhookContext = deviceWebhookContext & {
|
|
91
|
-
powerState: 'ON' | 'OFF'
|
|
92
|
-
brightness: number
|
|
93
|
-
color: string
|
|
94
|
-
colorTemperature: number
|
|
95
|
-
}
|
|
91
|
+
powerState: 'ON' | 'OFF'
|
|
92
|
+
brightness: number
|
|
93
|
+
color: string // RGB 255:255:255
|
|
94
|
+
colorTemperature: number // 2700~6500
|
|
95
|
+
}
|
|
96
96
|
|
|
97
97
|
export type stripLightWebhookContext = deviceWebhookContext & {
|
|
98
|
-
powerState: 'ON' | 'OFF'
|
|
99
|
-
brightness: number
|
|
100
|
-
color: string
|
|
101
|
-
}
|
|
98
|
+
powerState: 'ON' | 'OFF'
|
|
99
|
+
brightness: number
|
|
100
|
+
color: string // RGB 255:255:255
|
|
101
|
+
}
|
|
102
102
|
|
|
103
103
|
export type plugWebhookContext = deviceWebhookContext & {
|
|
104
|
-
powerState: 'ON' | 'OFF'
|
|
105
|
-
}
|
|
104
|
+
powerState: 'ON' | 'OFF'
|
|
105
|
+
}
|
|
106
106
|
|
|
107
107
|
export type plugMiniUSWebhookContext = deviceWebhookContext & {
|
|
108
|
-
powerState: 'ON' | 'OFF'
|
|
109
|
-
}
|
|
108
|
+
powerState: 'ON' | 'OFF'
|
|
109
|
+
}
|
|
110
110
|
|
|
111
111
|
export type plugMiniJPWebhookContext = deviceWebhookContext & {
|
|
112
|
-
powerState: 'ON' | 'OFF'
|
|
113
|
-
}
|
|
112
|
+
powerState: 'ON' | 'OFF'
|
|
113
|
+
}
|
|
114
114
|
|
|
115
115
|
export type robotVacuumCleanerS1WebhookContext = deviceWebhookContext & {
|
|
116
|
-
workingStatus: 'Standby' | 'Clearing' | 'Paused' | 'GotoChargeBase' | 'Charging' | 'ChargeDone' | 'Dormant' | 'InTrouble'
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
};
|
|
116
|
+
workingStatus: 'Standby' | 'Clearing' | 'Paused' | 'GotoChargeBase' | 'Charging' | 'ChargeDone' | 'Dormant' | 'InTrouble' | 'InRemoteControl' | 'InDustCollecting'
|
|
117
|
+
onlineStatus: 'online' | 'offline'
|
|
118
|
+
battery: number // 0~100
|
|
119
|
+
}
|
|
121
120
|
|
|
122
121
|
export type robotVacuumCleanerS1PlusWebhookContext = deviceWebhookContext & {
|
|
123
|
-
workingStatus: 'Standby' | 'Clearing' | 'Paused' | 'GotoChargeBase' | 'Charging' | 'ChargeDone' | 'Dormant' | 'InTrouble'
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
};
|
|
122
|
+
workingStatus: 'Standby' | 'Clearing' | 'Paused' | 'GotoChargeBase' | 'Charging' | 'ChargeDone' | 'Dormant' | 'InTrouble' | 'InRemoteControl' | 'InDustCollecting'
|
|
123
|
+
onlineStatus: 'online' | 'offline'
|
|
124
|
+
battery: number // 0~100
|
|
125
|
+
}
|
|
128
126
|
|
|
129
127
|
export type floorCleaningRobotS10WebhookContext = deviceWebhookContext & {
|
|
130
|
-
workingStatus: 'Standby' | 'Clearing' | 'Paused' | 'GotoChargeBase' | 'Charging' | 'ChargeDone' | 'Dormant' | 'InTrouble'
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
| 'drying' | 'collectDust' | 'remoteControl' | 'cleanWithExplorer' | 'fillWaterForHumi' | 'markingHumi',
|
|
137
|
-
};
|
|
128
|
+
workingStatus: 'Standby' | 'Clearing' | 'Paused' | 'GotoChargeBase' | 'Charging' | 'ChargeDone' | 'Dormant' | 'InTrouble' | 'InRemoteControl' | 'InDustCollecting'
|
|
129
|
+
onlineStatus: 'online' | 'offline'
|
|
130
|
+
battery: number // 0~100
|
|
131
|
+
waterBaseBattery: number // 0~100
|
|
132
|
+
taskType: 'standBy' | 'explore' | 'cleanAll' | 'cleanArea' | 'cleanRoom' | 'fillWater' | 'deepWashing' | 'backToCharge' | 'markingWaterBase' | 'drying' | 'collectDust' | 'remoteControl' | 'cleanWithExplorer' | 'fillWaterForHumi' | 'markingHumi'
|
|
133
|
+
}
|
|
138
134
|
|
|
139
135
|
export type ceilingLightWebhookContext = deviceWebhookContext & {
|
|
140
|
-
powerState: 'ON' | 'OFF'
|
|
141
|
-
brightness: number
|
|
142
|
-
colorTemperature: number
|
|
143
|
-
}
|
|
136
|
+
powerState: 'ON' | 'OFF'
|
|
137
|
+
brightness: number
|
|
138
|
+
colorTemperature: number // 2700~6500
|
|
139
|
+
}
|
|
144
140
|
|
|
145
141
|
export type ceilingLightProWebhookContext = deviceWebhookContext & {
|
|
146
|
-
powerState: 'ON' | 'OFF'
|
|
147
|
-
brightness: number
|
|
148
|
-
colorTemperature: number
|
|
149
|
-
}
|
|
142
|
+
powerState: 'ON' | 'OFF'
|
|
143
|
+
brightness: number
|
|
144
|
+
colorTemperature: number // 2700~6500
|
|
145
|
+
}
|
|
150
146
|
|
|
151
147
|
export type keypadWebhookContext = deviceWebhookContext & {
|
|
152
|
-
eventName: 'createKey' | 'deleteKey'
|
|
153
|
-
commandId: string
|
|
154
|
-
result: 'success' | 'failed' | 'timeout'
|
|
155
|
-
}
|
|
148
|
+
eventName: 'createKey' | 'deleteKey'
|
|
149
|
+
commandId: string
|
|
150
|
+
result: 'success' | 'failed' | 'timeout'
|
|
151
|
+
}
|
|
156
152
|
|
|
157
153
|
export type keypadTouchWebhookContext = deviceWebhookContext & {
|
|
158
|
-
eventName: 'createKey' | 'deleteKey'
|
|
159
|
-
commandId: string
|
|
160
|
-
result: 'success' | 'failed' | 'timeout'
|
|
161
|
-
}
|
|
154
|
+
eventName: 'createKey' | 'deleteKey'
|
|
155
|
+
commandId: string
|
|
156
|
+
result: 'success' | 'failed' | 'timeout'
|
|
157
|
+
}
|
|
162
158
|
|
|
163
159
|
export type hub2WebhookContext = deviceWebhookContext & {
|
|
164
|
-
temperature: number
|
|
165
|
-
humidity: number
|
|
166
|
-
lightLevel: number
|
|
167
|
-
scale: 'CELSIUS' | 'FAHRENHEIT'
|
|
168
|
-
}
|
|
160
|
+
temperature: number
|
|
161
|
+
humidity: number
|
|
162
|
+
lightLevel: number
|
|
163
|
+
scale: 'CELSIUS' | 'FAHRENHEIT'
|
|
164
|
+
}
|
|
169
165
|
|
|
170
166
|
export type batteryCirculatorFanWebhookContext = deviceWebhookContext & {
|
|
171
|
-
mode: 'direct' | 'natural' | 'sleep' | 'baby'
|
|
172
|
-
version: string
|
|
173
|
-
battery: number
|
|
174
|
-
powerState: 'ON' | 'OFF'
|
|
175
|
-
nightStatus: 'off' | 1 | 2
|
|
176
|
-
oscillation: 'on' | 'off'
|
|
177
|
-
verticalOscillation: 'on' | 'off'
|
|
178
|
-
chargingStatus: 'charging' | 'uncharged'
|
|
179
|
-
fanSpeed: number
|
|
180
|
-
}
|
|
167
|
+
mode: 'direct' | 'natural' | 'sleep' | 'baby'
|
|
168
|
+
version: string
|
|
169
|
+
battery: number
|
|
170
|
+
powerState: 'ON' | 'OFF'
|
|
171
|
+
nightStatus: 'off' | 1 | 2
|
|
172
|
+
oscillation: 'on' | 'off'
|
|
173
|
+
verticalOscillation: 'on' | 'off'
|
|
174
|
+
chargingStatus: 'charging' | 'uncharged'
|
|
175
|
+
fanSpeed: number // 1~100
|
|
176
|
+
}
|
|
181
177
|
|
|
182
178
|
export type blindTiltWebhookContext = deviceWebhookContext & {
|
|
183
|
-
version: string
|
|
184
|
-
calibrate: boolean
|
|
185
|
-
group: boolean
|
|
186
|
-
direction: string
|
|
187
|
-
slidePosition: number
|
|
188
|
-
battery: number
|
|
189
|
-
}
|
|
179
|
+
version: string
|
|
180
|
+
calibrate: boolean
|
|
181
|
+
group: boolean
|
|
182
|
+
direction: string
|
|
183
|
+
slidePosition: number // 0~100
|
|
184
|
+
battery: number
|
|
185
|
+
}
|
|
190
186
|
|
|
191
187
|
export type humidifierWebhookContext = deviceWebhookContext & {
|
|
192
|
-
temperature: number
|
|
193
|
-
humidity: number
|
|
194
|
-
scale: 'CELSIUS' | 'FAHRENHEIT'
|
|
195
|
-
}
|
|
196
|
-
|
|
188
|
+
temperature: number
|
|
189
|
+
humidity: number
|
|
190
|
+
scale: 'CELSIUS' | 'FAHRENHEIT'
|
|
191
|
+
}
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
*
|
|
3
3
|
* irdevicelist.ts: @switchbot/homebridge-switchbot platform class.
|
|
4
4
|
*/
|
|
5
|
-
//a list of virtual infrared remote devices that are linked to SwitchBot Hubs.
|
|
6
|
-
export
|
|
7
|
-
device: irdevice[]
|
|
8
|
-
}
|
|
5
|
+
// a list of virtual infrared remote devices that are linked to SwitchBot Hubs.
|
|
6
|
+
export interface infraredRemoteList {
|
|
7
|
+
device: irdevice[]
|
|
8
|
+
}
|
|
9
9
|
|
|
10
|
-
export
|
|
11
|
-
deviceId?: string
|
|
12
|
-
deviceName: string
|
|
13
|
-
remoteType: string
|
|
14
|
-
hubDeviceId: string
|
|
15
|
-
}
|
|
10
|
+
export interface irdevice {
|
|
11
|
+
deviceId?: string
|
|
12
|
+
deviceName: string
|
|
13
|
+
remoteType: string
|
|
14
|
+
hubDeviceId: string
|
|
15
|
+
}
|
package/src/types/pushbody.ts
CHANGED
package/src/utils.ts
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
*
|
|
3
3
|
* util.ts: @switchbot/homebridge-switchbot platform class.
|
|
4
4
|
*/
|
|
5
|
+
import type { devicesConfig } from './settings.js'
|
|
6
|
+
import type { blindTilt, curtain, curtain3, device } from './types/devicelist.js'
|
|
7
|
+
|
|
5
8
|
export enum SwitchBotModel {
|
|
6
9
|
HubMini = 'W0202200',
|
|
7
10
|
HubPlus = 'SwitchBot Hub S1',
|
|
@@ -115,19 +118,16 @@ export enum BlindTiltMappingMode {
|
|
|
115
118
|
UseTiltForDirection = 'use_tilt_for_direction',
|
|
116
119
|
}
|
|
117
120
|
|
|
118
|
-
import type { devicesConfig } from './settings.js';
|
|
119
|
-
import type { blindTilt, curtain, curtain3, device } from './types/devicelist.js';
|
|
120
|
-
|
|
121
121
|
export function isCurtainDevice(device: device & devicesConfig): device is (curtain | curtain3) & devicesConfig {
|
|
122
|
-
return device.deviceType === 'Curtain' || device.deviceType === 'Curtain3'
|
|
122
|
+
return device.deviceType === 'Curtain' || device.deviceType === 'Curtain3'
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
export function isBlindTiltDevice(device: device & devicesConfig): device is blindTilt & devicesConfig {
|
|
126
|
-
return device.deviceType === 'Blind Tilt'
|
|
126
|
+
return device.deviceType === 'Blind Tilt'
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
export function sleep(ms: number): Promise<void> {
|
|
130
|
-
return new Promise(
|
|
130
|
+
return new Promise(resolve => setTimeout(resolve, ms))
|
|
131
131
|
}
|
|
132
132
|
/**
|
|
133
133
|
* Check if the humidity is within the min and max range
|
|
@@ -135,63 +135,62 @@ export function sleep(ms: number): Promise<void> {
|
|
|
135
135
|
* @param min - The minimum humidity value
|
|
136
136
|
* @param max - The maximum humidity value
|
|
137
137
|
* @returns The humidity value
|
|
138
|
-
|
|
138
|
+
*/
|
|
139
139
|
export function validHumidity(humidity: number, min?: number, max?: number): number {
|
|
140
140
|
if (humidity < (min || 0)) {
|
|
141
|
-
return min ?? 0
|
|
141
|
+
return min ?? 0
|
|
142
142
|
} else if (humidity > (max || 100)) {
|
|
143
|
-
return max ?? 100
|
|
143
|
+
return max ?? 100
|
|
144
144
|
}
|
|
145
|
-
return humidity
|
|
145
|
+
return humidity
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
/**
|
|
149
149
|
* Converts the value to celsius if the temperature units are in Fahrenheit
|
|
150
|
-
|
|
150
|
+
*/
|
|
151
151
|
export function convertUnits(value: number, unit: string, convert?: string): number {
|
|
152
152
|
if (unit === 'CELSIUS' && convert === 'CELSIUS') {
|
|
153
|
-
return Math.round((value * 9) / 5 + 32)
|
|
153
|
+
return Math.round((value * 9) / 5 + 32)
|
|
154
154
|
} else if (unit === 'FAHRENHEIT' && convert === 'FAHRENHEIT') {
|
|
155
155
|
// celsius should be to the nearest 0.5 degree
|
|
156
|
-
return Math.round((5 / 9) * (value - 32) * 2) / 2
|
|
156
|
+
return Math.round((5 / 9) * (value - 32) * 2) / 2
|
|
157
157
|
}
|
|
158
|
-
return value
|
|
158
|
+
return value
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
|
|
162
161
|
export function rgb2hs(r: any, g: any, b: any) {
|
|
163
162
|
/**
|
|
164
163
|
* Credit:
|
|
165
164
|
* https://github.com/WickyNilliams/pure-color
|
|
166
|
-
|
|
167
|
-
r = parseInt(r)
|
|
168
|
-
g = parseInt(g)
|
|
169
|
-
b = parseInt(b)
|
|
170
|
-
const min = Math.min(r, g, b)
|
|
171
|
-
const max = Math.max(r, g, b)
|
|
172
|
-
const delta = max - min
|
|
173
|
-
let h
|
|
174
|
-
let s
|
|
165
|
+
*/
|
|
166
|
+
r = Number.parseInt(r)
|
|
167
|
+
g = Number.parseInt(g)
|
|
168
|
+
b = Number.parseInt(b)
|
|
169
|
+
const min = Math.min(r, g, b)
|
|
170
|
+
const max = Math.max(r, g, b)
|
|
171
|
+
const delta = max - min
|
|
172
|
+
let h
|
|
173
|
+
let s
|
|
175
174
|
if (max === 0) {
|
|
176
|
-
s = 0
|
|
175
|
+
s = 0
|
|
177
176
|
} else {
|
|
178
|
-
s = (delta / max) * 100
|
|
177
|
+
s = (delta / max) * 100
|
|
179
178
|
}
|
|
180
179
|
if (max === min) {
|
|
181
|
-
h = 0
|
|
180
|
+
h = 0
|
|
182
181
|
} else if (r === max) {
|
|
183
|
-
h = (g - b) / delta
|
|
182
|
+
h = (g - b) / delta
|
|
184
183
|
} else if (g === max) {
|
|
185
|
-
h = 2 + (b - r) / delta
|
|
184
|
+
h = 2 + (b - r) / delta
|
|
186
185
|
} else if (b === max) {
|
|
187
|
-
h = 4 + (r - g) / delta
|
|
186
|
+
h = 4 + (r - g) / delta
|
|
188
187
|
}
|
|
189
|
-
h = Math.min(h * 60, 360)
|
|
188
|
+
h = Math.min(h * 60, 360)
|
|
190
189
|
|
|
191
190
|
if (h < 0) {
|
|
192
|
-
h += 360
|
|
191
|
+
h += 360
|
|
193
192
|
}
|
|
194
|
-
return [Math.round(h), Math.round(s)]
|
|
193
|
+
return [Math.round(h), Math.round(s)]
|
|
195
194
|
}
|
|
196
195
|
|
|
197
196
|
export function hs2rgb(h: any, s: any) {
|
|
@@ -199,48 +198,48 @@ export function hs2rgb(h: any, s: any) {
|
|
|
199
198
|
Credit:
|
|
200
199
|
https://github.com/WickyNilliams/pure-color
|
|
201
200
|
*/
|
|
202
|
-
h = parseInt(h) / 60
|
|
203
|
-
s = parseInt(s) / 100
|
|
204
|
-
const f = h - Math.floor(h)
|
|
205
|
-
const p = 255 * (1 - s)
|
|
206
|
-
const q = 255 * (1 - s * f)
|
|
207
|
-
const t = 255 * (1 - s * (1 - f))
|
|
208
|
-
let rgb
|
|
201
|
+
h = Number.parseInt(h) / 60
|
|
202
|
+
s = Number.parseInt(s) / 100
|
|
203
|
+
const f = h - Math.floor(h)
|
|
204
|
+
const p = 255 * (1 - s)
|
|
205
|
+
const q = 255 * (1 - s * f)
|
|
206
|
+
const t = 255 * (1 - s * (1 - f))
|
|
207
|
+
let rgb
|
|
209
208
|
switch (Math.floor(h) % 6) {
|
|
210
209
|
case 0:
|
|
211
|
-
rgb = [255, t, p]
|
|
212
|
-
break
|
|
210
|
+
rgb = [255, t, p]
|
|
211
|
+
break
|
|
213
212
|
case 1:
|
|
214
|
-
rgb = [q, 255, p]
|
|
215
|
-
break
|
|
213
|
+
rgb = [q, 255, p]
|
|
214
|
+
break
|
|
216
215
|
case 2:
|
|
217
|
-
rgb = [p, 255, t]
|
|
218
|
-
break
|
|
216
|
+
rgb = [p, 255, t]
|
|
217
|
+
break
|
|
219
218
|
case 3:
|
|
220
|
-
rgb = [p, q, 255]
|
|
221
|
-
break
|
|
219
|
+
rgb = [p, q, 255]
|
|
220
|
+
break
|
|
222
221
|
case 4:
|
|
223
|
-
rgb = [t, p, 255]
|
|
224
|
-
break
|
|
222
|
+
rgb = [t, p, 255]
|
|
223
|
+
break
|
|
225
224
|
case 5:
|
|
226
|
-
rgb = [255, p, q]
|
|
227
|
-
break
|
|
225
|
+
rgb = [255, p, q]
|
|
226
|
+
break
|
|
228
227
|
}
|
|
229
228
|
if (rgb[0] === 255) {
|
|
230
|
-
rgb[1] *= 0.8
|
|
231
|
-
rgb[2] *= 0.8
|
|
229
|
+
rgb[1] *= 0.8
|
|
230
|
+
rgb[2] *= 0.8
|
|
232
231
|
if (rgb[1] <= 25 && rgb[2] <= 25) {
|
|
233
|
-
rgb[1] = 0
|
|
234
|
-
rgb[2] = 0
|
|
232
|
+
rgb[1] = 0
|
|
233
|
+
rgb[2] = 0
|
|
235
234
|
}
|
|
236
235
|
}
|
|
237
|
-
return [Math.round(rgb[0]), Math.round(rgb[1]), Math.round(rgb[2])]
|
|
236
|
+
return [Math.round(rgb[0]), Math.round(rgb[1]), Math.round(rgb[2])]
|
|
238
237
|
}
|
|
239
238
|
|
|
240
239
|
export function k2rgb(k: number) {
|
|
241
240
|
// Set kelvin to nearest 100, between 2000 and 7100
|
|
242
|
-
k = Math.round(k / 100) * 100
|
|
243
|
-
k = Math.max(Math.min(k, 7100), 2000)
|
|
241
|
+
k = Math.round(k / 100) * 100
|
|
242
|
+
k = Math.max(Math.min(k, 7100), 2000)
|
|
244
243
|
|
|
245
244
|
// k should now appear in our table of kelvin to rgb
|
|
246
245
|
const values = {
|
|
@@ -295,10 +294,10 @@ export function k2rgb(k: number) {
|
|
|
295
294
|
6900: [247, 245, 255],
|
|
296
295
|
7000: [245, 243, 255],
|
|
297
296
|
7100: [243, 242, 255],
|
|
298
|
-
}
|
|
297
|
+
}
|
|
299
298
|
|
|
300
299
|
// Return the value
|
|
301
|
-
return values[k]
|
|
300
|
+
return values[k]
|
|
302
301
|
}
|
|
303
302
|
|
|
304
303
|
export function m2hs(m) {
|
|
@@ -708,8 +707,8 @@ export function m2hs(m) {
|
|
|
708
707
|
498: [63.8, 28.3],
|
|
709
708
|
499: [63.9, 28.3],
|
|
710
709
|
500: [64.1, 28.3],
|
|
711
|
-
}
|
|
712
|
-
const input = Math.min(Math.max(Math.round(m), 140), 500)
|
|
713
|
-
const toReturn = table[input]
|
|
714
|
-
return [Math.round(toReturn[1]), Math.round(toReturn[0])]
|
|
710
|
+
}
|
|
711
|
+
const input = Math.min(Math.max(Math.round(m), 140), 500)
|
|
712
|
+
const toReturn = table[input]
|
|
713
|
+
return [Math.round(toReturn[1]), Math.round(toReturn[0])]
|
|
715
714
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"target": "ES2022",
|
|
4
|
-
"module": "ES2022",
|
|
5
4
|
"lib": [
|
|
6
5
|
"DOM",
|
|
7
6
|
"ES2022"
|
|
8
7
|
],
|
|
9
|
-
"declaration": true,
|
|
10
|
-
"declarationMap": true,
|
|
11
|
-
"sourceMap": true,
|
|
12
|
-
"outDir": "dist",
|
|
13
8
|
"rootDir": "src",
|
|
9
|
+
"module": "ES2022",
|
|
10
|
+
"moduleResolution": "node",
|
|
11
|
+
"types": ["node"],
|
|
14
12
|
"strict": true,
|
|
15
|
-
"esModuleInterop": true,
|
|
16
13
|
"noImplicitAny": false,
|
|
14
|
+
"declaration": true,
|
|
15
|
+
"declarationMap": true,
|
|
16
|
+
"outDir": "dist",
|
|
17
|
+
"sourceMap": true,
|
|
17
18
|
"allowSyntheticDefaultImports": true,
|
|
18
|
-
"
|
|
19
|
-
"
|
|
19
|
+
"esModuleInterop": true,
|
|
20
|
+
"forceConsistentCasingInFileNames": true
|
|
20
21
|
},
|
|
21
22
|
"include": [
|
|
22
23
|
"src"
|
|
@@ -24,4 +25,4 @@
|
|
|
24
25
|
"exclude": [
|
|
25
26
|
"**/*.spec.ts"
|
|
26
27
|
]
|
|
27
|
-
}
|
|
28
|
+
}
|