homebridge-smarthq-client 1.0.0
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/LICENSE +21 -0
- package/Readme.md +138 -0
- package/config.schema.json +146 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/platform.d.ts +40 -0
- package/dist/platform.js +243 -0
- package/dist/platform.js.map +1 -0
- package/dist/refrigerator/controlLock.d.ts +19 -0
- package/dist/refrigerator/controlLock.js +85 -0
- package/dist/refrigerator/controlLock.js.map +1 -0
- package/dist/refrigerator/convertibleDrawer.d.ts +27 -0
- package/dist/refrigerator/convertibleDrawer.js +317 -0
- package/dist/refrigerator/convertibleDrawer.js.map +1 -0
- package/dist/refrigerator/dispenserLight.d.ts +19 -0
- package/dist/refrigerator/dispenserLight.js +85 -0
- package/dist/refrigerator/dispenserLight.js.map +1 -0
- package/dist/refrigerator/energy.d.ts +19 -0
- package/dist/refrigerator/energy.js +93 -0
- package/dist/refrigerator/energy.js.map +1 -0
- package/dist/refrigerator/freezer.d.ts +41 -0
- package/dist/refrigerator/freezer.js +188 -0
- package/dist/refrigerator/freezer.js.map +1 -0
- package/dist/refrigerator/iceMaker.d.ts +19 -0
- package/dist/refrigerator/iceMaker.js +81 -0
- package/dist/refrigerator/iceMaker.js.map +1 -0
- package/dist/refrigerator/interiorLight.d.ts +21 -0
- package/dist/refrigerator/interiorLight.js +100 -0
- package/dist/refrigerator/interiorLight.js.map +1 -0
- package/dist/refrigerator/refrigerator.d.ts +41 -0
- package/dist/refrigerator/refrigerator.js +204 -0
- package/dist/refrigerator/refrigerator.js.map +1 -0
- package/dist/refrigerator/refrigeratorAlerts.d.ts +36 -0
- package/dist/refrigerator/refrigeratorAlerts.js +204 -0
- package/dist/refrigerator/refrigeratorAlerts.js.map +1 -0
- package/dist/refrigerator/sabbathMode.d.ts +20 -0
- package/dist/refrigerator/sabbathMode.js +91 -0
- package/dist/refrigerator/sabbathMode.js.map +1 -0
- package/dist/refrigerator/temperatureUnits.d.ts +21 -0
- package/dist/refrigerator/temperatureUnits.js +147 -0
- package/dist/refrigerator/temperatureUnits.js.map +1 -0
- package/dist/refrigerator/turboCoolMode.d.ts +23 -0
- package/dist/refrigerator/turboCoolMode.js +134 -0
- package/dist/refrigerator/turboCoolMode.js.map +1 -0
- package/dist/refrigerator/waterFilter.d.ts +19 -0
- package/dist/refrigerator/waterFilter.js +89 -0
- package/dist/refrigerator/waterFilter.js.map +1 -0
- package/dist/refrigeratorServices.d.ts +5 -0
- package/dist/refrigeratorServices.js +54 -0
- package/dist/refrigeratorServices.js.map +1 -0
- package/dist/settings.d.ts +12 -0
- package/dist/settings.js +13 -0
- package/dist/settings.js.map +1 -0
- package/dist/smartHqApi.d.ts +29 -0
- package/dist/smartHqApi.js +267 -0
- package/dist/smartHqApi.js.map +1 -0
- package/dist/smarthq-types.d.ts +29 -0
- package/dist/smarthq-types.js +2 -0
- package/dist/smarthq-types.js.map +1 -0
- package/eslint.config.js +12 -0
- package/images/homebridge.svg +1 -0
- package/package.json +61 -0
- package/src/@types/homebridge-lib.d.ts +14 -0
- package/src/index.ts +11 -0
- package/src/platform.ts +300 -0
- package/src/refrigerator/controlLock.ts +103 -0
- package/src/refrigerator/convertibleDrawer.ts +381 -0
- package/src/refrigerator/dispenserLight.ts +103 -0
- package/src/refrigerator/energy.ts +106 -0
- package/src/refrigerator/freezer.ts +227 -0
- package/src/refrigerator/iceMaker.ts +100 -0
- package/src/refrigerator/interiorLight.ts +118 -0
- package/src/refrigerator/refrigerator.ts +241 -0
- package/src/refrigerator/refrigeratorAlerts.ts +228 -0
- package/src/refrigerator/sabbathMode.ts +111 -0
- package/src/refrigerator/temperatureUnits.ts +178 -0
- package/src/refrigerator/turboCoolMode.ts +164 -0
- package/src/refrigerator/waterFilter.ts +107 -0
- package/src/refrigeratorServices.ts +60 -0
- package/src/settings.ts +14 -0
- package/src/smartHqApi.ts +305 -0
- package/src/smarthq-types.ts +31 -0
- package/tsconfig.json +24 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { SmartHqApi } from '../smartHqApi.js';
|
|
2
|
+
/**
|
|
3
|
+
* Platform Accessory
|
|
4
|
+
* An instance of this class is created for each accessory your platform registers
|
|
5
|
+
* Each accessory may expose multiple services of different service types.
|
|
6
|
+
*/
|
|
7
|
+
export class TemperatureUnits {
|
|
8
|
+
platform;
|
|
9
|
+
accessory;
|
|
10
|
+
deviceServices;
|
|
11
|
+
deviceId;
|
|
12
|
+
smartHqApi;
|
|
13
|
+
log;
|
|
14
|
+
constructor(platform, accessory, deviceServices, deviceId) {
|
|
15
|
+
this.platform = platform;
|
|
16
|
+
this.accessory = accessory;
|
|
17
|
+
this.deviceServices = deviceServices;
|
|
18
|
+
this.deviceId = deviceId;
|
|
19
|
+
this.platform = platform;
|
|
20
|
+
this.accessory = accessory;
|
|
21
|
+
this.deviceServices = deviceServices;
|
|
22
|
+
this.deviceId = deviceId;
|
|
23
|
+
this.log = platform.log;
|
|
24
|
+
this.smartHqApi = new SmartHqApi(this.platform);
|
|
25
|
+
//=====================================================================================
|
|
26
|
+
// Check to see if the device has any supported Temperature Units services
|
|
27
|
+
// If not, then don't add services for device that doesn't support it
|
|
28
|
+
//=====================================================================================
|
|
29
|
+
if (!this.platform.deviceSupportsThisService(this.deviceServices, 'cloud.smarthq.device.refrigerator', 'cloud.smarthq.service.mode', 'cloud.smarthq.domain.temperatureunits')) {
|
|
30
|
+
this.log.info('No supported Temperature Units service found for device: ' + this.accessory.displayName);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
this.platform.debug('green', 'Adding Temperature Units Switches');
|
|
34
|
+
//=====================================================================================
|
|
35
|
+
// create Temperature Unit switches for the Refrigerator
|
|
36
|
+
//=====================================================================================
|
|
37
|
+
let displayName = "Units: Celsius";
|
|
38
|
+
const unitsCelsius = this.accessory.getService(displayName)
|
|
39
|
+
|| this.accessory.addService(this.platform.Service.Switch, displayName, 'units-celsius-123');
|
|
40
|
+
unitsCelsius.setCharacteristic(this.platform.Characteristic.Name, displayName);
|
|
41
|
+
unitsCelsius.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
|
|
42
|
+
unitsCelsius.setCharacteristic(this.platform.Characteristic.ConfiguredName, displayName);
|
|
43
|
+
unitsCelsius.getCharacteristic(this.platform.Characteristic.On)
|
|
44
|
+
.onGet(this.getunitsCelsius.bind(this))
|
|
45
|
+
.onSet(this.setunitsCelsius.bind(this));
|
|
46
|
+
displayName = "Units: Fahrenheit";
|
|
47
|
+
const unitsFahrenheit = this.accessory.getService(displayName)
|
|
48
|
+
|| this.accessory.addService(this.platform.Service.Switch, displayName, 'units-fahrenheit-123');
|
|
49
|
+
unitsFahrenheit.setCharacteristic(this.platform.Characteristic.Name, displayName);
|
|
50
|
+
unitsFahrenheit.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
|
|
51
|
+
unitsFahrenheit.setCharacteristic(this.platform.Characteristic.ConfiguredName, displayName);
|
|
52
|
+
unitsFahrenheit.getCharacteristic(this.platform.Characteristic.On)
|
|
53
|
+
.onGet(this.getunitsFahrenheit.bind(this))
|
|
54
|
+
.onSet(this.setunitsFahrenheit.bind(this));
|
|
55
|
+
}
|
|
56
|
+
//=====================================================================================
|
|
57
|
+
async getunitsCelsius() {
|
|
58
|
+
let isOn = false;
|
|
59
|
+
for (const service of this.deviceServices) {
|
|
60
|
+
if (service.serviceDeviceType === 'cloud.smarthq.device.refrigerator'
|
|
61
|
+
&& service.serviceType === 'cloud.smarthq.service.mode'
|
|
62
|
+
&& service.domainType === 'cloud.smarthq.domain.temperatureunits') {
|
|
63
|
+
const state = await this.smartHqApi.getServiceState(this.deviceId, service.serviceId);
|
|
64
|
+
if (state?.mode == null) {
|
|
65
|
+
this.platform.debug('blue', 'No state.mode returned from getunitsCelsius state');
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
const units = state?.mode;
|
|
69
|
+
if (units === 'cloud.smarthq.type.mode.celsius') {
|
|
70
|
+
isOn = true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return isOn;
|
|
75
|
+
}
|
|
76
|
+
//=====================================================================================
|
|
77
|
+
async setunitsCelsius(value) {
|
|
78
|
+
if (value) {
|
|
79
|
+
const cmdBody = {
|
|
80
|
+
command: {
|
|
81
|
+
commandType: 'cloud.smarthq.command.mode.set',
|
|
82
|
+
mode: 'cloud.smarthq.type.mode.celsius'
|
|
83
|
+
},
|
|
84
|
+
kind: 'service#command',
|
|
85
|
+
deviceId: this.deviceId,
|
|
86
|
+
serviceDeviceType: 'cloud.smarthq.device.refrigerator',
|
|
87
|
+
serviceType: 'cloud.smarthq.service.mode',
|
|
88
|
+
domainType: 'cloud.smarthq.domain.temperatureunits'
|
|
89
|
+
};
|
|
90
|
+
const response = await this.smartHqApi.command(JSON.stringify(cmdBody));
|
|
91
|
+
if (response == null) {
|
|
92
|
+
this.platform.debug('blue', 'No response from setunitsCelsius command');
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
// Update the opposite switch
|
|
96
|
+
const unitsFahrenheit = this.accessory.getService("Units: Fahrenheit");
|
|
97
|
+
unitsFahrenheit?.getCharacteristic(this.platform.Characteristic.On).updateValue(false);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//=====================================================================================
|
|
101
|
+
async getunitsFahrenheit() {
|
|
102
|
+
let isOn = false;
|
|
103
|
+
for (const service of this.deviceServices) {
|
|
104
|
+
if (service.serviceDeviceType === 'cloud.smarthq.device.refrigerator'
|
|
105
|
+
&& service.serviceType === 'cloud.smarthq.service.mode'
|
|
106
|
+
&& service.domainType === 'cloud.smarthq.domain.temperatureunits') {
|
|
107
|
+
const state = await this.smartHqApi.getServiceState(this.deviceId, service.serviceId);
|
|
108
|
+
if (state?.mode == null) {
|
|
109
|
+
this.platform.debug('blue', 'No state.mode returned from getunitsFahrenheit state');
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
const units = state?.mode;
|
|
113
|
+
if (units === 'cloud.smarthq.type.mode.fahrenheit') {
|
|
114
|
+
isOn = true;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return isOn;
|
|
119
|
+
}
|
|
120
|
+
//=====================================================================================
|
|
121
|
+
async setunitsFahrenheit(value) {
|
|
122
|
+
this.platform.debug("blue", "Triggered setunitsFahrenheit: " + value);
|
|
123
|
+
if (value) {
|
|
124
|
+
const cmdBody = {
|
|
125
|
+
command: {
|
|
126
|
+
commandType: 'cloud.smarthq.command.mode.set',
|
|
127
|
+
mode: 'cloud.smarthq.type.mode.fahrenheit'
|
|
128
|
+
},
|
|
129
|
+
kind: 'service#command',
|
|
130
|
+
deviceId: this.deviceId,
|
|
131
|
+
serviceDeviceType: 'cloud.smarthq.device.refrigerator',
|
|
132
|
+
serviceType: 'cloud.smarthq.service.mode',
|
|
133
|
+
domainType: 'cloud.smarthq.domain.temperatureunits'
|
|
134
|
+
};
|
|
135
|
+
const response = await this.smartHqApi.command(JSON.stringify(cmdBody));
|
|
136
|
+
if (response == null) {
|
|
137
|
+
this.platform.debug('blue', 'No response from setunitsFahrenheit command');
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
// Update the opposite switch
|
|
141
|
+
// Update the opposite switch
|
|
142
|
+
const unitsCelsius = this.accessory.getService("Units: Celsius");
|
|
143
|
+
unitsCelsius?.getCharacteristic(this.platform.Characteristic.On).updateValue(false);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=temperatureUnits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"temperatureUnits.js","sourceRoot":"","sources":["../../src/refrigerator/temperatureUnits.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IAMR;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AC,kBAAkB,CAAC,KAA0B;QACjD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,gCAAgC,GAAG,KAAK,CAAC,CAAC;QACtE,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,OAAO,GAAG;gBACd,OAAO,EAAE;oBACP,WAAW,EAAE,gCAAgC;oBAC7C,IAAI,EAAE,oCAAoC;iBAC3C;gBACD,IAAI,EAAE,iBAAiB;gBACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,iBAAiB,EAAE,mCAAmC;gBACtD,WAAW,EAAE,4BAA4B;gBACzC,UAAU,EAAE,uCAAuC;aACpD,CAAC;YAEJ,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;YAExE,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;gBACrB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,6CAA6C,CAAC,CAAC;gBAC3E,OAAO;YACT,CAAC;YAEC,6BAA6B;YAC/B,6BAA6B;YAC3B,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;YACjE,YAAY,EAAE,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACtF,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CharacteristicValue, PlatformAccessory } from 'homebridge';
|
|
2
|
+
import { SmartHqPlatform } from '../platform.js';
|
|
3
|
+
import { DevService } from '../smarthq-types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Platform Accessory
|
|
6
|
+
* An instance of this class is created for each accessory your platform registers
|
|
7
|
+
* Each accessory may expose multiple services of different service types.
|
|
8
|
+
*/
|
|
9
|
+
export declare class TurboCoolMode {
|
|
10
|
+
private readonly platform;
|
|
11
|
+
private readonly accessory;
|
|
12
|
+
readonly deviceServices: DevService[];
|
|
13
|
+
readonly deviceId: string;
|
|
14
|
+
static turboCoolFreezerStatus: boolean;
|
|
15
|
+
static turboCoolFridgeStatus: boolean;
|
|
16
|
+
private readonly smartHqApi;
|
|
17
|
+
private log;
|
|
18
|
+
constructor(platform: SmartHqPlatform, accessory: PlatformAccessory, deviceServices: DevService[], deviceId: string);
|
|
19
|
+
getTurboCoolFridge(): Promise<CharacteristicValue>;
|
|
20
|
+
setTurboCoolFridge(value: CharacteristicValue): Promise<void>;
|
|
21
|
+
getTurboCoolFreezer(): Promise<CharacteristicValue>;
|
|
22
|
+
setTurboCoolFreezer(value: CharacteristicValue): Promise<void>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { SmartHqApi } from '../smartHqApi.js';
|
|
2
|
+
/**
|
|
3
|
+
* Platform Accessory
|
|
4
|
+
* An instance of this class is created for each accessory your platform registers
|
|
5
|
+
* Each accessory may expose multiple services of different service types.
|
|
6
|
+
*/
|
|
7
|
+
export class TurboCoolMode {
|
|
8
|
+
platform;
|
|
9
|
+
accessory;
|
|
10
|
+
deviceServices;
|
|
11
|
+
deviceId;
|
|
12
|
+
static turboCoolFreezerStatus = false;
|
|
13
|
+
static turboCoolFridgeStatus = false;
|
|
14
|
+
smartHqApi;
|
|
15
|
+
log;
|
|
16
|
+
constructor(platform, accessory, deviceServices, deviceId) {
|
|
17
|
+
this.platform = platform;
|
|
18
|
+
this.accessory = accessory;
|
|
19
|
+
this.deviceServices = deviceServices;
|
|
20
|
+
this.deviceId = deviceId;
|
|
21
|
+
this.platform = platform;
|
|
22
|
+
this.accessory = accessory;
|
|
23
|
+
this.deviceServices = deviceServices;
|
|
24
|
+
this.deviceId = deviceId;
|
|
25
|
+
this.log = platform.log;
|
|
26
|
+
this.smartHqApi = new SmartHqApi(this.platform);
|
|
27
|
+
//=====================================================================================
|
|
28
|
+
// Check to see if the device has any supported Turbo Cool services
|
|
29
|
+
// If not, then don't add services for device that doesn't support it
|
|
30
|
+
//=====================================================================================
|
|
31
|
+
if (!this.platform.deviceSupportsThisService(this.deviceServices, 'cloud.smarthq.device.refrigerator.freshfood', 'cloud.smarthq.service.toggle', 'cloud.smarthq.domain.turbo')) {
|
|
32
|
+
this.log.info('No supported Turbo Cool service found for device: ' + this.accessory.displayName);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
this.platform.debug('green', 'Adding Turbo Cool Mode Switches ');
|
|
36
|
+
//=====================================================================================
|
|
37
|
+
// create a Turbo Cool Refrigerator mode switch for the Refrigerator
|
|
38
|
+
//=====================================================================================
|
|
39
|
+
let displayName = "Turbo Cool Fridge";
|
|
40
|
+
const turboCoolFridge = this.accessory.getService(displayName)
|
|
41
|
+
|| this.accessory.addService(this.platform.Service.Switch, displayName, 'turbo-cool-123');
|
|
42
|
+
turboCoolFridge.setCharacteristic(this.platform.Characteristic.Name, displayName);
|
|
43
|
+
turboCoolFridge.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
|
|
44
|
+
turboCoolFridge.setCharacteristic(this.platform.Characteristic.ConfiguredName, displayName);
|
|
45
|
+
turboCoolFridge.getCharacteristic(this.platform.Characteristic.On)
|
|
46
|
+
.onGet(this.getTurboCoolFridge.bind(this))
|
|
47
|
+
.onSet(this.setTurboCoolFridge.bind(this));
|
|
48
|
+
//=====================================================================================
|
|
49
|
+
// create a Turbo Cool Freezer mode switch for the Freezer
|
|
50
|
+
//=====================================================================================
|
|
51
|
+
displayName = "Turbo Cool Freezer";
|
|
52
|
+
const turboCoolFreezer = this.accessory.getService(displayName)
|
|
53
|
+
|| this.accessory.addService(this.platform.Service.Switch, displayName, 'turbo-cool-freezer-123');
|
|
54
|
+
turboCoolFreezer.setCharacteristic(this.platform.Characteristic.Name, displayName);
|
|
55
|
+
turboCoolFreezer.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
|
|
56
|
+
turboCoolFreezer.setCharacteristic(this.platform.Characteristic.ConfiguredName, displayName);
|
|
57
|
+
turboCoolFreezer.getCharacteristic(this.platform.Characteristic.On)
|
|
58
|
+
.onGet(this.getTurboCoolFreezer.bind(this))
|
|
59
|
+
.onSet(this.setTurboCoolFreezer.bind(this));
|
|
60
|
+
}
|
|
61
|
+
//=====================================================================================
|
|
62
|
+
async getTurboCoolFridge() {
|
|
63
|
+
for (const service of this.deviceServices) {
|
|
64
|
+
if (service.serviceDeviceType === 'cloud.smarthq.device.refrigerator.freshfood'
|
|
65
|
+
&& service.serviceType === 'cloud.smarthq.service.toggle'
|
|
66
|
+
&& service.domainType === 'cloud.smarthq.domain.turbo') {
|
|
67
|
+
const state = await this.smartHqApi.getServiceState(this.deviceId, service.serviceId);
|
|
68
|
+
if (state?.on == null) {
|
|
69
|
+
this.platform.debug('blue', 'No state.on returned from getTurboCoolFridge state');
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
TurboCoolMode.turboCoolFridgeStatus = state?.on;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return TurboCoolMode.turboCoolFridgeStatus;
|
|
76
|
+
}
|
|
77
|
+
//=====================================================================================
|
|
78
|
+
async setTurboCoolFridge(value) {
|
|
79
|
+
this.platform.debug('blue', "Triggered setTurboCoolFridge toggle");
|
|
80
|
+
const cmdBody = {
|
|
81
|
+
kind: 'service#command',
|
|
82
|
+
deviceId: this.deviceId,
|
|
83
|
+
serviceDeviceType: 'cloud.smarthq.device.refrigerator.freshfood',
|
|
84
|
+
serviceType: 'cloud.smarthq.service.toggle',
|
|
85
|
+
domainType: 'cloud.smarthq.domain.turbo',
|
|
86
|
+
command: {
|
|
87
|
+
commandType: 'cloud.smarthq.command.toggle.set',
|
|
88
|
+
on: value
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const response = await this.smartHqApi.command(JSON.stringify(cmdBody));
|
|
92
|
+
if (response == null) {
|
|
93
|
+
this.platform.debug('blue', 'No response from setTurboCoolFridge command');
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//=====================================================================================
|
|
98
|
+
async getTurboCoolFreezer() {
|
|
99
|
+
for (const service of this.deviceServices) {
|
|
100
|
+
if (service.serviceDeviceType === 'cloud.smarthq.device.refrigerator.freezer'
|
|
101
|
+
&& service.serviceType === 'cloud.smarthq.service.toggle'
|
|
102
|
+
&& service.domainType === 'cloud.smarthq.domain.turbo') {
|
|
103
|
+
const state = await this.smartHqApi.getServiceState(this.deviceId, service.serviceId);
|
|
104
|
+
if (state?.on == null) {
|
|
105
|
+
this.platform.debug('blue', 'No state.on returned from getTurboCoolFreezer state');
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
TurboCoolMode.turboCoolFreezerStatus = state?.on;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return TurboCoolMode.turboCoolFreezerStatus;
|
|
112
|
+
}
|
|
113
|
+
//=====================================================================================
|
|
114
|
+
async setTurboCoolFreezer(value) {
|
|
115
|
+
this.platform.debug('blue', "Triggered setTurboCoolFreezer = toggle");
|
|
116
|
+
const cmdBody = {
|
|
117
|
+
kind: 'service#command',
|
|
118
|
+
deviceId: this.deviceId,
|
|
119
|
+
serviceDeviceType: 'cloud.smarthq.device.refrigerator.freezer',
|
|
120
|
+
serviceType: 'cloud.smarthq.service.toggle',
|
|
121
|
+
domainType: 'cloud.smarthq.domain.turbo',
|
|
122
|
+
command: {
|
|
123
|
+
commandType: 'cloud.smarthq.command.toggle.set',
|
|
124
|
+
on: value
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
const response = await this.smartHqApi.command(JSON.stringify(cmdBody));
|
|
128
|
+
if (response == null) {
|
|
129
|
+
this.platform.debug('blue', 'No response from setTurboCoolFreezer command');
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=turboCoolMode.js.map
|
|
@@ -0,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AAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,wCAAwC,CAAC,CAAC;QAEtE,MAAM,OAAO,GAAG;YACd,IAAI,EAAE,iBAAiB;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,iBAAiB,EAAG,2CAA2C;YAC/D,WAAW,EAAS,8BAA8B;YAClD,UAAU,EAAM,4BAA4B;YAC5C,OAAO,EAAE;gBACP,WAAW,EAAE,kCAAkC;gBAC/C,EAAE,EAAE,KAAK;aACV;SACF,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;QAExE,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;YACrB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,8CAA8C,CAAC,CAAC;YAC5E,OAAO;QACT,CAAC;IACH,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CharacteristicValue, PlatformAccessory } from 'homebridge';
|
|
2
|
+
import { SmartHqPlatform } from '../platform.js';
|
|
3
|
+
import { DevService } from '../smarthq-types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Platform Accessory
|
|
6
|
+
* An instance of this class is created for each accessory your platform registers
|
|
7
|
+
* Each accessory may expose multiple services of different service types.
|
|
8
|
+
*/
|
|
9
|
+
export declare class WaterFilter {
|
|
10
|
+
private readonly platform;
|
|
11
|
+
private readonly accessory;
|
|
12
|
+
readonly deviceServices: DevService[];
|
|
13
|
+
readonly deviceId: string;
|
|
14
|
+
private readonly smartHqApi;
|
|
15
|
+
private log;
|
|
16
|
+
constructor(platform: SmartHqPlatform, accessory: PlatformAccessory, deviceServices: DevService[], deviceId: string);
|
|
17
|
+
getWaterFilterChangeIndication(): Promise<CharacteristicValue>;
|
|
18
|
+
getWaterFilterLifeLevel(): Promise<CharacteristicValue>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { SmartHqApi } from '../smartHqApi.js';
|
|
2
|
+
/**
|
|
3
|
+
* Platform Accessory
|
|
4
|
+
* An instance of this class is created for each accessory your platform registers
|
|
5
|
+
* Each accessory may expose multiple services of different service types.
|
|
6
|
+
*/
|
|
7
|
+
export class WaterFilter {
|
|
8
|
+
platform;
|
|
9
|
+
accessory;
|
|
10
|
+
deviceServices;
|
|
11
|
+
deviceId;
|
|
12
|
+
smartHqApi;
|
|
13
|
+
log;
|
|
14
|
+
constructor(platform, accessory, deviceServices, deviceId) {
|
|
15
|
+
this.platform = platform;
|
|
16
|
+
this.accessory = accessory;
|
|
17
|
+
this.deviceServices = deviceServices;
|
|
18
|
+
this.deviceId = deviceId;
|
|
19
|
+
this.platform = platform;
|
|
20
|
+
this.accessory = accessory;
|
|
21
|
+
this.deviceServices = deviceServices;
|
|
22
|
+
this.deviceId = deviceId;
|
|
23
|
+
this.log = platform.log;
|
|
24
|
+
this.smartHqApi = new SmartHqApi(this.platform);
|
|
25
|
+
//=====================================================================================
|
|
26
|
+
// Check to see if the device has any supported FilterMaintenance services
|
|
27
|
+
// If not, then don't add services for device that doesn't support it
|
|
28
|
+
//=====================================================================================
|
|
29
|
+
if (!this.platform.deviceSupportsThisService(this.deviceServices, 'cloud.smarthq.device.waterfilter', 'cloud.smarthq.service.mode', 'cloud.smarthq.domain.state')) {
|
|
30
|
+
this.log.info('No supported FilterMaintenance service found for device: ' + this.accessory.displayName);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
this.platform.debug('green', 'Adding a Water Filter Sensor');
|
|
34
|
+
//=====================================================================================
|
|
35
|
+
// create a new water FilterMaintenance service for the Refrigerator
|
|
36
|
+
// This works in Homebridge and HomeKit has a native FilterMaintenance service type but the Home app does not implement it yet
|
|
37
|
+
// so no sensor/accessory will show up in the Home app for this service type.
|
|
38
|
+
//=====================================================================================
|
|
39
|
+
const displayName = "Filter Life";
|
|
40
|
+
const refrigeratorWaterFilter = this.accessory.getService(displayName)
|
|
41
|
+
|| this.accessory.addService(this.platform.Service.FilterMaintenance, displayName, 'filter-maintenance-1');
|
|
42
|
+
refrigeratorWaterFilter.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName);
|
|
43
|
+
refrigeratorWaterFilter.setCharacteristic(this.platform.Characteristic.ConfiguredName, displayName);
|
|
44
|
+
refrigeratorWaterFilter.getCharacteristic(this.platform.Characteristic.FilterChangeIndication)
|
|
45
|
+
.onGet(this.getWaterFilterChangeIndication.bind(this));
|
|
46
|
+
refrigeratorWaterFilter.getCharacteristic(this.platform.Characteristic.FilterLifeLevel)
|
|
47
|
+
.onGet(this.getWaterFilterLifeLevel.bind(this));
|
|
48
|
+
}
|
|
49
|
+
//=====================================================================================
|
|
50
|
+
async getWaterFilterChangeIndication() {
|
|
51
|
+
let filterStatus = 0;
|
|
52
|
+
for (const service of this.deviceServices) {
|
|
53
|
+
if (service.serviceDeviceType === 'cloud.smarthq.device.waterfilter'
|
|
54
|
+
&& service.serviceType === 'cloud.smarthq.service.mode') {
|
|
55
|
+
const state = await this.smartHqApi.getServiceState(this.deviceId, service.serviceId);
|
|
56
|
+
if (state?.mode == null) {
|
|
57
|
+
this.platform.debug('blue', 'No state.mode returned from getWaterFilterChangeIndication state');
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
if (state?.mode === 'cloud.smarthq.type.mode.good'
|
|
61
|
+
|| state?.mode === 'cloud.smarthq.type.mode.bypass'
|
|
62
|
+
|| state?.mode === 'cloud.smarthq.type.mode.expiringsoon') {
|
|
63
|
+
filterStatus = this.platform.Characteristic.FilterChangeIndication.FILTER_OK;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
filterStatus = this.platform.Characteristic.FilterChangeIndication.CHANGE_FILTER;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return filterStatus;
|
|
71
|
+
}
|
|
72
|
+
//=====================================================================================
|
|
73
|
+
async getWaterFilterLifeLevel() {
|
|
74
|
+
let filterRemaining = 0;
|
|
75
|
+
for (const service of this.deviceServices) {
|
|
76
|
+
if (service.serviceDeviceType === 'cloud.smarthq.device.waterfilter'
|
|
77
|
+
&& service.serviceType === 'cloud.smarthq.service.integer') {
|
|
78
|
+
const state = await this.smartHqApi.getServiceState(this.deviceId, service.serviceId);
|
|
79
|
+
if (state?.value == null) {
|
|
80
|
+
this.platform.debug('blue', 'No value returned from getWaterFilterLifeLevel state');
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
filterRemaining = state?.value;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return filterRemaining;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=waterFilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"waterFilter.js","sourceRoot":"","sources":["../../src/refrigerator/waterFilter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C;;;;GAIG;AACH,MAAM,OAAO,WAAW;IAMH;IACA;IACD;IACA;IAPD,UAAU,CAAa;IAChC,GAAG,CAAW;IAEtB,YACmB,QAAyB,EACzB,SAA4B,EAC7B,cAA4B,EAC5B,QAAgB;QAHf,aAAQ,GAAR,QAAQ,CAAiB;QACzB,cAAS,GAAT,SAAS,CAAmB;QAC7B,mBAAc,GAAd,cAAc,CAAc;QAC5B,aAAQ,GAAR,QAAQ,CAAQ;QAEhC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC;QAExB,IAAI,CAAC,UAAU,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,QAAQ,CAA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,CAAC,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;gBACtF,IAAI,KAAK,EAAE,KAAK,IAAI,IAAI,EAAE,CAAC;oBACzB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,sDAAsD,CAAC,CAAC;oBACpF,OAAO,KAAK,CAAC;gBACf,CAAC;gBACD,eAAe,GAAG,KAAK,EAAE,KAAK,CAAC;YACjC,CAAC;QACH,CAAC;QACD,OAAO,eAAe,CAAC;IACzB,CAAC;CAEF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DevService } from './smarthq-types.js';
|
|
2
|
+
import { PlatformAccessory } from 'homebridge';
|
|
3
|
+
import { SmartHqPlatform } from './platform.js';
|
|
4
|
+
import { DevDevice } from './smarthq-types.js';
|
|
5
|
+
export declare function setupRefrigeratorServices(this: SmartHqPlatform, accessory: PlatformAccessory, device: DevDevice, deviceServices: DevService[]): void;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// These functions setup the various services for a refrigerator appliance
|
|
2
|
+
// imported into platform.ts
|
|
3
|
+
// Refrigerator and Freezer are always added; the rest are optional based on config settings
|
|
4
|
+
import { Refrigerator } from './refrigerator/refrigerator.js';
|
|
5
|
+
import { Freezer } from './refrigerator/freezer.js';
|
|
6
|
+
import { ControlLock } from './refrigerator/controlLock.js';
|
|
7
|
+
import { ConvertibleDrawer } from './refrigerator/convertibleDrawer.js';
|
|
8
|
+
import { DispenserLight } from './refrigerator/dispenserLight.js';
|
|
9
|
+
import { EnergySensor } from './refrigerator/energy.js';
|
|
10
|
+
import { IceMaker } from './refrigerator/iceMaker.js';
|
|
11
|
+
import { InteriorLight } from './refrigerator/interiorLight.js';
|
|
12
|
+
import { SabbathMode } from './refrigerator/sabbathMode.js';
|
|
13
|
+
import { TemperatureUnits } from './refrigerator/temperatureUnits.js';
|
|
14
|
+
import { TurboCoolMode } from './refrigerator/turboCoolMode.js';
|
|
15
|
+
import { WaterFilter } from './refrigerator/waterFilter.js';
|
|
16
|
+
import { RefrigeratorAlerts } from './refrigerator/refrigeratorAlerts.js';
|
|
17
|
+
export function setupRefrigeratorServices(accessory, device, deviceServices) {
|
|
18
|
+
new Refrigerator(this, accessory, deviceServices, device.deviceId);
|
|
19
|
+
new Freezer(this, accessory, deviceServices, device.deviceId);
|
|
20
|
+
if (this.config.addConvertibleDrawer) {
|
|
21
|
+
new ConvertibleDrawer(this, accessory, deviceServices, device.deviceId);
|
|
22
|
+
}
|
|
23
|
+
if (this.config.addControlLock) {
|
|
24
|
+
new ControlLock(this, accessory, deviceServices, device.deviceId);
|
|
25
|
+
}
|
|
26
|
+
if (this.config.addDispenserLight) {
|
|
27
|
+
new DispenserLight(this, accessory, deviceServices, device.deviceId);
|
|
28
|
+
}
|
|
29
|
+
if (this.config.addEnergyMonitor) {
|
|
30
|
+
new EnergySensor(this, accessory, deviceServices, device.deviceId);
|
|
31
|
+
}
|
|
32
|
+
if (this.config.addIceMaker) {
|
|
33
|
+
new IceMaker(this, accessory, deviceServices, device.deviceId);
|
|
34
|
+
}
|
|
35
|
+
if (this.config.addInteriorLight) {
|
|
36
|
+
new InteriorLight(this, accessory, deviceServices, device.deviceId);
|
|
37
|
+
}
|
|
38
|
+
if (this.config.addSabbathMode) {
|
|
39
|
+
new SabbathMode(this, accessory, deviceServices, device.deviceId);
|
|
40
|
+
}
|
|
41
|
+
if (this.config.addTemperatureUnits) {
|
|
42
|
+
new TemperatureUnits(this, accessory, deviceServices, device.deviceId);
|
|
43
|
+
}
|
|
44
|
+
if (this.config.addTurboCool) {
|
|
45
|
+
new TurboCoolMode(this, accessory, deviceServices, device.deviceId);
|
|
46
|
+
}
|
|
47
|
+
if (this.config.addWaterFilter) {
|
|
48
|
+
new WaterFilter(this, accessory, deviceServices, device.deviceId);
|
|
49
|
+
}
|
|
50
|
+
if (this.config.addAlerts) {
|
|
51
|
+
new RefrigeratorAlerts(this, accessory, deviceServices, device.deviceId);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=refrigeratorServices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refrigeratorServices.js","sourceRoot":"","sources":["../src/refrigeratorServices.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,4BAA4B;AAC5B,4FAA4F;AAE5F,OAAO,EAAE,YAAY,EAAE,MAAY,gCAAgC,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAiB,2BAA2B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAa,+BAA+B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAO,qCAAqC,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAU,kCAAkC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAY,0BAA0B,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAgB,4BAA4B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAW,iCAAiC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAa,+BAA+B,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAQ,oCAAoC,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAW,iCAAiC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAa,+BAA+B,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAOxE,MAAM,UAAU,yBAAyB,CAAwB,SAA4B,EAAE,MAAiB,EAAE,cAA4B;IAC5I,IAAI,YAAY,CAAC,IAAI,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IACnE,IAAI,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IAE9D,IAAI,IAAI,CAAC,MAAM,CAAC,oBAAoB,EAAE,CAAC;QACrC,IAA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,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;QAC7B,IAAI,aAAa,CAAC,IAAI,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IAAA,CAAC;IAEvE,IAAI,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;QAC/B,IAAI,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IAAC,CAAC;IAEtE,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QAC1B,IAAI,kBAAkB,CAAC,IAAI,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IAAC,CAAC;AAC/E,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is the name of the platform that users will use to register the plugin in the Homebridge config.json
|
|
3
|
+
*/
|
|
4
|
+
export declare const PLATFORM_NAME = "SmartHqPlatform";
|
|
5
|
+
/**
|
|
6
|
+
* This must match the name of your plugin as defined the package.json `name` property
|
|
7
|
+
*/
|
|
8
|
+
export declare const PLUGIN_NAME = "homebridge-smarthq-client";
|
|
9
|
+
export declare const API_URL = "https://client.mysmarthq.com";
|
|
10
|
+
export declare const AUTH_URL = "https://accounts.brillion.geappliances.com/oauth2/auth";
|
|
11
|
+
export declare const ACCESSTOKEN_URL = "https://accounts.brillion.geappliances.com/oauth2/token";
|
|
12
|
+
export declare const TOKEN_STORE = "smarthq.tokens.json";
|
package/dist/settings.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is the name of the platform that users will use to register the plugin in the Homebridge config.json
|
|
3
|
+
*/
|
|
4
|
+
export const PLATFORM_NAME = "SmartHqPlatform";
|
|
5
|
+
/**
|
|
6
|
+
* This must match the name of your plugin as defined the package.json `name` property
|
|
7
|
+
*/
|
|
8
|
+
export const PLUGIN_NAME = 'homebridge-smarthq-client';
|
|
9
|
+
export const API_URL = 'https://client.mysmarthq.com';
|
|
10
|
+
export const AUTH_URL = 'https://accounts.brillion.geappliances.com/oauth2/auth';
|
|
11
|
+
export const ACCESSTOKEN_URL = 'https://accounts.brillion.geappliances.com/oauth2/token';
|
|
12
|
+
export const TOKEN_STORE = 'smarthq.tokens.json';
|
|
13
|
+
//# sourceMappingURL=settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC;AAE/C;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,2BAA2B,CAAC;AACvD,MAAM,CAAC,MAAM,OAAO,GAAO,8BAA8B,CAAC;AAE1D,MAAM,CAAC,MAAM,QAAQ,GAAM,wDAAwD,CAAC;AACpF,MAAM,CAAC,MAAM,eAAe,GAAI,yDAAyD,CAAC;AAC1F,MAAM,CAAC,MAAM,WAAW,GAAI,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
|
+
import { SmartHqPlatform } from './platform.js';
|
|
3
|
+
/**
|
|
4
|
+
* SmartHq Api functions
|
|
5
|
+
* This class is the main constructor for your plugin, this is where you should
|
|
6
|
+
* parse the user config and discover/register accessories with Homebridge.
|
|
7
|
+
*/
|
|
8
|
+
export declare class SmartHqApi {
|
|
9
|
+
private readonly platform;
|
|
10
|
+
refresh_token: string;
|
|
11
|
+
expires: number;
|
|
12
|
+
access_token: string;
|
|
13
|
+
constructor(platform: SmartHqPlatform);
|
|
14
|
+
authUrl(): string;
|
|
15
|
+
getOauthAccessToken(dataForBody: Record<string, string>): Promise<void>;
|
|
16
|
+
exchangeCodeForToken(code: string): Promise<void>;
|
|
17
|
+
refreshAccessToken(): Promise<void>;
|
|
18
|
+
saveToken(data: AxiosResponse['data']): void;
|
|
19
|
+
loadAccessToken(): void;
|
|
20
|
+
httpHeaders(): Promise<{
|
|
21
|
+
Authorization: string;
|
|
22
|
+
}>;
|
|
23
|
+
getAppliances(): Promise<any>;
|
|
24
|
+
getServiceState(deviceId: string, serviceId: string): Promise<any>;
|
|
25
|
+
getDeviceServices(deviceId: string): Promise<any>;
|
|
26
|
+
getRecentAlerts(): Promise<any>;
|
|
27
|
+
command(body: string): Promise<any>;
|
|
28
|
+
debug(color: string, message: string): void;
|
|
29
|
+
}
|