homebridge-adt-pulse 3.0.0-beta.4 → 3.0.0-beta.5
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/build/config.schema.json +237 -0
- package/build/src/index.js +6 -0
- package/build/src/index.js.map +1 -0
- package/build/src/lib/accessory.js +216 -0
- package/build/src/lib/accessory.js.map +1 -0
- package/build/src/lib/api.js +1876 -0
- package/build/src/lib/api.js.map +1 -0
- package/build/src/lib/detect.js +443 -0
- package/build/src/lib/detect.js.map +1 -0
- package/build/src/lib/platform.js +419 -0
- package/build/src/lib/platform.js.map +1 -0
- package/{src/lib/regex.ts → build/src/lib/regex.js} +1 -143
- package/build/src/lib/regex.js.map +1 -0
- package/build/src/lib/schema.js +29 -0
- package/build/src/lib/schema.js.map +1 -0
- package/build/src/lib/utility.js +434 -0
- package/build/src/lib/utility.js.map +1 -0
- package/build/src/scripts/repl.js +173 -0
- package/build/src/scripts/repl.js.map +1 -0
- package/build/src/scripts/test-api.js +171 -0
- package/build/src/scripts/test-api.js.map +1 -0
- package/package.json +5 -6
- package/src/index.ts +0 -18
- package/src/lib/accessory.ts +0 -405
- package/src/lib/api.ts +0 -3483
- package/src/lib/detect.ts +0 -728
- package/src/lib/platform.ts +0 -890
- package/src/lib/schema.ts +0 -34
- package/src/lib/utility.ts +0 -933
- package/src/scripts/repl.ts +0 -300
- package/src/scripts/test-api.ts +0 -278
- package/src/types/constant.d.ts +0 -308
- package/src/types/index.d.ts +0 -1472
- package/src/types/shared.d.ts +0 -517
- package/tsconfig.json +0 -32
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pluginAlias": "ADTPulse",
|
|
3
|
+
"pluginType": "platform",
|
|
4
|
+
"singular": true,
|
|
5
|
+
"headerDisplay": "An account to link your [ADT Pulse](https://portal.adtpulse.com/) system to Homebridge is required. This will be used to control your security panel and read sensor status.",
|
|
6
|
+
"footerDisplay": "If you need assistance, you may read the [plugin instructions](https://github.com/mrjackyliang/homebridge-adt-pulse#readme) or feel free to [submit an issue](https://github.com/mrjackyliang/homebridge-adt-pulse/issues/new/choose).",
|
|
7
|
+
"schema": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"name": {
|
|
11
|
+
"title": "Name",
|
|
12
|
+
"type": "string",
|
|
13
|
+
"default": "ADT Pulse",
|
|
14
|
+
"required": true,
|
|
15
|
+
"description": "Plugin name as displayed in the Homebridge log"
|
|
16
|
+
},
|
|
17
|
+
"username": {
|
|
18
|
+
"title": "Username",
|
|
19
|
+
"type": "string",
|
|
20
|
+
"default": "",
|
|
21
|
+
"required": true,
|
|
22
|
+
"format": "email",
|
|
23
|
+
"minLength": 6,
|
|
24
|
+
"maxLength": 50,
|
|
25
|
+
"description": "Email address used for ADT Pulse login"
|
|
26
|
+
},
|
|
27
|
+
"password": {
|
|
28
|
+
"title": "Password",
|
|
29
|
+
"type": "string",
|
|
30
|
+
"default": "",
|
|
31
|
+
"required": true,
|
|
32
|
+
"minLength": 8,
|
|
33
|
+
"maxLength": 50,
|
|
34
|
+
"description": "Password used for ADT Pulse login"
|
|
35
|
+
},
|
|
36
|
+
"fingerprint": {
|
|
37
|
+
"title": "MFA Fingerprint",
|
|
38
|
+
"type": "string",
|
|
39
|
+
"default": "",
|
|
40
|
+
"required": true,
|
|
41
|
+
"description": "MFA Fingerprint from browser registered with ADT Pulse"
|
|
42
|
+
},
|
|
43
|
+
"overrideSensors": {
|
|
44
|
+
"title": "Override Sensors",
|
|
45
|
+
"type": "array",
|
|
46
|
+
"items": {
|
|
47
|
+
"type": "object",
|
|
48
|
+
"properties": {
|
|
49
|
+
"name": {
|
|
50
|
+
"title": "Name",
|
|
51
|
+
"type": "string",
|
|
52
|
+
"default": "",
|
|
53
|
+
"required": true,
|
|
54
|
+
"description": "The sensor name for the sensor you would like to override"
|
|
55
|
+
},
|
|
56
|
+
"type": {
|
|
57
|
+
"title": "Type",
|
|
58
|
+
"type": "string",
|
|
59
|
+
"default": "",
|
|
60
|
+
"oneOf": [
|
|
61
|
+
{
|
|
62
|
+
"title": "Door/Window Sensor",
|
|
63
|
+
"enum": [
|
|
64
|
+
"sensor,doorWindow"
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"title": "Glass Break Detector",
|
|
69
|
+
"enum": [
|
|
70
|
+
"sensor,glass"
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"title": "Motion Sensor",
|
|
75
|
+
"enum": [
|
|
76
|
+
"sensor,motion"
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"title": "Carbon Monoxide Detector",
|
|
81
|
+
"enum": [
|
|
82
|
+
"sensor,co"
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"title": "Fire (Smoke/Heat) Detector",
|
|
87
|
+
"enum": [
|
|
88
|
+
"sensor,fire"
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
"required": true,
|
|
93
|
+
"description": "The sensor type for the sensor you would like to override"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"description": "When a sensor cannot be detected accurately, you can manually set the sensor here to override the default detection features"
|
|
98
|
+
},
|
|
99
|
+
"country": {
|
|
100
|
+
"title": "Country",
|
|
101
|
+
"type": "string",
|
|
102
|
+
"default": "us",
|
|
103
|
+
"oneOf": [
|
|
104
|
+
{
|
|
105
|
+
"title": "United States",
|
|
106
|
+
"enum": [
|
|
107
|
+
"us"
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"title": "Canada",
|
|
112
|
+
"enum": [
|
|
113
|
+
"ca"
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
],
|
|
117
|
+
"required": false,
|
|
118
|
+
"description": "Select a country where ADT Pulse will connect to"
|
|
119
|
+
},
|
|
120
|
+
"logLevel": {
|
|
121
|
+
"title": "Log Level",
|
|
122
|
+
"type": "integer",
|
|
123
|
+
"default": 30,
|
|
124
|
+
"oneOf": [
|
|
125
|
+
{
|
|
126
|
+
"title": "Errors (Level 10)",
|
|
127
|
+
"enum": [
|
|
128
|
+
10
|
|
129
|
+
]
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"title": "Warnings (Level 20)",
|
|
133
|
+
"enum": [
|
|
134
|
+
20
|
|
135
|
+
]
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"title": "Info (Level 30)",
|
|
139
|
+
"enum": [
|
|
140
|
+
30
|
|
141
|
+
]
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"title": "Debug (Level 40)",
|
|
145
|
+
"enum": [
|
|
146
|
+
40
|
|
147
|
+
]
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"title": "Verbose (Level 50)",
|
|
151
|
+
"enum": [
|
|
152
|
+
50
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
],
|
|
156
|
+
"required": false,
|
|
157
|
+
"pattern": "^([1-5])([0])$",
|
|
158
|
+
"description": "Higher levels mean more logs will show. Turn on Homebridge Debug Mode for levels 40 and 50. Recommended setting is \"Info (Level 30)\""
|
|
159
|
+
},
|
|
160
|
+
"logActivity": {
|
|
161
|
+
"title": "Log Activity",
|
|
162
|
+
"type": "boolean",
|
|
163
|
+
"default": true,
|
|
164
|
+
"required": false
|
|
165
|
+
},
|
|
166
|
+
"removeObsoleteZones": {
|
|
167
|
+
"title": "Remove Obsolete Zones",
|
|
168
|
+
"type": "boolean",
|
|
169
|
+
"default": true,
|
|
170
|
+
"required": false
|
|
171
|
+
},
|
|
172
|
+
"pausePlugin": {
|
|
173
|
+
"title": "Pause Plugin",
|
|
174
|
+
"type": "boolean",
|
|
175
|
+
"default": false,
|
|
176
|
+
"required": false
|
|
177
|
+
},
|
|
178
|
+
"resetAll": {
|
|
179
|
+
"title": "Reset Plugin \uD83D\uDED1",
|
|
180
|
+
"type": "boolean",
|
|
181
|
+
"default": false,
|
|
182
|
+
"required": false
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
"layout": [
|
|
187
|
+
{
|
|
188
|
+
"key": "name"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"display": "flex",
|
|
192
|
+
"flex-flow": "row nowrap",
|
|
193
|
+
"justify-content": "space-between",
|
|
194
|
+
"items": [
|
|
195
|
+
{
|
|
196
|
+
"key": "username",
|
|
197
|
+
"flex": "1 0 0px"
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"key": "password",
|
|
201
|
+
"flex": "1 0 0px"
|
|
202
|
+
}
|
|
203
|
+
]
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"key": "fingerprint"
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"key": "overrideSensors",
|
|
210
|
+
"buttonText": "Add Sensor",
|
|
211
|
+
"items": [
|
|
212
|
+
"overrideSensors[].name",
|
|
213
|
+
"overrideSensors[].type"
|
|
214
|
+
]
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
"key": "country"
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"key": "logLevel"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"key": "logActivity"
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
"key": "removeObsoleteZones"
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
"key": "pausePlugin"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"key": "resetAll"
|
|
233
|
+
}
|
|
234
|
+
],
|
|
235
|
+
"form": null,
|
|
236
|
+
"display": null
|
|
237
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAYrD,SAAS,UAAU,CAAC,GAAkB;IACpC,GAAG,CAAC,gBAAgB,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;AACrD,CAAC;AAGD,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
export class ADTPulseAccessory {
|
|
2
|
+
#accessory;
|
|
3
|
+
#api;
|
|
4
|
+
#characteristic;
|
|
5
|
+
#instance;
|
|
6
|
+
#log;
|
|
7
|
+
#services;
|
|
8
|
+
#state;
|
|
9
|
+
constructor(accessory, state, instance, service, characteristic, api, log) {
|
|
10
|
+
this.#accessory = accessory;
|
|
11
|
+
this.#api = api;
|
|
12
|
+
this.#characteristic = characteristic;
|
|
13
|
+
this.#instance = instance;
|
|
14
|
+
this.#log = log;
|
|
15
|
+
this.#services = {};
|
|
16
|
+
this.#state = state;
|
|
17
|
+
this.#services.Information = this.#accessory.getService(service.AccessoryInformation) ?? this.#accessory.addService(service.AccessoryInformation);
|
|
18
|
+
this.#services.Information
|
|
19
|
+
.setCharacteristic(this.#characteristic.Identify, false)
|
|
20
|
+
.setCharacteristic(this.#characteristic.Manufacturer, accessory.context.manufacturer ?? 'ADT')
|
|
21
|
+
.setCharacteristic(this.#characteristic.Model, accessory.context.model ?? 'N/A')
|
|
22
|
+
.setCharacteristic(this.#characteristic.Name, accessory.context.name)
|
|
23
|
+
.setCharacteristic(this.#characteristic.SerialNumber, accessory.context.serial ?? 'N/A')
|
|
24
|
+
.setCharacteristic(this.#characteristic.FirmwareRevision, accessory.context.firmware ?? 'N/A')
|
|
25
|
+
.setCharacteristic(this.#characteristic.HardwareRevision, accessory.context.hardware ?? 'N/A')
|
|
26
|
+
.setCharacteristic(this.#characteristic.SoftwareRevision, accessory.context.software ?? 'N/A');
|
|
27
|
+
switch (accessory.context.type) {
|
|
28
|
+
case 'co':
|
|
29
|
+
this.#services.Primary = this.#accessory.getService(service.CarbonMonoxideSensor) ?? this.#accessory.addService(service.CarbonMonoxideSensor);
|
|
30
|
+
break;
|
|
31
|
+
case 'doorWindow':
|
|
32
|
+
this.#services.Primary = this.#accessory.getService(service.ContactSensor) ?? this.#accessory.addService(service.ContactSensor);
|
|
33
|
+
break;
|
|
34
|
+
case 'fire':
|
|
35
|
+
this.#services.Primary = this.#accessory.getService(service.SmokeSensor) ?? this.#accessory.addService(service.SmokeSensor);
|
|
36
|
+
break;
|
|
37
|
+
case 'flood':
|
|
38
|
+
this.#services.Primary = this.#accessory.getService(service.LeakSensor) ?? this.#accessory.addService(service.LeakSensor);
|
|
39
|
+
break;
|
|
40
|
+
case 'gateway':
|
|
41
|
+
break;
|
|
42
|
+
case 'glass':
|
|
43
|
+
this.#services.Primary = this.#accessory.getService(service.MotionSensor) ?? this.#accessory.addService(service.MotionSensor);
|
|
44
|
+
break;
|
|
45
|
+
case 'motion':
|
|
46
|
+
this.#services.Primary = this.#accessory.getService(service.MotionSensor) ?? this.#accessory.addService(service.MotionSensor);
|
|
47
|
+
break;
|
|
48
|
+
case 'panel':
|
|
49
|
+
this.#services.Primary = this.#accessory.getService(service.SecuritySystem) ?? this.#accessory.addService(service.SecuritySystem);
|
|
50
|
+
break;
|
|
51
|
+
case 'temperature':
|
|
52
|
+
this.#services.Primary = this.#accessory.getService(service.TemperatureSensor) ?? this.#accessory.addService(service.TemperatureSensor);
|
|
53
|
+
break;
|
|
54
|
+
default:
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
if (this.#services.Primary === undefined) {
|
|
58
|
+
if (accessory.context.type !== 'gateway') {
|
|
59
|
+
this.#log.error(`Failed to initialize ${accessory.context.name} (id: ${accessory.context.id}, uuid: ${accessory.context.uuid}) accessory services ...`);
|
|
60
|
+
}
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
switch (accessory.context.type) {
|
|
64
|
+
case 'co':
|
|
65
|
+
this.#services.Primary.getCharacteristic(this.#characteristic.CarbonMonoxideDetected)
|
|
66
|
+
.onGet(() => this.getSensorStatus(accessory.context));
|
|
67
|
+
break;
|
|
68
|
+
case 'doorWindow':
|
|
69
|
+
this.#services.Primary.getCharacteristic(this.#characteristic.ContactSensorState)
|
|
70
|
+
.onGet(() => this.getSensorStatus(accessory.context));
|
|
71
|
+
break;
|
|
72
|
+
case 'fire':
|
|
73
|
+
this.#services.Primary.getCharacteristic(this.#characteristic.SmokeDetected)
|
|
74
|
+
.onGet(() => this.getSensorStatus(accessory.context));
|
|
75
|
+
break;
|
|
76
|
+
case 'flood':
|
|
77
|
+
this.#services.Primary.getCharacteristic(this.#characteristic.LeakDetected)
|
|
78
|
+
.onGet(() => this.getSensorStatus(accessory.context));
|
|
79
|
+
break;
|
|
80
|
+
case 'gateway':
|
|
81
|
+
break;
|
|
82
|
+
case 'glass':
|
|
83
|
+
this.#services.Primary.getCharacteristic(this.#characteristic.MotionDetected)
|
|
84
|
+
.onGet(() => this.getSensorStatus(accessory.context));
|
|
85
|
+
break;
|
|
86
|
+
case 'motion':
|
|
87
|
+
this.#services.Primary.getCharacteristic(this.#characteristic.MotionDetected)
|
|
88
|
+
.onGet(() => this.getSensorStatus(accessory.context));
|
|
89
|
+
break;
|
|
90
|
+
case 'panel':
|
|
91
|
+
this.#services.Primary.getCharacteristic(this.#characteristic.SecuritySystemCurrentState)
|
|
92
|
+
.onGet(() => this.getPanelStatus('current', accessory.context));
|
|
93
|
+
this.#services.Primary.getCharacteristic(this.#characteristic.SecuritySystemTargetState)
|
|
94
|
+
.onGet(() => this.getPanelStatus('target', accessory.context))
|
|
95
|
+
.onSet((value) => this.setPanelStatus(value, accessory.context));
|
|
96
|
+
break;
|
|
97
|
+
case 'temperature':
|
|
98
|
+
this.#services.Primary.getCharacteristic(this.#characteristic.CurrentTemperature)
|
|
99
|
+
.onGet(() => this.getSensorStatus(accessory.context));
|
|
100
|
+
break;
|
|
101
|
+
default:
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
getSensorStatus(context) {
|
|
106
|
+
const { name, type, zone } = context;
|
|
107
|
+
const sensor = this.#state.data.sensorsStatus.find((sensorStatus) => zone !== null && sensorStatus.name === name && sensorStatus.zone === zone);
|
|
108
|
+
if (sensor === undefined || !['co', 'doorWindow', 'fire', 'flood', 'glass', 'motion', 'temperature'].includes(type)) {
|
|
109
|
+
throw new this.#api.hap.HapStatusError(-70409);
|
|
110
|
+
}
|
|
111
|
+
const { status } = sensor;
|
|
112
|
+
if (status === 'Unknown') {
|
|
113
|
+
throw new this.#api.hap.HapStatusError(-70402);
|
|
114
|
+
}
|
|
115
|
+
switch (context.type) {
|
|
116
|
+
case 'co':
|
|
117
|
+
return this.#characteristic.CarbonMonoxideDetected.CO_LEVELS_NORMAL;
|
|
118
|
+
case 'doorWindow':
|
|
119
|
+
if (status.includes('Open')) {
|
|
120
|
+
return this.#characteristic.ContactSensorState.CONTACT_NOT_DETECTED;
|
|
121
|
+
}
|
|
122
|
+
if (status.includes('Closed')) {
|
|
123
|
+
return this.#characteristic.ContactSensorState.CONTACT_DETECTED;
|
|
124
|
+
}
|
|
125
|
+
break;
|
|
126
|
+
case 'fire':
|
|
127
|
+
return this.#characteristic.SmokeDetected.SMOKE_NOT_DETECTED;
|
|
128
|
+
case 'flood':
|
|
129
|
+
if (status.includes('ALARM')) {
|
|
130
|
+
return this.#characteristic.LeakDetected.LEAK_DETECTED;
|
|
131
|
+
}
|
|
132
|
+
if (status.includes('Okay')) {
|
|
133
|
+
return this.#characteristic.LeakDetected.LEAK_NOT_DETECTED;
|
|
134
|
+
}
|
|
135
|
+
break;
|
|
136
|
+
case 'glass':
|
|
137
|
+
if (status.includes('Okay')) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
if (status.includes('Tripped')) {
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
break;
|
|
144
|
+
case 'motion':
|
|
145
|
+
if (status.includes('No Motion')) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
if (status.includes('Motion')) {
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
break;
|
|
152
|
+
case 'temperature':
|
|
153
|
+
return 75;
|
|
154
|
+
default:
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
throw new this.#api.hap.HapStatusError(-70409);
|
|
158
|
+
}
|
|
159
|
+
getPanelStatus(mode, context) {
|
|
160
|
+
if (context.type !== 'panel') {
|
|
161
|
+
throw new this.#api.hap.HapStatusError(-70409);
|
|
162
|
+
}
|
|
163
|
+
if (this.#state.data.panelStatus === null
|
|
164
|
+
|| this.#state.data.panelStatus.state === null
|
|
165
|
+
|| this.#state.data.panelStatus.status === null) {
|
|
166
|
+
throw new this.#api.hap.HapStatusError(-70402);
|
|
167
|
+
}
|
|
168
|
+
const { state, status } = this.#state.data.panelStatus;
|
|
169
|
+
if (state === 'Status Unavailable') {
|
|
170
|
+
throw new this.#api.hap.HapStatusError(-70402);
|
|
171
|
+
}
|
|
172
|
+
if (mode === 'current' && status === 'BURGLARY ALARM') {
|
|
173
|
+
return this.#characteristic.SecuritySystemCurrentState.ALARM_TRIGGERED;
|
|
174
|
+
}
|
|
175
|
+
switch (state) {
|
|
176
|
+
case 'Armed Away':
|
|
177
|
+
return (mode === 'current') ? this.#characteristic.SecuritySystemCurrentState.AWAY_ARM : this.#characteristic.SecuritySystemTargetState.AWAY_ARM;
|
|
178
|
+
case 'Armed Stay':
|
|
179
|
+
return (mode === 'current') ? this.#characteristic.SecuritySystemCurrentState.STAY_ARM : this.#characteristic.SecuritySystemTargetState.STAY_ARM;
|
|
180
|
+
case 'Armed Night':
|
|
181
|
+
return (mode === 'current') ? this.#characteristic.SecuritySystemCurrentState.NIGHT_ARM : this.#characteristic.SecuritySystemTargetState.NIGHT_ARM;
|
|
182
|
+
case 'Disarmed':
|
|
183
|
+
return (mode === 'current') ? this.#characteristic.SecuritySystemCurrentState.DISARMED : this.#characteristic.SecuritySystemTargetState.DISARM;
|
|
184
|
+
default:
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
throw new this.#api.hap.HapStatusError(-70402);
|
|
188
|
+
}
|
|
189
|
+
async setPanelStatus(arm, context) {
|
|
190
|
+
let result;
|
|
191
|
+
if (context.type !== 'panel') {
|
|
192
|
+
throw new this.#api.hap.HapStatusError(-70409);
|
|
193
|
+
}
|
|
194
|
+
switch (arm) {
|
|
195
|
+
case this.#characteristic.SecuritySystemTargetState.STAY_ARM:
|
|
196
|
+
result = await this.#instance.setPanelStatus('stay');
|
|
197
|
+
break;
|
|
198
|
+
case this.#characteristic.SecuritySystemTargetState.AWAY_ARM:
|
|
199
|
+
result = await this.#instance.setPanelStatus('away');
|
|
200
|
+
break;
|
|
201
|
+
case this.#characteristic.SecuritySystemTargetState.NIGHT_ARM:
|
|
202
|
+
result = await this.#instance.setPanelStatus('night');
|
|
203
|
+
break;
|
|
204
|
+
case this.#characteristic.SecuritySystemTargetState.DISARM:
|
|
205
|
+
result = await this.#instance.setPanelStatus('off');
|
|
206
|
+
break;
|
|
207
|
+
default:
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
if (result && result.success) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
throw new this.#api.hap.HapStatusError(-70410);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=accessory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessory.js","sourceRoot":"","sources":["../../../src/lib/accessory.ts"],"names":[],"mappings":"AA8BA,MAAM,OAAO,iBAAiB;IAQ5B,UAAU,CAA6B;IASvC,IAAI,CAAuB;IAS3B,eAAe,CAAkC;IASjD,SAAS,CAA4B;IASrC,IAAI,CAAuB;IAS3B,SAAS,CAA4B;IAS5B,MAAM,CAAyB;IAexC,YAAY,SAAgD,EAAE,KAAwC,EAAE,QAA8C,EAAE,OAA4C,EAAE,cAA0D,EAAE,GAAoC,EAAE,GAAoC;QAC1U,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,IAAI,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