@pietrolubini/homebridge-ecoflow 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/.prettierrc.json +11 -0
- package/LICENSE +21 -0
- package/README.md +92 -0
- package/config.schema.json +49 -0
- package/dist/accessories/apis/ecoFlowHttpApi.d.ts +15 -0
- package/dist/accessories/apis/ecoFlowHttpApi.js +115 -0
- package/dist/accessories/apis/ecoFlowHttpApi.js.map +1 -0
- package/dist/accessories/apis/ecoFlowMqttApi.d.ts +23 -0
- package/dist/accessories/apis/ecoFlowMqttApi.js +86 -0
- package/dist/accessories/apis/ecoFlowMqttApi.js.map +1 -0
- package/dist/accessories/apis/interfaces/ecoFlowHttpContacts.d.ts +46 -0
- package/dist/accessories/apis/interfaces/ecoFlowHttpContacts.js +6 -0
- package/dist/accessories/apis/interfaces/ecoFlowHttpContacts.js.map +1 -0
- package/dist/accessories/apis/interfaces/ecoFlowMqttContacts.d.ts +68 -0
- package/dist/accessories/apis/interfaces/ecoFlowMqttContacts.js +9 -0
- package/dist/accessories/apis/interfaces/ecoFlowMqttContacts.js.map +1 -0
- package/dist/accessories/delta2maxAccessory.d.ts +27 -0
- package/dist/accessories/delta2maxAccessory.js +123 -0
- package/dist/accessories/delta2maxAccessory.js.map +1 -0
- package/dist/accessories/ecoFlowAccessory.d.ts +34 -0
- package/dist/accessories/ecoFlowAccessory.js +83 -0
- package/dist/accessories/ecoFlowAccessory.js.map +1 -0
- package/dist/accessories/services/accessoryInformationService.d.ts +6 -0
- package/dist/accessories/services/accessoryInformationService.js +24 -0
- package/dist/accessories/services/accessoryInformationService.js.map +1 -0
- package/dist/accessories/services/batteryService.d.ts +8 -0
- package/dist/accessories/services/batteryService.js +29 -0
- package/dist/accessories/services/batteryService.js.map +1 -0
- package/dist/accessories/services/outletAcService.d.ts +6 -0
- package/dist/accessories/services/outletAcService.js +15 -0
- package/dist/accessories/services/outletAcService.js.map +1 -0
- package/dist/accessories/services/outletCarService.d.ts +6 -0
- package/dist/accessories/services/outletCarService.js +10 -0
- package/dist/accessories/services/outletCarService.js.map +1 -0
- package/dist/accessories/services/outletServiceBase.d.ts +15 -0
- package/dist/accessories/services/outletServiceBase.js +44 -0
- package/dist/accessories/services/outletServiceBase.js.map +1 -0
- package/dist/accessories/services/outletUsbService.d.ts +6 -0
- package/dist/accessories/services/outletUsbService.js +10 -0
- package/dist/accessories/services/outletUsbService.js.map +1 -0
- package/dist/accessories/services/serviceBase.d.ts +11 -0
- package/dist/accessories/services/serviceBase.js +20 -0
- package/dist/accessories/services/serviceBase.js.map +1 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.js +5 -0
- package/dist/config.js.map +1 -0
- package/dist/helpers/machineId.d.ts +2 -0
- package/dist/helpers/machineId.js +15 -0
- package/dist/helpers/machineId.js.map +1 -0
- package/dist/helpers/machineIdHelper.cjs +5 -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 +26 -0
- package/dist/platform.js +96 -0
- package/dist/platform.js.map +1 -0
- package/dist/settings.d.ts +8 -0
- package/dist/settings.js +9 -0
- package/dist/settings.js.map +1 -0
- package/package.json +55 -0
package/.prettierrc.json
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 PietroLubini
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<span align="center">
|
|
2
|
+
|
|
3
|
+
# homebridge-ecoflow
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@pietrolubini/homebridge-ecoflow)
|
|
6
|
+
[](https://github.com/pietrolubini/homebridge-ecoflow/blob/main/LICENSE)
|
|
7
|
+
|
|
8
|
+
</span>
|
|
9
|
+
|
|
10
|
+
`homebridge-ecoflow` is a plugin for homebridge which allows you to control EcoFlow devices!
|
|
11
|
+
The goal is to add HomeKit support to EcoFlow devices and make them fully controllable from the native HomeKit iOS app and Siri.
|
|
12
|
+
|
|
13
|
+
> Feedback and contribution is helpful and will improve the plugin!
|
|
14
|
+
|
|
15
|
+
> If your device is not supported please create a request and specify the device model and type. Additional collaboration may be required to perform testing of new device.
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- Integrates EcoFlow devices into HomeKit
|
|
20
|
+
- Fully customizable HomeKit accessories
|
|
21
|
+
- HomeKit automations for your EcoFlow devices
|
|
22
|
+
|
|
23
|
+
## Supported device types
|
|
24
|
+
|
|
25
|
+
- Delta 2 Max
|
|
26
|
+
|
|
27
|
+
For a full list of devices that could be potentially added check [here](https://developer-eu.ecoflow.com/us/document/introduction)
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
If you are new to homebridge, please first read the homebridge [documentation](https://github.com/homebridge/homebridge#readme). If you are running on a Raspberry, you will find a tutorial in the [homebridge wiki](https://github.com/homebridge/homebridge/wiki/Install-Homebridge-on-Raspbian).
|
|
32
|
+
|
|
33
|
+
Install homebridge-ecoflow:
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
sudo npm install -g @pietrolubini/homebridge-ecoflow
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Configuration
|
|
40
|
+
|
|
41
|
+
Add the `EcoFlowHomebridge` platform in `config.json` in your home directory inside `.homebridge`.
|
|
42
|
+
|
|
43
|
+
Add your devices in the `devices` array.
|
|
44
|
+
|
|
45
|
+
Example configuration:
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
{
|
|
49
|
+
"platforms": [
|
|
50
|
+
{
|
|
51
|
+
"devices": [
|
|
52
|
+
{
|
|
53
|
+
"name": "Battery",
|
|
54
|
+
"model": "Delta 2 Max",
|
|
55
|
+
"serialNumber": "R123ABCDEGHI321",
|
|
56
|
+
"accessKey": "IROcwtlejtHj4qY4MRgCZW0CxoCdPVs3",
|
|
57
|
+
"secretKey": "yBwYgZWqNnAlULKmF1Qrydy2Iheexj22"
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
"platform": "EcoFlowHomebridge",
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### AccessKey and SecretKey
|
|
67
|
+
|
|
68
|
+
For the plugin to work EcoFlow account's `AccessKey` and `SecretKey` is required. To retrieve them
|
|
69
|
+
|
|
70
|
+
- Register on [EcoFlow IoT Developer Platform](https://developer-eu.ecoflow.com/)
|
|
71
|
+
- Wait until your request will be approved
|
|
72
|
+
- Generate `AccessKey`/`SecretKey` pair [here](https://developer-eu.ecoflow.com/us/security)
|
|
73
|
+
|
|
74
|
+
## Troubleshooting
|
|
75
|
+
|
|
76
|
+
### Debug
|
|
77
|
+
|
|
78
|
+
If you have any issues with the plugin or device services then you can run homebridge in debug mode, which will provide some additional information. This might be useful for debugging issues.
|
|
79
|
+
|
|
80
|
+
Homebridge debug mode:
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
homebridge -D
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Deep debug log, add the following to your config.json:
|
|
87
|
+
|
|
88
|
+
```json
|
|
89
|
+
"deepDebugLog": true
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
This will enable additional extra log which might be helpful to debug all kind of issues.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pluginAlias": "EcoFlowHomebridge",
|
|
3
|
+
"pluginType": "platform",
|
|
4
|
+
"singular": true,
|
|
5
|
+
"schema": {
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"devices": {
|
|
9
|
+
"type": "array",
|
|
10
|
+
"uniqueItems": true,
|
|
11
|
+
"items": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"properties": {
|
|
14
|
+
"name": {
|
|
15
|
+
"title": "Name",
|
|
16
|
+
"type": "string",
|
|
17
|
+
"required": true,
|
|
18
|
+
"description": "Name of the EcoFlow device"
|
|
19
|
+
},
|
|
20
|
+
"model": {
|
|
21
|
+
"title": "Model",
|
|
22
|
+
"type": "string",
|
|
23
|
+
"required": true,
|
|
24
|
+
"enum": ["Delta 2 Max"]
|
|
25
|
+
},
|
|
26
|
+
"serialNumber": {
|
|
27
|
+
"title": "Serial Number",
|
|
28
|
+
"type": "string",
|
|
29
|
+
"required": true,
|
|
30
|
+
"description": "Serial number of the EcoFlow device"
|
|
31
|
+
},
|
|
32
|
+
"accessKey": {
|
|
33
|
+
"title": "Access Key",
|
|
34
|
+
"type": "string",
|
|
35
|
+
"required": true,
|
|
36
|
+
"description": "Access Key from \"EcoFlow IoT Developer Platform\" (https://developer-eu.ecoflow.com)"
|
|
37
|
+
},
|
|
38
|
+
"secretKey": {
|
|
39
|
+
"title": "Secret Key",
|
|
40
|
+
"type": "string",
|
|
41
|
+
"required": true,
|
|
42
|
+
"description": "Secret Key from \"EcoFlow IoT Developer Platform\" (https://developer-eu.ecoflow.com)"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Logging } from 'homebridge';
|
|
2
|
+
import { AcquireCertificateResponseData, CmdResponseBase, CmdResponseData, HttpMethod } from './interfaces/ecoFlowHttpContacts.js';
|
|
3
|
+
import { DeviceConfig } from '../../config.js';
|
|
4
|
+
export declare class EcoFlowHttpApi {
|
|
5
|
+
private config;
|
|
6
|
+
private log;
|
|
7
|
+
constructor(config: DeviceConfig, log: Logging);
|
|
8
|
+
getQuotas<TCmdResponseData extends CmdResponseData>(quotas: string[]): Promise<TCmdResponseData>;
|
|
9
|
+
getAllQuotas<TCmdResponseData extends CmdResponseData>(): Promise<TCmdResponseData>;
|
|
10
|
+
acquireCertificate(): Promise<AcquireCertificateResponseData>;
|
|
11
|
+
protected execute<TResponse extends CmdResponseBase>(relativeUrl: string, method: HttpMethod, queryParameters?: object | null, body?: object | null): Promise<TResponse>;
|
|
12
|
+
private getNonce;
|
|
13
|
+
private composeSignMessage;
|
|
14
|
+
private createHmacSha256;
|
|
15
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import * as crypto from 'crypto';
|
|
2
|
+
import { HttpMethod, } from './interfaces/ecoFlowHttpContacts.js';
|
|
3
|
+
const ApiUrl = 'https://api-e.ecoflow.com';
|
|
4
|
+
const QuotaPath = '/iot-open/sign/device/quota';
|
|
5
|
+
const QuotaAllPath = '/iot-open/sign/device/quota/all';
|
|
6
|
+
const CertificatePath = '/iot-open/sign/certification';
|
|
7
|
+
export class EcoFlowHttpApi {
|
|
8
|
+
config;
|
|
9
|
+
log;
|
|
10
|
+
constructor(config, log) {
|
|
11
|
+
this.config = config;
|
|
12
|
+
this.log = log;
|
|
13
|
+
}
|
|
14
|
+
async getQuotas(quotas) {
|
|
15
|
+
this.log.debug('Get quotas:', quotas);
|
|
16
|
+
const requestCmd = {
|
|
17
|
+
sn: this.config.serialNumber,
|
|
18
|
+
params: {
|
|
19
|
+
quotas,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
const response = await this.execute(QuotaPath, HttpMethod.Post, requestCmd);
|
|
23
|
+
const data = response.data;
|
|
24
|
+
this.log.debug('Quotas:', data);
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
async getAllQuotas() {
|
|
28
|
+
this.log.debug('Get all quotas');
|
|
29
|
+
const requestCmd = {
|
|
30
|
+
sn: this.config.serialNumber,
|
|
31
|
+
};
|
|
32
|
+
const response = await this.execute(QuotaAllPath, HttpMethod.Get, requestCmd);
|
|
33
|
+
const data = response.data;
|
|
34
|
+
this.log.debug('All quotas:', data);
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
async acquireCertificate() {
|
|
38
|
+
this.log.debug('Acquire certificate for MQTT connection');
|
|
39
|
+
const response = await this.execute(CertificatePath, HttpMethod.Get);
|
|
40
|
+
this.log.debug('Certificate data:', response.data);
|
|
41
|
+
return response.data;
|
|
42
|
+
}
|
|
43
|
+
async execute(relativeUrl, method, queryParameters = null, body = null) {
|
|
44
|
+
const url = new URL(relativeUrl, ApiUrl);
|
|
45
|
+
const accessKey = this.config.accessKey;
|
|
46
|
+
const nonce = this.getNonce();
|
|
47
|
+
const timestamp = Date.now();
|
|
48
|
+
const queryParams = this.composeSignMessage(queryParameters);
|
|
49
|
+
let params = queryParams ? `${queryParams}&` : '';
|
|
50
|
+
const bodyParamsMessage = this.composeSignMessage(body);
|
|
51
|
+
params = bodyParamsMessage ? `${params}${bodyParamsMessage}&` : params;
|
|
52
|
+
const message = `${params}accessKey=${accessKey}&nonce=${nonce}×tamp=${timestamp}`;
|
|
53
|
+
const requestUrl = queryParams ? `${url}?${queryParams}` : url;
|
|
54
|
+
const headers = {
|
|
55
|
+
accessKey,
|
|
56
|
+
nonce,
|
|
57
|
+
timestamp: timestamp.toString(),
|
|
58
|
+
sign: this.createHmacSha256(this.config.secretKey, message),
|
|
59
|
+
};
|
|
60
|
+
const options = { method };
|
|
61
|
+
if (body) {
|
|
62
|
+
options.body = JSON.stringify(body);
|
|
63
|
+
headers['Content-Type'] = 'application/json';
|
|
64
|
+
}
|
|
65
|
+
options.headers = new Headers(headers);
|
|
66
|
+
try {
|
|
67
|
+
const response = await fetch(requestUrl, options);
|
|
68
|
+
const result = (await response.json());
|
|
69
|
+
if (result.code !== '0') {
|
|
70
|
+
throw Error(`Request '${url}' is failed [${response.status}]: ${response.statusText}; result: ${JSON.stringify(result)}`);
|
|
71
|
+
}
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
this.log.error('Request is failed:', e);
|
|
76
|
+
throw e;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
getNonce() {
|
|
80
|
+
const min = 0;
|
|
81
|
+
const max = 999999;
|
|
82
|
+
const randomNumber = Math.floor(Math.random() * (max - min + 1)) + min;
|
|
83
|
+
return randomNumber.toString().padStart(6, '0');
|
|
84
|
+
}
|
|
85
|
+
composeSignMessage(obj, prefix = '') {
|
|
86
|
+
if (!obj) {
|
|
87
|
+
return '';
|
|
88
|
+
}
|
|
89
|
+
const queryParts = [];
|
|
90
|
+
Object.keys(obj)
|
|
91
|
+
.sort()
|
|
92
|
+
.forEach(key => {
|
|
93
|
+
const value = obj[key];
|
|
94
|
+
const encodedKey = prefix ? `${prefix}.${key}` : key;
|
|
95
|
+
if (Array.isArray(value)) {
|
|
96
|
+
value.forEach((item, index) => {
|
|
97
|
+
queryParts.push(`${encodedKey}[${index}]=${item}`);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
else if (typeof value === 'object' && value !== null) {
|
|
101
|
+
// Recursively handle nested objects
|
|
102
|
+
queryParts.push(this.composeSignMessage(value, encodedKey));
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
// Handle primitive values
|
|
106
|
+
queryParts.push(`${encodedKey}=${value}`);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
return queryParts.join('&');
|
|
110
|
+
}
|
|
111
|
+
createHmacSha256(key, message) {
|
|
112
|
+
return crypto.createHmac('sha256', key).update(message).digest('hex');
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=ecoFlowHttpApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecoFlowHttpApi.js","sourceRoot":"","sources":["../../../src/accessories/apis/ecoFlowHttpApi.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAOL,UAAU,GACX,MAAM,qCAAqC,CAAC;AAG7C,MAAM,MAAM,GAAG,2BAA2B,CAAC;AAC3C,MAAM,SAAS,GAAG,6BAA6B,CAAC;AAChD,MAAM,YAAY,GAAG,iCAAiC,CAAC;AACvD,MAAM,eAAe,GAAG,8BAA8B,CAAC;AAEvD,MAAM,OAAO,cAAc;IACL;IAA8B;IAAlD,YAAoB,MAAoB,EAAU,GAAY;QAA1C,WAAM,GAAN,MAAM,CAAc;QAAU,QAAG,GAAH,GAAG,CAAS;IAAG,CAAC;IAE3D,KAAK,CAAC,SAAS,CAA2C,MAAgB;QAC/E,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QACtC,MAAM,UAAU,GAAwB;YACtC,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,YAAY;YAC5B,MAAM,EAAE;gBACN,MAAM;aACP;SACF,CAAC;QACF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAgC,SAAS,EA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K,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;oBAC5B,UAAU,CAAC,IAAI,CAAC,GAAG,UAAU,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC,CAAC;gBACrD,CAAC,CAAC,CAAC;YACL,CAAC;iBAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBACvD,oCAAoC;gBACpC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;YAC9D,CAAC;iBAAM,CAAC;gBACN,0BAA0B;gBAC1B,UAAU,CAAC,IAAI,CAAC,GAAG,UAAU,IAAI,KAAK,EAAE,CAAC,CAAC;YAC5C,CAAC;QACH,CAAC,CAAC,CAAC;QAEL,OAAO,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;IAEO,gBAAgB,CAAC,GAAW,EAAE,OAAe;QACnD,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACxE,CAAC;CACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Logging } from 'homebridge';
|
|
2
|
+
import { BmsStatusMqttMessageParams, InvStatusMqttMessageParams, MqttMessage, MqttMessageParams, MqttSetMessageBase, PdStatusMqttMessageParams } from './interfaces/ecoFlowMqttContacts.js';
|
|
3
|
+
import { EcoFlowHttpApi } from './ecoFlowHttpApi.js';
|
|
4
|
+
export declare class EcoFlowMqttApi {
|
|
5
|
+
private httpApi;
|
|
6
|
+
private log;
|
|
7
|
+
private client;
|
|
8
|
+
private certificateData;
|
|
9
|
+
private readonly bmsParamsSubject;
|
|
10
|
+
private readonly invParamsSubject;
|
|
11
|
+
private readonly pdParamsSubject;
|
|
12
|
+
bmsParams$: import("rxjs").Observable<BmsStatusMqttMessageParams>;
|
|
13
|
+
invParams$: import("rxjs").Observable<InvStatusMqttMessageParams>;
|
|
14
|
+
pdParams$: import("rxjs").Observable<PdStatusMqttMessageParams>;
|
|
15
|
+
constructor(httpApi: EcoFlowHttpApi, log: Logging);
|
|
16
|
+
destroy(): Promise<void>;
|
|
17
|
+
subscribe(topicPattern: string, serialNumber: string): Promise<void>;
|
|
18
|
+
publish(topicPattern: string, serialNumber: string, data: MqttSetMessageBase): Promise<void>;
|
|
19
|
+
processMqttMessage(message: MqttMessage<MqttMessageParams>): void;
|
|
20
|
+
private connect;
|
|
21
|
+
private acquireCertificate;
|
|
22
|
+
private composeTopic;
|
|
23
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import mqtt from 'mqtt';
|
|
2
|
+
import { MqttMessageType, } from './interfaces/ecoFlowMqttContacts.js';
|
|
3
|
+
import { Subject } from 'rxjs';
|
|
4
|
+
import { getMachineId } from './../../helpers/machineId.js';
|
|
5
|
+
export class EcoFlowMqttApi {
|
|
6
|
+
httpApi;
|
|
7
|
+
log;
|
|
8
|
+
client = null;
|
|
9
|
+
certificateData = null;
|
|
10
|
+
bmsParamsSubject = new Subject();
|
|
11
|
+
invParamsSubject = new Subject();
|
|
12
|
+
pdParamsSubject = new Subject();
|
|
13
|
+
bmsParams$ = this.bmsParamsSubject.asObservable();
|
|
14
|
+
invParams$ = this.invParamsSubject.asObservable();
|
|
15
|
+
pdParams$ = this.pdParamsSubject.asObservable();
|
|
16
|
+
constructor(httpApi, log) {
|
|
17
|
+
this.httpApi = httpApi;
|
|
18
|
+
this.log = log;
|
|
19
|
+
}
|
|
20
|
+
async destroy() {
|
|
21
|
+
await this.client?.unsubscribeAsync('#');
|
|
22
|
+
this.log.debug('Unsubscribed from all topics');
|
|
23
|
+
await this.client?.end();
|
|
24
|
+
this.log.info('Disconnected from EcoFlow MQTT Service');
|
|
25
|
+
}
|
|
26
|
+
async subscribe(topicPattern, serialNumber) {
|
|
27
|
+
const client = await this.connect();
|
|
28
|
+
const topic = this.composeTopic(topicPattern, serialNumber);
|
|
29
|
+
await client.subscribeAsync(topic);
|
|
30
|
+
this.log.debug('Subscribed to topic:', topic);
|
|
31
|
+
client.on('message', (_, message) => {
|
|
32
|
+
const mqttMessage = JSON.parse(message.toString());
|
|
33
|
+
this.processMqttMessage(mqttMessage);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async publish(topicPattern, serialNumber, data) {
|
|
37
|
+
const client = await this.connect();
|
|
38
|
+
const topic = this.composeTopic(topicPattern, serialNumber);
|
|
39
|
+
const message = JSON.stringify(data);
|
|
40
|
+
await client.publishAsync(topic, message);
|
|
41
|
+
this.log.debug(`Published to topic '${topic}'`, message);
|
|
42
|
+
}
|
|
43
|
+
processMqttMessage(message) {
|
|
44
|
+
if (message.typeCode === MqttMessageType.BMS) {
|
|
45
|
+
const params = message.params;
|
|
46
|
+
this.log.debug('BMS:', params);
|
|
47
|
+
this.bmsParamsSubject.next(params);
|
|
48
|
+
}
|
|
49
|
+
else if (message.typeCode === MqttMessageType.INV) {
|
|
50
|
+
const params = message.params;
|
|
51
|
+
this.log.debug('INV:', params);
|
|
52
|
+
this.invParamsSubject.next(params);
|
|
53
|
+
}
|
|
54
|
+
else if (message.typeCode === MqttMessageType.PD) {
|
|
55
|
+
const params = message.params;
|
|
56
|
+
this.log.debug('PD:', params);
|
|
57
|
+
this.pdParamsSubject.next(params);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async connect() {
|
|
61
|
+
if (!this.client) {
|
|
62
|
+
const certificateData = await this.acquireCertificate();
|
|
63
|
+
const clientId = `HOMEBRIDGE_${(await getMachineId(this.log)).toUpperCase()}`;
|
|
64
|
+
this.client = await mqtt.connectAsync(`${certificateData.protocol}://${certificateData.url}:${certificateData.port}`, {
|
|
65
|
+
username: `${certificateData.certificateAccount}`,
|
|
66
|
+
password: `${certificateData.certificatePassword}`,
|
|
67
|
+
clientId,
|
|
68
|
+
protocolVersion: 5,
|
|
69
|
+
});
|
|
70
|
+
this.log.info('Connected to EcoFlow MQTT Service');
|
|
71
|
+
}
|
|
72
|
+
return this.client;
|
|
73
|
+
}
|
|
74
|
+
async acquireCertificate() {
|
|
75
|
+
if (!this.certificateData) {
|
|
76
|
+
this.certificateData = await this.httpApi.acquireCertificate();
|
|
77
|
+
}
|
|
78
|
+
return this.certificateData;
|
|
79
|
+
}
|
|
80
|
+
composeTopic(topicPattern, serialNumber) {
|
|
81
|
+
return topicPattern
|
|
82
|
+
.replace('<certificateAccount>', this.certificateData.certificateAccount)
|
|
83
|
+
.replace('<sn>', serialNumber);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=ecoFlowMqttApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecoFlowMqttApi.js","sourceRoot":"","sources":["../../../src/accessories/apis/ecoFlowMqttApi.ts"],"names":[],"mappings":"AAAA,OAAO,IAAoB,MAAM,MAAM,CAAC;AAExC,OAAO,EAKL,eAAe,GAGhB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAI5D,MAAM,OAAO,cAAc;IAUL;IAAiC;IAT7C,MAAM,GAAsB,IAAI,CAAC;IACjC,eAAe,GAA0C,IAAI,CAAC;IACrD,gBAAgB,GAAwC,IAAI,OAAO,EAA8B,CAAC;IAClG,gBAAgB,GAAwC,IAAI,OAAO,EAA8B,CAAC;IAClG,eAAe,GAAuC,IAAI,OAAO,EAA6B,CAAC;IACzG,UAAU,GAAG,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE,CAAC;IAClD,UAAU,GAAG,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE,CAAC;IAClD,SAAS,GAAG,IAAI,CAAC,eAAe,CAAC,YAAY,EAAE,CAAC;IAEvD,YAAoB,OAAuB,EAAU,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AC9E,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC,YAAY,CACnC,GAAG,eAAe,CAAC,QAAQ,MAAM,eAAe,CAAC,GAAG,IAAI,eAAe,CAAC,IAAI,EAAE,EAC9E;gBACE,QAAQ,EAAE,GAAG,eAAe,CAAC,kBAAkB,EAAE;gBACjD,QAAQ,EAAE,GAAG,eAAe,CAAC,mBAAmB,EAAE;gBAClD,QAAQ;gBACR,eAAe,EAAE,CAAC;aACnB,CACF,CAAC;YACF,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;QACrD,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAEO,KAAK,CAAC,kBAAkB;QAC9B,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YAC1B,IAAI,CAAC,eAAe,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC;QACjE,CAAC;QACD,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAEO,YAAY,CAAC,YAAoB,EAAE,YAAoB;QAC7D,OAAO,YAAY;aAChB,OAAO,CAAC,sBAAsB,EAAE,IAAI,CAAC,eAAgB,CAAC,kBAAkB,CAAC;aACzE,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACnC,CAAC;CACF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export declare enum HttpMethod {
|
|
2
|
+
Get = "GET",
|
|
3
|
+
Post = "POST"
|
|
4
|
+
}
|
|
5
|
+
export interface CmdResponseBase {
|
|
6
|
+
code: string;
|
|
7
|
+
message: string;
|
|
8
|
+
}
|
|
9
|
+
export interface CmdResponseData {
|
|
10
|
+
}
|
|
11
|
+
export interface CmdResponse<TData extends CmdResponseData> extends CmdResponseBase {
|
|
12
|
+
code: string;
|
|
13
|
+
message: string;
|
|
14
|
+
data: TData;
|
|
15
|
+
}
|
|
16
|
+
export interface GetCmdRequest {
|
|
17
|
+
sn: string;
|
|
18
|
+
}
|
|
19
|
+
export interface GetQuotasCmdRequest extends GetCmdRequest {
|
|
20
|
+
params: GetQuotasCmdRequestParams;
|
|
21
|
+
}
|
|
22
|
+
export interface GetQuotasCmdRequestParams {
|
|
23
|
+
quotas: string[];
|
|
24
|
+
}
|
|
25
|
+
export interface AcquireCertificateResponseData extends CmdResponseData {
|
|
26
|
+
certificateAccount: string;
|
|
27
|
+
certificatePassword: string;
|
|
28
|
+
url: string;
|
|
29
|
+
port: string;
|
|
30
|
+
protocol: string;
|
|
31
|
+
}
|
|
32
|
+
export interface GetQuotaAllCmdResponseData extends CmdResponseData {
|
|
33
|
+
'bms_bmsStatus.f32ShowSoc': number;
|
|
34
|
+
'inv.inputWatts': number;
|
|
35
|
+
'inv.cfgAcEnabled': boolean;
|
|
36
|
+
'inv.outputWatts': number;
|
|
37
|
+
'pd.carState': boolean;
|
|
38
|
+
'pd.carWatts': number;
|
|
39
|
+
'pd.dcOutState': boolean;
|
|
40
|
+
'pd.usb1Watts': number;
|
|
41
|
+
'pd.usb2Watts': number;
|
|
42
|
+
'pd.qcUsb1Watts': number;
|
|
43
|
+
'pd.qcUsb2Watts': number;
|
|
44
|
+
'pd.typec1Watts': number;
|
|
45
|
+
'pd.typec2Watts': number;
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecoFlowHttpContacts.js","sourceRoot":"","sources":["../../../../src/accessories/apis/interfaces/ecoFlowHttpContacts.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,yBAAW,CAAA;IACX,2BAAa,CAAA;AACf,CAAC,EAHW,UAAU,KAAV,UAAU,QAGrB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export declare enum MqttMessageType {
|
|
2
|
+
PD = "pdStatus",
|
|
3
|
+
MPPT = "mpptStatus",
|
|
4
|
+
INV = "invStatus",
|
|
5
|
+
BMS = "bmsStatus",
|
|
6
|
+
EMS = "emsStatus"
|
|
7
|
+
}
|
|
8
|
+
export interface MqttMessageBase {
|
|
9
|
+
typeCode: MqttMessageType;
|
|
10
|
+
}
|
|
11
|
+
export interface MqttMessage<TParams extends MqttMessageParams> extends MqttMessageBase {
|
|
12
|
+
params: TParams;
|
|
13
|
+
}
|
|
14
|
+
export interface MqttMessageParams {
|
|
15
|
+
}
|
|
16
|
+
export interface PdStatusMqttMessageCarParams {
|
|
17
|
+
carState?: boolean;
|
|
18
|
+
carWatts?: number;
|
|
19
|
+
}
|
|
20
|
+
export interface PdStatusMqttMessageUsbParams {
|
|
21
|
+
dcOutState?: boolean;
|
|
22
|
+
usb1Watts?: number;
|
|
23
|
+
usb2Watts?: number;
|
|
24
|
+
qcUsb1Watts?: number;
|
|
25
|
+
qcUsb2Watts?: number;
|
|
26
|
+
typec1Watts?: number;
|
|
27
|
+
typec2Watts?: number;
|
|
28
|
+
}
|
|
29
|
+
export interface PdStatusMqttMessageParams extends MqttMessageParams, PdStatusMqttMessageCarParams, PdStatusMqttMessageUsbParams {
|
|
30
|
+
beepMode?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface MpptStatusMqttMessageParams extends MqttMessageParams {
|
|
33
|
+
}
|
|
34
|
+
export interface InvStatusMqttMessageAcParams {
|
|
35
|
+
cfgAcEnabled?: boolean;
|
|
36
|
+
outputWatts?: number;
|
|
37
|
+
}
|
|
38
|
+
export interface InvStatusMqttMessageParams extends MqttMessageParams, InvStatusMqttMessageAcParams {
|
|
39
|
+
inputWatts?: number;
|
|
40
|
+
}
|
|
41
|
+
export interface BmsStatusMqttMessageParams extends MqttMessageParams {
|
|
42
|
+
soc?: number;
|
|
43
|
+
vol?: number;
|
|
44
|
+
amp?: number;
|
|
45
|
+
temp?: number;
|
|
46
|
+
f32ShowSoc?: number;
|
|
47
|
+
}
|
|
48
|
+
export interface EmsStatusMqttMessageParams extends MqttMessageParams {
|
|
49
|
+
}
|
|
50
|
+
export interface MqttSetMessageBase {
|
|
51
|
+
id: number;
|
|
52
|
+
version: string;
|
|
53
|
+
moduleType: number;
|
|
54
|
+
operateType: string;
|
|
55
|
+
}
|
|
56
|
+
export interface MqttSetMessageParams {
|
|
57
|
+
}
|
|
58
|
+
export interface MqttSetEnabledMessageParams extends MqttSetMessageParams {
|
|
59
|
+
enabled: number;
|
|
60
|
+
}
|
|
61
|
+
export interface MqttSetAcEnabledMessageParams extends MqttSetEnabledMessageParams {
|
|
62
|
+
out_voltage: number;
|
|
63
|
+
out_freq: number;
|
|
64
|
+
xboost: number;
|
|
65
|
+
}
|
|
66
|
+
export interface MqttSetMessage<TParams extends MqttSetMessageParams> extends MqttSetMessageBase {
|
|
67
|
+
params: TParams;
|
|
68
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export var MqttMessageType;
|
|
2
|
+
(function (MqttMessageType) {
|
|
3
|
+
MqttMessageType["PD"] = "pdStatus";
|
|
4
|
+
MqttMessageType["MPPT"] = "mpptStatus";
|
|
5
|
+
MqttMessageType["INV"] = "invStatus";
|
|
6
|
+
MqttMessageType["BMS"] = "bmsStatus";
|
|
7
|
+
MqttMessageType["EMS"] = "emsStatus";
|
|
8
|
+
})(MqttMessageType || (MqttMessageType = {}));
|
|
9
|
+
//# sourceMappingURL=ecoFlowMqttContacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecoFlowMqttContacts.js","sourceRoot":"","sources":["../../../../src/accessories/apis/interfaces/ecoFlowMqttContacts.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,kCAAe,CAAA;IACf,sCAAmB,CAAA;IACnB,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;AACnB,CAAC,EANW,eAAe,KAAf,eAAe,QAM1B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { EcoFlowAccessoryWithQuota } from './ecoFlowAccessory.js';
|
|
2
|
+
import { ServiceBase } from './services/serviceBase.js';
|
|
3
|
+
import { GetQuotaAllCmdResponseData } from './apis/interfaces/ecoFlowHttpContacts.js';
|
|
4
|
+
import { Subscription } from 'rxjs';
|
|
5
|
+
import { EcoFlowHomebridgePlatform } from 'platform.js';
|
|
6
|
+
import { PlatformAccessory } from 'homebridge';
|
|
7
|
+
import { DeviceConfig } from 'config.js';
|
|
8
|
+
export declare class Delta2MaxAccessory extends EcoFlowAccessoryWithQuota<GetQuotaAllCmdResponseData> {
|
|
9
|
+
readonly platform: EcoFlowHomebridgePlatform;
|
|
10
|
+
readonly accessory: PlatformAccessory;
|
|
11
|
+
readonly config: DeviceConfig;
|
|
12
|
+
private readonly batteryService;
|
|
13
|
+
private readonly outletUsbService;
|
|
14
|
+
private readonly outletAcService;
|
|
15
|
+
private readonly outletCarService;
|
|
16
|
+
constructor(platform: EcoFlowHomebridgePlatform, accessory: PlatformAccessory, config: DeviceConfig);
|
|
17
|
+
protected getServices(): ServiceBase[];
|
|
18
|
+
protected updateInitialValues(initialData: GetQuotaAllCmdResponseData): void;
|
|
19
|
+
protected subscribeOnParameterUpdates(): Subscription[];
|
|
20
|
+
private updateBmsInitialValues;
|
|
21
|
+
private updateInvInitialValues;
|
|
22
|
+
private updatePdInitialValues;
|
|
23
|
+
private updateBmsValues;
|
|
24
|
+
private updateInvValues;
|
|
25
|
+
private updatePdValues;
|
|
26
|
+
private getUsbWatts;
|
|
27
|
+
}
|