node-alarm-dot-com 2.1.0-beta.5 → 2.1.0-beta.7
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/_models/DeviceStates.d.ts +68 -2
- package/dist/_models/IdentityResponse.d.ts +114 -96
- package/dist/_models/States.d.ts +2 -1
- package/dist/_models/States.js +1 -0
- package/dist/_models/SystemState.d.ts +2 -1
- package/dist/_models/SystemState.js +1 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.js +33 -23
- package/package.json +1 -1
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Relationship } from './IdentityResponse';
|
2
|
-
import { AutomationType, RelationshipType } from './SystemState';
|
3
|
-
import { GARAGE_STATES, LIGHT_STATES, LOCK_STATES, SENSOR_STATES, SYSTEM_STATES, THERMOSTAT_STATES } from './States';
|
4
2
|
import { SensorType } from './SensorType';
|
3
|
+
import { GARAGE_STATES, LIGHT_STATES, LOCK_STATES, SENSOR_STATES, SYSTEM_STATES, THERMOSTAT_STATES } from './States';
|
4
|
+
import { AutomationType, RelationshipType } from './SystemState';
|
5
5
|
export interface ApiLightState extends ApiDeviceState {
|
6
6
|
data: {
|
7
7
|
id: string;
|
@@ -1052,6 +1052,72 @@ export interface ThermostatState extends DeviceState {
|
|
1052
1052
|
};
|
1053
1053
|
};
|
1054
1054
|
}
|
1055
|
+
export interface ApiAccessControlState extends ApiDeviceState {
|
1056
|
+
data: {
|
1057
|
+
id: string;
|
1058
|
+
type: RelationshipType.AccessControl;
|
1059
|
+
attributes: {
|
1060
|
+
managedDeviceType: number;
|
1061
|
+
state: LOCK_STATES;
|
1062
|
+
desiredState: LOCK_STATES;
|
1063
|
+
canBuzz: boolean;
|
1064
|
+
canLockUnlock: boolean;
|
1065
|
+
readerAntiPassbackEnabled: boolean;
|
1066
|
+
apbDelay: number;
|
1067
|
+
twoPersonAccessEnabled: boolean;
|
1068
|
+
hasMiwaLock: boolean;
|
1069
|
+
twoPersonAccessSupported: boolean;
|
1070
|
+
hasState: boolean;
|
1071
|
+
canBeRenamed: boolean;
|
1072
|
+
canBeDeleted: boolean;
|
1073
|
+
canAccessWebSettings: boolean;
|
1074
|
+
canAccessAppSettings: boolean;
|
1075
|
+
webSettings: number;
|
1076
|
+
canAccessTroubleshootingWizard: boolean;
|
1077
|
+
troubleshootingWizard: null;
|
1078
|
+
addDeviceResource: number;
|
1079
|
+
canBeAssociatedToVideoDevice: boolean;
|
1080
|
+
associatedCameraDeviceIds: {};
|
1081
|
+
macAddress: string;
|
1082
|
+
manufacturer: string;
|
1083
|
+
isAssignedToCareReceiver: boolean;
|
1084
|
+
isOAuth: boolean;
|
1085
|
+
isZWave: boolean;
|
1086
|
+
supportsCommandClassBasic: boolean;
|
1087
|
+
isMalfunctioning: boolean;
|
1088
|
+
isZWaveWakeupNode: boolean;
|
1089
|
+
unitSupportsRemovingWakeupNode: boolean;
|
1090
|
+
primaryAssociatedDeviceIds: null;
|
1091
|
+
canBeSaved: boolean;
|
1092
|
+
canChangeDescription: boolean;
|
1093
|
+
description: string;
|
1094
|
+
deviceModelId: number;
|
1095
|
+
canConfirmStateChange: boolean;
|
1096
|
+
canReceiveCommands: boolean;
|
1097
|
+
remoteCommandsEnabled: boolean;
|
1098
|
+
hasPermissionToChangeState: boolean;
|
1099
|
+
deviceIcon: {
|
1100
|
+
"icon": number;
|
1101
|
+
};
|
1102
|
+
batteryLevelNull: null;
|
1103
|
+
batteryLevelClassification: null;
|
1104
|
+
};
|
1105
|
+
relationships: {
|
1106
|
+
system: {
|
1107
|
+
data: {
|
1108
|
+
id: string;
|
1109
|
+
type: RelationshipType.System;
|
1110
|
+
};
|
1111
|
+
};
|
1112
|
+
stateInfo: {
|
1113
|
+
data: {
|
1114
|
+
id: string;
|
1115
|
+
type: RelationshipType.State;
|
1116
|
+
};
|
1117
|
+
};
|
1118
|
+
};
|
1119
|
+
};
|
1120
|
+
}
|
1055
1121
|
/**
|
1056
1122
|
* Base interface for retrieving device state from Alarm.com's API
|
1057
1123
|
* All devices retrieved contain these properties.
|
@@ -3,107 +3,125 @@
|
|
3
3
|
* It's then parsed and the authentication token stored for future use.
|
4
4
|
*/
|
5
5
|
export interface IdentityResponse {
|
6
|
-
data:
|
7
|
-
id: number;
|
8
|
-
type: 'identity';
|
9
|
-
attributes: {
|
10
|
-
timezone: string;
|
11
|
-
initialSetupSteps: [];
|
12
|
-
helpTours: number[];
|
13
|
-
logoSource: string;
|
14
|
-
logoName: string;
|
15
|
-
dealerPath: string;
|
16
|
-
favIconUrl: string;
|
17
|
-
poweredByPath: string;
|
18
|
-
copyrightInfo: string;
|
19
|
-
trademarkInfo: string;
|
20
|
-
hasCompletedOnboarding: boolean;
|
21
|
-
isEnterprise: boolean;
|
22
|
-
isAccessControl: boolean;
|
23
|
-
isCommercial: boolean;
|
24
|
-
isPointCentral: boolean;
|
25
|
-
isPcRpm: boolean;
|
26
|
-
isPointCentralSTR: boolean;
|
27
|
-
isMobileApp: boolean;
|
28
|
-
useWebsockets: boolean;
|
29
|
-
websocketServiceEndpoint: string;
|
30
|
-
enabledWebsocketMessageHandlers: null;
|
31
|
-
canBrowserEnableFlashDirectly: boolean;
|
32
|
-
supportsEnableFlashPrompt: boolean;
|
33
|
-
supportedNativeBridgeFeatures: null;
|
34
|
-
hasTroubleConditionsService: boolean;
|
35
|
-
errorReportingConfiguration: {
|
36
|
-
providerName: string;
|
37
|
-
apiKey: null;
|
38
|
-
scriptUrl: null;
|
39
|
-
isEnabled: boolean;
|
40
|
-
machineName: string;
|
41
|
-
logErrorsToConsole: boolean;
|
42
|
-
showNotificationOnError: boolean;
|
43
|
-
redirectToErrorRouteOnUnhandledError: boolean;
|
44
|
-
environment: string;
|
45
|
-
servicePlan: string;
|
46
|
-
};
|
47
|
-
enableHomeScreenConfiguration: boolean;
|
48
|
-
accountType: number;
|
49
|
-
externalTerms: string;
|
50
|
-
externalPrivacyPolicy: string;
|
51
|
-
applicationSessionProperties: {
|
52
|
-
shouldTimeout: boolean;
|
53
|
-
keepAliveUrl: string;
|
54
|
-
enableKeepAlive: boolean;
|
55
|
-
logoutTimeoutMs: number;
|
56
|
-
inactivityWarningTimeoutMs: number;
|
57
|
-
};
|
58
|
-
postLoginRedirect: null;
|
59
|
-
canDonateClips: boolean;
|
60
|
-
hasInternalBetaAccess: boolean;
|
61
|
-
};
|
62
|
-
relationships: {
|
63
|
-
dealer: {
|
64
|
-
data: Relationship;
|
65
|
-
};
|
66
|
-
primaryColor: {
|
67
|
-
data: Relationship;
|
68
|
-
};
|
69
|
-
secondaryColor: {
|
70
|
-
data: Relationship;
|
71
|
-
};
|
72
|
-
navColor: {
|
73
|
-
data: Relationship;
|
74
|
-
};
|
75
|
-
profile: {
|
76
|
-
data: Relationship;
|
77
|
-
};
|
78
|
-
accountInformation: {
|
79
|
-
data: Relationship;
|
80
|
-
};
|
81
|
-
availableRouteItems: {
|
82
|
-
data: Relationship[];
|
83
|
-
meta: {
|
84
|
-
count: string;
|
85
|
-
};
|
86
|
-
};
|
87
|
-
wizard: {
|
88
|
-
data: Relationship[] | null;
|
89
|
-
};
|
90
|
-
clipDonationAgreement: {
|
91
|
-
data: Relationship;
|
92
|
-
};
|
93
|
-
selectedSystem: {
|
94
|
-
data: Relationship;
|
95
|
-
};
|
96
|
-
selectedSystemGroup: {
|
97
|
-
data: Relationship | null;
|
98
|
-
};
|
99
|
-
};
|
100
|
-
};
|
6
|
+
data: IdentityData[];
|
101
7
|
included: any[];
|
102
8
|
meta: {
|
103
9
|
transformer_version: string;
|
104
10
|
};
|
105
11
|
}
|
12
|
+
export interface IdentityData {
|
13
|
+
id: number;
|
14
|
+
type: 'identity';
|
15
|
+
attributes: {
|
16
|
+
timezone: string;
|
17
|
+
preferredTimezone: string;
|
18
|
+
initialSetupSteps: [];
|
19
|
+
helpTours: number[];
|
20
|
+
logoSource: string;
|
21
|
+
logoName: string;
|
22
|
+
dealerPath: string;
|
23
|
+
mobileAppBrand: string;
|
24
|
+
favIconUrl: string;
|
25
|
+
poweredByPath: string;
|
26
|
+
copyrightInfo: string;
|
27
|
+
trademarkInfo: string;
|
28
|
+
hasCompletedOnboarding: boolean;
|
29
|
+
isEnterprise: boolean;
|
30
|
+
isAccessControl: boolean;
|
31
|
+
isCommercial: boolean;
|
32
|
+
isPointCentral: boolean;
|
33
|
+
isPcRpm: boolean;
|
34
|
+
isPointCentralSTR: boolean;
|
35
|
+
isPointCentralAccessControl: boolean;
|
36
|
+
isPointCentralAccessControlSTR: boolean;
|
37
|
+
isUsingEnterpriseLocationsCache: boolean;
|
38
|
+
isMobileApp: boolean;
|
39
|
+
isMobileTechApp: boolean;
|
40
|
+
isVisualIdentification: boolean;
|
41
|
+
isEscalatedEvents: boolean;
|
42
|
+
isWindowsDevice: boolean;
|
43
|
+
applicationBuildNumber: number;
|
44
|
+
canViewHighlights: boolean;
|
45
|
+
canViewVideoClips: boolean;
|
46
|
+
hasAccessToAudioForNonDoorbellCameras: boolean;
|
47
|
+
hasSmartArmingSensorBased: boolean;
|
48
|
+
isSmartDisarmEligible: boolean;
|
49
|
+
canEditNoiseSensors: boolean;
|
50
|
+
isManagedAccessAccount: boolean;
|
51
|
+
supportedNativeBridgeFeatures: null;
|
52
|
+
supportedNativeViewTransitions: null;
|
53
|
+
supportedDisplayModeFeatures: null;
|
54
|
+
hasTroubleConditionsService: boolean;
|
55
|
+
errorReportingConfiguration: {
|
56
|
+
providerName: string;
|
57
|
+
apiKey: null;
|
58
|
+
scriptUrl: null;
|
59
|
+
isEnabled: boolean;
|
60
|
+
machineName: string;
|
61
|
+
logErrorsToConsole: boolean;
|
62
|
+
showNotificationOnError: boolean;
|
63
|
+
redirectToErrorRouteOnUnhandledError: boolean;
|
64
|
+
environment: string;
|
65
|
+
servicePlan: string;
|
66
|
+
};
|
67
|
+
enableHomeScreenConfiguration: boolean;
|
68
|
+
accountType: number;
|
69
|
+
externalTerms: string;
|
70
|
+
externalPrivacyPolicy: string;
|
71
|
+
shouldHidePrivacyPolicyLink: boolean;
|
72
|
+
shouldHideTermsAndConditionsLink: boolean;
|
73
|
+
applicationSessionProperties: {
|
74
|
+
shouldTimeout: boolean;
|
75
|
+
keepAliveUrl: string;
|
76
|
+
enableKeepAlive: boolean;
|
77
|
+
logoutTimeoutMs: number;
|
78
|
+
inactivityWarningTimeoutMs: number;
|
79
|
+
};
|
80
|
+
postLoginRedirect: null;
|
81
|
+
localizeTempUnitsToCelsius: boolean;
|
82
|
+
canDonateClips: boolean;
|
83
|
+
hasInternalBetaAccess: boolean;
|
84
|
+
};
|
85
|
+
relationships: {
|
86
|
+
dealer: {
|
87
|
+
data: Relationship;
|
88
|
+
};
|
89
|
+
primaryColor: {
|
90
|
+
data: Relationship;
|
91
|
+
};
|
92
|
+
secondaryColor: {
|
93
|
+
data: Relationship;
|
94
|
+
};
|
95
|
+
navColor: {
|
96
|
+
data: Relationship;
|
97
|
+
};
|
98
|
+
profile: {
|
99
|
+
data: Relationship;
|
100
|
+
};
|
101
|
+
accountInformation: {
|
102
|
+
data: Relationship;
|
103
|
+
};
|
104
|
+
availableRouteItems: {
|
105
|
+
data: Relationship[];
|
106
|
+
meta: {
|
107
|
+
count: string;
|
108
|
+
};
|
109
|
+
};
|
110
|
+
wizard: {
|
111
|
+
data: Relationship[] | null;
|
112
|
+
};
|
113
|
+
clipDonationAgreement: {
|
114
|
+
data: Relationship;
|
115
|
+
};
|
116
|
+
selectedSystem: {
|
117
|
+
data: Relationship;
|
118
|
+
};
|
119
|
+
selectedSystemGroup: {
|
120
|
+
data: Relationship | null;
|
121
|
+
};
|
122
|
+
};
|
123
|
+
}
|
106
124
|
export interface Relationship {
|
107
125
|
id: string;
|
108
|
-
type: 'devices/partition' | 'devices/lock' | 'video/camera' | 'devices/garage-door' | 'automation/scene' | 'devices/sensor' | 'devices/light' | 'devices/thermostat' | 'geolocation/geo-device' | 'geolocation/fence' | 'systems/configuration' | 'navigation/route-item' | 'dealers/dealer' | 'ui/color' | 'profile/profile' | 'accountInformation/account-information';
|
126
|
+
type: 'devices/partition' | 'devices/lock' | 'video/camera' | 'devices/garage-door' | 'automation/scene' | 'devices/sensor' | 'devices/light' | 'devices/thermostat' | 'geolocation/geo-device' | 'geolocation/fence' | 'systems/configuration' | 'navigation/route-item' | 'devices/access-control-access-point-device' | 'dealers/dealer' | 'ui/color' | 'profile/profile' | 'accountInformation/account-information';
|
109
127
|
}
|
package/dist/_models/States.d.ts
CHANGED
@@ -78,5 +78,6 @@ export declare enum REL_TYPES {
|
|
78
78
|
THERMOSTAT = "devices/thermostat",
|
79
79
|
GEO_DEVICE = "geolocation/geo-device",
|
80
80
|
GEO_FENCE = "geolocation/fence",
|
81
|
-
SCENE = "automation/scene"
|
81
|
+
SCENE = "automation/scene",
|
82
|
+
ACCESS_CONTROL = "devices/access-control-access-point-device"
|
82
83
|
}
|
package/dist/_models/States.js
CHANGED
@@ -91,4 +91,5 @@ var REL_TYPES;
|
|
91
91
|
REL_TYPES["GEO_DEVICE"] = "geolocation/geo-device";
|
92
92
|
REL_TYPES["GEO_FENCE"] = "geolocation/fence";
|
93
93
|
REL_TYPES["SCENE"] = "automation/scene";
|
94
|
+
REL_TYPES["ACCESS_CONTROL"] = "devices/access-control-access-point-device";
|
94
95
|
})(REL_TYPES = exports.REL_TYPES || (exports.REL_TYPES = {}));
|
@@ -203,7 +203,8 @@ export declare enum RelationshipType {
|
|
203
203
|
GeoFence = "geolocation/fence",
|
204
204
|
SystemConfig = "systems/configuration",
|
205
205
|
System = "systems/system",
|
206
|
-
State = "devices/state-info"
|
206
|
+
State = "devices/state-info",
|
207
|
+
AccessControl = "devices/access-control-access-point-device"
|
207
208
|
}
|
208
209
|
export declare enum AutomationType {
|
209
210
|
PeakProtect = "automation/peak-protect",
|
@@ -16,6 +16,7 @@ var RelationshipType;
|
|
16
16
|
RelationshipType["SystemConfig"] = "systems/configuration";
|
17
17
|
RelationshipType["System"] = "systems/system";
|
18
18
|
RelationshipType["State"] = "devices/state-info";
|
19
|
+
RelationshipType["AccessControl"] = "devices/access-control-access-point-device";
|
19
20
|
})(RelationshipType = exports.RelationshipType || (exports.RelationshipType = {}));
|
20
21
|
var AutomationType;
|
21
22
|
(function (AutomationType) {
|
package/dist/index.d.ts
CHANGED
@@ -3,9 +3,10 @@
|
|
3
3
|
*/
|
4
4
|
import { AuthOpts } from './_models/AuthOpts';
|
5
5
|
import { ApiDeviceState } from './_models/DeviceStates';
|
6
|
+
import { IdentityResponse } from './_models/IdentityResponse';
|
6
7
|
import { PartitionActionOptions } from './_models/PartitionActionOptions';
|
7
8
|
import { FlattenedSystemState } from './_models/SystemState';
|
8
|
-
import { THERMOSTAT_STATES } from
|
9
|
+
import { THERMOSTAT_STATES } from './_models/States';
|
9
10
|
export * from './_models/AuthOpts';
|
10
11
|
export * from './_models/DeviceStates';
|
11
12
|
export * from './_models/IdentityResponse';
|
@@ -23,6 +24,11 @@ export * from './_models/SensorType';
|
|
23
24
|
* @returns {Promise}
|
24
25
|
*/
|
25
26
|
export declare function login(username: string, password: string, existingMfaToken?: string): Promise<AuthOpts>;
|
27
|
+
/**
|
28
|
+
* This function returns the alarm.com system identity for the currently logged in system.
|
29
|
+
* The information returned is useful for finding current systems and global config.
|
30
|
+
*/
|
31
|
+
export declare function getIdentitiesState(loginCookies: string, ajaxKey: string): Promise<IdentityResponse>;
|
26
32
|
/**
|
27
33
|
* Retrieve information about the current state of a security system including
|
28
34
|
* attributes, partitions, accessory components and relationships.
|
package/dist/index.js
CHANGED
@@ -20,7 +20,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
20
20
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
21
21
|
};
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
23
|
-
exports.authenticatedPost = exports.authenticatedGet = exports.setThermostatTargetCoolTemperature = exports.setThermostatTargetHeatTemperature = exports.setThermostatState = exports.openGarage = exports.closeGarage = exports.setLockUnsecure = exports.setLockSecure = exports.setLightOff = exports.setLightOn = exports.disarm = exports.armAway = exports.armStay = exports.getComponents = exports.getCurrentState = exports.login = void 0;
|
23
|
+
exports.authenticatedPost = exports.authenticatedGet = exports.setThermostatTargetCoolTemperature = exports.setThermostatTargetHeatTemperature = exports.setThermostatState = exports.openGarage = exports.closeGarage = exports.setLockUnsecure = exports.setLockSecure = exports.setLightOff = exports.setLightOn = exports.disarm = exports.armAway = exports.armStay = exports.getComponents = exports.getCurrentState = exports.getIdentitiesState = exports.login = void 0;
|
24
24
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
25
25
|
__exportStar(require("./_models/AuthOpts"), exports);
|
26
26
|
__exportStar(require("./_models/DeviceStates"), exports);
|
@@ -55,7 +55,9 @@ const UA = `node-alarm-dot-com/${require('../package.json').version}`;
|
|
55
55
|
async function login(username, password, existingMfaToken) {
|
56
56
|
let loginCookies;
|
57
57
|
let ajaxKey;
|
58
|
-
let loginFormBody
|
58
|
+
let loginFormBody;
|
59
|
+
let identities;
|
60
|
+
let systems;
|
59
61
|
// load initial alarm.com page to gather required hidden form fields
|
60
62
|
await get(ADCLOGIN_URL)
|
61
63
|
.then((res) => {
|
@@ -107,7 +109,29 @@ async function login(username, password, existingMfaToken) {
|
|
107
109
|
.catch((err) => {
|
108
110
|
throw new Error(`POST ${ADCFORMLOGIN_URL} failed: ${err.message || err}`);
|
109
111
|
});
|
110
|
-
await
|
112
|
+
await getIdentitiesState(loginCookies, ajaxKey)
|
113
|
+
.then((res) => {
|
114
|
+
systems = (res.data || []).map((d) => {
|
115
|
+
return d.relationships.selectedSystem.data.id;
|
116
|
+
});
|
117
|
+
})
|
118
|
+
.catch((err) => {
|
119
|
+
throw new Error(`GET ${IDENTITIES_URL} failed: ${err.message || err}`);
|
120
|
+
});
|
121
|
+
return {
|
122
|
+
cookie: loginCookies,
|
123
|
+
ajaxKey: ajaxKey,
|
124
|
+
systems: systems,
|
125
|
+
identities: identities
|
126
|
+
};
|
127
|
+
}
|
128
|
+
exports.login = login;
|
129
|
+
/**
|
130
|
+
* This function returns the alarm.com system identity for the currently logged in system.
|
131
|
+
* The information returned is useful for finding current systems and global config.
|
132
|
+
*/
|
133
|
+
async function getIdentitiesState(loginCookies, ajaxKey) {
|
134
|
+
return await get(IDENTITIES_URL, {
|
111
135
|
/* eslint-disable @typescript-eslint/naming-convention */
|
112
136
|
headers: {
|
113
137
|
Accept: 'application/vnd.api+json',
|
@@ -120,20 +144,13 @@ async function login(username, password, existingMfaToken) {
|
|
120
144
|
})
|
121
145
|
.then((res) => {
|
122
146
|
// gather identities and systems
|
123
|
-
|
124
|
-
systems = (identities.data || []).map((d) => getValue(d, 'relationships.selectedSystem.data.id'));
|
147
|
+
return res.body;
|
125
148
|
})
|
126
149
|
.catch((err) => {
|
127
150
|
throw new Error(`GET ${IDENTITIES_URL} failed: ${err.message || err}`);
|
128
151
|
});
|
129
|
-
return {
|
130
|
-
cookie: loginCookies,
|
131
|
-
ajaxKey: ajaxKey,
|
132
|
-
systems: systems,
|
133
|
-
identities: identities
|
134
|
-
};
|
135
152
|
}
|
136
|
-
exports.
|
153
|
+
exports.getIdentitiesState = getIdentitiesState;
|
137
154
|
/**
|
138
155
|
* Retrieve information about the current state of a security system including
|
139
156
|
* attributes, partitions, accessory components and relationships.
|
@@ -171,16 +188,14 @@ async function getCurrentState(systemID, authOpts) {
|
|
171
188
|
if (typeof garageIDs[0] !== 'undefined') {
|
172
189
|
components.set('garages', await getComponents(GARAGE_URL, garageIDs, authOpts));
|
173
190
|
}
|
174
|
-
const thermostatIDs = rels.thermostats.data.map(thermostat => thermostat.id);
|
191
|
+
const thermostatIDs = rels.thermostats.data.map((thermostat) => thermostat.id);
|
175
192
|
if (typeof thermostatIDs[0] !== 'undefined') {
|
176
193
|
components.set('thermostats', await getComponents(THERMOSTAT_URL, thermostatIDs, authOpts));
|
177
194
|
}
|
178
195
|
return {
|
179
196
|
id: res.data.id,
|
180
197
|
attributes: res.data.attributes,
|
181
|
-
partitions: components.has('partitions')
|
182
|
-
? components.get('partitions').data
|
183
|
-
: [],
|
198
|
+
partitions: components.has('partitions') ? components.get('partitions').data : [],
|
184
199
|
sensors: components.has('sensors') ? components.get('sensors').data : [],
|
185
200
|
lights: components.has('lights') ? components.get('lights').data : [],
|
186
201
|
locks: components.has('locks') ? components.get('locks').data : [],
|
@@ -596,14 +611,9 @@ async function get(url, opts) {
|
|
596
611
|
status = res.status;
|
597
612
|
resHeaders = res.headers;
|
598
613
|
const type = res.headers.get('content-type') || '';
|
599
|
-
const body = await (type.indexOf('json') !== -1
|
600
|
-
? res.status === 204
|
601
|
-
? {}
|
602
|
-
: res.json()
|
603
|
-
: res.text());
|
614
|
+
const body = await (type.indexOf('json') !== -1 ? (res.status === 204 ? {} : res.json()) : res.text());
|
604
615
|
if (status === 409) {
|
605
|
-
throw new Error('Two factor is enabled on this account but not setup in the plugin.' +
|
606
|
-
' See the wiki for details');
|
616
|
+
throw new Error('Two factor is enabled on this account but not setup in the plugin.' + ' See the wiki for details');
|
607
617
|
}
|
608
618
|
if (status >= 400) {
|
609
619
|
throw new Error(body.Message || body || status);
|