homebridge-solaxcloud-api 2.3.3 → 2.4.1
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/CHANGELOG.md +150 -131
- package/LICENSE +175 -175
- package/README.md +1 -0
- package/config.sample +15 -15
- package/config.schema.json +113 -106
- package/dist/batteryAccessory.d.ts +70 -70
- package/dist/batteryAccessory.d.ts.map +1 -1
- package/dist/batteryAccessory.js +124 -123
- package/dist/batteryAccessory.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +6 -6
- package/dist/lightSensorAccessory.d.ts +34 -34
- package/dist/lightSensorAccessory.js +58 -58
- package/dist/motionAccessory.d.ts +53 -53
- package/dist/motionAccessory.js +93 -93
- package/dist/outletAccessory.d.ts +104 -100
- package/dist/outletAccessory.d.ts.map +1 -1
- package/dist/outletAccessory.js +196 -187
- package/dist/outletAccessory.js.map +1 -1
- package/dist/platform.d.ts +67 -56
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +320 -265
- package/dist/platform.js.map +1 -1
- package/dist/platformAccessory.d.ts +70 -70
- package/dist/platformAccessory.js +102 -102
- package/dist/platformInverter.d.ts +180 -176
- package/dist/platformInverter.d.ts.map +1 -1
- package/dist/platformInverter.js +348 -343
- package/dist/platformInverter.js.map +1 -1
- package/dist/platformMeters.d.ts +68 -68
- package/dist/platformMeters.js +2 -2
- package/dist/settings.d.ts +8 -8
- package/dist/settings.js +11 -11
- package/dist/solaxcloudfetch.d.ts +1 -1
- package/dist/solaxcloudfetch.js +21 -21
- package/dist/solaxcloudfetch.js.map +1 -1
- package/dist/statistics.d.ts +36 -36
- package/dist/statistics.js +88 -88
- package/dist/util.d.ts +23 -23
- package/dist/util.js +42 -42
- package/package.json +55 -54
- package/test/batteryAccessory.test.ts +16 -0
- package/test/helpers.ts +36 -0
- package/test/lightSensorAccessory.test.ts +28 -0
- package/test/motionAccessory.test.ts +36 -0
- package/test/outletAccessory.test.ts +75 -0
- package/test/platformAccessory.test.ts +24 -0
- package/test/platformConfig.test.ts +188 -0
- package/test/platformTotalizer.test.ts +97 -0
- package/config.json +0 -16
- package/dist/solaxcloudapi.d.ts +0 -163
- package/dist/solaxcloudapi.d.ts.map +0 -1
- package/dist/solaxcloudapi.js +0 -226
- package/dist/solaxcloudapi.js.map +0 -1
- package/test/solaxcloudapi.test.ts +0 -164
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batteryAccessory.js","sourceRoot":"","sources":["../src/batteryAccessory.ts"],"names":[],"mappings":";;;AAEA,2DAA6D;AAE7D;;GAEG;AACU,QAAA,sBAAsB,GAAG;IACpC,YAAY,EAAE,CAAC;IACf,QAAQ,EAAE,CAAC;IACX,cAAc,EAAE,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAEjC;;;GAGG;AACH,MAAa,qBAAsB,SAAQ,0CAAsB;IAgB/D;;;;;;;OAOG;IACH,YAAY,GAAY,EAAE,GAAQ,EAAE,IAAY,EAAE,MAAc,EAAE,KAAa;QAC7E,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QAnBvC;;WAEG;QACK,iBAAY,GAAG,CAAC,CAAC;QAEzB;;WAEG;QACK,uBAAkB,GAAG,8BAAsB,CAAC,YAAY,CAAC;QAa/D,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,qBAAqB,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QAElD,IAAI,CAAC,cAAc,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAE7D,oCAAoC;QACpC,IAAI,CAAC,cAAc;aAChB,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,YAAY,CAAC;aAC3D,EAAE,kBAA+B,IAAI,CAAC,QAAQ,CAAC,IA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AG,IAAI,CAAC,IAAI,8BAA8B,IAAI,CAAC,kBAAkB,GAAG,CAAC,CAAC;QAErF,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAC1C,CAAC;IAED;;;OAGG;IACI,cAAc,CAAC,KAAa;QACjC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,6BAA6B,KAAK,GAAG,CAAC,CAAC;QAElE,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;QAEhC,IAAI,CAAC,cAAc,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;IAC7F,CAAC;IAED;;;OAGG;IACI,mBAAmB;QACxB,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACjC,CAAC;IAED;;;OAGG;IACH,WAAW;QACT,OAAO,CAAE,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,cAAc,CAAE,CAAC;IAC1D,CAAC;CAEF;AApID,sDAoIC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { API } from 'homebridge';
|
|
2
|
-
declare const _default: (api: API) => void;
|
|
3
|
-
/**
|
|
4
|
-
* This method registers the platform with Homebridge
|
|
5
|
-
*/
|
|
6
|
-
export = _default;
|
|
1
|
+
import { API } from 'homebridge';
|
|
2
|
+
declare const _default: (api: API) => void;
|
|
3
|
+
/**
|
|
4
|
+
* This method registers the platform with Homebridge
|
|
5
|
+
*/
|
|
6
|
+
export = _default;
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const settings_1 = require("./settings");
|
|
3
|
-
const platform_1 = require("./platform");
|
|
4
|
-
module.exports = (api) => {
|
|
5
|
-
api.registerPlatform(settings_1.PLATFORM_NAME, platform_1.SolaxCloudAPIPlatform);
|
|
6
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
const settings_1 = require("./settings");
|
|
3
|
+
const platform_1 = require("./platform");
|
|
4
|
+
module.exports = (api) => {
|
|
5
|
+
api.registerPlatform(settings_1.PLATFORM_NAME, platform_1.SolaxCloudAPIPlatform);
|
|
6
|
+
};
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { AccessoryPlugin, API, CharacteristicGetCallback, Logging, Service } from 'homebridge';
|
|
2
|
-
import { SolaxPlatformAccessory } from './platformAccessory';
|
|
3
|
-
/**
|
|
4
|
-
* Solax Light Sensor Accessory.
|
|
5
|
-
* Virtual light sensor used to monitor and measure both power consumption from Solax devices
|
|
6
|
-
* (for "Home app"-only purists).
|
|
7
|
-
* Using Lux to display power comsumption.
|
|
8
|
-
*/
|
|
9
|
-
export declare class SolaxLightSensorAccessory extends SolaxPlatformAccessory implements AccessoryPlugin {
|
|
10
|
-
private readonly lightService;
|
|
11
|
-
/**
|
|
12
|
-
* Ambient light level.
|
|
13
|
-
*/
|
|
14
|
-
private lux;
|
|
15
|
-
/**
|
|
16
|
-
* Solax virtual light sensor class constructor.
|
|
17
|
-
* @param {Logging} log The platform logging for homebridge.
|
|
18
|
-
* @param {API} api The platform API.
|
|
19
|
-
* @param {string} name The accessory name.
|
|
20
|
-
* @param {string} serial "Real world" serial number for this accessory.
|
|
21
|
-
* @param {string} model Accessory model.
|
|
22
|
-
*/
|
|
23
|
-
constructor(log: Logging, api: API, name: string, serial: string, model: string);
|
|
24
|
-
/**
|
|
25
|
-
* Gets the current ambient light level (power consumpion in Watts).
|
|
26
|
-
*/
|
|
27
|
-
getAmbientLightLevel(callback: CharacteristicGetCallback): void;
|
|
28
|
-
/**
|
|
29
|
-
* Sets the current ambient light level (power consumption in Watts).
|
|
30
|
-
* @param {number} lux The lux (power consumption) value to set.
|
|
31
|
-
*/
|
|
32
|
-
setAmbientLightLevel(lux: number): void;
|
|
33
|
-
getServices(): Service[];
|
|
34
|
-
}
|
|
1
|
+
import { AccessoryPlugin, API, CharacteristicGetCallback, Logging, Service } from 'homebridge';
|
|
2
|
+
import { SolaxPlatformAccessory } from './platformAccessory';
|
|
3
|
+
/**
|
|
4
|
+
* Solax Light Sensor Accessory.
|
|
5
|
+
* Virtual light sensor used to monitor and measure both power consumption from Solax devices
|
|
6
|
+
* (for "Home app"-only purists).
|
|
7
|
+
* Using Lux to display power comsumption.
|
|
8
|
+
*/
|
|
9
|
+
export declare class SolaxLightSensorAccessory extends SolaxPlatformAccessory implements AccessoryPlugin {
|
|
10
|
+
private readonly lightService;
|
|
11
|
+
/**
|
|
12
|
+
* Ambient light level.
|
|
13
|
+
*/
|
|
14
|
+
private lux;
|
|
15
|
+
/**
|
|
16
|
+
* Solax virtual light sensor class constructor.
|
|
17
|
+
* @param {Logging} log The platform logging for homebridge.
|
|
18
|
+
* @param {API} api The platform API.
|
|
19
|
+
* @param {string} name The accessory name.
|
|
20
|
+
* @param {string} serial "Real world" serial number for this accessory.
|
|
21
|
+
* @param {string} model Accessory model.
|
|
22
|
+
*/
|
|
23
|
+
constructor(log: Logging, api: API, name: string, serial: string, model: string);
|
|
24
|
+
/**
|
|
25
|
+
* Gets the current ambient light level (power consumpion in Watts).
|
|
26
|
+
*/
|
|
27
|
+
getAmbientLightLevel(callback: CharacteristicGetCallback): void;
|
|
28
|
+
/**
|
|
29
|
+
* Sets the current ambient light level (power consumption in Watts).
|
|
30
|
+
* @param {number} lux The lux (power consumption) value to set.
|
|
31
|
+
*/
|
|
32
|
+
setAmbientLightLevel(lux: number): void;
|
|
33
|
+
getServices(): Service[];
|
|
34
|
+
}
|
|
35
35
|
//# sourceMappingURL=lightSensorAccessory.d.ts.map
|
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SolaxLightSensorAccessory = void 0;
|
|
4
|
-
const platformAccessory_1 = require("./platformAccessory");
|
|
5
|
-
/**
|
|
6
|
-
* Solax Light Sensor Accessory.
|
|
7
|
-
* Virtual light sensor used to monitor and measure both power consumption from Solax devices
|
|
8
|
-
* (for "Home app"-only purists).
|
|
9
|
-
* Using Lux to display power comsumption.
|
|
10
|
-
*/
|
|
11
|
-
class SolaxLightSensorAccessory extends platformAccessory_1.SolaxPlatformAccessory {
|
|
12
|
-
/**
|
|
13
|
-
* Solax virtual light sensor class constructor.
|
|
14
|
-
* @param {Logging} log The platform logging for homebridge.
|
|
15
|
-
* @param {API} api The platform API.
|
|
16
|
-
* @param {string} name The accessory name.
|
|
17
|
-
* @param {string} serial "Real world" serial number for this accessory.
|
|
18
|
-
* @param {string} model Accessory model.
|
|
19
|
-
*/
|
|
20
|
-
constructor(log, api, name, serial, model) {
|
|
21
|
-
super(log, api, name, serial, model);
|
|
22
|
-
/**
|
|
23
|
-
* Ambient light level.
|
|
24
|
-
*/
|
|
25
|
-
this.lux = 0;
|
|
26
|
-
this.log.debug(`Creating light sensor "${this.name}"`);
|
|
27
|
-
this.lightService = new this.api.hap.Service.LightSensor(name);
|
|
28
|
-
this.lightService
|
|
29
|
-
.getCharacteristic(this.api.hap.Characteristic.CurrentAmbientLightLevel)
|
|
30
|
-
.on("get" /* GET */, this.getAmbientLightLevel.bind(this));
|
|
31
|
-
log.info(`Light sensor (watts reader) "${name}" created!`);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Gets the current ambient light level (power consumpion in Watts).
|
|
35
|
-
*/
|
|
36
|
-
getAmbientLightLevel(callback) {
|
|
37
|
-
this.log.debug(`${this.name}: GET Ambient Light Level (lux=${this.lux})`);
|
|
38
|
-
callback(null, this.lux);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Sets the current ambient light level (power consumption in Watts).
|
|
42
|
-
* @param {number} lux The lux (power consumption) value to set.
|
|
43
|
-
*/
|
|
44
|
-
setAmbientLightLevel(lux) {
|
|
45
|
-
this.log.debug(`${this.name}: SET Ambient Light Level (lux=${lux})`);
|
|
46
|
-
// Minimum value allowed for light sensor is 0.1
|
|
47
|
-
this.lux = Math.max(0.1, lux);
|
|
48
|
-
this.lightService.updateCharacteristic(this.api.hap.Characteristic.CurrentAmbientLightLevel, this.lux);
|
|
49
|
-
}
|
|
50
|
-
/*
|
|
51
|
-
* This method is called directly after creation of this instance.
|
|
52
|
-
* It should return all services which should be added to the accessory.
|
|
53
|
-
*/
|
|
54
|
-
getServices() {
|
|
55
|
-
return [this.informationService, this.lightService];
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.SolaxLightSensorAccessory = SolaxLightSensorAccessory;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SolaxLightSensorAccessory = void 0;
|
|
4
|
+
const platformAccessory_1 = require("./platformAccessory");
|
|
5
|
+
/**
|
|
6
|
+
* Solax Light Sensor Accessory.
|
|
7
|
+
* Virtual light sensor used to monitor and measure both power consumption from Solax devices
|
|
8
|
+
* (for "Home app"-only purists).
|
|
9
|
+
* Using Lux to display power comsumption.
|
|
10
|
+
*/
|
|
11
|
+
class SolaxLightSensorAccessory extends platformAccessory_1.SolaxPlatformAccessory {
|
|
12
|
+
/**
|
|
13
|
+
* Solax virtual light sensor class constructor.
|
|
14
|
+
* @param {Logging} log The platform logging for homebridge.
|
|
15
|
+
* @param {API} api The platform API.
|
|
16
|
+
* @param {string} name The accessory name.
|
|
17
|
+
* @param {string} serial "Real world" serial number for this accessory.
|
|
18
|
+
* @param {string} model Accessory model.
|
|
19
|
+
*/
|
|
20
|
+
constructor(log, api, name, serial, model) {
|
|
21
|
+
super(log, api, name, serial, model);
|
|
22
|
+
/**
|
|
23
|
+
* Ambient light level.
|
|
24
|
+
*/
|
|
25
|
+
this.lux = 0;
|
|
26
|
+
this.log.debug(`Creating light sensor "${this.name}"`);
|
|
27
|
+
this.lightService = new this.api.hap.Service.LightSensor(name);
|
|
28
|
+
this.lightService
|
|
29
|
+
.getCharacteristic(this.api.hap.Characteristic.CurrentAmbientLightLevel)
|
|
30
|
+
.on("get" /* GET */, this.getAmbientLightLevel.bind(this));
|
|
31
|
+
log.info(`Light sensor (watts reader) "${name}" created!`);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Gets the current ambient light level (power consumpion in Watts).
|
|
35
|
+
*/
|
|
36
|
+
getAmbientLightLevel(callback) {
|
|
37
|
+
this.log.debug(`${this.name}: GET Ambient Light Level (lux=${this.lux})`);
|
|
38
|
+
callback(null, this.lux);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Sets the current ambient light level (power consumption in Watts).
|
|
42
|
+
* @param {number} lux The lux (power consumption) value to set.
|
|
43
|
+
*/
|
|
44
|
+
setAmbientLightLevel(lux) {
|
|
45
|
+
this.log.debug(`${this.name}: SET Ambient Light Level (lux=${lux})`);
|
|
46
|
+
// Minimum value allowed for light sensor is 0.1
|
|
47
|
+
this.lux = Math.max(0.1, lux);
|
|
48
|
+
this.lightService.updateCharacteristic(this.api.hap.Characteristic.CurrentAmbientLightLevel, this.lux);
|
|
49
|
+
}
|
|
50
|
+
/*
|
|
51
|
+
* This method is called directly after creation of this instance.
|
|
52
|
+
* It should return all services which should be added to the accessory.
|
|
53
|
+
*/
|
|
54
|
+
getServices() {
|
|
55
|
+
return [this.informationService, this.lightService];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.SolaxLightSensorAccessory = SolaxLightSensorAccessory;
|
|
59
59
|
//# sourceMappingURL=lightSensorAccessory.js.map
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Service, AccessoryPlugin, Logging, CharacteristicGetCallback, API } from 'homebridge';
|
|
3
|
-
import { SolaxPlatformAccessory } from './platformAccessory';
|
|
4
|
-
/**
|
|
5
|
-
* Solax Motion Accessory.
|
|
6
|
-
* Virtual motion sensor triggered whenever new data is fetched from Solax Cloud.
|
|
7
|
-
* Sensor will automatically clear itself after MOTION_TIMEOUT seconds (defaults to 5 seconds).
|
|
8
|
-
*/
|
|
9
|
-
export declare class SolaxMotionAccessory extends SolaxPlatformAccessory implements AccessoryPlugin {
|
|
10
|
-
/**
|
|
11
|
-
* Homekit Motion Service for this accessory.
|
|
12
|
-
*/
|
|
13
|
-
private readonly motionService;
|
|
14
|
-
/**
|
|
15
|
-
* Whether motion is detected (Solax Cloud data updated).
|
|
16
|
-
*/
|
|
17
|
-
private motion;
|
|
18
|
-
/**
|
|
19
|
-
* Interval before clearing motion (in seconds).
|
|
20
|
-
*/
|
|
21
|
-
private motionTimeout;
|
|
22
|
-
/**
|
|
23
|
-
* Solax virtual motion sensor class constructor.
|
|
24
|
-
* @param {Logging} log The platform logging for homebridge.
|
|
25
|
-
* @param {API} api The API for Solax Cloud platform.
|
|
26
|
-
* @param {string} name The accessory name.
|
|
27
|
-
* @param {string} serial "Real-world" serial number for this accessory.
|
|
28
|
-
* @param {string} model Accessory model.
|
|
29
|
-
*/
|
|
30
|
-
constructor(log: Logging, api: API, name: string, serial: string, model: string);
|
|
31
|
-
sleep: typeof import("timers/promises").setTimeout;
|
|
32
|
-
/**
|
|
33
|
-
* Gets the motion sensor state Characteristic.
|
|
34
|
-
* @param {CharacteristicGetCallback} callback The callback.
|
|
35
|
-
*/
|
|
36
|
-
getState(callback: CharacteristicGetCallback): void;
|
|
37
|
-
/**
|
|
38
|
-
* Sets the motion sensor state.
|
|
39
|
-
* @param {boolean} motion Whether motion was detected.
|
|
40
|
-
*/
|
|
41
|
-
setState(motion: boolean): void;
|
|
42
|
-
/**
|
|
43
|
-
* Sets the motion timeout.
|
|
44
|
-
* @param {number} timeout Number of seconds before clearing motion.
|
|
45
|
-
*/
|
|
46
|
-
setMotionTimeout(timeout: number): void;
|
|
47
|
-
/**
|
|
48
|
-
* Gets the motion timeout.
|
|
49
|
-
* @return {number} Number of seconds before clearing motion.
|
|
50
|
-
*/
|
|
51
|
-
getMotionTimeout(): number;
|
|
52
|
-
getServices(): Service[];
|
|
53
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Service, AccessoryPlugin, Logging, CharacteristicGetCallback, API } from 'homebridge';
|
|
3
|
+
import { SolaxPlatformAccessory } from './platformAccessory';
|
|
4
|
+
/**
|
|
5
|
+
* Solax Motion Accessory.
|
|
6
|
+
* Virtual motion sensor triggered whenever new data is fetched from Solax Cloud.
|
|
7
|
+
* Sensor will automatically clear itself after MOTION_TIMEOUT seconds (defaults to 5 seconds).
|
|
8
|
+
*/
|
|
9
|
+
export declare class SolaxMotionAccessory extends SolaxPlatformAccessory implements AccessoryPlugin {
|
|
10
|
+
/**
|
|
11
|
+
* Homekit Motion Service for this accessory.
|
|
12
|
+
*/
|
|
13
|
+
private readonly motionService;
|
|
14
|
+
/**
|
|
15
|
+
* Whether motion is detected (Solax Cloud data updated).
|
|
16
|
+
*/
|
|
17
|
+
private motion;
|
|
18
|
+
/**
|
|
19
|
+
* Interval before clearing motion (in seconds).
|
|
20
|
+
*/
|
|
21
|
+
private motionTimeout;
|
|
22
|
+
/**
|
|
23
|
+
* Solax virtual motion sensor class constructor.
|
|
24
|
+
* @param {Logging} log The platform logging for homebridge.
|
|
25
|
+
* @param {API} api The API for Solax Cloud platform.
|
|
26
|
+
* @param {string} name The accessory name.
|
|
27
|
+
* @param {string} serial "Real-world" serial number for this accessory.
|
|
28
|
+
* @param {string} model Accessory model.
|
|
29
|
+
*/
|
|
30
|
+
constructor(log: Logging, api: API, name: string, serial: string, model: string);
|
|
31
|
+
sleep: typeof import("timers/promises").setTimeout;
|
|
32
|
+
/**
|
|
33
|
+
* Gets the motion sensor state Characteristic.
|
|
34
|
+
* @param {CharacteristicGetCallback} callback The callback.
|
|
35
|
+
*/
|
|
36
|
+
getState(callback: CharacteristicGetCallback): void;
|
|
37
|
+
/**
|
|
38
|
+
* Sets the motion sensor state.
|
|
39
|
+
* @param {boolean} motion Whether motion was detected.
|
|
40
|
+
*/
|
|
41
|
+
setState(motion: boolean): void;
|
|
42
|
+
/**
|
|
43
|
+
* Sets the motion timeout.
|
|
44
|
+
* @param {number} timeout Number of seconds before clearing motion.
|
|
45
|
+
*/
|
|
46
|
+
setMotionTimeout(timeout: number): void;
|
|
47
|
+
/**
|
|
48
|
+
* Gets the motion timeout.
|
|
49
|
+
* @return {number} Number of seconds before clearing motion.
|
|
50
|
+
*/
|
|
51
|
+
getMotionTimeout(): number;
|
|
52
|
+
getServices(): Service[];
|
|
53
|
+
}
|
|
54
54
|
//# sourceMappingURL=motionAccessory.d.ts.map
|
package/dist/motionAccessory.js
CHANGED
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SolaxMotionAccessory = void 0;
|
|
7
|
-
const util_1 = __importDefault(require("util"));
|
|
8
|
-
const platformAccessory_1 = require("./platformAccessory");
|
|
9
|
-
/**
|
|
10
|
-
* Motion timeout in seconds.
|
|
11
|
-
*/
|
|
12
|
-
const MOTION_TIMEOUT = 5;
|
|
13
|
-
/**
|
|
14
|
-
* Solax Motion Accessory.
|
|
15
|
-
* Virtual motion sensor triggered whenever new data is fetched from Solax Cloud.
|
|
16
|
-
* Sensor will automatically clear itself after MOTION_TIMEOUT seconds (defaults to 5 seconds).
|
|
17
|
-
*/
|
|
18
|
-
class SolaxMotionAccessory extends platformAccessory_1.SolaxPlatformAccessory {
|
|
19
|
-
/**
|
|
20
|
-
* Solax virtual motion sensor class constructor.
|
|
21
|
-
* @param {Logging} log The platform logging for homebridge.
|
|
22
|
-
* @param {API} api The API for Solax Cloud platform.
|
|
23
|
-
* @param {string} name The accessory name.
|
|
24
|
-
* @param {string} serial "Real-world" serial number for this accessory.
|
|
25
|
-
* @param {string} model Accessory model.
|
|
26
|
-
*/
|
|
27
|
-
constructor(log, api, name, serial, model) {
|
|
28
|
-
super(log, api, name, serial, model);
|
|
29
|
-
/**
|
|
30
|
-
* Whether motion is detected (Solax Cloud data updated).
|
|
31
|
-
*/
|
|
32
|
-
this.motion = false;
|
|
33
|
-
/**
|
|
34
|
-
* Interval before clearing motion (in seconds).
|
|
35
|
-
*/
|
|
36
|
-
this.motionTimeout = MOTION_TIMEOUT;
|
|
37
|
-
this.sleep = util_1.default.promisify(setTimeout);
|
|
38
|
-
this.log.debug(`Creating motion sensor "${this.name}"`);
|
|
39
|
-
this.motionService = new this.api.hap.Service.MotionSensor(this.name);
|
|
40
|
-
this.motionService
|
|
41
|
-
.getCharacteristic(this.api.hap.Characteristic.MotionDetected)
|
|
42
|
-
.on("get" /* GET */, this.getState.bind(this));
|
|
43
|
-
log.info(`Motion sensor "${name}" created!`);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Gets the motion sensor state Characteristic.
|
|
47
|
-
* @param {CharacteristicGetCallback} callback The callback.
|
|
48
|
-
*/
|
|
49
|
-
getState(callback) {
|
|
50
|
-
this.log.debug(`${this.name}: GET State (motion=${this.motion})`);
|
|
51
|
-
callback(null, this.motion);
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Sets the motion sensor state.
|
|
55
|
-
* @param {boolean} motion Whether motion was detected.
|
|
56
|
-
*/
|
|
57
|
-
setState(motion) {
|
|
58
|
-
this.log.debug(`${this.name}: SET State (motion=${motion})`);
|
|
59
|
-
this.motionService
|
|
60
|
-
.getCharacteristic(this.api.hap.Characteristic.MotionDetected)
|
|
61
|
-
.updateValue(motion);
|
|
62
|
-
this.motion = motion;
|
|
63
|
-
if (this.motion) {
|
|
64
|
-
// turn it off after timeout
|
|
65
|
-
this.sleep(this.motionTimeout * 1000).then(() => this.setState(false));
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Sets the motion timeout.
|
|
70
|
-
* @param {number} timeout Number of seconds before clearing motion.
|
|
71
|
-
*/
|
|
72
|
-
setMotionTimeout(timeout) {
|
|
73
|
-
this.motionTimeout = timeout;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Gets the motion timeout.
|
|
77
|
-
* @return {number} Number of seconds before clearing motion.
|
|
78
|
-
*/
|
|
79
|
-
getMotionTimeout() {
|
|
80
|
-
return this.motionTimeout;
|
|
81
|
-
}
|
|
82
|
-
/*
|
|
83
|
-
* This method is called directly after creation of this instance.
|
|
84
|
-
* It should return all services which should be added to the accessory.
|
|
85
|
-
*/
|
|
86
|
-
getServices() {
|
|
87
|
-
return [
|
|
88
|
-
this.informationService,
|
|
89
|
-
this.motionService,
|
|
90
|
-
];
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
exports.SolaxMotionAccessory = SolaxMotionAccessory;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SolaxMotionAccessory = void 0;
|
|
7
|
+
const util_1 = __importDefault(require("util"));
|
|
8
|
+
const platformAccessory_1 = require("./platformAccessory");
|
|
9
|
+
/**
|
|
10
|
+
* Motion timeout in seconds.
|
|
11
|
+
*/
|
|
12
|
+
const MOTION_TIMEOUT = 5;
|
|
13
|
+
/**
|
|
14
|
+
* Solax Motion Accessory.
|
|
15
|
+
* Virtual motion sensor triggered whenever new data is fetched from Solax Cloud.
|
|
16
|
+
* Sensor will automatically clear itself after MOTION_TIMEOUT seconds (defaults to 5 seconds).
|
|
17
|
+
*/
|
|
18
|
+
class SolaxMotionAccessory extends platformAccessory_1.SolaxPlatformAccessory {
|
|
19
|
+
/**
|
|
20
|
+
* Solax virtual motion sensor class constructor.
|
|
21
|
+
* @param {Logging} log The platform logging for homebridge.
|
|
22
|
+
* @param {API} api The API for Solax Cloud platform.
|
|
23
|
+
* @param {string} name The accessory name.
|
|
24
|
+
* @param {string} serial "Real-world" serial number for this accessory.
|
|
25
|
+
* @param {string} model Accessory model.
|
|
26
|
+
*/
|
|
27
|
+
constructor(log, api, name, serial, model) {
|
|
28
|
+
super(log, api, name, serial, model);
|
|
29
|
+
/**
|
|
30
|
+
* Whether motion is detected (Solax Cloud data updated).
|
|
31
|
+
*/
|
|
32
|
+
this.motion = false;
|
|
33
|
+
/**
|
|
34
|
+
* Interval before clearing motion (in seconds).
|
|
35
|
+
*/
|
|
36
|
+
this.motionTimeout = MOTION_TIMEOUT;
|
|
37
|
+
this.sleep = util_1.default.promisify(setTimeout);
|
|
38
|
+
this.log.debug(`Creating motion sensor "${this.name}"`);
|
|
39
|
+
this.motionService = new this.api.hap.Service.MotionSensor(this.name);
|
|
40
|
+
this.motionService
|
|
41
|
+
.getCharacteristic(this.api.hap.Characteristic.MotionDetected)
|
|
42
|
+
.on("get" /* GET */, this.getState.bind(this));
|
|
43
|
+
log.info(`Motion sensor "${name}" created!`);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Gets the motion sensor state Characteristic.
|
|
47
|
+
* @param {CharacteristicGetCallback} callback The callback.
|
|
48
|
+
*/
|
|
49
|
+
getState(callback) {
|
|
50
|
+
this.log.debug(`${this.name}: GET State (motion=${this.motion})`);
|
|
51
|
+
callback(null, this.motion);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Sets the motion sensor state.
|
|
55
|
+
* @param {boolean} motion Whether motion was detected.
|
|
56
|
+
*/
|
|
57
|
+
setState(motion) {
|
|
58
|
+
this.log.debug(`${this.name}: SET State (motion=${motion})`);
|
|
59
|
+
this.motionService
|
|
60
|
+
.getCharacteristic(this.api.hap.Characteristic.MotionDetected)
|
|
61
|
+
.updateValue(motion);
|
|
62
|
+
this.motion = motion;
|
|
63
|
+
if (this.motion) {
|
|
64
|
+
// turn it off after timeout
|
|
65
|
+
this.sleep(this.motionTimeout * 1000).then(() => this.setState(false));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Sets the motion timeout.
|
|
70
|
+
* @param {number} timeout Number of seconds before clearing motion.
|
|
71
|
+
*/
|
|
72
|
+
setMotionTimeout(timeout) {
|
|
73
|
+
this.motionTimeout = timeout;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Gets the motion timeout.
|
|
77
|
+
* @return {number} Number of seconds before clearing motion.
|
|
78
|
+
*/
|
|
79
|
+
getMotionTimeout() {
|
|
80
|
+
return this.motionTimeout;
|
|
81
|
+
}
|
|
82
|
+
/*
|
|
83
|
+
* This method is called directly after creation of this instance.
|
|
84
|
+
* It should return all services which should be added to the accessory.
|
|
85
|
+
*/
|
|
86
|
+
getServices() {
|
|
87
|
+
return [
|
|
88
|
+
this.informationService,
|
|
89
|
+
this.motionService,
|
|
90
|
+
];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.SolaxMotionAccessory = SolaxMotionAccessory;
|
|
94
94
|
//# sourceMappingURL=motionAccessory.js.map
|