@switchbot/homebridge-switchbot 3.7.1-beta.12 → 3.7.1-beta.13
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/dist/device/blindtilt.d.ts +8 -8
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +34 -66
- 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 +61 -97
- 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 +5 -5
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +36 -71
- 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 +22 -37
- 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 +64 -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 +5 -6
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +141 -146
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +2 -2
- 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 +54 -47
- package/src/device/blindtilt.ts +419 -456
- package/src/device/bot.ts +656 -693
- 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 +400 -435
- 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 +169 -184
- package/src/homebridge-ui/server.ts +16 -15
- package/src/index.ts +5 -6
- package/src/irdevice/airconditioner.ts +280 -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 +1281 -1281
- package/src/settings.ts +170 -170
- package/src/types/bledevicestatus.ts +255 -255
- 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 -127
- 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/src/irdevice/other.ts
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
*
|
|
3
3
|
* other.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'
|
|
6
6
|
|
|
7
|
-
import type { SwitchBotPlatform } from '../platform.js'
|
|
8
|
-
import type { irDevicesConfig } from '../settings.js'
|
|
9
|
-
import type { irdevice } from '../types/irdevicelist.js'
|
|
10
|
-
|
|
7
|
+
import type { SwitchBotPlatform } from '../platform.js'
|
|
8
|
+
import type { irDevicesConfig } from '../settings.js'
|
|
9
|
+
import type { irdevice } from '../types/irdevicelist.js'
|
|
10
|
+
|
|
11
|
+
import { irdeviceBase } from './irdevice.js'
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Platform Accessory
|
|
@@ -17,361 +18,323 @@ import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge
|
|
|
17
18
|
export class Others extends irdeviceBase {
|
|
18
19
|
// Services
|
|
19
20
|
private Switch?: {
|
|
20
|
-
Name: CharacteristicValue
|
|
21
|
-
Service: Service
|
|
22
|
-
}
|
|
21
|
+
Name: CharacteristicValue
|
|
22
|
+
Service: Service
|
|
23
|
+
}
|
|
23
24
|
|
|
24
25
|
private GarageDoor?: {
|
|
25
|
-
Name: CharacteristicValue
|
|
26
|
-
Service: Service
|
|
27
|
-
}
|
|
26
|
+
Name: CharacteristicValue
|
|
27
|
+
Service: Service
|
|
28
|
+
}
|
|
28
29
|
|
|
29
30
|
private Door?: {
|
|
30
|
-
Name: CharacteristicValue
|
|
31
|
-
Service: Service
|
|
32
|
-
}
|
|
31
|
+
Name: CharacteristicValue
|
|
32
|
+
Service: Service
|
|
33
|
+
}
|
|
33
34
|
|
|
34
35
|
private Window?: {
|
|
35
|
-
Name: CharacteristicValue
|
|
36
|
-
Service: Service
|
|
37
|
-
}
|
|
36
|
+
Name: CharacteristicValue
|
|
37
|
+
Service: Service
|
|
38
|
+
}
|
|
38
39
|
|
|
39
40
|
private WindowCovering?: {
|
|
40
|
-
Name: CharacteristicValue
|
|
41
|
-
Service: Service
|
|
42
|
-
}
|
|
41
|
+
Name: CharacteristicValue
|
|
42
|
+
Service: Service
|
|
43
|
+
}
|
|
43
44
|
|
|
44
45
|
private LockMechanism?: {
|
|
45
|
-
Name: CharacteristicValue
|
|
46
|
-
Service: Service
|
|
47
|
-
}
|
|
46
|
+
Name: CharacteristicValue
|
|
47
|
+
Service: Service
|
|
48
|
+
}
|
|
48
49
|
|
|
49
50
|
private Faucet?: {
|
|
50
|
-
Name: CharacteristicValue
|
|
51
|
-
Service: Service
|
|
52
|
-
}
|
|
51
|
+
Name: CharacteristicValue
|
|
52
|
+
Service: Service
|
|
53
|
+
}
|
|
53
54
|
|
|
54
55
|
private Fan?: {
|
|
55
|
-
Name: CharacteristicValue
|
|
56
|
-
Service: Service
|
|
57
|
-
}
|
|
56
|
+
Name: CharacteristicValue
|
|
57
|
+
Service: Service
|
|
58
|
+
}
|
|
58
59
|
|
|
59
60
|
private StatefulProgrammableSwitch?: {
|
|
60
|
-
Name: CharacteristicValue
|
|
61
|
-
Service: Service
|
|
62
|
-
}
|
|
61
|
+
Name: CharacteristicValue
|
|
62
|
+
Service: Service
|
|
63
|
+
}
|
|
63
64
|
|
|
64
65
|
private Outlet?: {
|
|
65
|
-
Name: CharacteristicValue
|
|
66
|
-
Service: Service
|
|
67
|
-
}
|
|
66
|
+
Name: CharacteristicValue
|
|
67
|
+
Service: Service
|
|
68
|
+
}
|
|
68
69
|
|
|
69
|
-
On!: boolean
|
|
70
|
+
On!: boolean
|
|
70
71
|
|
|
71
72
|
// Config
|
|
72
|
-
otherDeviceType?: string
|
|
73
|
+
otherDeviceType?: string
|
|
73
74
|
|
|
74
75
|
constructor(
|
|
75
76
|
readonly platform: SwitchBotPlatform,
|
|
76
77
|
accessory: PlatformAccessory,
|
|
77
78
|
device: irdevice & irDevicesConfig,
|
|
78
79
|
) {
|
|
79
|
-
super(platform, accessory, device)
|
|
80
|
+
super(platform, accessory, device)
|
|
80
81
|
|
|
81
82
|
// default placeholders
|
|
82
|
-
this.getOtherConfigSettings(accessory, device)
|
|
83
|
+
this.getOtherConfigSettings(accessory, device)
|
|
83
84
|
|
|
84
85
|
// deviceType
|
|
85
86
|
if (this.otherDeviceType === 'switch') {
|
|
86
87
|
// Set category
|
|
87
|
-
accessory.category = this.hap.Categories.SWITCH
|
|
88
|
+
accessory.category = this.hap.Categories.SWITCH
|
|
88
89
|
// Initialize Switch Service
|
|
89
|
-
accessory.context.Switch = accessory.context.Switch ?? {}
|
|
90
|
+
accessory.context.Switch = accessory.context.Switch ?? {}
|
|
90
91
|
this.Switch = {
|
|
91
92
|
Name: accessory.displayName,
|
|
92
93
|
Service: accessory.getService(this.hap.Service.Switch) ?? accessory.addService(this.hap.Service.Switch) as Service,
|
|
93
|
-
}
|
|
94
|
-
accessory.context.Switch = this.Switch as object
|
|
95
|
-
this.debugLog('Displaying as Switch')
|
|
94
|
+
}
|
|
95
|
+
accessory.context.Switch = this.Switch as object
|
|
96
|
+
this.debugLog('Displaying as Switch')
|
|
96
97
|
// Initialize Switch Characteristics
|
|
97
|
-
this.Switch.Service
|
|
98
|
-
.setCharacteristic(this.hap.Characteristic.Name, this.Switch.Name)
|
|
99
|
-
.getCharacteristic(this.hap.Characteristic.On)
|
|
100
|
-
.onSet(this.OnSet.bind(this));
|
|
98
|
+
this.Switch.Service.setCharacteristic(this.hap.Characteristic.Name, this.Switch.Name).getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this))
|
|
101
99
|
// Remove other services
|
|
102
|
-
this.removeFanService(accessory)
|
|
103
|
-
this.removeLockService(accessory)
|
|
104
|
-
this.removeDoorService(accessory)
|
|
105
|
-
this.removeFaucetService(accessory)
|
|
106
|
-
this.removeOutletService(accessory)
|
|
107
|
-
this.removeWindowService(accessory)
|
|
108
|
-
this.removeGarageDoorService(accessory)
|
|
109
|
-
this.removeWindowCoveringService(accessory)
|
|
110
|
-
this.removeStatefulProgrammableSwitchService(accessory)
|
|
100
|
+
this.removeFanService(accessory)
|
|
101
|
+
this.removeLockService(accessory)
|
|
102
|
+
this.removeDoorService(accessory)
|
|
103
|
+
this.removeFaucetService(accessory)
|
|
104
|
+
this.removeOutletService(accessory)
|
|
105
|
+
this.removeWindowService(accessory)
|
|
106
|
+
this.removeGarageDoorService(accessory)
|
|
107
|
+
this.removeWindowCoveringService(accessory)
|
|
108
|
+
this.removeStatefulProgrammableSwitchService(accessory)
|
|
111
109
|
} else if (this.otherDeviceType === 'garagedoor') {
|
|
112
110
|
// Set category
|
|
113
|
-
accessory.category = this.hap.Categories.GARAGE_DOOR_OPENER
|
|
111
|
+
accessory.category = this.hap.Categories.GARAGE_DOOR_OPENER
|
|
114
112
|
// Initialize GarageDoor Service
|
|
115
|
-
accessory.context.GarageDoor = accessory.context.GarageDoor ?? {}
|
|
113
|
+
accessory.context.GarageDoor = accessory.context.GarageDoor ?? {}
|
|
116
114
|
this.GarageDoor = {
|
|
117
115
|
Name: accessory.displayName,
|
|
118
116
|
Service: accessory.getService(this.hap.Service.GarageDoorOpener) ?? accessory.addService(this.hap.Service.GarageDoorOpener) as Service,
|
|
119
|
-
}
|
|
120
|
-
accessory.context.GarageDoor = this.GarageDoor as object
|
|
121
|
-
this.debugLog('Displaying as Garage Door Opener')
|
|
117
|
+
}
|
|
118
|
+
accessory.context.GarageDoor = this.GarageDoor as object
|
|
119
|
+
this.debugLog('Displaying as Garage Door Opener')
|
|
122
120
|
// Initialize GarageDoor Characteristics
|
|
123
|
-
this.GarageDoor.Service
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
minValue: 0,
|
|
130
|
-
maxValue: 100,
|
|
131
|
-
minStep: 100,
|
|
132
|
-
})
|
|
133
|
-
.onSet(this.OnSet.bind(this));
|
|
121
|
+
this.GarageDoor.Service.setCharacteristic(this.hap.Characteristic.Name, this.GarageDoor.Name).setCharacteristic(this.hap.Characteristic.ObstructionDetected, false).getCharacteristic(this.hap.Characteristic.TargetDoorState).setProps({
|
|
122
|
+
validValues: [0, 100],
|
|
123
|
+
minValue: 0,
|
|
124
|
+
maxValue: 100,
|
|
125
|
+
minStep: 100,
|
|
126
|
+
}).onSet(this.OnSet.bind(this))
|
|
134
127
|
// Remove other services
|
|
135
|
-
this.removeFanService(accessory)
|
|
136
|
-
this.removeLockService(accessory)
|
|
137
|
-
this.removeDoorService(accessory)
|
|
138
|
-
this.removeFaucetService(accessory)
|
|
139
|
-
this.removeOutletService(accessory)
|
|
140
|
-
this.removeSwitchService(accessory)
|
|
141
|
-
this.removeWindowService(accessory)
|
|
142
|
-
this.removeWindowCoveringService(accessory)
|
|
143
|
-
this.removeStatefulProgrammableSwitchService(accessory)
|
|
128
|
+
this.removeFanService(accessory)
|
|
129
|
+
this.removeLockService(accessory)
|
|
130
|
+
this.removeDoorService(accessory)
|
|
131
|
+
this.removeFaucetService(accessory)
|
|
132
|
+
this.removeOutletService(accessory)
|
|
133
|
+
this.removeSwitchService(accessory)
|
|
134
|
+
this.removeWindowService(accessory)
|
|
135
|
+
this.removeWindowCoveringService(accessory)
|
|
136
|
+
this.removeStatefulProgrammableSwitchService(accessory)
|
|
144
137
|
} else if (this.otherDeviceType === 'door') {
|
|
145
138
|
// Set category
|
|
146
|
-
accessory.category = this.hap.Categories.DOOR
|
|
139
|
+
accessory.category = this.hap.Categories.DOOR
|
|
147
140
|
// Initialize Door Service
|
|
148
|
-
accessory.context.Door = accessory.context.Door ?? {}
|
|
141
|
+
accessory.context.Door = accessory.context.Door ?? {}
|
|
149
142
|
this.Door = {
|
|
150
143
|
Name: accessory.displayName,
|
|
151
144
|
Service: accessory.getService(this.hap.Service.Door) ?? accessory.addService(this.hap.Service.Door) as Service,
|
|
152
|
-
}
|
|
153
|
-
accessory.context.Door = this.Door as object
|
|
154
|
-
this.debugLog('Displaying as Door')
|
|
145
|
+
}
|
|
146
|
+
accessory.context.Door = this.Door as object
|
|
147
|
+
this.debugLog('Displaying as Door')
|
|
155
148
|
// Initialize Door Characteristics
|
|
156
|
-
this.Door.Service
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
maxValue: 100,
|
|
163
|
-
minStep: 100,
|
|
164
|
-
})
|
|
165
|
-
.onSet(this.OnSet.bind(this));
|
|
149
|
+
this.Door.Service.setCharacteristic(this.hap.Characteristic.Name, this.Door.Name).setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED).getCharacteristic(this.hap.Characteristic.TargetPosition).setProps({
|
|
150
|
+
validValues: [0, 100],
|
|
151
|
+
minValue: 0,
|
|
152
|
+
maxValue: 100,
|
|
153
|
+
minStep: 100,
|
|
154
|
+
}).onSet(this.OnSet.bind(this))
|
|
166
155
|
// Remove other services
|
|
167
|
-
this.removeFanService(accessory)
|
|
168
|
-
this.removeLockService(accessory)
|
|
169
|
-
this.removeOutletService(accessory)
|
|
170
|
-
this.removeFaucetService(accessory)
|
|
171
|
-
this.removeSwitchService(accessory)
|
|
172
|
-
this.removeWindowService(accessory)
|
|
173
|
-
this.removeGarageDoorService(accessory)
|
|
174
|
-
this.removeWindowCoveringService(accessory)
|
|
175
|
-
this.removeStatefulProgrammableSwitchService(accessory)
|
|
156
|
+
this.removeFanService(accessory)
|
|
157
|
+
this.removeLockService(accessory)
|
|
158
|
+
this.removeOutletService(accessory)
|
|
159
|
+
this.removeFaucetService(accessory)
|
|
160
|
+
this.removeSwitchService(accessory)
|
|
161
|
+
this.removeWindowService(accessory)
|
|
162
|
+
this.removeGarageDoorService(accessory)
|
|
163
|
+
this.removeWindowCoveringService(accessory)
|
|
164
|
+
this.removeStatefulProgrammableSwitchService(accessory)
|
|
176
165
|
} else if (this.otherDeviceType === 'window') {
|
|
177
166
|
// Set category
|
|
178
|
-
accessory.category = this.hap.Categories.WINDOW
|
|
167
|
+
accessory.category = this.hap.Categories.WINDOW
|
|
179
168
|
// Initialize Window Service
|
|
180
|
-
accessory.context.Window = accessory.context.Window ?? {}
|
|
169
|
+
accessory.context.Window = accessory.context.Window ?? {}
|
|
181
170
|
this.Window = {
|
|
182
171
|
Name: accessory.displayName,
|
|
183
172
|
Service: accessory.getService(this.hap.Service.Window) ?? accessory.addService(this.hap.Service.Window) as Service,
|
|
184
|
-
}
|
|
185
|
-
accessory.context.Window = this.Window as object
|
|
186
|
-
this.debugLog('Displaying as Window')
|
|
173
|
+
}
|
|
174
|
+
accessory.context.Window = this.Window as object
|
|
175
|
+
this.debugLog('Displaying as Window')
|
|
187
176
|
// Initialize Window Characteristics
|
|
188
|
-
this.Window.Service
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
maxValue: 100,
|
|
195
|
-
minStep: 100,
|
|
196
|
-
})
|
|
197
|
-
.onSet(this.OnSet.bind(this));
|
|
177
|
+
this.Window.Service.setCharacteristic(this.hap.Characteristic.Name, this.Window.Name).setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED).getCharacteristic(this.hap.Characteristic.TargetPosition).setProps({
|
|
178
|
+
validValues: [0, 100],
|
|
179
|
+
minValue: 0,
|
|
180
|
+
maxValue: 100,
|
|
181
|
+
minStep: 100,
|
|
182
|
+
}).onSet(this.OnSet.bind(this))
|
|
198
183
|
// Remove other services
|
|
199
|
-
this.removeFanService(accessory)
|
|
200
|
-
this.removeLockService(accessory)
|
|
201
|
-
this.removeDoorService(accessory)
|
|
202
|
-
this.removeOutletService(accessory)
|
|
203
|
-
this.removeFaucetService(accessory)
|
|
204
|
-
this.removeSwitchService(accessory)
|
|
205
|
-
this.removeGarageDoorService(accessory)
|
|
206
|
-
this.removeWindowCoveringService(accessory)
|
|
207
|
-
this.removeStatefulProgrammableSwitchService(accessory)
|
|
184
|
+
this.removeFanService(accessory)
|
|
185
|
+
this.removeLockService(accessory)
|
|
186
|
+
this.removeDoorService(accessory)
|
|
187
|
+
this.removeOutletService(accessory)
|
|
188
|
+
this.removeFaucetService(accessory)
|
|
189
|
+
this.removeSwitchService(accessory)
|
|
190
|
+
this.removeGarageDoorService(accessory)
|
|
191
|
+
this.removeWindowCoveringService(accessory)
|
|
192
|
+
this.removeStatefulProgrammableSwitchService(accessory)
|
|
208
193
|
} else if (this.otherDeviceType === 'windowcovering') {
|
|
209
194
|
// Set category
|
|
210
|
-
accessory.category = this.hap.Categories.WINDOW_COVERING
|
|
195
|
+
accessory.category = this.hap.Categories.WINDOW_COVERING
|
|
211
196
|
// Initialize WindowCovering Service
|
|
212
|
-
accessory.context.WindowCovering = accessory.context.WindowCovering ?? {}
|
|
197
|
+
accessory.context.WindowCovering = accessory.context.WindowCovering ?? {}
|
|
213
198
|
this.WindowCovering = {
|
|
214
199
|
Name: accessory.displayName,
|
|
215
200
|
Service: accessory.getService(this.hap.Service.WindowCovering) ?? accessory.addService(this.hap.Service.WindowCovering) as Service,
|
|
216
|
-
}
|
|
217
|
-
accessory.context.WindowCovering = this.WindowCovering as object
|
|
218
|
-
this.debugLog('Displaying as Window Covering')
|
|
201
|
+
}
|
|
202
|
+
accessory.context.WindowCovering = this.WindowCovering as object
|
|
203
|
+
this.debugLog('Displaying as Window Covering')
|
|
219
204
|
// Initialize WindowCovering Characteristics
|
|
220
|
-
this.WindowCovering.Service
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
minValue: 0,
|
|
227
|
-
maxValue: 100,
|
|
228
|
-
minStep: 100,
|
|
229
|
-
})
|
|
230
|
-
.onSet(this.OnSet.bind(this));
|
|
205
|
+
this.WindowCovering.Service.setCharacteristic(this.hap.Characteristic.Name, this.WindowCovering.Name).setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED).getCharacteristic(this.hap.Characteristic.TargetPosition).setProps({
|
|
206
|
+
validValues: [0, 100],
|
|
207
|
+
minValue: 0,
|
|
208
|
+
maxValue: 100,
|
|
209
|
+
minStep: 100,
|
|
210
|
+
}).onSet(this.OnSet.bind(this))
|
|
231
211
|
// Remove other services
|
|
232
|
-
this.removeFanService(accessory)
|
|
233
|
-
this.removeLockService(accessory)
|
|
234
|
-
this.removeDoorService(accessory)
|
|
235
|
-
this.removeOutletService(accessory)
|
|
236
|
-
this.removeFaucetService(accessory)
|
|
237
|
-
this.removeSwitchService(accessory)
|
|
238
|
-
this.removeWindowService(accessory)
|
|
239
|
-
this.removeGarageDoorService(accessory)
|
|
240
|
-
this.removeStatefulProgrammableSwitchService(accessory)
|
|
212
|
+
this.removeFanService(accessory)
|
|
213
|
+
this.removeLockService(accessory)
|
|
214
|
+
this.removeDoorService(accessory)
|
|
215
|
+
this.removeOutletService(accessory)
|
|
216
|
+
this.removeFaucetService(accessory)
|
|
217
|
+
this.removeSwitchService(accessory)
|
|
218
|
+
this.removeWindowService(accessory)
|
|
219
|
+
this.removeGarageDoorService(accessory)
|
|
220
|
+
this.removeStatefulProgrammableSwitchService(accessory)
|
|
241
221
|
} else if (this.otherDeviceType === 'lock') {
|
|
242
222
|
// Set category
|
|
243
|
-
accessory.category = this.hap.Categories.DOOR_LOCK
|
|
223
|
+
accessory.category = this.hap.Categories.DOOR_LOCK
|
|
244
224
|
// Initialize Lock Service
|
|
245
|
-
accessory.context.LockMechanism = accessory.context.LockMechanism ?? {}
|
|
225
|
+
accessory.context.LockMechanism = accessory.context.LockMechanism ?? {}
|
|
246
226
|
this.LockMechanism = {
|
|
247
227
|
Name: accessory.displayName,
|
|
248
228
|
Service: accessory.getService(this.hap.Service.LockMechanism) ?? accessory.addService(this.hap.Service.LockMechanism) as Service,
|
|
249
|
-
}
|
|
250
|
-
accessory.context.LockMechanism = this.LockMechanism as object
|
|
251
|
-
this.debugLog('Displaying as Lock')
|
|
229
|
+
}
|
|
230
|
+
accessory.context.LockMechanism = this.LockMechanism as object
|
|
231
|
+
this.debugLog('Displaying as Lock')
|
|
252
232
|
// Initialize Lock Characteristics
|
|
253
|
-
this.LockMechanism.Service
|
|
254
|
-
.setCharacteristic(this.hap.Characteristic.Name, this.LockMechanism.Name)
|
|
255
|
-
.setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
|
|
256
|
-
.getCharacteristic(this.hap.Characteristic.LockTargetState)
|
|
257
|
-
.onSet(this.OnSet.bind(this));
|
|
233
|
+
this.LockMechanism.Service.setCharacteristic(this.hap.Characteristic.Name, this.LockMechanism.Name).setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED).getCharacteristic(this.hap.Characteristic.LockTargetState).onSet(this.OnSet.bind(this))
|
|
258
234
|
// Remove other services
|
|
259
|
-
this.removeFanService(accessory)
|
|
260
|
-
this.removeDoorService(accessory)
|
|
261
|
-
this.removeOutletService(accessory)
|
|
262
|
-
this.removeSwitchService(accessory)
|
|
263
|
-
this.removeFaucetService(accessory)
|
|
264
|
-
this.removeWindowService(accessory)
|
|
265
|
-
this.removeGarageDoorService(accessory)
|
|
266
|
-
this.removeWindowCoveringService(accessory)
|
|
267
|
-
this.removeStatefulProgrammableSwitchService(accessory)
|
|
235
|
+
this.removeFanService(accessory)
|
|
236
|
+
this.removeDoorService(accessory)
|
|
237
|
+
this.removeOutletService(accessory)
|
|
238
|
+
this.removeSwitchService(accessory)
|
|
239
|
+
this.removeFaucetService(accessory)
|
|
240
|
+
this.removeWindowService(accessory)
|
|
241
|
+
this.removeGarageDoorService(accessory)
|
|
242
|
+
this.removeWindowCoveringService(accessory)
|
|
243
|
+
this.removeStatefulProgrammableSwitchService(accessory)
|
|
268
244
|
} else if (this.otherDeviceType === 'faucet') {
|
|
269
245
|
// Set category
|
|
270
|
-
accessory.category = this.hap.Categories.FAUCET
|
|
246
|
+
accessory.category = this.hap.Categories.FAUCET
|
|
271
247
|
// Initialize Faucet Service
|
|
272
|
-
accessory.context.Faucet = accessory.context.Faucet ?? {}
|
|
248
|
+
accessory.context.Faucet = accessory.context.Faucet ?? {}
|
|
273
249
|
this.Faucet = {
|
|
274
250
|
Name: accessory.displayName,
|
|
275
251
|
Service: accessory.getService(this.hap.Service.Faucet) ?? accessory.addService(this.hap.Service.Faucet) as Service,
|
|
276
|
-
}
|
|
277
|
-
accessory.context.Faucet = this.Faucet as object
|
|
278
|
-
this.debugLog('Displaying as Faucet')
|
|
252
|
+
}
|
|
253
|
+
accessory.context.Faucet = this.Faucet as object
|
|
254
|
+
this.debugLog('Displaying as Faucet')
|
|
279
255
|
// Initialize Faucet Characteristics
|
|
280
|
-
this.Faucet.Service
|
|
281
|
-
.setCharacteristic(this.hap.Characteristic.Name, this.Faucet.Name)
|
|
282
|
-
.getCharacteristic(this.hap.Characteristic.Active)
|
|
283
|
-
.onSet(this.OnSet.bind(this));
|
|
256
|
+
this.Faucet.Service.setCharacteristic(this.hap.Characteristic.Name, this.Faucet.Name).getCharacteristic(this.hap.Characteristic.Active).onSet(this.OnSet.bind(this))
|
|
284
257
|
// Remove other services
|
|
285
|
-
this.removeFanService(accessory)
|
|
286
|
-
this.removeLockService(accessory)
|
|
287
|
-
this.removeDoorService(accessory)
|
|
288
|
-
this.removeOutletService(accessory)
|
|
289
|
-
this.removeSwitchService(accessory)
|
|
290
|
-
this.removeWindowService(accessory)
|
|
291
|
-
this.removeGarageDoorService(accessory)
|
|
292
|
-
this.removeWindowCoveringService(accessory)
|
|
293
|
-
this.removeStatefulProgrammableSwitchService(accessory)
|
|
258
|
+
this.removeFanService(accessory)
|
|
259
|
+
this.removeLockService(accessory)
|
|
260
|
+
this.removeDoorService(accessory)
|
|
261
|
+
this.removeOutletService(accessory)
|
|
262
|
+
this.removeSwitchService(accessory)
|
|
263
|
+
this.removeWindowService(accessory)
|
|
264
|
+
this.removeGarageDoorService(accessory)
|
|
265
|
+
this.removeWindowCoveringService(accessory)
|
|
266
|
+
this.removeStatefulProgrammableSwitchService(accessory)
|
|
294
267
|
} else if (this.otherDeviceType === 'fan') {
|
|
295
268
|
// Set category
|
|
296
|
-
accessory.category = this.hap.Categories.FAN
|
|
269
|
+
accessory.category = this.hap.Categories.FAN
|
|
297
270
|
// Initialize Fan Service
|
|
298
|
-
accessory.context.Fan = accessory.context.Fan ?? {}
|
|
271
|
+
accessory.context.Fan = accessory.context.Fan ?? {}
|
|
299
272
|
this.Fan = {
|
|
300
273
|
Name: accessory.displayName,
|
|
301
274
|
Service: accessory.getService(this.hap.Service.Fanv2) ?? accessory.addService(this.hap.Service.Fanv2) as Service,
|
|
302
|
-
}
|
|
303
|
-
accessory.context.Fan = this.Fan as object
|
|
304
|
-
this.debugLog('Displaying as Fan')
|
|
275
|
+
}
|
|
276
|
+
accessory.context.Fan = this.Fan as object
|
|
277
|
+
this.debugLog('Displaying as Fan')
|
|
305
278
|
// Initialize Fan Characteristics
|
|
306
|
-
this.Fan.Service
|
|
307
|
-
.setCharacteristic(this.hap.Characteristic.Name, this.Fan.Name)
|
|
308
|
-
.getCharacteristic(this.hap.Characteristic.Active)
|
|
309
|
-
.onSet(this.OnSet.bind(this));
|
|
279
|
+
this.Fan.Service.setCharacteristic(this.hap.Characteristic.Name, this.Fan.Name).getCharacteristic(this.hap.Characteristic.Active).onSet(this.OnSet.bind(this))
|
|
310
280
|
// Remove other services
|
|
311
|
-
this.removeLockService(accessory)
|
|
312
|
-
this.removeDoorService(accessory)
|
|
313
|
-
this.removeFaucetService(accessory)
|
|
314
|
-
this.removeOutletService(accessory)
|
|
315
|
-
this.removeSwitchService(accessory)
|
|
316
|
-
this.removeWindowService(accessory)
|
|
317
|
-
this.removeGarageDoorService(accessory)
|
|
318
|
-
this.removeWindowCoveringService(accessory)
|
|
319
|
-
this.removeStatefulProgrammableSwitchService(accessory)
|
|
281
|
+
this.removeLockService(accessory)
|
|
282
|
+
this.removeDoorService(accessory)
|
|
283
|
+
this.removeFaucetService(accessory)
|
|
284
|
+
this.removeOutletService(accessory)
|
|
285
|
+
this.removeSwitchService(accessory)
|
|
286
|
+
this.removeWindowService(accessory)
|
|
287
|
+
this.removeGarageDoorService(accessory)
|
|
288
|
+
this.removeWindowCoveringService(accessory)
|
|
289
|
+
this.removeStatefulProgrammableSwitchService(accessory)
|
|
320
290
|
} else if (this.otherDeviceType === 'stateful') {
|
|
321
291
|
// Set category
|
|
322
|
-
accessory.category = this.hap.Categories.PROGRAMMABLE_SWITCH
|
|
292
|
+
accessory.category = this.hap.Categories.PROGRAMMABLE_SWITCH
|
|
323
293
|
// Initialize StatefulProgrammableSwitch Service
|
|
324
|
-
accessory.context.StatefulProgrammableSwitch = accessory.context.StatefulProgrammableSwitch ?? {}
|
|
294
|
+
accessory.context.StatefulProgrammableSwitch = accessory.context.StatefulProgrammableSwitch ?? {}
|
|
325
295
|
this.StatefulProgrammableSwitch = {
|
|
326
296
|
Name: accessory.displayName,
|
|
327
|
-
Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch)
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
this.debugLog('Displaying as Stateful Programmable Switch');
|
|
297
|
+
Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch) ?? accessory.addService(this.hap.Service.StatefulProgrammableSwitch) as Service,
|
|
298
|
+
}
|
|
299
|
+
accessory.context.StatefulProgrammableSwitch = this.StatefulProgrammableSwitch as object
|
|
300
|
+
this.debugLog('Displaying as Stateful Programmable Switch')
|
|
332
301
|
// Initialize StatefulProgrammableSwitch Characteristics
|
|
333
|
-
this.StatefulProgrammableSwitch.Service
|
|
334
|
-
.setCharacteristic(this.hap.Characteristic.Name, this.StatefulProgrammableSwitch.Name)
|
|
335
|
-
.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState)
|
|
336
|
-
.onSet(this.OnSet.bind(this));
|
|
302
|
+
this.StatefulProgrammableSwitch.Service.setCharacteristic(this.hap.Characteristic.Name, this.StatefulProgrammableSwitch.Name).getCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState).onSet(this.OnSet.bind(this))
|
|
337
303
|
// Remove other services
|
|
338
|
-
this.removeFanService(accessory)
|
|
339
|
-
this.removeLockService(accessory)
|
|
340
|
-
this.removeDoorService(accessory)
|
|
341
|
-
this.removeFaucetService(accessory)
|
|
342
|
-
this.removeOutletService(accessory)
|
|
343
|
-
this.removeSwitchService(accessory)
|
|
344
|
-
this.removeWindowService(accessory)
|
|
345
|
-
this.removeGarageDoorService(accessory)
|
|
346
|
-
this.removeWindowCoveringService(accessory)
|
|
304
|
+
this.removeFanService(accessory)
|
|
305
|
+
this.removeLockService(accessory)
|
|
306
|
+
this.removeDoorService(accessory)
|
|
307
|
+
this.removeFaucetService(accessory)
|
|
308
|
+
this.removeOutletService(accessory)
|
|
309
|
+
this.removeSwitchService(accessory)
|
|
310
|
+
this.removeWindowService(accessory)
|
|
311
|
+
this.removeGarageDoorService(accessory)
|
|
312
|
+
this.removeWindowCoveringService(accessory)
|
|
347
313
|
} else if (this.otherDeviceType === 'outlet') {
|
|
348
314
|
// Set category
|
|
349
|
-
accessory.category = this.hap.Categories.OUTLET
|
|
315
|
+
accessory.category = this.hap.Categories.OUTLET
|
|
350
316
|
// Initialize Switch property
|
|
351
|
-
accessory.context.Outlet = accessory.context.Outlet ?? {}
|
|
317
|
+
accessory.context.Outlet = accessory.context.Outlet ?? {}
|
|
352
318
|
this.Outlet = {
|
|
353
319
|
Name: accessory.displayName,
|
|
354
320
|
Service: accessory.getService(this.hap.Service.Outlet) ?? accessory.addService(this.hap.Service.Outlet) as Service,
|
|
355
|
-
}
|
|
356
|
-
accessory.context.Outlet = this.Outlet as object
|
|
357
|
-
this.debugLog('Displaying as Outlet')
|
|
321
|
+
}
|
|
322
|
+
accessory.context.Outlet = this.Outlet as object
|
|
323
|
+
this.debugLog('Displaying as Outlet')
|
|
358
324
|
// Initialize Outlet Characteristics
|
|
359
|
-
this.Outlet.Service
|
|
360
|
-
.setCharacteristic(this.hap.Characteristic.Name, this.Outlet.Name)
|
|
361
|
-
.getCharacteristic(this.hap.Characteristic.On)
|
|
362
|
-
.onSet(this.OnSet.bind(this));
|
|
325
|
+
this.Outlet.Service.setCharacteristic(this.hap.Characteristic.Name, this.Outlet.Name).getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this))
|
|
363
326
|
// Remove other services
|
|
364
|
-
this.removeFanService(accessory)
|
|
365
|
-
this.removeLockService(accessory)
|
|
366
|
-
this.removeDoorService(accessory)
|
|
367
|
-
this.removeFaucetService(accessory)
|
|
368
|
-
this.removeSwitchService(accessory)
|
|
369
|
-
this.removeWindowService(accessory)
|
|
370
|
-
this.removeGarageDoorService(accessory)
|
|
371
|
-
this.removeWindowCoveringService(accessory)
|
|
372
|
-
this.removeStatefulProgrammableSwitchService(accessory)
|
|
327
|
+
this.removeFanService(accessory)
|
|
328
|
+
this.removeLockService(accessory)
|
|
329
|
+
this.removeDoorService(accessory)
|
|
330
|
+
this.removeFaucetService(accessory)
|
|
331
|
+
this.removeSwitchService(accessory)
|
|
332
|
+
this.removeWindowService(accessory)
|
|
333
|
+
this.removeGarageDoorService(accessory)
|
|
334
|
+
this.removeWindowCoveringService(accessory)
|
|
335
|
+
this.removeStatefulProgrammableSwitchService(accessory)
|
|
373
336
|
} else {
|
|
374
|
-
this.errorLog('Device Type not set')
|
|
337
|
+
this.errorLog('Device Type not set')
|
|
375
338
|
}
|
|
376
339
|
}
|
|
377
340
|
|
|
@@ -381,458 +344,451 @@ export class Others extends irdeviceBase {
|
|
|
381
344
|
async OnSet(value: CharacteristicValue): Promise<void> {
|
|
382
345
|
if (this.otherDeviceType === 'switch') {
|
|
383
346
|
if (this.Switch) {
|
|
384
|
-
await this.debugLog(`Set On: ${value}`)
|
|
385
|
-
this.On = value
|
|
347
|
+
await this.debugLog(`Set On: ${value}`)
|
|
348
|
+
this.On = value !== false
|
|
386
349
|
}
|
|
387
350
|
} else if (this.otherDeviceType === 'garagedoor') {
|
|
388
351
|
if (this.GarageDoor) {
|
|
389
|
-
await this.debugLog(`Set TargetDoorState: ${value}`)
|
|
390
|
-
this.On = value
|
|
352
|
+
await this.debugLog(`Set TargetDoorState: ${value}`)
|
|
353
|
+
this.On = value !== this.hap.Characteristic.TargetDoorState.CLOSED
|
|
391
354
|
}
|
|
392
355
|
} else if (this.otherDeviceType === 'door') {
|
|
393
356
|
if (this.Door) {
|
|
394
|
-
await this.debugLog(`Set TargetPosition: ${value}`)
|
|
395
|
-
this.On = value
|
|
357
|
+
await this.debugLog(`Set TargetPosition: ${value}`)
|
|
358
|
+
this.On = value !== 0
|
|
396
359
|
}
|
|
397
360
|
} else if (this.otherDeviceType === 'window') {
|
|
398
361
|
if (this.Window) {
|
|
399
|
-
await this.debugLog(`Set TargetPosition: ${value}`)
|
|
400
|
-
this.On = value
|
|
362
|
+
await this.debugLog(`Set TargetPosition: ${value}`)
|
|
363
|
+
this.On = value !== 0
|
|
401
364
|
}
|
|
402
365
|
} else if (this.otherDeviceType === 'windowcovering') {
|
|
403
366
|
if (this.WindowCovering) {
|
|
404
|
-
await this.debugLog(`Set TargetPosition: ${value}`)
|
|
405
|
-
this.On = value
|
|
367
|
+
await this.debugLog(`Set TargetPosition: ${value}`)
|
|
368
|
+
this.On = value !== 0
|
|
406
369
|
}
|
|
407
370
|
} else if (this.otherDeviceType === 'lock') {
|
|
408
371
|
if (this.LockMechanism) {
|
|
409
|
-
await this.debugLog(`Set LockTargetState: ${value}`)
|
|
410
|
-
this.On = value
|
|
372
|
+
await this.debugLog(`Set LockTargetState: ${value}`)
|
|
373
|
+
this.On = value !== this.hap.Characteristic.LockTargetState.SECURED
|
|
411
374
|
}
|
|
412
375
|
} else if (this.otherDeviceType === 'faucet') {
|
|
413
376
|
if (this.Faucet) {
|
|
414
|
-
await this.debugLog(`Set Active: ${value}`)
|
|
415
|
-
this.On = value
|
|
377
|
+
await this.debugLog(`Set Active: ${value}`)
|
|
378
|
+
this.On = value !== this.hap.Characteristic.Active.INACTIVE
|
|
416
379
|
}
|
|
417
380
|
} else if (this.otherDeviceType === 'stateful') {
|
|
418
381
|
if (this.StatefulProgrammableSwitch) {
|
|
419
|
-
await this.debugLog(`Set ProgrammableSwitchOutputState: ${value}`)
|
|
420
|
-
this.On = value
|
|
382
|
+
await this.debugLog(`Set ProgrammableSwitchOutputState: ${value}`)
|
|
383
|
+
this.On = value !== 0
|
|
421
384
|
}
|
|
422
385
|
} else {
|
|
423
386
|
if (this.Outlet) {
|
|
424
|
-
await this.debugLog(`Set On: ${value}`)
|
|
425
|
-
this.On = value
|
|
387
|
+
await this.debugLog(`Set On: ${value}`)
|
|
388
|
+
this.On = value !== false
|
|
426
389
|
}
|
|
427
390
|
}
|
|
428
|
-
//pushChanges
|
|
391
|
+
// pushChanges
|
|
429
392
|
if (this.On === true) {
|
|
430
|
-
await this.pushOnChanges(this.On)
|
|
393
|
+
await this.pushOnChanges(this.On)
|
|
431
394
|
} else {
|
|
432
|
-
await this.pushOffChanges(this.On)
|
|
395
|
+
await this.pushOffChanges(this.On)
|
|
433
396
|
}
|
|
434
397
|
}
|
|
435
398
|
|
|
436
399
|
/**
|
|
437
400
|
* Pushes the requested changes to the SwitchBot API
|
|
438
|
-
* deviceType
|
|
439
|
-
* Other -
|
|
440
|
-
* Other - "command" "turnOn" "default"
|
|
441
|
-
* Other - "command" "volumeAdd" "default"
|
|
442
|
-
* Other - "command" "volumeSub" "default"
|
|
443
|
-
* Other - "command" "channelAdd" "default"
|
|
444
|
-
* Other - "command" "channelSub" "default"
|
|
401
|
+
* deviceType commandType Command command parameter Description
|
|
402
|
+
* Other - "command" "turnOff" "default" = set to OFF state
|
|
403
|
+
* Other - "command" "turnOn" "default" = set to ON state
|
|
404
|
+
* Other - "command" "volumeAdd" "default" = volume up
|
|
405
|
+
* Other - "command" "volumeSub" "default" = volume down
|
|
406
|
+
* Other - "command" "channelAdd" "default" = next channel
|
|
407
|
+
* Other - "command" "channelSub" "default" = previous channel
|
|
445
408
|
*/
|
|
446
409
|
async pushOnChanges(On: boolean): Promise<void> {
|
|
447
|
-
await this.debugLog(`pushOnChanges On: ${On}
|
|
448
|
-
+ ` disablePushOn: ${this.disablePushOn}, customize: ${this.device.customize}, customOn: ${this.device.customOn}`);
|
|
410
|
+
await this.debugLog(`pushOnChanges On: ${On}, disablePushOn: ${this.disablePushOn}, customize: ${this.device.customize}, customOn: ${this.device.customOn}`)
|
|
449
411
|
if (this.device.customize) {
|
|
450
412
|
if (On === true && !this.disablePushOn) {
|
|
451
|
-
const commandType: string = await this.commandType()
|
|
452
|
-
const command: string = await this.commandOn()
|
|
413
|
+
const commandType: string = await this.commandType()
|
|
414
|
+
const command: string = await this.commandOn()
|
|
453
415
|
const bodyChange = JSON.stringify({
|
|
454
|
-
command
|
|
416
|
+
command,
|
|
455
417
|
parameter: 'default',
|
|
456
|
-
commandType
|
|
457
|
-
})
|
|
458
|
-
await this.pushChanges(bodyChange)
|
|
418
|
+
commandType,
|
|
419
|
+
})
|
|
420
|
+
await this.pushChanges(bodyChange)
|
|
459
421
|
}
|
|
460
422
|
} else {
|
|
461
|
-
this.errorLog('On Command not set')
|
|
423
|
+
this.errorLog('On Command not set')
|
|
462
424
|
}
|
|
463
425
|
}
|
|
464
426
|
|
|
465
427
|
async pushOffChanges(On: boolean): Promise<void> {
|
|
466
|
-
await this.debugLog(`pushOffChanges On: ${On}
|
|
467
|
-
+ ` disablePushOff: ${this.disablePushOff}, customize: ${this.device.customize}, customOff: ${this.device.customOff}`);
|
|
428
|
+
await this.debugLog(`pushOffChanges On: ${On}, disablePushOff: ${this.disablePushOff}, customize: ${this.device.customize}, customOff: ${this.device.customOff}`)
|
|
468
429
|
if (this.device.customize) {
|
|
469
430
|
if (On === false && !this.disablePushOff) {
|
|
470
|
-
const commandType: string = await this.commandType()
|
|
471
|
-
const command: string = await this.commandOff()
|
|
431
|
+
const commandType: string = await this.commandType()
|
|
432
|
+
const command: string = await this.commandOff()
|
|
472
433
|
const bodyChange = JSON.stringify({
|
|
473
|
-
command
|
|
434
|
+
command,
|
|
474
435
|
parameter: 'default',
|
|
475
|
-
commandType
|
|
476
|
-
})
|
|
477
|
-
await this.pushChanges(bodyChange)
|
|
436
|
+
commandType,
|
|
437
|
+
})
|
|
438
|
+
await this.pushChanges(bodyChange)
|
|
478
439
|
}
|
|
479
440
|
} else {
|
|
480
|
-
this.errorLog('Off Command not set.')
|
|
441
|
+
this.errorLog('Off Command not set.')
|
|
481
442
|
}
|
|
482
443
|
}
|
|
483
444
|
|
|
484
445
|
async pushChanges(bodyChange: any): Promise<void> {
|
|
485
|
-
await this.debugLog('pushChanges')
|
|
446
|
+
await this.debugLog('pushChanges')
|
|
486
447
|
if (this.device.connectionType === 'OpenAPI') {
|
|
487
|
-
this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`)
|
|
448
|
+
this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`)
|
|
488
449
|
try {
|
|
489
|
-
const { body, statusCode } = await this.pushChangeRequest(bodyChange)
|
|
490
|
-
const deviceStatus: any = await body.json()
|
|
491
|
-
await this.pushStatusCodes(statusCode, deviceStatus)
|
|
450
|
+
const { body, statusCode } = await this.pushChangeRequest(bodyChange)
|
|
451
|
+
const deviceStatus: any = await body.json()
|
|
452
|
+
await this.pushStatusCodes(statusCode, deviceStatus)
|
|
492
453
|
if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
|
|
493
|
-
await this.successfulPushChange(statusCode, deviceStatus, bodyChange)
|
|
494
|
-
await this.updateHomeKitCharacteristics()
|
|
454
|
+
await this.successfulPushChange(statusCode, deviceStatus, bodyChange)
|
|
455
|
+
await this.updateHomeKitCharacteristics()
|
|
495
456
|
} else {
|
|
496
|
-
await this.statusCode(statusCode)
|
|
497
|
-
await this.statusCode(deviceStatus.statusCode)
|
|
457
|
+
await this.statusCode(statusCode)
|
|
458
|
+
await this.statusCode(deviceStatus.statusCode)
|
|
498
459
|
}
|
|
499
460
|
} catch (e: any) {
|
|
500
|
-
await this.apiError(e)
|
|
501
|
-
await this.pushChangeError(e)
|
|
461
|
+
await this.apiError(e)
|
|
462
|
+
await this.pushChangeError(e)
|
|
502
463
|
}
|
|
503
464
|
} else {
|
|
504
|
-
await this.warnLog(`Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`)
|
|
465
|
+
await this.warnLog(`Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`)
|
|
505
466
|
}
|
|
506
467
|
}
|
|
507
468
|
|
|
508
469
|
async updateHomeKitCharacteristics(): Promise<void> {
|
|
509
|
-
await this.debugLog('updateHomeKitCharacteristics')
|
|
470
|
+
await this.debugLog('updateHomeKitCharacteristics')
|
|
510
471
|
// State
|
|
511
472
|
if (this.otherDeviceType === 'switch' && this.Switch) {
|
|
512
473
|
if (this.On === undefined) {
|
|
513
|
-
await this.debugLog(`On: ${this.On}`)
|
|
474
|
+
await this.debugLog(`On: ${this.On}`)
|
|
514
475
|
} else {
|
|
515
|
-
this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, this.On)
|
|
516
|
-
await this.debugLog(`updateCharacteristic On: ${this.On}`)
|
|
476
|
+
this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, this.On)
|
|
477
|
+
await this.debugLog(`updateCharacteristic On: ${this.On}`)
|
|
517
478
|
}
|
|
518
479
|
} else if (this.otherDeviceType === 'garagedoor' && this.GarageDoor) {
|
|
519
480
|
if (this.On === undefined) {
|
|
520
|
-
await this.debugLog(`On: ${this.On}`)
|
|
481
|
+
await this.debugLog(`On: ${this.On}`)
|
|
521
482
|
} else {
|
|
522
483
|
if (this.On) {
|
|
523
|
-
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, this.hap.Characteristic.TargetDoorState.OPEN)
|
|
524
|
-
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, this.hap.Characteristic.CurrentDoorState.OPEN)
|
|
525
|
-
await this.debugLog(`updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open (${this.On})`)
|
|
484
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, this.hap.Characteristic.TargetDoorState.OPEN)
|
|
485
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, this.hap.Characteristic.CurrentDoorState.OPEN)
|
|
486
|
+
await this.debugLog(`updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open (${this.On})`)
|
|
526
487
|
} else {
|
|
527
|
-
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, this.hap.Characteristic.TargetDoorState.CLOSED)
|
|
528
|
-
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, this.hap.Characteristic.CurrentDoorState.CLOSED)
|
|
529
|
-
await this.debugLog(`updateCharacteristicc TargetDoorState: Closed, CurrentDoorState: Closed (${this.On})`)
|
|
488
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, this.hap.Characteristic.TargetDoorState.CLOSED)
|
|
489
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, this.hap.Characteristic.CurrentDoorState.CLOSED)
|
|
490
|
+
await this.debugLog(`updateCharacteristicc TargetDoorState: Closed, CurrentDoorState: Closed (${this.On})`)
|
|
530
491
|
}
|
|
531
492
|
}
|
|
532
|
-
await this.debugLog(`Garage Door On: ${this.On}`)
|
|
493
|
+
await this.debugLog(`Garage Door On: ${this.On}`)
|
|
533
494
|
} else if (this.otherDeviceType === 'door' && this.Door) {
|
|
534
495
|
if (this.On === undefined) {
|
|
535
|
-
await this.debugLog(`On: ${this.On}`)
|
|
496
|
+
await this.debugLog(`On: ${this.On}`)
|
|
536
497
|
} else {
|
|
537
498
|
if (this.On) {
|
|
538
|
-
this.Door.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100)
|
|
539
|
-
this.Door.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100)
|
|
540
|
-
this.Door.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
|
|
541
|
-
await this.debugLog(`updateCharacteristicc TargetPosition: 100, CurrentPosition: 100 (${this.On})`)
|
|
499
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100)
|
|
500
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100)
|
|
501
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
|
|
502
|
+
await this.debugLog(`updateCharacteristicc TargetPosition: 100, CurrentPosition: 100 (${this.On})`)
|
|
542
503
|
} else {
|
|
543
|
-
this.Door.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0)
|
|
544
|
-
this.Door.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0)
|
|
545
|
-
this.Door.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
|
|
546
|
-
await this.debugLog(`updateCharacteristicc TargetPosition: 0, CurrentPosition: 0 (${this.On})`)
|
|
504
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0)
|
|
505
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0)
|
|
506
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
|
|
507
|
+
await this.debugLog(`updateCharacteristicc TargetPosition: 0, CurrentPosition: 0 (${this.On})`)
|
|
547
508
|
}
|
|
548
509
|
}
|
|
549
|
-
await this.debugLog(`Door On: ${this.On}`)
|
|
510
|
+
await this.debugLog(`Door On: ${this.On}`)
|
|
550
511
|
} else if (this.otherDeviceType === 'window' && this.Window) {
|
|
551
512
|
if (this.On === undefined) {
|
|
552
|
-
await this.debugLog(`On: ${this.On}`)
|
|
513
|
+
await this.debugLog(`On: ${this.On}`)
|
|
553
514
|
} else {
|
|
554
515
|
if (this.On) {
|
|
555
|
-
this.Window.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100)
|
|
556
|
-
this.Window.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100)
|
|
557
|
-
this.Window.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
|
|
558
|
-
await this.debugLog(`updateCharacteristicc TargetPosition: 100, CurrentPosition: 100 (${this.On})`)
|
|
516
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100)
|
|
517
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100)
|
|
518
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
|
|
519
|
+
await this.debugLog(`updateCharacteristicc TargetPosition: 100, CurrentPosition: 100 (${this.On})`)
|
|
559
520
|
} else {
|
|
560
|
-
this.Window.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0)
|
|
561
|
-
this.Window.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0)
|
|
562
|
-
this.Window.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
|
|
563
|
-
await this.debugLog(`updateCharacteristicc TargetPosition: 0, CurrentPosition: 0 (${this.On})`)
|
|
521
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0)
|
|
522
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0)
|
|
523
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
|
|
524
|
+
await this.debugLog(`updateCharacteristicc TargetPosition: 0, CurrentPosition: 0 (${this.On})`)
|
|
564
525
|
}
|
|
565
526
|
}
|
|
566
|
-
await this.debugLog(`Window On: ${this.On}`)
|
|
527
|
+
await this.debugLog(`Window On: ${this.On}`)
|
|
567
528
|
} else if (this.otherDeviceType === 'windowcovering' && this.WindowCovering) {
|
|
568
529
|
if (this.On === undefined) {
|
|
569
|
-
await this.debugLog(`On: ${this.On}`)
|
|
530
|
+
await this.debugLog(`On: ${this.On}`)
|
|
570
531
|
} else {
|
|
571
532
|
if (this.On) {
|
|
572
|
-
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100)
|
|
573
|
-
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100)
|
|
574
|
-
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
|
|
575
|
-
await this.debugLog(`updateCharacteristicc TargetPosition: 100, CurrentPosition: 100 (${this.On})`)
|
|
533
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100)
|
|
534
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100)
|
|
535
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
|
|
536
|
+
await this.debugLog(`updateCharacteristicc TargetPosition: 100, CurrentPosition: 100 (${this.On})`)
|
|
576
537
|
} else {
|
|
577
|
-
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0)
|
|
578
|
-
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0)
|
|
579
|
-
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
|
|
580
|
-
await this.debugLog(`updateCharacteristicc TargetPosition: 0, CurrentPosition: 0 (${this.On})`)
|
|
538
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 0)
|
|
539
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 0)
|
|
540
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
|
|
541
|
+
await this.debugLog(`updateCharacteristicc TargetPosition: 0, CurrentPosition: 0 (${this.On})`)
|
|
581
542
|
}
|
|
582
543
|
}
|
|
583
|
-
await this.debugLog(`Window Covering On: ${this.On}`)
|
|
544
|
+
await this.debugLog(`Window Covering On: ${this.On}`)
|
|
584
545
|
} else if (this.otherDeviceType === 'lock' && this.LockMechanism) {
|
|
585
546
|
if (this.On === undefined) {
|
|
586
|
-
await this.debugLog(`On: ${this.On}`)
|
|
547
|
+
await this.debugLog(`On: ${this.On}`)
|
|
587
548
|
} else {
|
|
588
549
|
if (this.On) {
|
|
589
|
-
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState,
|
|
590
|
-
|
|
591
|
-
this.
|
|
592
|
-
this.hap.Characteristic.LockCurrentState.UNSECURED);
|
|
593
|
-
await this.debugLog(`updateCharacteristicc LockTargetState: UNSECURED, LockCurrentState: UNSECURED (${this.On})`);
|
|
550
|
+
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.hap.Characteristic.LockTargetState.UNSECURED)
|
|
551
|
+
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, this.hap.Characteristic.LockCurrentState.UNSECURED)
|
|
552
|
+
await this.debugLog(`updateCharacteristicc LockTargetState: UNSECURED, LockCurrentState: UNSECURED (${this.On})`)
|
|
594
553
|
} else {
|
|
595
|
-
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState,
|
|
596
|
-
|
|
597
|
-
this.
|
|
598
|
-
this.hap.Characteristic.LockCurrentState.SECURED);
|
|
599
|
-
await this.debugLog(`updateCharacteristic LockTargetState: SECURED, LockCurrentState: SECURED (${this.On})`);
|
|
554
|
+
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.hap.Characteristic.LockTargetState.SECURED)
|
|
555
|
+
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, this.hap.Characteristic.LockCurrentState.SECURED)
|
|
556
|
+
await this.debugLog(`updateCharacteristic LockTargetState: SECURED, LockCurrentState: SECURED (${this.On})`)
|
|
600
557
|
}
|
|
601
558
|
}
|
|
602
|
-
await this.debugLog(`Lock On: ${this.On}`)
|
|
559
|
+
await this.debugLog(`Lock On: ${this.On}`)
|
|
603
560
|
} else if (this.otherDeviceType === 'faucet' && this.Faucet) {
|
|
604
561
|
if (this.On === undefined) {
|
|
605
|
-
await this.debugLog(`On: ${this.On}`)
|
|
562
|
+
await this.debugLog(`On: ${this.On}`)
|
|
606
563
|
} else {
|
|
607
564
|
if (this.On) {
|
|
608
|
-
this.Faucet.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.ACTIVE)
|
|
609
|
-
await this.debugLog(`updateCharacteristic Active: ${this.On}`)
|
|
565
|
+
this.Faucet.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.ACTIVE)
|
|
566
|
+
await this.debugLog(`updateCharacteristic Active: ${this.On}`)
|
|
610
567
|
} else {
|
|
611
|
-
this.Faucet.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.INACTIVE)
|
|
612
|
-
await this.debugLog(`updateCharacteristic Active: ${this.On}`)
|
|
568
|
+
this.Faucet.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.INACTIVE)
|
|
569
|
+
await this.debugLog(`updateCharacteristic Active: ${this.On}`)
|
|
613
570
|
}
|
|
614
571
|
}
|
|
615
|
-
await this.debugLog(`Faucet On: ${this.On}`)
|
|
572
|
+
await this.debugLog(`Faucet On: ${this.On}`)
|
|
616
573
|
} else if (this.otherDeviceType === 'fan' && this.Fan) {
|
|
617
574
|
if (this.On === undefined) {
|
|
618
|
-
await this.debugLog(`On: ${this.On}`)
|
|
575
|
+
await this.debugLog(`On: ${this.On}`)
|
|
619
576
|
} else {
|
|
620
577
|
if (this.On) {
|
|
621
|
-
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.ACTIVE)
|
|
622
|
-
await this.debugLog(`updateCharacteristic Active: ${this.On}`)
|
|
578
|
+
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.ACTIVE)
|
|
579
|
+
await this.debugLog(`updateCharacteristic Active: ${this.On}`)
|
|
623
580
|
} else {
|
|
624
|
-
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.INACTIVE)
|
|
625
|
-
await this.debugLog(`updateCharacteristic Active: ${this.On}`)
|
|
581
|
+
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.INACTIVE)
|
|
582
|
+
await this.debugLog(`updateCharacteristic Active: ${this.On}`)
|
|
626
583
|
}
|
|
627
584
|
}
|
|
628
|
-
await this.debugLog(`Fan On: ${this.On}`)
|
|
585
|
+
await this.debugLog(`Fan On: ${this.On}`)
|
|
629
586
|
} else if (this.otherDeviceType === 'stateful' && this.StatefulProgrammableSwitch) {
|
|
630
587
|
if (this.On === undefined) {
|
|
631
|
-
await this.debugLog(`On: ${this.On}`)
|
|
588
|
+
await this.debugLog(`On: ${this.On}`)
|
|
632
589
|
} else {
|
|
633
590
|
if (this.On) {
|
|
634
|
-
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent,
|
|
635
|
-
|
|
636
|
-
this.
|
|
637
|
-
await this.debugLog(`updateCharacteristic ProgrammableSwitchEvent: ProgrammableSwitchOutputState: (${this.On})`);
|
|
591
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS)
|
|
592
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, 1)
|
|
593
|
+
await this.debugLog(`updateCharacteristic ProgrammableSwitchEvent: ProgrammableSwitchOutputState: (${this.On})`)
|
|
638
594
|
} else {
|
|
639
|
-
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent,
|
|
640
|
-
|
|
641
|
-
this.
|
|
642
|
-
await this.debugLog(`updateCharacteristic ProgrammableSwitchEvent: ProgrammableSwitchOutputState: (${this.On})`);
|
|
595
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, this.hap.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS)
|
|
596
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, 0)
|
|
597
|
+
await this.debugLog(`updateCharacteristic ProgrammableSwitchEvent: ProgrammableSwitchOutputState: (${this.On})`)
|
|
643
598
|
}
|
|
644
599
|
}
|
|
645
|
-
await this.debugLog(`StatefulProgrammableSwitch On: ${this.On}`)
|
|
600
|
+
await this.debugLog(`StatefulProgrammableSwitch On: ${this.On}`)
|
|
646
601
|
} else if (this.otherDeviceType === 'outlet' && this.Outlet) {
|
|
647
602
|
if (this.On === undefined) {
|
|
648
|
-
await this.debugLog(`On: ${this.On}`)
|
|
603
|
+
await this.debugLog(`On: ${this.On}`)
|
|
649
604
|
} else {
|
|
650
|
-
this.Outlet.Service.updateCharacteristic(this.hap.Characteristic.On, this.On)
|
|
651
|
-
await this.debugLog(`updateCharacteristic On: ${this.On}`)
|
|
605
|
+
this.Outlet.Service.updateCharacteristic(this.hap.Characteristic.On, this.On)
|
|
606
|
+
await this.debugLog(`updateCharacteristic On: ${this.On}`)
|
|
652
607
|
}
|
|
653
608
|
} else {
|
|
654
|
-
await this.errorLog(`otherDeviceType: ${this.otherDeviceType}, On: ${this.On}`)
|
|
609
|
+
await this.errorLog(`otherDeviceType: ${this.otherDeviceType}, On: ${this.On}`)
|
|
655
610
|
}
|
|
656
611
|
}
|
|
657
612
|
|
|
658
613
|
async apiError(e: any): Promise<void> {
|
|
659
614
|
if (this.otherDeviceType === 'garagedoor') {
|
|
660
615
|
if (this.GarageDoor) {
|
|
661
|
-
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, e)
|
|
662
|
-
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, e)
|
|
663
|
-
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.ObstructionDetected, e)
|
|
616
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.TargetDoorState, e)
|
|
617
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.CurrentDoorState, e)
|
|
618
|
+
this.GarageDoor.Service.updateCharacteristic(this.hap.Characteristic.ObstructionDetected, e)
|
|
664
619
|
}
|
|
665
620
|
} else if (this.otherDeviceType === 'door') {
|
|
666
621
|
if (this.Door) {
|
|
667
|
-
this.Door.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e)
|
|
668
|
-
this.Door.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e)
|
|
669
|
-
this.Door.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e)
|
|
622
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e)
|
|
623
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e)
|
|
624
|
+
this.Door.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e)
|
|
670
625
|
}
|
|
671
626
|
} else if (this.otherDeviceType === 'window') {
|
|
672
627
|
if (this.Window) {
|
|
673
|
-
this.Window.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e)
|
|
674
|
-
this.Window.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e)
|
|
675
|
-
this.Window.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e)
|
|
628
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e)
|
|
629
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e)
|
|
630
|
+
this.Window.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e)
|
|
676
631
|
}
|
|
677
632
|
} else if (this.otherDeviceType === 'windowcovering') {
|
|
678
633
|
if (this.WindowCovering) {
|
|
679
|
-
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e)
|
|
680
|
-
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e)
|
|
681
|
-
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e)
|
|
634
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e)
|
|
635
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e)
|
|
636
|
+
this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e)
|
|
682
637
|
}
|
|
683
638
|
} else if (this.otherDeviceType === 'lock') {
|
|
684
639
|
if (this.LockMechanism) {
|
|
685
|
-
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, e)
|
|
686
|
-
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, e)
|
|
640
|
+
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, e)
|
|
641
|
+
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, e)
|
|
687
642
|
}
|
|
688
643
|
} else if (this.otherDeviceType === 'faucet') {
|
|
689
644
|
if (this.Faucet) {
|
|
690
|
-
this.Faucet.Service.updateCharacteristic(this.hap.Characteristic.Active, e)
|
|
645
|
+
this.Faucet.Service.updateCharacteristic(this.hap.Characteristic.Active, e)
|
|
691
646
|
}
|
|
692
647
|
} else if (this.otherDeviceType === 'fan') {
|
|
693
648
|
if (this.Fan) {
|
|
694
|
-
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.On, e)
|
|
649
|
+
this.Fan.Service.updateCharacteristic(this.hap.Characteristic.On, e)
|
|
695
650
|
}
|
|
696
651
|
} else if (this.otherDeviceType === 'stateful') {
|
|
697
652
|
if (this.StatefulProgrammableSwitch) {
|
|
698
|
-
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, e)
|
|
699
|
-
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, e)
|
|
653
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchEvent, e)
|
|
654
|
+
this.StatefulProgrammableSwitch.Service.updateCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState, e)
|
|
700
655
|
}
|
|
701
656
|
} else if (this.otherDeviceType === 'switch') {
|
|
702
657
|
if (this.Switch) {
|
|
703
|
-
this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, e)
|
|
658
|
+
this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, e)
|
|
704
659
|
}
|
|
705
660
|
} else {
|
|
706
661
|
if (this.Outlet) {
|
|
707
|
-
this.Outlet.Service.updateCharacteristic(this.hap.Characteristic.On, e)
|
|
662
|
+
this.Outlet.Service.updateCharacteristic(this.hap.Characteristic.On, e)
|
|
708
663
|
}
|
|
709
664
|
}
|
|
710
665
|
}
|
|
711
666
|
|
|
712
667
|
async removeOutletService(accessory: PlatformAccessory): Promise<void> {
|
|
713
668
|
// If Outlet.Service still present, then remove first
|
|
714
|
-
accessory.context.Outlet = accessory.context.Outlet ?? {}
|
|
669
|
+
accessory.context.Outlet = accessory.context.Outlet ?? {}
|
|
715
670
|
this.Outlet = {
|
|
716
671
|
Name: accessory.displayName,
|
|
717
672
|
Service: accessory.getService(this.hap.Service.Outlet) as Service,
|
|
718
|
-
}
|
|
719
|
-
accessory.context.Outlet = this.Outlet as object
|
|
720
|
-
this.warnLog('Removing any leftover Outlet Service')
|
|
721
|
-
accessory.removeService(this.Outlet.Service)
|
|
673
|
+
}
|
|
674
|
+
accessory.context.Outlet = this.Outlet as object
|
|
675
|
+
this.warnLog('Removing any leftover Outlet Service')
|
|
676
|
+
accessory.removeService(this.Outlet.Service)
|
|
722
677
|
}
|
|
723
678
|
|
|
724
679
|
async removeGarageDoorService(accessory: PlatformAccessory): Promise<void> {
|
|
725
680
|
// If GarageDoor.Service still present, then remove first
|
|
726
|
-
accessory.context.GarageDoor = accessory.context.GarageDoor ?? {}
|
|
681
|
+
accessory.context.GarageDoor = accessory.context.GarageDoor ?? {}
|
|
727
682
|
this.GarageDoor = {
|
|
728
683
|
Name: accessory.displayName,
|
|
729
684
|
Service: accessory.getService(this.hap.Service.GarageDoorOpener) as Service,
|
|
730
|
-
}
|
|
731
|
-
accessory.context.GarageDoor = this.GarageDoor as object
|
|
732
|
-
this.warnLog('Removing any leftover Garage Door Service')
|
|
733
|
-
accessory.removeService(this.GarageDoor.Service)
|
|
685
|
+
}
|
|
686
|
+
accessory.context.GarageDoor = this.GarageDoor as object
|
|
687
|
+
this.warnLog('Removing any leftover Garage Door Service')
|
|
688
|
+
accessory.removeService(this.GarageDoor.Service)
|
|
734
689
|
}
|
|
735
690
|
|
|
736
691
|
async removeDoorService(accessory: PlatformAccessory): Promise<void> {
|
|
737
692
|
// If Door.Service still present, then remove first
|
|
738
|
-
accessory.context.Door = accessory.context.Door ?? {}
|
|
693
|
+
accessory.context.Door = accessory.context.Door ?? {}
|
|
739
694
|
this.Door = {
|
|
740
695
|
Name: accessory.displayName,
|
|
741
696
|
Service: accessory.getService(this.hap.Service.Door) as Service,
|
|
742
|
-
}
|
|
743
|
-
accessory.context.Door = this.Door as object
|
|
744
|
-
this.warnLog('Removing any leftover Door Service')
|
|
745
|
-
accessory.removeService(this.Door.Service)
|
|
697
|
+
}
|
|
698
|
+
accessory.context.Door = this.Door as object
|
|
699
|
+
this.warnLog('Removing any leftover Door Service')
|
|
700
|
+
accessory.removeService(this.Door.Service)
|
|
746
701
|
}
|
|
747
702
|
|
|
748
703
|
async removeLockService(accessory: PlatformAccessory): Promise<void> {
|
|
749
704
|
// If Lock.Service still present, then remove first
|
|
750
|
-
accessory.context.LockMechanism = accessory.context.LockMechanism ?? {}
|
|
705
|
+
accessory.context.LockMechanism = accessory.context.LockMechanism ?? {}
|
|
751
706
|
this.LockMechanism = {
|
|
752
707
|
Name: accessory.displayName,
|
|
753
708
|
Service: accessory.getService(this.hap.Service.LockMechanism) as Service,
|
|
754
|
-
}
|
|
755
|
-
accessory.context.LockMechanism = this.LockMechanism as object
|
|
756
|
-
this.warnLog('Removing any leftover Lock Service')
|
|
757
|
-
accessory.removeService(this.LockMechanism.Service)
|
|
709
|
+
}
|
|
710
|
+
accessory.context.LockMechanism = this.LockMechanism as object
|
|
711
|
+
this.warnLog('Removing any leftover Lock Service')
|
|
712
|
+
accessory.removeService(this.LockMechanism.Service)
|
|
758
713
|
}
|
|
759
714
|
|
|
760
715
|
async removeFaucetService(accessory: PlatformAccessory): Promise<void> {
|
|
761
716
|
// If Faucet.Service still present, then remove first
|
|
762
|
-
accessory.context.Faucet = accessory.context.Faucet ?? {}
|
|
717
|
+
accessory.context.Faucet = accessory.context.Faucet ?? {}
|
|
763
718
|
this.Faucet = {
|
|
764
719
|
Name: accessory.displayName,
|
|
765
720
|
Service: accessory.getService(this.hap.Service.Faucet) as Service,
|
|
766
|
-
}
|
|
767
|
-
accessory.context.Faucet = this.Faucet as object
|
|
768
|
-
this.warnLog('Removing any leftover Faucet Service')
|
|
769
|
-
accessory.removeService(this.Faucet.Service)
|
|
721
|
+
}
|
|
722
|
+
accessory.context.Faucet = this.Faucet as object
|
|
723
|
+
this.warnLog('Removing any leftover Faucet Service')
|
|
724
|
+
accessory.removeService(this.Faucet.Service)
|
|
770
725
|
}
|
|
771
726
|
|
|
772
727
|
async removeFanService(accessory: PlatformAccessory): Promise<void> {
|
|
773
728
|
// If Fan Service still present, then remove first
|
|
774
|
-
accessory.context.Fan = accessory.context.Fan ?? {}
|
|
729
|
+
accessory.context.Fan = accessory.context.Fan ?? {}
|
|
775
730
|
this.Fan = {
|
|
776
731
|
Name: accessory.displayName,
|
|
777
732
|
Service: accessory.getService(this.hap.Service.Fanv2) as Service,
|
|
778
|
-
}
|
|
779
|
-
accessory.context.Fan = this.Fan as object
|
|
780
|
-
this.warnLog('Removing any leftover Fan Service')
|
|
781
|
-
accessory.removeService(this.Fan.Service)
|
|
733
|
+
}
|
|
734
|
+
accessory.context.Fan = this.Fan as object
|
|
735
|
+
this.warnLog('Removing any leftover Fan Service')
|
|
736
|
+
accessory.removeService(this.Fan.Service)
|
|
782
737
|
}
|
|
783
738
|
|
|
784
739
|
async removeWindowService(accessory: PlatformAccessory): Promise<void> {
|
|
785
740
|
// If Window.Service still present, then remove first
|
|
786
|
-
accessory.context.Window = accessory.context.Window ?? {}
|
|
741
|
+
accessory.context.Window = accessory.context.Window ?? {}
|
|
787
742
|
this.Window = {
|
|
788
743
|
Name: accessory.displayName,
|
|
789
744
|
Service: accessory.getService(this.hap.Service.Window) as Service,
|
|
790
|
-
}
|
|
791
|
-
accessory.context.Window = this.Window as object
|
|
792
|
-
this.warnLog('Removing any leftover Window Service')
|
|
793
|
-
accessory.removeService(this.Window.Service)
|
|
745
|
+
}
|
|
746
|
+
accessory.context.Window = this.Window as object
|
|
747
|
+
this.warnLog('Removing any leftover Window Service')
|
|
748
|
+
accessory.removeService(this.Window.Service)
|
|
794
749
|
}
|
|
795
750
|
|
|
796
751
|
async removeWindowCoveringService(accessory: PlatformAccessory): Promise<void> {
|
|
797
752
|
// If WindowCovering.Service still present, then remove first
|
|
798
|
-
accessory.context.WindowCovering = accessory.context.WindowCovering ?? {}
|
|
753
|
+
accessory.context.WindowCovering = accessory.context.WindowCovering ?? {}
|
|
799
754
|
this.WindowCovering = {
|
|
800
755
|
Name: accessory.displayName,
|
|
801
756
|
Service: accessory.getService(this.hap.Service.WindowCovering) as Service,
|
|
802
|
-
}
|
|
803
|
-
accessory.context.WindowCovering = this.WindowCovering as object
|
|
804
|
-
this.warnLog('Removing any leftover Window Covering Service')
|
|
805
|
-
accessory.removeService(this.WindowCovering.Service)
|
|
757
|
+
}
|
|
758
|
+
accessory.context.WindowCovering = this.WindowCovering as object
|
|
759
|
+
this.warnLog('Removing any leftover Window Covering Service')
|
|
760
|
+
accessory.removeService(this.WindowCovering.Service)
|
|
806
761
|
}
|
|
807
762
|
|
|
808
763
|
async removeStatefulProgrammableSwitchService(accessory: PlatformAccessory): Promise<void> {
|
|
809
764
|
// If StatefulProgrammableSwitch.Service still present, then remove first
|
|
810
|
-
accessory.context.StatefulProgrammableSwitch = accessory.context.StatefulProgrammableSwitch ?? {}
|
|
765
|
+
accessory.context.StatefulProgrammableSwitch = accessory.context.StatefulProgrammableSwitch ?? {}
|
|
811
766
|
this.StatefulProgrammableSwitch = {
|
|
812
767
|
Name: accessory.displayName,
|
|
813
768
|
Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch) as Service,
|
|
814
|
-
}
|
|
815
|
-
accessory.context.StatefulProgrammableSwitch = this.StatefulProgrammableSwitch as object
|
|
816
|
-
this.warnLog('Removing any leftover Stateful Programmable Switch Service')
|
|
817
|
-
accessory.removeService(this.StatefulProgrammableSwitch.Service)
|
|
769
|
+
}
|
|
770
|
+
accessory.context.StatefulProgrammableSwitch = this.StatefulProgrammableSwitch as object
|
|
771
|
+
this.warnLog('Removing any leftover Stateful Programmable Switch Service')
|
|
772
|
+
accessory.removeService(this.StatefulProgrammableSwitch.Service)
|
|
818
773
|
}
|
|
819
774
|
|
|
820
775
|
async removeSwitchService(accessory: PlatformAccessory): Promise<void> {
|
|
821
776
|
// If Switch.Service still present, then remove first
|
|
822
|
-
accessory.context.Switch = accessory.context.Switch ?? {}
|
|
777
|
+
accessory.context.Switch = accessory.context.Switch ?? {}
|
|
823
778
|
this.Switch = {
|
|
824
779
|
Name: accessory.displayName,
|
|
825
780
|
Service: accessory.getService(this.hap.Service.Switch) as Service,
|
|
826
|
-
}
|
|
827
|
-
accessory.context.Switch = this.Switch as object
|
|
828
|
-
this.warnLog('Removing any leftover Switch Service')
|
|
829
|
-
accessory.removeService(this.Switch.Service)
|
|
781
|
+
}
|
|
782
|
+
accessory.context.Switch = this.Switch as object
|
|
783
|
+
this.warnLog('Removing any leftover Switch Service')
|
|
784
|
+
accessory.removeService(this.Switch.Service)
|
|
830
785
|
}
|
|
831
786
|
|
|
832
787
|
async getOtherConfigSettings(accessory: PlatformAccessory, device: irdevice & irDevicesConfig): Promise<void> {
|
|
833
|
-
this.otherDeviceType = accessory.context.otherDeviceType
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
788
|
+
this.otherDeviceType = accessory.context.otherDeviceType
|
|
789
|
+
? accessory.context.otherDeviceType
|
|
790
|
+
: device.other?.deviceType ? device.other.deviceType : 'outlet'
|
|
791
|
+
const deviceType = accessory.context.otherDeviceType ? 'Accessory Cache' : device.other?.deviceType ? 'Device Config' : 'Default'
|
|
792
|
+
await this.debugLog(`Use ${deviceType} Type: ${this.otherDeviceType}`)
|
|
837
793
|
}
|
|
838
794
|
}
|