homebridge-solaxcloud-api 2.3.3 → 2.4.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/CHANGELOG.md +140 -131
- package/LICENSE +175 -175
- package/config.sample +15 -15
- package/config.schema.json +105 -105
- 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 +100 -100
- package/dist/outletAccessory.js +187 -187
- package/dist/platform.d.ts +62 -56
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +294 -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/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,71 +1,71 @@
|
|
|
1
|
-
import { Service, AccessoryPlugin, Logging, API } from 'homebridge';
|
|
2
|
-
/**
|
|
3
|
-
* Solax Cloud generic platform accessory.
|
|
4
|
-
* Handles basic info: accessory name, manufacturer (Solax), inverter model and serial number.
|
|
5
|
-
*/
|
|
6
|
-
export declare class SolaxPlatformAccessory implements AccessoryPlugin {
|
|
7
|
-
/**
|
|
8
|
-
* Accessory logging.
|
|
9
|
-
*/
|
|
10
|
-
protected readonly log: Logging;
|
|
11
|
-
/**
|
|
12
|
-
* Platform API.
|
|
13
|
-
*/
|
|
14
|
-
protected readonly api: API;
|
|
15
|
-
/**
|
|
16
|
-
* Accessory name.
|
|
17
|
-
*/
|
|
18
|
-
protected readonly name: string;
|
|
19
|
-
/**
|
|
20
|
-
* Acessory display name.
|
|
21
|
-
*/
|
|
22
|
-
protected readonly displayName: string;
|
|
23
|
-
/**
|
|
24
|
-
* Real-world accessory serial number.
|
|
25
|
-
*/
|
|
26
|
-
protected trueSerialNumber: string;
|
|
27
|
-
/**
|
|
28
|
-
* Accessory serial number (string from 64 bit hash)
|
|
29
|
-
*/
|
|
30
|
-
protected serialNumber: string;
|
|
31
|
-
/**
|
|
32
|
-
* Accessory model.
|
|
33
|
-
*/
|
|
34
|
-
protected model: string;
|
|
35
|
-
/**
|
|
36
|
-
* Accessory HomeKit information service.
|
|
37
|
-
*/
|
|
38
|
-
protected readonly informationService: Service;
|
|
39
|
-
/**
|
|
40
|
-
* Virtual accessory main class constructor.
|
|
41
|
-
* @param {Logging} log The platform logging for homebridge.
|
|
42
|
-
* @param {API} api The API for Solax Cloud platform.
|
|
43
|
-
* @param {string} name The accessory name.
|
|
44
|
-
* @param {string} serial "Real-world" serial number for this accessory.
|
|
45
|
-
* @param {string} model Accessory model.
|
|
46
|
-
*/
|
|
47
|
-
constructor(log: Logging, api: API, name: string, serialNumber: string, model: string);
|
|
48
|
-
/**
|
|
49
|
-
* Handle requests to get the current value of the "Model" characteristic.
|
|
50
|
-
* @returns {string} The model.
|
|
51
|
-
*/
|
|
52
|
-
getModel(): string;
|
|
53
|
-
/**
|
|
54
|
-
* Sets the model string for Model characteristic.
|
|
55
|
-
* @param {string} model Model to set.
|
|
56
|
-
*/
|
|
57
|
-
setModel(model: string): void;
|
|
58
|
-
/**
|
|
59
|
-
* Handle requests to get the current value of the "SerialNumber" characteristic.
|
|
60
|
-
* @returns {string} The inverter serial number.
|
|
61
|
-
*/
|
|
62
|
-
getSerial(): string;
|
|
63
|
-
/**
|
|
64
|
-
* Sets model serial information for this outlet.
|
|
65
|
-
* @param {string} serial Serial number to set.
|
|
66
|
-
*/
|
|
67
|
-
setSerial(serial: string): void;
|
|
68
|
-
identify(): void;
|
|
69
|
-
getServices(): Service[];
|
|
70
|
-
}
|
|
1
|
+
import { Service, AccessoryPlugin, Logging, API } from 'homebridge';
|
|
2
|
+
/**
|
|
3
|
+
* Solax Cloud generic platform accessory.
|
|
4
|
+
* Handles basic info: accessory name, manufacturer (Solax), inverter model and serial number.
|
|
5
|
+
*/
|
|
6
|
+
export declare class SolaxPlatformAccessory implements AccessoryPlugin {
|
|
7
|
+
/**
|
|
8
|
+
* Accessory logging.
|
|
9
|
+
*/
|
|
10
|
+
protected readonly log: Logging;
|
|
11
|
+
/**
|
|
12
|
+
* Platform API.
|
|
13
|
+
*/
|
|
14
|
+
protected readonly api: API;
|
|
15
|
+
/**
|
|
16
|
+
* Accessory name.
|
|
17
|
+
*/
|
|
18
|
+
protected readonly name: string;
|
|
19
|
+
/**
|
|
20
|
+
* Acessory display name.
|
|
21
|
+
*/
|
|
22
|
+
protected readonly displayName: string;
|
|
23
|
+
/**
|
|
24
|
+
* Real-world accessory serial number.
|
|
25
|
+
*/
|
|
26
|
+
protected trueSerialNumber: string;
|
|
27
|
+
/**
|
|
28
|
+
* Accessory serial number (string from 64 bit hash)
|
|
29
|
+
*/
|
|
30
|
+
protected serialNumber: string;
|
|
31
|
+
/**
|
|
32
|
+
* Accessory model.
|
|
33
|
+
*/
|
|
34
|
+
protected model: string;
|
|
35
|
+
/**
|
|
36
|
+
* Accessory HomeKit information service.
|
|
37
|
+
*/
|
|
38
|
+
protected readonly informationService: Service;
|
|
39
|
+
/**
|
|
40
|
+
* Virtual accessory main class constructor.
|
|
41
|
+
* @param {Logging} log The platform logging for homebridge.
|
|
42
|
+
* @param {API} api The API for Solax Cloud platform.
|
|
43
|
+
* @param {string} name The accessory name.
|
|
44
|
+
* @param {string} serial "Real-world" serial number for this accessory.
|
|
45
|
+
* @param {string} model Accessory model.
|
|
46
|
+
*/
|
|
47
|
+
constructor(log: Logging, api: API, name: string, serialNumber: string, model: string);
|
|
48
|
+
/**
|
|
49
|
+
* Handle requests to get the current value of the "Model" characteristic.
|
|
50
|
+
* @returns {string} The model.
|
|
51
|
+
*/
|
|
52
|
+
getModel(): string;
|
|
53
|
+
/**
|
|
54
|
+
* Sets the model string for Model characteristic.
|
|
55
|
+
* @param {string} model Model to set.
|
|
56
|
+
*/
|
|
57
|
+
setModel(model: string): void;
|
|
58
|
+
/**
|
|
59
|
+
* Handle requests to get the current value of the "SerialNumber" characteristic.
|
|
60
|
+
* @returns {string} The inverter serial number.
|
|
61
|
+
*/
|
|
62
|
+
getSerial(): string;
|
|
63
|
+
/**
|
|
64
|
+
* Sets model serial information for this outlet.
|
|
65
|
+
* @param {string} serial Serial number to set.
|
|
66
|
+
*/
|
|
67
|
+
setSerial(serial: string): void;
|
|
68
|
+
identify(): void;
|
|
69
|
+
getServices(): Service[];
|
|
70
|
+
}
|
|
71
71
|
//# sourceMappingURL=platformAccessory.d.ts.map
|
|
@@ -1,103 +1,103 @@
|
|
|
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.SolaxPlatformAccessory = void 0;
|
|
7
|
-
const util_1 = require("./util");
|
|
8
|
-
const os_1 = __importDefault(require("os"));
|
|
9
|
-
const string_hash_64_1 = __importDefault(require("string-hash-64"));
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
11
|
-
const plugin = require('../package.json');
|
|
12
|
-
/**
|
|
13
|
-
* Solax Cloud generic platform accessory.
|
|
14
|
-
* Handles basic info: accessory name, manufacturer (Solax), inverter model and serial number.
|
|
15
|
-
*/
|
|
16
|
-
class SolaxPlatformAccessory {
|
|
17
|
-
/**
|
|
18
|
-
* Virtual accessory main class constructor.
|
|
19
|
-
* @param {Logging} log The platform logging for homebridge.
|
|
20
|
-
* @param {API} api The API for Solax Cloud platform.
|
|
21
|
-
* @param {string} name The accessory name.
|
|
22
|
-
* @param {string} serial "Real-world" serial number for this accessory.
|
|
23
|
-
* @param {string} model Accessory model.
|
|
24
|
-
*/
|
|
25
|
-
constructor(log, api, name, serialNumber, model) {
|
|
26
|
-
/**
|
|
27
|
-
* Accessory model.
|
|
28
|
-
*/
|
|
29
|
-
this.model = 'Solax inverter';
|
|
30
|
-
this.api = api;
|
|
31
|
-
this.log = log;
|
|
32
|
-
// name
|
|
33
|
-
this.name = name;
|
|
34
|
-
// display name
|
|
35
|
-
this.displayName = name;
|
|
36
|
-
// serial
|
|
37
|
-
this.trueSerialNumber = serialNumber;
|
|
38
|
-
// hash "real-world" serial and hostname to 64 bit hex string
|
|
39
|
-
this.serialNumber = (0, string_hash_64_1.default)(`${serialNumber}-${os_1.default.hostname()}`).toString(16);
|
|
40
|
-
// remove non-standard chars from model name
|
|
41
|
-
this.model = util_1.Util.normalizeName(model);
|
|
42
|
-
// information service
|
|
43
|
-
this.informationService =
|
|
44
|
-
new this.api.hap.Service.AccessoryInformation()
|
|
45
|
-
.setCharacteristic(this.api.hap.Characteristic.Name, this.name)
|
|
46
|
-
.setCharacteristic(this.api.hap.Characteristic.Manufacturer, 'Solax')
|
|
47
|
-
.setCharacteristic(this.api.hap.Characteristic.FirmwareRevision, plugin.version)
|
|
48
|
-
.setCharacteristic(this.api.hap.Characteristic.SerialNumber, this.serialNumber)
|
|
49
|
-
.setCharacteristic(this.api.hap.Characteristic.Model, this.model);
|
|
50
|
-
this.informationService.getCharacteristic(this.api.hap.Characteristic.SerialNumber).onGet(this.getSerial.bind(this));
|
|
51
|
-
this.informationService.getCharacteristic(this.api.hap.Characteristic.Model).onGet(this.getModel.bind(this));
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Handle requests to get the current value of the "Model" characteristic.
|
|
55
|
-
* @returns {string} The model.
|
|
56
|
-
*/
|
|
57
|
-
getModel() {
|
|
58
|
-
this.log.debug(`${this.name}: GET Model (model=${this.model})`);
|
|
59
|
-
return this.model;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Sets the model string for Model characteristic.
|
|
63
|
-
* @param {string} model Model to set.
|
|
64
|
-
*/
|
|
65
|
-
setModel(model) {
|
|
66
|
-
this.log.debug(`${this.name}: SET Model (model=${model})`);
|
|
67
|
-
this.model = model;
|
|
68
|
-
this.informationService.setCharacteristic(this.api.hap.Characteristic.Model, model);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Handle requests to get the current value of the "SerialNumber" characteristic.
|
|
72
|
-
* @returns {string} The inverter serial number.
|
|
73
|
-
*/
|
|
74
|
-
getSerial() {
|
|
75
|
-
this.log.debug(`${this.name}: GET Serial (serial=${this.serialNumber})`);
|
|
76
|
-
return this.serialNumber;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Sets model serial information for this outlet.
|
|
80
|
-
* @param {string} serial Serial number to set.
|
|
81
|
-
*/
|
|
82
|
-
setSerial(serial) {
|
|
83
|
-
this.log.debug(`${this.name}: SET Serial (serial=${serial})`);
|
|
84
|
-
this.serialNumber = serial;
|
|
85
|
-
this.informationService.setCharacteristic(this.api.hap.Characteristic.SerialNumber, serial);
|
|
86
|
-
}
|
|
87
|
-
/*
|
|
88
|
-
* This method is optional to implement. It is called when HomeKit ask to identify the accessory.
|
|
89
|
-
* Typical this only ever happens at the pairing process.
|
|
90
|
-
*/
|
|
91
|
-
identify() {
|
|
92
|
-
this.log.info(`${this.name}: Identify (true serial=${this.trueSerialNumber}, serial=${this.serialNumber})`);
|
|
93
|
-
}
|
|
94
|
-
/*
|
|
95
|
-
* This method is called directly after creation of this instance.
|
|
96
|
-
* It should return all services which should be added to the accessory.
|
|
97
|
-
*/
|
|
98
|
-
getServices() {
|
|
99
|
-
return [this.informationService];
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
exports.SolaxPlatformAccessory = SolaxPlatformAccessory;
|
|
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.SolaxPlatformAccessory = void 0;
|
|
7
|
+
const util_1 = require("./util");
|
|
8
|
+
const os_1 = __importDefault(require("os"));
|
|
9
|
+
const string_hash_64_1 = __importDefault(require("string-hash-64"));
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
11
|
+
const plugin = require('../package.json');
|
|
12
|
+
/**
|
|
13
|
+
* Solax Cloud generic platform accessory.
|
|
14
|
+
* Handles basic info: accessory name, manufacturer (Solax), inverter model and serial number.
|
|
15
|
+
*/
|
|
16
|
+
class SolaxPlatformAccessory {
|
|
17
|
+
/**
|
|
18
|
+
* Virtual accessory main class constructor.
|
|
19
|
+
* @param {Logging} log The platform logging for homebridge.
|
|
20
|
+
* @param {API} api The API for Solax Cloud platform.
|
|
21
|
+
* @param {string} name The accessory name.
|
|
22
|
+
* @param {string} serial "Real-world" serial number for this accessory.
|
|
23
|
+
* @param {string} model Accessory model.
|
|
24
|
+
*/
|
|
25
|
+
constructor(log, api, name, serialNumber, model) {
|
|
26
|
+
/**
|
|
27
|
+
* Accessory model.
|
|
28
|
+
*/
|
|
29
|
+
this.model = 'Solax inverter';
|
|
30
|
+
this.api = api;
|
|
31
|
+
this.log = log;
|
|
32
|
+
// name
|
|
33
|
+
this.name = name;
|
|
34
|
+
// display name
|
|
35
|
+
this.displayName = name;
|
|
36
|
+
// serial
|
|
37
|
+
this.trueSerialNumber = serialNumber;
|
|
38
|
+
// hash "real-world" serial and hostname to 64 bit hex string
|
|
39
|
+
this.serialNumber = (0, string_hash_64_1.default)(`${serialNumber}-${os_1.default.hostname()}`).toString(16);
|
|
40
|
+
// remove non-standard chars from model name
|
|
41
|
+
this.model = util_1.Util.normalizeName(model);
|
|
42
|
+
// information service
|
|
43
|
+
this.informationService =
|
|
44
|
+
new this.api.hap.Service.AccessoryInformation()
|
|
45
|
+
.setCharacteristic(this.api.hap.Characteristic.Name, this.name)
|
|
46
|
+
.setCharacteristic(this.api.hap.Characteristic.Manufacturer, 'Solax')
|
|
47
|
+
.setCharacteristic(this.api.hap.Characteristic.FirmwareRevision, plugin.version)
|
|
48
|
+
.setCharacteristic(this.api.hap.Characteristic.SerialNumber, this.serialNumber)
|
|
49
|
+
.setCharacteristic(this.api.hap.Characteristic.Model, this.model);
|
|
50
|
+
this.informationService.getCharacteristic(this.api.hap.Characteristic.SerialNumber).onGet(this.getSerial.bind(this));
|
|
51
|
+
this.informationService.getCharacteristic(this.api.hap.Characteristic.Model).onGet(this.getModel.bind(this));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Handle requests to get the current value of the "Model" characteristic.
|
|
55
|
+
* @returns {string} The model.
|
|
56
|
+
*/
|
|
57
|
+
getModel() {
|
|
58
|
+
this.log.debug(`${this.name}: GET Model (model=${this.model})`);
|
|
59
|
+
return this.model;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Sets the model string for Model characteristic.
|
|
63
|
+
* @param {string} model Model to set.
|
|
64
|
+
*/
|
|
65
|
+
setModel(model) {
|
|
66
|
+
this.log.debug(`${this.name}: SET Model (model=${model})`);
|
|
67
|
+
this.model = model;
|
|
68
|
+
this.informationService.setCharacteristic(this.api.hap.Characteristic.Model, model);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Handle requests to get the current value of the "SerialNumber" characteristic.
|
|
72
|
+
* @returns {string} The inverter serial number.
|
|
73
|
+
*/
|
|
74
|
+
getSerial() {
|
|
75
|
+
this.log.debug(`${this.name}: GET Serial (serial=${this.serialNumber})`);
|
|
76
|
+
return this.serialNumber;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Sets model serial information for this outlet.
|
|
80
|
+
* @param {string} serial Serial number to set.
|
|
81
|
+
*/
|
|
82
|
+
setSerial(serial) {
|
|
83
|
+
this.log.debug(`${this.name}: SET Serial (serial=${serial})`);
|
|
84
|
+
this.serialNumber = serial;
|
|
85
|
+
this.informationService.setCharacteristic(this.api.hap.Characteristic.SerialNumber, serial);
|
|
86
|
+
}
|
|
87
|
+
/*
|
|
88
|
+
* This method is optional to implement. It is called when HomeKit ask to identify the accessory.
|
|
89
|
+
* Typical this only ever happens at the pairing process.
|
|
90
|
+
*/
|
|
91
|
+
identify() {
|
|
92
|
+
this.log.info(`${this.name}: Identify (true serial=${this.trueSerialNumber}, serial=${this.serialNumber})`);
|
|
93
|
+
}
|
|
94
|
+
/*
|
|
95
|
+
* This method is called directly after creation of this instance.
|
|
96
|
+
* It should return all services which should be added to the accessory.
|
|
97
|
+
*/
|
|
98
|
+
getServices() {
|
|
99
|
+
return [this.informationService];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.SolaxPlatformAccessory = SolaxPlatformAccessory;
|
|
103
103
|
//# sourceMappingURL=platformAccessory.js.map
|