@switchbot/homebridge-switchbot 3.5.0-beta.57 → 3.5.0-beta.59
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/.vscode/settings.json +4 -1
- package/dist/device/blindtilt.d.ts +5 -5
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +103 -69
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +4 -4
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +201 -154
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +3 -3
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +41 -36
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +3 -3
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +36 -37
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +4 -4
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +76 -55
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +4 -4
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +99 -55
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +4 -4
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +11 -9
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts +3 -3
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +54 -24
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts +4 -4
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +40 -57
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +3 -3
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +39 -39
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +3 -3
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +41 -50
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +4 -4
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +36 -33
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +3 -3
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +68 -59
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +3 -3
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +42 -51
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +3 -3
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +42 -51
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +3 -3
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +52 -40
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +3 -3
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +13 -13
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +4 -4
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +81 -98
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts +3 -3
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +39 -31
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/homebridge-ui/public/index.html +20 -14
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +3 -3
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +9 -9
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +3 -3
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +1 -1
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +3 -3
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +2 -2
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +6 -6
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +37 -29
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +3 -3
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts +9 -14
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +67 -88
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +3 -3
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +1 -1
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +3 -3
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +3 -3
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +3 -3
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +2 -2
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +3 -3
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +2 -2
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +7 -7
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +20 -23
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +24 -10
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +16 -0
- package/dist/settings.js.map +1 -1
- package/eslint.config.js +89 -78
- package/package.json +3 -3
- package/src/device/blindtilt.ts +120 -87
- package/src/device/bot.ts +238 -175
- package/src/device/ceilinglight.ts +49 -46
- package/src/device/colorbulb.ts +40 -43
- package/src/device/contact.ts +91 -65
- package/src/device/curtain.ts +113 -66
- package/src/device/device.ts +12 -13
- package/src/device/fan.ts +66 -29
- package/src/device/hub.ts +53 -60
- package/src/device/humidifier.ts +54 -56
- package/src/device/iosensor.ts +57 -56
- package/src/device/lightstrip.ts +43 -39
- package/src/device/lock.ts +79 -68
- package/src/device/meter.ts +54 -54
- package/src/device/meterplus.ts +54 -54
- package/src/device/motion.ts +62 -46
- package/src/device/plug.ts +19 -18
- package/src/device/robotvacuumcleaner.ts +89 -104
- package/src/device/waterdetector.ts +46 -34
- package/src/homebridge-ui/public/index.html +20 -14
- package/src/index.ts +3 -2
- package/src/irdevice/airconditioner.ts +13 -11
- package/src/irdevice/airpurifier.ts +5 -3
- package/src/irdevice/camera.ts +6 -4
- package/src/irdevice/fan.ts +42 -29
- package/src/irdevice/irdevice.ts +4 -5
- package/src/irdevice/light.ts +83 -103
- package/src/irdevice/other.ts +5 -3
- package/src/irdevice/tv.ts +7 -5
- package/src/irdevice/vacuumcleaner.ts +6 -4
- package/src/irdevice/waterheater.ts +6 -4
- package/src/platform.ts +59 -66
- package/src/settings.ts +73 -58
package/dist/device/bot.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import { request } from 'undici';
|
|
6
6
|
import { deviceBase } from './device.js';
|
|
7
7
|
import { interval, Subject } from 'rxjs';
|
|
8
|
-
import { debounceTime, skipWhile, take, tap } from 'rxjs/operators';
|
|
9
8
|
import { Devices } from '../settings.js';
|
|
9
|
+
import { debounceTime, skipWhile, take, tap } from 'rxjs/operators';
|
|
10
10
|
/**
|
|
11
11
|
* Platform Accessory
|
|
12
12
|
* An instance of this class is created for each accessory your platform registers
|
|
@@ -21,7 +21,7 @@ export class Bot extends deviceBase {
|
|
|
21
21
|
Door;
|
|
22
22
|
Window;
|
|
23
23
|
WindowCovering;
|
|
24
|
-
|
|
24
|
+
LockMechanism;
|
|
25
25
|
Faucet;
|
|
26
26
|
Fan;
|
|
27
27
|
StatefulProgrammableSwitch;
|
|
@@ -46,17 +46,37 @@ export class Bot extends deviceBase {
|
|
|
46
46
|
this.botUpdateInProgress = false;
|
|
47
47
|
// Initialize Battery property
|
|
48
48
|
this.Battery = {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
Name: accessory.context.BatteryName ?? `${accessory.displayName} Battery`,
|
|
50
|
+
Service: accessory.getService(this.hap.Service.Battery) ?? accessory.addService(this.hap.Service.Battery),
|
|
51
|
+
BatteryLevel: accessory.context.BatteryLevel ?? 100,
|
|
52
|
+
StatusLowBattery: accessory.context.StatusLowBattery ?? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
|
|
52
53
|
};
|
|
54
|
+
// Initialize Battery Characteristics
|
|
55
|
+
this.Battery.Service
|
|
56
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.Battery.Name)
|
|
57
|
+
.setCharacteristic(this.hap.Characteristic.StatusLowBattery, this.Battery.StatusLowBattery)
|
|
58
|
+
.setCharacteristic(this.hap.Characteristic.ChargingState, this.hap.Characteristic.ChargingState.NOT_CHARGEABLE);
|
|
59
|
+
accessory.context.Battery.Name = this.Battery.Name;
|
|
53
60
|
// deviceType
|
|
54
61
|
if (this.botDeviceType === 'switch') {
|
|
55
|
-
// Initialize Switch
|
|
62
|
+
// Initialize Switch Service
|
|
56
63
|
this.Switch = {
|
|
57
|
-
|
|
58
|
-
|
|
64
|
+
Name: accessory.context.Name ?? accessory.displayName,
|
|
65
|
+
Service: accessory.getService(this.hap.Service.Switch) ?? accessory.addService(this.hap.Service.Switch),
|
|
66
|
+
On: accessory.context.On ?? false,
|
|
59
67
|
};
|
|
68
|
+
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Switch`);
|
|
69
|
+
// Initialize Switch Characteristics
|
|
70
|
+
this.Switch.Service
|
|
71
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.Switch.Name)
|
|
72
|
+
.setCharacteristic(this.hap.Characteristic.On, this.Switch.On)
|
|
73
|
+
.getCharacteristic(this.hap.Characteristic.On)
|
|
74
|
+
.onGet(() => {
|
|
75
|
+
return this.Switch.On;
|
|
76
|
+
})
|
|
77
|
+
.onSet(this.OnSet.bind(this));
|
|
78
|
+
accessory.context.Name = this.Switch.Name;
|
|
79
|
+
// Remove other services
|
|
60
80
|
this.removeFanService(accessory);
|
|
61
81
|
this.removeLockService(accessory);
|
|
62
82
|
this.removeDoorService(accessory);
|
|
@@ -66,20 +86,31 @@ export class Bot extends deviceBase {
|
|
|
66
86
|
this.removeGarageDoorService(accessory);
|
|
67
87
|
this.removeWindowCoveringService(accessory);
|
|
68
88
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
69
|
-
// Add switchService
|
|
70
|
-
const switchService = `${accessory.displayName} Switch`;
|
|
71
|
-
(this.Switch.Service = accessory.getService(this.hap.Service.Switch)
|
|
72
|
-
|| accessory.addService(this.hap.Service.Switch)), switchService;
|
|
73
|
-
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Switch`);
|
|
74
|
-
this.Switch.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
75
|
-
this.Switch.Service.getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
76
89
|
}
|
|
77
90
|
else if (this.botDeviceType === 'garagedoor') {
|
|
78
|
-
// Initialize
|
|
91
|
+
// Initialize GarageDoor Service
|
|
79
92
|
this.GarageDoor = {
|
|
80
|
-
|
|
81
|
-
|
|
93
|
+
Name: accessory.context.Name ?? accessory.displayName,
|
|
94
|
+
Service: accessory.getService(this.hap.Service.GarageDoorOpener) ?? accessory.addService(this.hap.Service.GarageDoorOpener),
|
|
95
|
+
On: accessory.context.On ?? false,
|
|
82
96
|
};
|
|
97
|
+
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Garage Door Opener`);
|
|
98
|
+
// Initialize GarageDoor Characteristics
|
|
99
|
+
this.GarageDoor.Service
|
|
100
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.GarageDoor.Name)
|
|
101
|
+
.setCharacteristic(this.hap.Characteristic.ObstructionDetected, false)
|
|
102
|
+
.getCharacteristic(this.hap.Characteristic.TargetDoorState).setProps({
|
|
103
|
+
validValues: [0, 100],
|
|
104
|
+
minValue: 0,
|
|
105
|
+
maxValue: 100,
|
|
106
|
+
minStep: 100,
|
|
107
|
+
})
|
|
108
|
+
.onGet(() => {
|
|
109
|
+
return this.GarageDoor.On;
|
|
110
|
+
})
|
|
111
|
+
.onSet(this.OnSet.bind(this));
|
|
112
|
+
accessory.context.Name = this.GarageDoor.Name;
|
|
113
|
+
// Remove other services
|
|
83
114
|
this.removeFanService(accessory);
|
|
84
115
|
this.removeLockService(accessory);
|
|
85
116
|
this.removeDoorService(accessory);
|
|
@@ -89,117 +120,127 @@ export class Bot extends deviceBase {
|
|
|
89
120
|
this.removeWindowService(accessory);
|
|
90
121
|
this.removeWindowCoveringService(accessory);
|
|
91
122
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
92
|
-
// Add garageDoorService
|
|
93
|
-
const garageDoorService = `${accessory.displayName} Garage Door Opener`;
|
|
94
|
-
(this.GarageDoor.Service = accessory.getService(this.hap.Service.GarageDoorOpener)
|
|
95
|
-
|| accessory.addService(this.hap.Service.GarageDoorOpener)), garageDoorService;
|
|
96
|
-
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Garage Door Opener`);
|
|
97
|
-
this.GarageDoor.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
98
|
-
this.GarageDoor.Service.getCharacteristic(this.hap.Characteristic.TargetDoorState).onSet(this.OnSet.bind(this));
|
|
99
|
-
this.GarageDoor.Service.setCharacteristic(this.hap.Characteristic.ObstructionDetected, false);
|
|
100
123
|
}
|
|
101
124
|
else if (this.botDeviceType === 'door') {
|
|
102
|
-
// Initialize
|
|
125
|
+
// Initialize Door Service
|
|
103
126
|
this.Door = {
|
|
104
|
-
|
|
105
|
-
|
|
127
|
+
Name: accessory.context.Name ?? accessory.displayName,
|
|
128
|
+
Service: accessory.getService(this.hap.Service.Door) ?? accessory.addService(this.hap.Service.Door),
|
|
129
|
+
On: accessory.context.On ?? false,
|
|
106
130
|
};
|
|
107
|
-
this.removeFanService(accessory);
|
|
108
|
-
this.removeLockService(accessory);
|
|
109
|
-
this.removeOutletService(accessory);
|
|
110
|
-
this.removeFaucetService(accessory);
|
|
111
|
-
this.removeSwitchService(accessory);
|
|
112
|
-
this.removeWindowService(accessory);
|
|
113
|
-
this.removeGarageDoorService(accessory);
|
|
114
|
-
this.removeWindowCoveringService(accessory);
|
|
115
|
-
this.removeStatefulProgrammableSwitchService(accessory);
|
|
116
|
-
// Add doorService
|
|
117
|
-
const doorService = `${accessory.displayName} Door`;
|
|
118
|
-
(this.Door.Service = accessory.getService(this.hap.Service.Door)
|
|
119
|
-
|| accessory.addService(this.hap.Service.Door)), doorService;
|
|
120
131
|
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Door`);
|
|
121
|
-
|
|
132
|
+
// Initialize Door Characteristics
|
|
122
133
|
this.Door.Service
|
|
123
|
-
.
|
|
124
|
-
.
|
|
134
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.Door.Name)
|
|
135
|
+
.setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
|
|
136
|
+
.getCharacteristic(this.hap.Characteristic.TargetPosition).setProps({
|
|
125
137
|
validValues: [0, 100],
|
|
126
138
|
minValue: 0,
|
|
127
139
|
maxValue: 100,
|
|
128
140
|
minStep: 100,
|
|
141
|
+
})
|
|
142
|
+
.onGet(() => {
|
|
143
|
+
return this.Door.On;
|
|
129
144
|
})
|
|
130
145
|
.onSet(this.OnSet.bind(this));
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
else if (this.botDeviceType === 'window') {
|
|
134
|
-
// Initialize Switch property
|
|
135
|
-
this.Window = {
|
|
136
|
-
Service: accessory.getService(this.hap.Service.Window),
|
|
137
|
-
On: accessory.context.On || false,
|
|
138
|
-
};
|
|
146
|
+
accessory.context.Name = this.Door.Name;
|
|
147
|
+
// Remove other services
|
|
139
148
|
this.removeFanService(accessory);
|
|
140
149
|
this.removeLockService(accessory);
|
|
141
|
-
this.removeDoorService(accessory);
|
|
142
150
|
this.removeOutletService(accessory);
|
|
143
151
|
this.removeFaucetService(accessory);
|
|
144
152
|
this.removeSwitchService(accessory);
|
|
153
|
+
this.removeWindowService(accessory);
|
|
145
154
|
this.removeGarageDoorService(accessory);
|
|
146
155
|
this.removeWindowCoveringService(accessory);
|
|
147
156
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
157
|
+
}
|
|
158
|
+
else if (this.botDeviceType === 'window') {
|
|
159
|
+
// Initialize Window Service
|
|
160
|
+
this.Window = {
|
|
161
|
+
Name: accessory.context.Name ?? accessory.displayName,
|
|
162
|
+
Service: accessory.getService(this.hap.Service.Window) ?? accessory.addService(this.hap.Service.Window),
|
|
163
|
+
On: accessory.context.On ?? false,
|
|
164
|
+
};
|
|
152
165
|
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Window`);
|
|
153
|
-
|
|
166
|
+
// Initialize Window Characteristics
|
|
154
167
|
this.Window.Service
|
|
155
|
-
.
|
|
156
|
-
.
|
|
168
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.Window.Name)
|
|
169
|
+
.setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
|
|
170
|
+
.getCharacteristic(this.hap.Characteristic.TargetPosition).setProps({
|
|
157
171
|
validValues: [0, 100],
|
|
158
172
|
minValue: 0,
|
|
159
173
|
maxValue: 100,
|
|
160
174
|
minStep: 100,
|
|
175
|
+
})
|
|
176
|
+
.onGet(() => {
|
|
177
|
+
return this.Window.On;
|
|
161
178
|
})
|
|
162
179
|
.onSet(this.OnSet.bind(this));
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
else if (this.botDeviceType === 'windowcovering') {
|
|
166
|
-
// Initialize Switch property
|
|
167
|
-
this.WindowCovering = {
|
|
168
|
-
Service: accessory.getService(this.hap.Service.WindowCovering),
|
|
169
|
-
On: accessory.context.On || false,
|
|
170
|
-
};
|
|
180
|
+
accessory.context.Name = this.Window.Name;
|
|
181
|
+
// Remove other services
|
|
171
182
|
this.removeFanService(accessory);
|
|
172
183
|
this.removeLockService(accessory);
|
|
173
184
|
this.removeDoorService(accessory);
|
|
174
185
|
this.removeOutletService(accessory);
|
|
175
186
|
this.removeFaucetService(accessory);
|
|
176
187
|
this.removeSwitchService(accessory);
|
|
177
|
-
this.removeWindowService(accessory);
|
|
178
188
|
this.removeGarageDoorService(accessory);
|
|
189
|
+
this.removeWindowCoveringService(accessory);
|
|
179
190
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
191
|
+
}
|
|
192
|
+
else if (this.botDeviceType === 'windowcovering') {
|
|
193
|
+
// Initialize WindowCovering Service
|
|
194
|
+
this.WindowCovering = {
|
|
195
|
+
Name: accessory.context.Name ?? accessory.displayName,
|
|
196
|
+
Service: accessory.getService(this.hap.Service.WindowCovering) ?? accessory.addService(this.hap.Service.WindowCovering),
|
|
197
|
+
On: accessory.context.On ?? false,
|
|
198
|
+
};
|
|
184
199
|
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Window Covering`);
|
|
185
|
-
|
|
200
|
+
// Initialize WindowCovering Characteristics
|
|
186
201
|
this.WindowCovering.Service
|
|
187
|
-
.
|
|
188
|
-
.
|
|
202
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.WindowCovering.Name)
|
|
203
|
+
.setCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
|
|
204
|
+
.getCharacteristic(this.hap.Characteristic.TargetPosition).setProps({
|
|
189
205
|
validValues: [0, 100],
|
|
190
206
|
minValue: 0,
|
|
191
207
|
maxValue: 100,
|
|
192
208
|
minStep: 100,
|
|
209
|
+
})
|
|
210
|
+
.onGet(() => {
|
|
211
|
+
return this.WindowCovering.On;
|
|
193
212
|
})
|
|
194
213
|
.onSet(this.OnSet.bind(this));
|
|
195
|
-
|
|
214
|
+
accessory.context.Name = this.WindowCovering.Name;
|
|
215
|
+
// Remove other services
|
|
216
|
+
this.removeFanService(accessory);
|
|
217
|
+
this.removeLockService(accessory);
|
|
218
|
+
this.removeDoorService(accessory);
|
|
219
|
+
this.removeOutletService(accessory);
|
|
220
|
+
this.removeFaucetService(accessory);
|
|
221
|
+
this.removeSwitchService(accessory);
|
|
222
|
+
this.removeWindowService(accessory);
|
|
223
|
+
this.removeGarageDoorService(accessory);
|
|
224
|
+
this.removeStatefulProgrammableSwitchService(accessory);
|
|
196
225
|
}
|
|
197
226
|
else if (this.botDeviceType === 'lock') {
|
|
198
|
-
// Initialize
|
|
199
|
-
this.
|
|
200
|
-
|
|
201
|
-
|
|
227
|
+
// Initialize Lock Service
|
|
228
|
+
this.LockMechanism = {
|
|
229
|
+
Name: accessory.context.Name ?? accessory.displayName,
|
|
230
|
+
Service: accessory.getService(this.hap.Service.LockMechanism) ?? accessory.addService(this.hap.Service.LockMechanism),
|
|
231
|
+
On: accessory.context.On ?? false,
|
|
202
232
|
};
|
|
233
|
+
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Lock`);
|
|
234
|
+
// Initialize Lock Characteristics
|
|
235
|
+
this.LockMechanism.Service
|
|
236
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.LockMechanism.Name)
|
|
237
|
+
.getCharacteristic(this.hap.Characteristic.LockTargetState)
|
|
238
|
+
.onGet(() => {
|
|
239
|
+
return this.LockMechanism.On;
|
|
240
|
+
})
|
|
241
|
+
.onSet(this.OnSet.bind(this));
|
|
242
|
+
accessory.context.Name = this.LockMechanism.Name;
|
|
243
|
+
// Remove other services
|
|
203
244
|
this.removeFanService(accessory);
|
|
204
245
|
this.removeDoorService(accessory);
|
|
205
246
|
this.removeOutletService(accessory);
|
|
@@ -209,20 +250,25 @@ export class Bot extends deviceBase {
|
|
|
209
250
|
this.removeGarageDoorService(accessory);
|
|
210
251
|
this.removeWindowCoveringService(accessory);
|
|
211
252
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
212
|
-
// Add lockService
|
|
213
|
-
const lockService = `${accessory.displayName} Lock`;
|
|
214
|
-
(this.Lock.Service = accessory.getService(this.hap.Service.LockMechanism)
|
|
215
|
-
|| accessory.addService(this.hap.Service.LockMechanism)), lockService;
|
|
216
|
-
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Lock`);
|
|
217
|
-
this.Lock.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
218
|
-
this.Lock.Service.getCharacteristic(this.hap.Characteristic.LockTargetState).onSet(this.OnSet.bind(this));
|
|
219
253
|
}
|
|
220
254
|
else if (this.botDeviceType === 'faucet') {
|
|
221
|
-
// Initialize
|
|
255
|
+
// Initialize Faucet Service
|
|
222
256
|
this.Faucet = {
|
|
223
|
-
|
|
224
|
-
|
|
257
|
+
Name: accessory.context.Name ?? accessory.displayName,
|
|
258
|
+
Service: accessory.getService(this.hap.Service.Faucet) ?? accessory.addService(this.hap.Service.Faucet),
|
|
259
|
+
On: accessory.context.On ?? false,
|
|
225
260
|
};
|
|
261
|
+
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Faucet`);
|
|
262
|
+
// Initialize Faucet Characteristics
|
|
263
|
+
this.Faucet.Service
|
|
264
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.Faucet.Name)
|
|
265
|
+
.getCharacteristic(this.hap.Characteristic.Active)
|
|
266
|
+
.onGet(() => {
|
|
267
|
+
return this.Faucet.On;
|
|
268
|
+
})
|
|
269
|
+
.onSet(this.OnSet.bind(this));
|
|
270
|
+
accessory.context.Name = this.Faucet.Name;
|
|
271
|
+
// Remove other services
|
|
226
272
|
this.removeFanService(accessory);
|
|
227
273
|
this.removeLockService(accessory);
|
|
228
274
|
this.removeDoorService(accessory);
|
|
@@ -232,20 +278,25 @@ export class Bot extends deviceBase {
|
|
|
232
278
|
this.removeGarageDoorService(accessory);
|
|
233
279
|
this.removeWindowCoveringService(accessory);
|
|
234
280
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
235
|
-
// Add faucetService
|
|
236
|
-
const faucetService = `${accessory.displayName} Faucet`;
|
|
237
|
-
(this.Faucet.Service = accessory.getService(this.hap.Service.Faucet)
|
|
238
|
-
|| accessory.addService(this.hap.Service.Faucet)), faucetService;
|
|
239
|
-
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Faucet`);
|
|
240
|
-
this.Faucet.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
241
|
-
this.Faucet.Service.getCharacteristic(this.hap.Characteristic.Active).onSet(this.OnSet.bind(this));
|
|
242
281
|
}
|
|
243
282
|
else if (this.botDeviceType === 'fan') {
|
|
244
|
-
// Initialize
|
|
283
|
+
// Initialize Fan Service
|
|
245
284
|
this.Fan = {
|
|
246
|
-
|
|
247
|
-
|
|
285
|
+
Name: accessory.context.Name ?? accessory.displayName,
|
|
286
|
+
Service: accessory.getService(this.hap.Service.Fanv2) ?? accessory.addService(this.hap.Service.Fanv2),
|
|
287
|
+
On: accessory.context.On ?? false,
|
|
248
288
|
};
|
|
289
|
+
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Fan`);
|
|
290
|
+
// Initialize Fan Characteristics
|
|
291
|
+
this.Fan.Service
|
|
292
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.Fan.Name)
|
|
293
|
+
.getCharacteristic(this.hap.Characteristic.On)
|
|
294
|
+
.onGet(() => {
|
|
295
|
+
return this.Fan.On;
|
|
296
|
+
})
|
|
297
|
+
.onSet(this.OnSet.bind(this));
|
|
298
|
+
accessory.context.Name = this.Fan.Name;
|
|
299
|
+
// Remove other services
|
|
249
300
|
this.removeLockService(accessory);
|
|
250
301
|
this.removeDoorService(accessory);
|
|
251
302
|
this.removeFaucetService(accessory);
|
|
@@ -255,20 +306,26 @@ export class Bot extends deviceBase {
|
|
|
255
306
|
this.removeGarageDoorService(accessory);
|
|
256
307
|
this.removeWindowCoveringService(accessory);
|
|
257
308
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
258
|
-
// Add fanService
|
|
259
|
-
const fanService = `${accessory.displayName} Fan`;
|
|
260
|
-
(this.Fan.Service = accessory.getService(this.hap.Service.Fanv2)
|
|
261
|
-
|| accessory.addService(this.hap.Service.Fanv2)), fanService;
|
|
262
|
-
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Fan`);
|
|
263
|
-
this.Fan.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
264
|
-
this.Fan.Service.getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
265
309
|
}
|
|
266
310
|
else if (this.botDeviceType === 'stateful') {
|
|
267
|
-
// Initialize
|
|
311
|
+
// Initialize StatefulProgrammableSwitch Service
|
|
268
312
|
this.StatefulProgrammableSwitch = {
|
|
269
|
-
|
|
270
|
-
|
|
313
|
+
Name: accessory.context.Name ?? accessory.displayName,
|
|
314
|
+
Service: accessory.getService(this.hap.Service.StatefulProgrammableSwitch)
|
|
315
|
+
?? accessory.addService(this.hap.Service.StatefulProgrammableSwitch),
|
|
316
|
+
On: accessory.context.On ?? false,
|
|
271
317
|
};
|
|
318
|
+
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Stateful Programmable Switch`);
|
|
319
|
+
// Initialize StatefulProgrammableSwitch Characteristics
|
|
320
|
+
this.StatefulProgrammableSwitch.Service
|
|
321
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.StatefulProgrammableSwitch.Name)
|
|
322
|
+
.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState)
|
|
323
|
+
.onGet(() => {
|
|
324
|
+
return this.StatefulProgrammableSwitch.On;
|
|
325
|
+
})
|
|
326
|
+
.onSet(this.OnSet.bind(this));
|
|
327
|
+
accessory.context.Name = this.StatefulProgrammableSwitch.Name;
|
|
328
|
+
// Remove other services
|
|
272
329
|
this.removeFanService(accessory);
|
|
273
330
|
this.removeLockService(accessory);
|
|
274
331
|
this.removeDoorService(accessory);
|
|
@@ -278,22 +335,25 @@ export class Bot extends deviceBase {
|
|
|
278
335
|
this.removeWindowService(accessory);
|
|
279
336
|
this.removeGarageDoorService(accessory);
|
|
280
337
|
this.removeWindowCoveringService(accessory);
|
|
281
|
-
// Add statefulProgrammableSwitchService
|
|
282
|
-
const statefulProgrammableSwitchService = `${accessory.displayName} Stateful Programmable Switch`;
|
|
283
|
-
(this.StatefulProgrammableSwitch.Service = accessory.getService(this.hap.Service.StatefulProgrammableSwitch) ||
|
|
284
|
-
accessory.addService(this.hap.Service.StatefulProgrammableSwitch)), statefulProgrammableSwitchService;
|
|
285
|
-
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Stateful Programmable Switch`);
|
|
286
|
-
this.StatefulProgrammableSwitch.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
287
|
-
this.StatefulProgrammableSwitch.Service
|
|
288
|
-
.getCharacteristic(this.hap.Characteristic.ProgrammableSwitchOutputState)
|
|
289
|
-
.onSet(this.OnSet.bind(this));
|
|
290
338
|
}
|
|
291
339
|
else {
|
|
292
340
|
// Initialize Switch property
|
|
293
341
|
this.Outlet = {
|
|
294
|
-
|
|
295
|
-
|
|
342
|
+
Name: accessory.context.Name ?? accessory.displayName,
|
|
343
|
+
Service: accessory.getService(this.hap.Service.Outlet) ?? accessory.addService(this.hap.Service.Outlet),
|
|
344
|
+
On: accessory.context.On ?? false,
|
|
296
345
|
};
|
|
346
|
+
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Outlet`);
|
|
347
|
+
// Initialize Outlet Characteristics
|
|
348
|
+
this.Outlet.Service
|
|
349
|
+
.setCharacteristic(this.hap.Characteristic.Name, this.Outlet.Name)
|
|
350
|
+
.getCharacteristic(this.hap.Characteristic.On)
|
|
351
|
+
.onGet(() => {
|
|
352
|
+
return this.Outlet.On;
|
|
353
|
+
})
|
|
354
|
+
.onSet(this.OnSet.bind(this));
|
|
355
|
+
accessory.context.Name = this.Outlet.Name;
|
|
356
|
+
// Remove other services
|
|
297
357
|
this.removeFanService(accessory);
|
|
298
358
|
this.removeLockService(accessory);
|
|
299
359
|
this.removeDoorService(accessory);
|
|
@@ -303,22 +363,9 @@ export class Bot extends deviceBase {
|
|
|
303
363
|
this.removeGarageDoorService(accessory);
|
|
304
364
|
this.removeWindowCoveringService(accessory);
|
|
305
365
|
this.removeStatefulProgrammableSwitchService(accessory);
|
|
306
|
-
// Add outletService
|
|
307
|
-
const outletService = `${accessory.displayName} Outlet`;
|
|
308
|
-
(this.Outlet.Service = accessory.getService(this.hap.Service.Outlet)
|
|
309
|
-
|| accessory.addService(this.hap.Service.Outlet)), outletService;
|
|
310
|
-
this.debugWarnLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Outlet`);
|
|
311
|
-
this.Outlet.Service.setCharacteristic(this.hap.Characteristic.Name, accessory.displayName);
|
|
312
|
-
this.Outlet.Service.getCharacteristic(this.hap.Characteristic.On).onSet(this.OnSet.bind(this));
|
|
313
366
|
}
|
|
314
367
|
// Retrieve initial values and updateHomekit
|
|
315
368
|
this.refreshStatus();
|
|
316
|
-
// batteryService
|
|
317
|
-
const batteryService = `${accessory.displayName} Battery`;
|
|
318
|
-
(this.Battery.Service = this.accessory.getService(this.hap.Service.Battery)
|
|
319
|
-
|| accessory.addService(this.hap.Service.Battery)), batteryService;
|
|
320
|
-
this.Battery.Service.setCharacteristic(this.hap.Characteristic.Name, `${accessory.displayName} Battery`);
|
|
321
|
-
this.Battery.Service.setCharacteristic(this.hap.Characteristic.ChargingState, this.hap.Characteristic.ChargingState.NOT_CHARGEABLE);
|
|
322
369
|
// Retrieve initial values and updateHomekit
|
|
323
370
|
this.updateHomeKitCharacteristics();
|
|
324
371
|
// Start an update interval
|
|
@@ -769,11 +816,11 @@ export class Bot extends deviceBase {
|
|
|
769
816
|
this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set LockTargetState: ${value}`);
|
|
770
817
|
if (value === this.hap.Characteristic.LockTargetState.SECURED) {
|
|
771
818
|
await this.setOn(false);
|
|
772
|
-
this.
|
|
819
|
+
this.LockMechanism.On = false;
|
|
773
820
|
}
|
|
774
821
|
else {
|
|
775
822
|
await this.setOn(true);
|
|
776
|
-
this.
|
|
823
|
+
this.LockMechanism.On = true;
|
|
777
824
|
}
|
|
778
825
|
}
|
|
779
826
|
else if (this.botDeviceType === 'faucet') {
|
|
@@ -918,25 +965,25 @@ export class Bot extends deviceBase {
|
|
|
918
965
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Window Covering On: ${this.WindowCovering.On}`);
|
|
919
966
|
}
|
|
920
967
|
else if (this.botDeviceType === 'lock') {
|
|
921
|
-
if (this.
|
|
922
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.
|
|
968
|
+
if (this.LockMechanism.On === undefined) {
|
|
969
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.LockMechanism.On}`);
|
|
923
970
|
}
|
|
924
971
|
else {
|
|
925
|
-
if (this.
|
|
926
|
-
this.
|
|
927
|
-
this.
|
|
972
|
+
if (this.LockMechanism.On) {
|
|
973
|
+
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.hap.Characteristic.LockTargetState.UNSECURED);
|
|
974
|
+
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, this.hap.Characteristic.LockCurrentState.UNSECURED);
|
|
928
975
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristicc`
|
|
929
|
-
+ ` LockTargetState: UNSECURED, LockCurrentState: UNSECURED (${this.
|
|
976
|
+
+ ` LockTargetState: UNSECURED, LockCurrentState: UNSECURED (${this.LockMechanism.On})`);
|
|
930
977
|
}
|
|
931
978
|
else {
|
|
932
|
-
this.
|
|
933
|
-
this.
|
|
979
|
+
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockTargetState, this.hap.Characteristic.LockTargetState.SECURED);
|
|
980
|
+
this.LockMechanism.Service.updateCharacteristic(this.hap.Characteristic.LockCurrentState, this.hap.Characteristic.LockCurrentState.SECURED);
|
|
934
981
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic`
|
|
935
|
-
+ ` LockTargetState: SECURED, LockCurrentState: SECURED (${this.
|
|
982
|
+
+ ` LockTargetState: SECURED, LockCurrentState: SECURED (${this.LockMechanism.On})`);
|
|
936
983
|
}
|
|
937
984
|
}
|
|
938
|
-
await this.setOn(Boolean(this.
|
|
939
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Lock On: ${this.
|
|
985
|
+
await this.setOn(Boolean(this.LockMechanism.On));
|
|
986
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Lock On: ${this.LockMechanism.On}`);
|
|
940
987
|
}
|
|
941
988
|
else if (this.botDeviceType === 'faucet') {
|
|
942
989
|
if (this.Faucet.On === undefined) {
|
|
@@ -1060,10 +1107,10 @@ export class Bot extends deviceBase {
|
|
|
1060
1107
|
}
|
|
1061
1108
|
async removeLockService(accessory) {
|
|
1062
1109
|
// If lockService still present, then remove first
|
|
1063
|
-
if (this.
|
|
1064
|
-
this.
|
|
1110
|
+
if (this.LockMechanism?.Service) {
|
|
1111
|
+
this.LockMechanism.Service = this.accessory.getService(this.hap.Service.LockMechanism);
|
|
1065
1112
|
this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Lock Service`);
|
|
1066
|
-
accessory.removeService(this.
|
|
1113
|
+
accessory.removeService(this.LockMechanism.Service);
|
|
1067
1114
|
}
|
|
1068
1115
|
}
|
|
1069
1116
|
async removeFaucetService(accessory) {
|
|
@@ -1129,7 +1176,7 @@ export class Bot extends deviceBase {
|
|
|
1129
1176
|
On = this.WindowCovering.On ? true : false;
|
|
1130
1177
|
}
|
|
1131
1178
|
else if (this.botDeviceType === 'lock') {
|
|
1132
|
-
On = this.
|
|
1179
|
+
On = this.LockMechanism.On ? true : false;
|
|
1133
1180
|
}
|
|
1134
1181
|
else if (this.botDeviceType === 'faucet') {
|
|
1135
1182
|
On = this.Faucet.On ? true : false;
|
|
@@ -1162,7 +1209,7 @@ export class Bot extends deviceBase {
|
|
|
1162
1209
|
this.WindowCovering.On = On;
|
|
1163
1210
|
}
|
|
1164
1211
|
else if (this.botDeviceType === 'lock') {
|
|
1165
|
-
this.
|
|
1212
|
+
this.LockMechanism.On = On;
|
|
1166
1213
|
}
|
|
1167
1214
|
else if (this.botDeviceType === 'faucet') {
|
|
1168
1215
|
this.Faucet.On = On;
|