@switchbot/homebridge-switchbot 3.8.3-beta.3 → 3.8.3-beta.31
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/workflows/beta-release.yml +7 -4
- package/.github/workflows/release.yml +7 -6
- package/CHANGELOG.md +2 -1
- package/config.schema.json +24 -0
- package/dist/device/blindtilt.d.ts +1 -4
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +33 -34
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +1 -4
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +30 -31
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +1 -4
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +50 -54
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +1 -4
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +62 -66
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +1 -4
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +18 -18
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +1 -4
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +31 -32
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +6 -6
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +33 -17
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts +1 -4
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +47 -49
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts +1 -4
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +18 -18
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +1 -4
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +43 -46
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +1 -4
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +18 -18
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +1 -4
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +51 -54
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +1 -4
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +31 -32
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +1 -4
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +18 -18
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +1 -4
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +18 -18
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +1 -4
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +18 -18
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +1 -4
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +29 -30
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +1 -4
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +36 -38
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts +1 -4
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +18 -18
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +11 -12
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +11 -12
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +9 -10
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +15 -16
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +6 -6
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js +7 -13
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +9 -10
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +9 -10
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +27 -28
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +9 -10
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +9 -10
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +6 -14
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +127 -188
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +4 -3
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js.map +1 -1
- package/docs/assets/highlight.css +42 -0
- package/docs/assets/main.js +1 -1
- package/docs/functions/default.html +1 -1
- package/docs/index.html +61 -50
- package/docs/media/security-privacy-bluetooth.png +0 -0
- package/package.json +14 -15
- package/src/device/blindtilt.ts +35 -39
- package/src/device/bot.ts +31 -35
- package/src/device/ceilinglight.ts +51 -58
- package/src/device/colorbulb.ts +63 -70
- package/src/device/contact.ts +19 -22
- package/src/device/curtain.ts +33 -37
- package/src/device/device.ts +32 -21
- package/src/device/fan.ts +48 -53
- package/src/device/hub.ts +19 -22
- package/src/device/humidifier.ts +44 -50
- package/src/device/iosensor.ts +19 -22
- package/src/device/lightstrip.ts +52 -58
- package/src/device/lock.ts +32 -36
- package/src/device/meter.ts +19 -22
- package/src/device/meterplus.ts +19 -22
- package/src/device/motion.ts +19 -22
- package/src/device/plug.ts +30 -34
- package/src/device/robotvacuumcleaner.ts +37 -46
- package/src/device/waterdetector.ts +19 -22
- package/src/irdevice/airconditioner.ts +12 -14
- package/src/irdevice/airpurifier.ts +12 -13
- package/src/irdevice/camera.ts +10 -11
- package/src/irdevice/fan.ts +16 -17
- package/src/irdevice/irdevice.ts +9 -17
- package/src/irdevice/light.ts +10 -11
- package/src/irdevice/other.ts +10 -11
- package/src/irdevice/tv.ts +28 -29
- package/src/irdevice/vacuumcleaner.ts +10 -11
- package/src/irdevice/waterheater.ts +10 -11
- package/src/platform.ts +131 -188
- package/src/settings.ts +8 -4
- package/src/utils.ts +2 -1
- package/dist/types/bledevicestatus.d.ts +0 -281
- package/dist/types/bledevicestatus.d.ts.map +0 -1
- package/dist/types/bledevicestatus.js +0 -2
- package/dist/types/bledevicestatus.js.map +0 -1
- package/dist/types/devicelist.d.ts +0 -89
- package/dist/types/devicelist.d.ts.map +0 -1
- package/dist/types/devicelist.js +0 -6
- package/dist/types/devicelist.js.map +0 -1
- package/dist/types/deviceresponse.d.ts +0 -13
- package/dist/types/deviceresponse.d.ts.map +0 -1
- package/dist/types/deviceresponse.js +0 -2
- package/dist/types/deviceresponse.js.map +0 -1
- package/dist/types/devicestatus.d.ts +0 -149
- package/dist/types/devicestatus.d.ts.map +0 -1
- package/dist/types/devicestatus.js +0 -3
- package/dist/types/devicestatus.js.map +0 -1
- package/dist/types/devicewebhookstatus.d.ts +0 -156
- package/dist/types/devicewebhookstatus.d.ts.map +0 -1
- package/dist/types/devicewebhookstatus.js +0 -2
- package/dist/types/devicewebhookstatus.js.map +0 -1
- package/dist/types/irdevicelist.d.ts +0 -10
- package/dist/types/irdevicelist.d.ts.map +0 -1
- package/dist/types/irdevicelist.js +0 -2
- package/dist/types/irdevicelist.js.map +0 -1
- package/dist/types/pushbody.d.ts +0 -6
- package/dist/types/pushbody.d.ts.map +0 -1
- package/dist/types/pushbody.js +0 -2
- package/dist/types/pushbody.js.map +0 -1
- package/src/types/bledevicestatus.ts +0 -303
- package/src/types/devicelist.ts +0 -124
- package/src/types/deviceresponse.ts +0 -14
- package/src/types/devicestatus.ts +0 -178
- package/src/types/devicewebhookstatus.ts +0 -191
- package/src/types/irdevicelist.ts +0 -15
- package/src/types/pushbody.ts +0 -9
package/src/irdevice/camera.ts
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* camera.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
5
|
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'
|
|
6
|
+
import type { bodyChange, irdevice } from 'node-switchbot'
|
|
6
7
|
|
|
7
8
|
import type { SwitchBotPlatform } from '../platform.js'
|
|
8
9
|
import type { irDevicesConfig } from '../settings.js'
|
|
9
|
-
import type { irdevice } from '../types/irdevicelist.js'
|
|
10
10
|
|
|
11
11
|
import { irdeviceBase } from './irdevice.js'
|
|
12
12
|
|
|
@@ -72,11 +72,11 @@ export class Camera extends irdeviceBase {
|
|
|
72
72
|
if (this.Switch.On && !this.disablePushOn) {
|
|
73
73
|
const commandType: string = await this.commandType()
|
|
74
74
|
const command: string = await this.commandOn()
|
|
75
|
-
const bodyChange =
|
|
75
|
+
const bodyChange: bodyChange = {
|
|
76
76
|
command,
|
|
77
77
|
parameter: 'default',
|
|
78
78
|
commandType,
|
|
79
|
-
}
|
|
79
|
+
}
|
|
80
80
|
await this.pushChanges(bodyChange)
|
|
81
81
|
}
|
|
82
82
|
}
|
|
@@ -86,11 +86,11 @@ export class Camera extends irdeviceBase {
|
|
|
86
86
|
if (!this.Switch.On && !this.disablePushOff) {
|
|
87
87
|
const commandType: string = await this.commandType()
|
|
88
88
|
const command: string = await this.commandOff()
|
|
89
|
-
const bodyChange =
|
|
89
|
+
const bodyChange: bodyChange = {
|
|
90
90
|
command,
|
|
91
91
|
parameter: 'default',
|
|
92
92
|
commandType,
|
|
93
|
-
}
|
|
93
|
+
}
|
|
94
94
|
await this.pushChanges(bodyChange)
|
|
95
95
|
}
|
|
96
96
|
}
|
|
@@ -100,14 +100,13 @@ export class Camera extends irdeviceBase {
|
|
|
100
100
|
if (this.device.connectionType === 'OpenAPI') {
|
|
101
101
|
this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`)
|
|
102
102
|
try {
|
|
103
|
-
const { body
|
|
104
|
-
const deviceStatus: any = await body
|
|
105
|
-
await this.pushStatusCodes(
|
|
106
|
-
if (await this.successfulStatusCodes(
|
|
107
|
-
await this.successfulPushChange(
|
|
103
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
104
|
+
const deviceStatus: any = await body
|
|
105
|
+
await this.pushStatusCodes(deviceStatus)
|
|
106
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
107
|
+
await this.successfulPushChange(deviceStatus, bodyChange)
|
|
108
108
|
await this.updateHomeKitCharacteristics()
|
|
109
109
|
} else {
|
|
110
|
-
await this.statusCode(statusCode)
|
|
111
110
|
await this.statusCode(deviceStatus.statusCode)
|
|
112
111
|
}
|
|
113
112
|
} catch (e: any) {
|
package/src/irdevice/fan.ts
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* fan.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
5
|
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'
|
|
6
|
+
import type { bodyChange, irdevice } from 'node-switchbot'
|
|
6
7
|
|
|
7
8
|
import type { SwitchBotPlatform } from '../platform.js'
|
|
8
9
|
import type { irDevicesConfig } from '../settings.js'
|
|
9
|
-
import type { irdevice } from '../types/irdevicelist.js'
|
|
10
10
|
|
|
11
11
|
import { irdeviceBase } from './irdevice.js'
|
|
12
12
|
|
|
@@ -136,11 +136,11 @@ export class IRFan extends irdeviceBase {
|
|
|
136
136
|
if (this.Fan.Active === this.hap.Characteristic.Active.ACTIVE && !this.disablePushOn) {
|
|
137
137
|
const commandType: string = await this.commandType()
|
|
138
138
|
const command: string = await this.commandOn()
|
|
139
|
-
const bodyChange =
|
|
139
|
+
const bodyChange: bodyChange = {
|
|
140
140
|
command,
|
|
141
141
|
parameter: 'default',
|
|
142
142
|
commandType,
|
|
143
|
-
}
|
|
143
|
+
}
|
|
144
144
|
await this.pushChanges(bodyChange)
|
|
145
145
|
}
|
|
146
146
|
}
|
|
@@ -150,39 +150,39 @@ export class IRFan extends irdeviceBase {
|
|
|
150
150
|
if (this.Fan.Active === this.hap.Characteristic.Active.INACTIVE && !this.disablePushOff) {
|
|
151
151
|
const commandType: string = await this.commandType()
|
|
152
152
|
const command: string = await this.commandOff()
|
|
153
|
-
const bodyChange =
|
|
153
|
+
const bodyChange: bodyChange = {
|
|
154
154
|
command,
|
|
155
155
|
parameter: 'default',
|
|
156
156
|
commandType,
|
|
157
|
-
}
|
|
157
|
+
}
|
|
158
158
|
await this.pushChanges(bodyChange)
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
async pushFanSpeedUpChanges(): Promise<void> {
|
|
163
|
-
const bodyChange =
|
|
163
|
+
const bodyChange: bodyChange = {
|
|
164
164
|
command: 'highSpeed',
|
|
165
165
|
parameter: 'default',
|
|
166
166
|
commandType: 'command',
|
|
167
|
-
}
|
|
167
|
+
}
|
|
168
168
|
await this.pushChanges(bodyChange)
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
async pushFanSpeedDownChanges(): Promise<void> {
|
|
172
|
-
const bodyChange =
|
|
172
|
+
const bodyChange: bodyChange = {
|
|
173
173
|
command: 'lowSpeed',
|
|
174
174
|
parameter: 'default',
|
|
175
175
|
commandType: 'command',
|
|
176
|
-
}
|
|
176
|
+
}
|
|
177
177
|
await this.pushChanges(bodyChange)
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
async pushFanSwingChanges(): Promise<void> {
|
|
181
|
-
const bodyChange =
|
|
181
|
+
const bodyChange: bodyChange = {
|
|
182
182
|
command: 'swing',
|
|
183
183
|
parameter: 'default',
|
|
184
184
|
commandType: 'command',
|
|
185
|
-
}
|
|
185
|
+
}
|
|
186
186
|
await this.pushChanges(bodyChange)
|
|
187
187
|
}
|
|
188
188
|
|
|
@@ -191,14 +191,13 @@ export class IRFan extends irdeviceBase {
|
|
|
191
191
|
if (this.device.connectionType === 'OpenAPI') {
|
|
192
192
|
this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`)
|
|
193
193
|
try {
|
|
194
|
-
const { body
|
|
195
|
-
const deviceStatus: any = await body
|
|
196
|
-
await this.pushStatusCodes(
|
|
197
|
-
if (await this.successfulStatusCodes(
|
|
198
|
-
await this.successfulPushChange(
|
|
194
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
195
|
+
const deviceStatus: any = await body
|
|
196
|
+
await this.pushStatusCodes(deviceStatus)
|
|
197
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
198
|
+
await this.successfulPushChange(deviceStatus, bodyChange)
|
|
199
199
|
await this.updateHomeKitCharacteristics()
|
|
200
200
|
} else {
|
|
201
|
-
await this.statusCode(statusCode)
|
|
202
201
|
await this.statusCode(deviceStatus.statusCode)
|
|
203
202
|
}
|
|
204
203
|
} catch (e: any) {
|
package/src/irdevice/irdevice.ts
CHANGED
|
@@ -3,14 +3,10 @@
|
|
|
3
3
|
* device.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
5
|
import type { API, CharacteristicValue, HAP, Logging, PlatformAccessory, Service } from 'homebridge'
|
|
6
|
+
import type { bodyChange, irdevice } from 'node-switchbot'
|
|
6
7
|
|
|
7
8
|
import type { SwitchBotPlatform } from '../platform.js'
|
|
8
9
|
import type { irDevicesConfig, SwitchBotPlatformConfig } from '../settings.js'
|
|
9
|
-
import type { irdevice } from '../types/irdevicelist.js'
|
|
10
|
-
|
|
11
|
-
import { request } from 'undici'
|
|
12
|
-
|
|
13
|
-
import { Devices } from '../settings.js'
|
|
14
10
|
|
|
15
11
|
export abstract class irdeviceBase {
|
|
16
12
|
public readonly api: API
|
|
@@ -129,16 +125,13 @@ export abstract class irdeviceBase {
|
|
|
129
125
|
this.debugSuccessLog(`version: ${accessory.context.version}`)
|
|
130
126
|
}
|
|
131
127
|
|
|
132
|
-
async pushChangeRequest(bodyChange:
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
method: 'POST',
|
|
136
|
-
headers: this.platform.generateHeaders(),
|
|
137
|
-
})
|
|
128
|
+
async pushChangeRequest(bodyChange: bodyChange): Promise<{ body: any, statusCode: number }> {
|
|
129
|
+
const { response, statusCode } = await this.platform.switchBotAPI.controlDevice(this.device.deviceId, bodyChange.command, bodyChange.parameter, bodyChange.commandType)
|
|
130
|
+
return { body: response, statusCode }
|
|
138
131
|
}
|
|
139
132
|
|
|
140
|
-
async successfulStatusCodes(
|
|
141
|
-
return (
|
|
133
|
+
async successfulStatusCodes(deviceStatus: any) {
|
|
134
|
+
return (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)
|
|
142
135
|
}
|
|
143
136
|
|
|
144
137
|
/**
|
|
@@ -163,14 +156,13 @@ export abstract class irdeviceBase {
|
|
|
163
156
|
}
|
|
164
157
|
}
|
|
165
158
|
|
|
166
|
-
async pushStatusCodes(
|
|
167
|
-
await this.debugWarnLog(`statusCode: ${statusCode}`)
|
|
159
|
+
async pushStatusCodes(deviceStatus: any) {
|
|
168
160
|
await this.debugWarnLog(`deviceStatus: ${JSON.stringify(deviceStatus)}`)
|
|
169
161
|
await this.debugWarnLog(`deviceStatus statusCode: ${deviceStatus.statusCode}`)
|
|
170
162
|
}
|
|
171
163
|
|
|
172
|
-
async successfulPushChange(
|
|
173
|
-
this.debugSuccessLog(`
|
|
164
|
+
async successfulPushChange(deviceStatus: any, bodyChange: any) {
|
|
165
|
+
this.debugSuccessLog(`deviceStatus StatusCode: ${deviceStatus.statusCode}`)
|
|
174
166
|
this.successLog(`request to SwitchBot API, body: ${JSON.stringify(JSON.parse(bodyChange))} sent successfully`)
|
|
175
167
|
}
|
|
176
168
|
|
package/src/irdevice/light.ts
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* light.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
5
|
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'
|
|
6
|
+
import type { bodyChange, irdevice } from 'node-switchbot'
|
|
6
7
|
|
|
7
8
|
import type { SwitchBotPlatform } from '../platform.js'
|
|
8
9
|
import type { irDevicesConfig } from '../settings.js'
|
|
9
|
-
import type { irdevice } from '../types/irdevicelist.js'
|
|
10
10
|
|
|
11
11
|
import { irdeviceBase } from './irdevice.js'
|
|
12
12
|
|
|
@@ -170,11 +170,11 @@ export class Light extends irdeviceBase {
|
|
|
170
170
|
if (On === true && this.disablePushOn === false) {
|
|
171
171
|
const commandType: string = await this.commandType()
|
|
172
172
|
const command: string = await this.commandOn()
|
|
173
|
-
const bodyChange =
|
|
173
|
+
const bodyChange: bodyChange = {
|
|
174
174
|
command,
|
|
175
175
|
parameter: 'default',
|
|
176
176
|
commandType,
|
|
177
|
-
}
|
|
177
|
+
}
|
|
178
178
|
await this.pushChanges(bodyChange, On)
|
|
179
179
|
}
|
|
180
180
|
}
|
|
@@ -184,11 +184,11 @@ export class Light extends irdeviceBase {
|
|
|
184
184
|
if (On === false && this.disablePushOff === false) {
|
|
185
185
|
const commandType: string = await this.commandType()
|
|
186
186
|
const command: string = await this.commandOff()
|
|
187
|
-
const bodyChange =
|
|
187
|
+
const bodyChange: bodyChange = {
|
|
188
188
|
command,
|
|
189
189
|
parameter: 'default',
|
|
190
190
|
commandType,
|
|
191
|
-
}
|
|
191
|
+
}
|
|
192
192
|
await this.pushChanges(bodyChange, On)
|
|
193
193
|
}
|
|
194
194
|
}
|
|
@@ -198,15 +198,14 @@ export class Light extends irdeviceBase {
|
|
|
198
198
|
if (this.device.connectionType === 'OpenAPI') {
|
|
199
199
|
this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`)
|
|
200
200
|
try {
|
|
201
|
-
const { body
|
|
202
|
-
const deviceStatus: any = await body
|
|
203
|
-
await this.pushStatusCodes(
|
|
204
|
-
if (await this.successfulStatusCodes(
|
|
205
|
-
await this.successfulPushChange(
|
|
201
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
202
|
+
const deviceStatus: any = await body
|
|
203
|
+
await this.pushStatusCodes(deviceStatus)
|
|
204
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
205
|
+
await this.successfulPushChange(deviceStatus, bodyChange)
|
|
206
206
|
this.accessory.context.On = On
|
|
207
207
|
await this.updateHomeKitCharacteristics()
|
|
208
208
|
} else {
|
|
209
|
-
await this.statusCode(statusCode)
|
|
210
209
|
await this.statusCode(deviceStatus.statusCode)
|
|
211
210
|
}
|
|
212
211
|
} catch (e: any) {
|
package/src/irdevice/other.ts
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* other.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
5
|
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'
|
|
6
|
+
import type { bodyChange, irdevice } from 'node-switchbot'
|
|
6
7
|
|
|
7
8
|
import type { SwitchBotPlatform } from '../platform.js'
|
|
8
9
|
import type { irDevicesConfig } from '../settings.js'
|
|
9
|
-
import type { irdevice } from '../types/irdevicelist.js'
|
|
10
10
|
|
|
11
11
|
import { irdeviceBase } from './irdevice.js'
|
|
12
12
|
|
|
@@ -412,11 +412,11 @@ export class Others extends irdeviceBase {
|
|
|
412
412
|
if (On === true && !this.disablePushOn) {
|
|
413
413
|
const commandType: string = await this.commandType()
|
|
414
414
|
const command: string = await this.commandOn()
|
|
415
|
-
const bodyChange =
|
|
415
|
+
const bodyChange: bodyChange = {
|
|
416
416
|
command,
|
|
417
417
|
parameter: 'default',
|
|
418
418
|
commandType,
|
|
419
|
-
}
|
|
419
|
+
}
|
|
420
420
|
await this.pushChanges(bodyChange)
|
|
421
421
|
}
|
|
422
422
|
} else {
|
|
@@ -430,11 +430,11 @@ export class Others extends irdeviceBase {
|
|
|
430
430
|
if (On === false && !this.disablePushOff) {
|
|
431
431
|
const commandType: string = await this.commandType()
|
|
432
432
|
const command: string = await this.commandOff()
|
|
433
|
-
const bodyChange =
|
|
433
|
+
const bodyChange: bodyChange = {
|
|
434
434
|
command,
|
|
435
435
|
parameter: 'default',
|
|
436
436
|
commandType,
|
|
437
|
-
}
|
|
437
|
+
}
|
|
438
438
|
await this.pushChanges(bodyChange)
|
|
439
439
|
}
|
|
440
440
|
} else {
|
|
@@ -447,14 +447,13 @@ export class Others extends irdeviceBase {
|
|
|
447
447
|
if (this.device.connectionType === 'OpenAPI') {
|
|
448
448
|
this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`)
|
|
449
449
|
try {
|
|
450
|
-
const { body
|
|
451
|
-
const deviceStatus: any = await body
|
|
452
|
-
await this.pushStatusCodes(
|
|
453
|
-
if (await this.successfulStatusCodes(
|
|
454
|
-
await this.successfulPushChange(
|
|
450
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
451
|
+
const deviceStatus: any = await body
|
|
452
|
+
await this.pushStatusCodes(deviceStatus)
|
|
453
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
454
|
+
await this.successfulPushChange(deviceStatus, bodyChange)
|
|
455
455
|
await this.updateHomeKitCharacteristics()
|
|
456
456
|
} else {
|
|
457
|
-
await this.statusCode(statusCode)
|
|
458
457
|
await this.statusCode(deviceStatus.statusCode)
|
|
459
458
|
}
|
|
460
459
|
} catch (e: any) {
|
package/src/irdevice/tv.ts
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* tv.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
5
|
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'
|
|
6
|
+
import type { bodyChange, irdevice } from 'node-switchbot'
|
|
6
7
|
|
|
7
8
|
import type { SwitchBotPlatform } from '../platform.js'
|
|
8
9
|
import type { irDevicesConfig } from '../settings.js'
|
|
9
|
-
import type { irdevice } from '../types/irdevicelist.js'
|
|
10
10
|
|
|
11
11
|
import { irdeviceBase } from './irdevice.js'
|
|
12
12
|
|
|
@@ -210,11 +210,11 @@ export class TV extends irdeviceBase {
|
|
|
210
210
|
if (this.Television.Active === this.hap.Characteristic.Active.ACTIVE && !this.disablePushOn) {
|
|
211
211
|
const commandType: string = await this.commandType()
|
|
212
212
|
const command: string = await this.commandOn()
|
|
213
|
-
const bodyChange =
|
|
213
|
+
const bodyChange: bodyChange = {
|
|
214
214
|
command,
|
|
215
215
|
parameter: 'default',
|
|
216
216
|
commandType,
|
|
217
|
-
}
|
|
217
|
+
}
|
|
218
218
|
await this.pushTVChanges(bodyChange)
|
|
219
219
|
}
|
|
220
220
|
}
|
|
@@ -224,11 +224,11 @@ export class TV extends irdeviceBase {
|
|
|
224
224
|
if (this.Television.Active === this.hap.Characteristic.Active.INACTIVE && !this.disablePushOff) {
|
|
225
225
|
const commandType: string = await this.commandType()
|
|
226
226
|
const command: string = await this.commandOff()
|
|
227
|
-
const bodyChange =
|
|
227
|
+
const bodyChange: bodyChange = {
|
|
228
228
|
command,
|
|
229
229
|
parameter: 'default',
|
|
230
230
|
commandType,
|
|
231
|
-
}
|
|
231
|
+
}
|
|
232
232
|
await this.pushTVChanges(bodyChange)
|
|
233
233
|
}
|
|
234
234
|
}
|
|
@@ -236,11 +236,11 @@ export class TV extends irdeviceBase {
|
|
|
236
236
|
async pushOkChanges(): Promise<void> {
|
|
237
237
|
await this.debugLog(`pushOkChanges disablePushDetail: ${this.disablePushDetail}`)
|
|
238
238
|
if (!this.disablePushDetail) {
|
|
239
|
-
const bodyChange =
|
|
239
|
+
const bodyChange: bodyChange = {
|
|
240
240
|
command: 'Ok',
|
|
241
241
|
parameter: 'default',
|
|
242
242
|
commandType: 'command',
|
|
243
|
-
}
|
|
243
|
+
}
|
|
244
244
|
await this.pushTVChanges(bodyChange)
|
|
245
245
|
}
|
|
246
246
|
}
|
|
@@ -248,11 +248,11 @@ export class TV extends irdeviceBase {
|
|
|
248
248
|
async pushBackChanges(): Promise<void> {
|
|
249
249
|
await this.debugLog(`pushBackChanges disablePushDetail: ${this.disablePushDetail}`)
|
|
250
250
|
if (!this.disablePushDetail) {
|
|
251
|
-
const bodyChange =
|
|
251
|
+
const bodyChange: bodyChange = {
|
|
252
252
|
command: 'Back',
|
|
253
253
|
parameter: 'default',
|
|
254
254
|
commandType: 'command',
|
|
255
|
-
}
|
|
255
|
+
}
|
|
256
256
|
await this.pushTVChanges(bodyChange)
|
|
257
257
|
}
|
|
258
258
|
}
|
|
@@ -260,11 +260,11 @@ export class TV extends irdeviceBase {
|
|
|
260
260
|
async pushMenuChanges(): Promise<void> {
|
|
261
261
|
await this.debugLog(`pushMenuChanges disablePushDetail: ${this.disablePushDetail}`)
|
|
262
262
|
if (!this.disablePushDetail) {
|
|
263
|
-
const bodyChange =
|
|
263
|
+
const bodyChange: bodyChange = {
|
|
264
264
|
command: 'Menu',
|
|
265
265
|
parameter: 'default',
|
|
266
266
|
commandType: 'command',
|
|
267
|
-
}
|
|
267
|
+
}
|
|
268
268
|
await this.pushTVChanges(bodyChange)
|
|
269
269
|
}
|
|
270
270
|
}
|
|
@@ -272,11 +272,11 @@ export class TV extends irdeviceBase {
|
|
|
272
272
|
async pushUpChanges(): Promise<void> {
|
|
273
273
|
await this.debugLog(`pushUpChanges disablePushDetail: ${this.disablePushDetail}`)
|
|
274
274
|
if (!this.disablePushDetail) {
|
|
275
|
-
const bodyChange =
|
|
275
|
+
const bodyChange: bodyChange = {
|
|
276
276
|
command: 'Up',
|
|
277
277
|
parameter: 'default',
|
|
278
278
|
commandType: 'command',
|
|
279
|
-
}
|
|
279
|
+
}
|
|
280
280
|
await this.pushTVChanges(bodyChange)
|
|
281
281
|
}
|
|
282
282
|
}
|
|
@@ -284,11 +284,11 @@ export class TV extends irdeviceBase {
|
|
|
284
284
|
async pushDownChanges(): Promise<void> {
|
|
285
285
|
await this.debugLog(`pushDownChanges disablePushDetail: ${this.disablePushDetail}`)
|
|
286
286
|
if (!this.disablePushDetail) {
|
|
287
|
-
const bodyChange =
|
|
287
|
+
const bodyChange: bodyChange = {
|
|
288
288
|
command: 'Down',
|
|
289
289
|
parameter: 'default',
|
|
290
290
|
commandType: 'command',
|
|
291
|
-
}
|
|
291
|
+
}
|
|
292
292
|
await this.pushTVChanges(bodyChange)
|
|
293
293
|
}
|
|
294
294
|
}
|
|
@@ -296,11 +296,11 @@ export class TV extends irdeviceBase {
|
|
|
296
296
|
async pushRightChanges(): Promise<void> {
|
|
297
297
|
await this.debugLog(`pushRightChanges disablePushDetail: ${this.disablePushDetail}`)
|
|
298
298
|
if (!this.disablePushDetail) {
|
|
299
|
-
const bodyChange =
|
|
299
|
+
const bodyChange: bodyChange = {
|
|
300
300
|
command: 'Right',
|
|
301
301
|
parameter: 'default',
|
|
302
302
|
commandType: 'command',
|
|
303
|
-
}
|
|
303
|
+
}
|
|
304
304
|
await this.pushTVChanges(bodyChange)
|
|
305
305
|
}
|
|
306
306
|
}
|
|
@@ -308,11 +308,11 @@ export class TV extends irdeviceBase {
|
|
|
308
308
|
async pushLeftChanges(): Promise<void> {
|
|
309
309
|
await this.debugLog(`pushLeftChanges disablePushDetail: ${this.disablePushDetail}`)
|
|
310
310
|
if (!this.disablePushDetail) {
|
|
311
|
-
const bodyChange =
|
|
311
|
+
const bodyChange: bodyChange = {
|
|
312
312
|
command: 'Left',
|
|
313
313
|
parameter: 'default',
|
|
314
314
|
commandType: 'command',
|
|
315
|
-
}
|
|
315
|
+
}
|
|
316
316
|
await this.pushTVChanges(bodyChange)
|
|
317
317
|
}
|
|
318
318
|
}
|
|
@@ -320,11 +320,11 @@ export class TV extends irdeviceBase {
|
|
|
320
320
|
async pushVolumeUpChanges(): Promise<void> {
|
|
321
321
|
await this.debugLog(`pushVolumeUpChanges disablePushDetail: ${this.disablePushDetail}`)
|
|
322
322
|
if (!this.disablePushDetail) {
|
|
323
|
-
const bodyChange =
|
|
323
|
+
const bodyChange: bodyChange = {
|
|
324
324
|
command: 'volumeAdd',
|
|
325
325
|
parameter: 'default',
|
|
326
326
|
commandType: 'command',
|
|
327
|
-
}
|
|
327
|
+
}
|
|
328
328
|
await this.pushTVChanges(bodyChange)
|
|
329
329
|
}
|
|
330
330
|
}
|
|
@@ -332,11 +332,11 @@ export class TV extends irdeviceBase {
|
|
|
332
332
|
async pushVolumeDownChanges(): Promise<void> {
|
|
333
333
|
await this.debugLog(`pushVolumeDownChanges disablePushDetail: ${this.disablePushDetail}`)
|
|
334
334
|
if (!this.disablePushDetail) {
|
|
335
|
-
const bodyChange =
|
|
335
|
+
const bodyChange: bodyChange = {
|
|
336
336
|
command: 'volumeSub',
|
|
337
337
|
parameter: 'default',
|
|
338
338
|
commandType: 'command',
|
|
339
|
-
}
|
|
339
|
+
}
|
|
340
340
|
await this.pushTVChanges(bodyChange)
|
|
341
341
|
}
|
|
342
342
|
}
|
|
@@ -346,14 +346,13 @@ export class TV extends irdeviceBase {
|
|
|
346
346
|
if (this.device.connectionType === 'OpenAPI') {
|
|
347
347
|
await this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`)
|
|
348
348
|
try {
|
|
349
|
-
const { body
|
|
350
|
-
const deviceStatus: any = await body
|
|
351
|
-
await this.pushStatusCodes(
|
|
352
|
-
if (await this.successfulStatusCodes(
|
|
353
|
-
await this.successfulPushChange(
|
|
349
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
350
|
+
const deviceStatus: any = await body
|
|
351
|
+
await this.pushStatusCodes(deviceStatus)
|
|
352
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
353
|
+
await this.successfulPushChange(deviceStatus, bodyChange)
|
|
354
354
|
await this.updateHomeKitCharacteristics()
|
|
355
355
|
} else {
|
|
356
|
-
await this.statusCode(statusCode)
|
|
357
356
|
await this.statusCode(deviceStatus.statusCode)
|
|
358
357
|
}
|
|
359
358
|
} catch (e: any) {
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* vacuumcleaner.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
5
|
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'
|
|
6
|
+
import type { bodyChange, irdevice } from 'node-switchbot'
|
|
6
7
|
|
|
7
8
|
import type { SwitchBotPlatform } from '../platform.js'
|
|
8
9
|
import type { irDevicesConfig } from '../settings.js'
|
|
9
|
-
import type { irdevice } from '../types/irdevicelist.js'
|
|
10
10
|
|
|
11
11
|
import { irdeviceBase } from './irdevice.js'
|
|
12
12
|
|
|
@@ -69,11 +69,11 @@ export class VacuumCleaner extends irdeviceBase {
|
|
|
69
69
|
if (this.Switch.On && !this.disablePushOn) {
|
|
70
70
|
const commandType: string = await this.commandType()
|
|
71
71
|
const command: string = await this.commandOn()
|
|
72
|
-
const bodyChange =
|
|
72
|
+
const bodyChange: bodyChange = {
|
|
73
73
|
command,
|
|
74
74
|
parameter: 'default',
|
|
75
75
|
commandType,
|
|
76
|
-
}
|
|
76
|
+
}
|
|
77
77
|
await this.pushChanges(bodyChange)
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -83,11 +83,11 @@ export class VacuumCleaner extends irdeviceBase {
|
|
|
83
83
|
if (!this.Switch.On && !this.disablePushOff) {
|
|
84
84
|
const commandType: string = await this.commandType()
|
|
85
85
|
const command: string = await this.commandOff()
|
|
86
|
-
const bodyChange =
|
|
86
|
+
const bodyChange: bodyChange = {
|
|
87
87
|
command,
|
|
88
88
|
parameter: 'default',
|
|
89
89
|
commandType,
|
|
90
|
-
}
|
|
90
|
+
}
|
|
91
91
|
await this.pushChanges(bodyChange)
|
|
92
92
|
}
|
|
93
93
|
}
|
|
@@ -97,14 +97,13 @@ export class VacuumCleaner extends irdeviceBase {
|
|
|
97
97
|
if (this.device.connectionType === 'OpenAPI') {
|
|
98
98
|
await this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`)
|
|
99
99
|
try {
|
|
100
|
-
const { body
|
|
101
|
-
const deviceStatus: any = await body
|
|
102
|
-
await this.pushStatusCodes(
|
|
103
|
-
if (await this.successfulStatusCodes(
|
|
104
|
-
await this.successfulPushChange(
|
|
100
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
101
|
+
const deviceStatus: any = await body
|
|
102
|
+
await this.pushStatusCodes(deviceStatus)
|
|
103
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
104
|
+
await this.successfulPushChange(deviceStatus, bodyChange)
|
|
105
105
|
await this.updateHomeKitCharacteristics()
|
|
106
106
|
} else {
|
|
107
|
-
await this.statusCode(statusCode)
|
|
108
107
|
await this.statusCode(deviceStatus.statusCode)
|
|
109
108
|
}
|
|
110
109
|
} catch (e: any) {
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* waterheater.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
5
|
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'
|
|
6
|
+
import type { bodyChange, irdevice } from 'node-switchbot'
|
|
6
7
|
|
|
7
8
|
import type { SwitchBotPlatform } from '../platform.js'
|
|
8
9
|
import type { irDevicesConfig } from '../settings.js'
|
|
9
|
-
import type { irdevice } from '../types/irdevicelist.js'
|
|
10
10
|
|
|
11
11
|
import { irdeviceBase } from './irdevice.js'
|
|
12
12
|
|
|
@@ -70,11 +70,11 @@ export class WaterHeater extends irdeviceBase {
|
|
|
70
70
|
if (this.Valve.Active === this.hap.Characteristic.Active.ACTIVE && !this.disablePushOn) {
|
|
71
71
|
const commandType: string = await this.commandType()
|
|
72
72
|
const command: string = await this.commandOn()
|
|
73
|
-
const bodyChange =
|
|
73
|
+
const bodyChange: bodyChange = {
|
|
74
74
|
command,
|
|
75
75
|
parameter: 'default',
|
|
76
76
|
commandType,
|
|
77
|
-
}
|
|
77
|
+
}
|
|
78
78
|
await this.pushChanges(bodyChange)
|
|
79
79
|
}
|
|
80
80
|
}
|
|
@@ -84,11 +84,11 @@ export class WaterHeater extends irdeviceBase {
|
|
|
84
84
|
if (this.Valve.Active === this.hap.Characteristic.Active.INACTIVE && !this.disablePushOff) {
|
|
85
85
|
const commandType: string = await this.commandType()
|
|
86
86
|
const command: string = await this.commandOff()
|
|
87
|
-
const bodyChange =
|
|
87
|
+
const bodyChange: bodyChange = {
|
|
88
88
|
command,
|
|
89
89
|
parameter: 'default',
|
|
90
90
|
commandType,
|
|
91
|
-
}
|
|
91
|
+
}
|
|
92
92
|
await this.pushChanges(bodyChange)
|
|
93
93
|
}
|
|
94
94
|
}
|
|
@@ -98,14 +98,13 @@ export class WaterHeater extends irdeviceBase {
|
|
|
98
98
|
if (this.device.connectionType === 'OpenAPI') {
|
|
99
99
|
this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`)
|
|
100
100
|
try {
|
|
101
|
-
const { body
|
|
102
|
-
const deviceStatus: any = await body
|
|
103
|
-
await this.pushStatusCodes(
|
|
104
|
-
if (await this.successfulStatusCodes(
|
|
105
|
-
await this.successfulPushChange(
|
|
101
|
+
const { body } = await this.pushChangeRequest(bodyChange)
|
|
102
|
+
const deviceStatus: any = await body
|
|
103
|
+
await this.pushStatusCodes(deviceStatus)
|
|
104
|
+
if (await this.successfulStatusCodes(deviceStatus)) {
|
|
105
|
+
await this.successfulPushChange(deviceStatus, bodyChange)
|
|
106
106
|
await this.updateHomeKitCharacteristics()
|
|
107
107
|
} else {
|
|
108
|
-
await this.statusCode(statusCode)
|
|
109
108
|
await this.statusCode(deviceStatus.statusCode)
|
|
110
109
|
}
|
|
111
110
|
} catch (e: any) {
|