homebridge-foxess 1.0.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/.eslintrc +11 -0
- package/.github/dependabot.yml +19 -0
- package/.github/workflows/build.yml +26 -0
- package/.github/workflows/npmpublish.yml +34 -0
- package/.vscode/launch.json +23 -0
- package/.vscode/tasks.json +31 -0
- package/README.md +51 -0
- package/config.schema.json +32 -0
- package/dist/accessories/realTimeUsage.js +55 -0
- package/dist/accessories/realTimeUsage.js.map +1 -0
- package/dist/foxess/api.js +9 -0
- package/dist/foxess/api.js.map +1 -0
- package/dist/foxess/base.js +54 -0
- package/dist/foxess/base.js.map +1 -0
- package/dist/foxess/devices.js +23 -0
- package/dist/foxess/devices.js.map +1 -0
- package/dist/foxess/getDeviceList.js +41 -0
- package/dist/foxess/getDeviceList.js.map +1 -0
- package/dist/foxess/realTimeData.js +126 -0
- package/dist/foxess/realTimeData.js.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/local.js +52 -0
- package/dist/local.js.map +1 -0
- package/dist/platform.js +123 -0
- package/dist/platform.js.map +1 -0
- package/dist/settings.js +6 -0
- package/dist/settings.js.map +1 -0
- package/nodemon.json +12 -0
- package/package.json +55 -0
- package/release.sh +2 -0
- package/src/accessories/realTimeUsage.ts +64 -0
- package/src/foxess/api.ts +3 -0
- package/src/foxess/base.ts +37 -0
- package/src/foxess/devices.ts +16 -0
- package/src/foxess/getDeviceList.ts +27 -0
- package/src/foxess/realTimeData.ts +109 -0
- package/src/index.ts +7 -0
- package/src/local.ts +18 -0
- package/src/platform.ts +98 -0
- package/src/settings.ts +2 -0
- package/tsconfig.json +24 -0
package/.eslintrc
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
|
3
|
+
# Please see the documentation for all configuration options:
|
|
4
|
+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
5
|
+
|
|
6
|
+
version: 2
|
|
7
|
+
updates:
|
|
8
|
+
|
|
9
|
+
# Maintain dependencies for GitHub Actions
|
|
10
|
+
- package-ecosystem: "github-actions"
|
|
11
|
+
directory: "/"
|
|
12
|
+
schedule:
|
|
13
|
+
interval: "monthly"
|
|
14
|
+
|
|
15
|
+
# Maintain dependencies for npm
|
|
16
|
+
- package-ecosystem: "npm"
|
|
17
|
+
directory: "/"
|
|
18
|
+
schedule:
|
|
19
|
+
interval: "monthly"
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
|
|
2
|
+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
|
3
|
+
|
|
4
|
+
name: Node.js CI
|
|
5
|
+
|
|
6
|
+
on: [push, pull_request]
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
strategy:
|
|
14
|
+
matrix:
|
|
15
|
+
node-version: [16.x, 18.x, 20.x]
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
20
|
+
uses: actions/setup-node@v4.0.1
|
|
21
|
+
with:
|
|
22
|
+
node-version: ${{ matrix.node-version }}
|
|
23
|
+
- run: npm ci
|
|
24
|
+
- run: npm run build --if-present
|
|
25
|
+
env:
|
|
26
|
+
CI: true
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
|
2
|
+
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
|
|
3
|
+
|
|
4
|
+
name: Node.js Package
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
release:
|
|
8
|
+
types: [created]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: actions/setup-node@v4.0.1
|
|
17
|
+
with:
|
|
18
|
+
node-version: 20
|
|
19
|
+
- run: npm ci
|
|
20
|
+
- run: npm run prepublishOnly
|
|
21
|
+
|
|
22
|
+
publish-npm:
|
|
23
|
+
needs: build
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@v4
|
|
27
|
+
- uses: actions/setup-node@v4.0.1
|
|
28
|
+
with:
|
|
29
|
+
node-version: 20
|
|
30
|
+
registry-url: https://registry.npmjs.org/
|
|
31
|
+
- run: npm ci
|
|
32
|
+
- run: npm publish
|
|
33
|
+
env:
|
|
34
|
+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.2.0",
|
|
3
|
+
"configurations": [
|
|
4
|
+
{
|
|
5
|
+
"name": "Current TS File",
|
|
6
|
+
"type": "node",
|
|
7
|
+
"request": "launch",
|
|
8
|
+
"args": ["${relativeFile}"],
|
|
9
|
+
"runtimeArgs": ["-r", "ts-node/register"],
|
|
10
|
+
"cwd": "${workspaceRoot}",
|
|
11
|
+
"internalConsoleOptions": "openOnSessionStart"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "Main",
|
|
15
|
+
"type": "node",
|
|
16
|
+
"request": "launch",
|
|
17
|
+
"args": ["src/index.ts"],
|
|
18
|
+
"runtimeArgs": ["-r", "ts-node/register"],
|
|
19
|
+
"cwd": "${workspaceFolder}",
|
|
20
|
+
"internalConsoleOptions": "openOnSessionStart"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
|
3
|
+
// for the documentation about the tasks.json format
|
|
4
|
+
"version": "2.0.0",
|
|
5
|
+
"command": "npm",
|
|
6
|
+
"tasks": [
|
|
7
|
+
{
|
|
8
|
+
"label": "build",
|
|
9
|
+
"type": "shell",
|
|
10
|
+
"args": [
|
|
11
|
+
"run",
|
|
12
|
+
"build"
|
|
13
|
+
],
|
|
14
|
+
"problemMatcher": [],
|
|
15
|
+
"group": {
|
|
16
|
+
"_id": "build",
|
|
17
|
+
"isDefault": false
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"label": "test",
|
|
22
|
+
"type": "shell",
|
|
23
|
+
"args": [
|
|
24
|
+
"run",
|
|
25
|
+
"mocha",
|
|
26
|
+
"-r ts-node/register ${relativeFile}"
|
|
27
|
+
],
|
|
28
|
+
"problemMatcher": []
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
package/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+

|
|
2
|
+
[](https://www.npmjs.com/package/homebridge-foxess)
|
|
3
|
+
[](https://badge.fury.io/js/homebridge-foxess)
|
|
4
|
+

|
|
5
|
+
|
|
6
|
+
# Homebridge FoxESS
|
|
7
|
+
|
|
8
|
+
This plugin exposes HomeKit to solar data provided by FoxESS and those who use its platform, such as [Energizer Solar](https://portal.energizersolar.com/).
|
|
9
|
+
|
|
10
|
+
Created are various accessories that help power-optimising automations in HomeKit.
|
|
11
|
+
|
|
12
|
+
Currently, only a light sensor is exposed that indicates the current solar generation.
|
|
13
|
+
|
|
14
|
+
*This plugin is still in early development.*
|
|
15
|
+
|
|
16
|
+
Example `config.json`:
|
|
17
|
+
|
|
18
|
+
```json
|
|
19
|
+
"platforms": [
|
|
20
|
+
{
|
|
21
|
+
"name": "FoxESS",
|
|
22
|
+
"platform": "HomebridgeFoxESS",
|
|
23
|
+
"apiKey": "<your-api-key>",
|
|
24
|
+
"interval": "60000"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Parameters
|
|
30
|
+
|
|
31
|
+
| Parameter | Description | Required | Default
|
|
32
|
+
| --------- | ----- | ------- | ------ |
|
|
33
|
+
| `apiKey`| API Key provided by FoxESS Cloud. | `true` | |
|
|
34
|
+
| `interval`| How often to update current usage | `false` | `300000` (5 minutes) |
|
|
35
|
+
|
|
36
|
+
## Obtaining an API Key
|
|
37
|
+
|
|
38
|
+
1. Login to [FoxESS Cloud](https://www.foxesscloud.com)
|
|
39
|
+
1. Click on the top-right user icon, and select [User Profile](https://www.foxesscloud.com/user/center)
|
|
40
|
+
1. Under 'API Management', hit 'Generate API Key'.
|
|
41
|
+
|
|
42
|
+
Note: There is currently a limit of 1440 calls per day for an API Key, equating to once per minute.
|
|
43
|
+
|
|
44
|
+
## TODOs
|
|
45
|
+
|
|
46
|
+
| Area | Item |
|
|
47
|
+
| ---- | ---- |
|
|
48
|
+
| Optimise API Usage | Allow device SNs to be specified in config, instead of requesting data from FoxESS. |
|
|
49
|
+
| Optimise API Usage | Use a global timer to look-up real-time inverter data for all inverters, instead of 1 call per inverter. |
|
|
50
|
+
| Functionality | Add a motion sensor to show when power usage is from the grid. |
|
|
51
|
+
| Other | Move FoxESS Library into its own Node package |
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pluginAlias": "HomebridgeFoxESS",
|
|
3
|
+
"pluginType": "platform",
|
|
4
|
+
"singular": false,
|
|
5
|
+
"headerDisplay": "FoxESS for HomeKit",
|
|
6
|
+
"footerDisplay": "Created by teh-hippo",
|
|
7
|
+
"schema": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"name": {
|
|
11
|
+
"title": "Accessory Name",
|
|
12
|
+
"description": "Name for the accessory",
|
|
13
|
+
"type": "string",
|
|
14
|
+
"required": true
|
|
15
|
+
},
|
|
16
|
+
"apiKey": {
|
|
17
|
+
"title": "API Key",
|
|
18
|
+
"description": "API Key provided by FoxESS",
|
|
19
|
+
"type": "string",
|
|
20
|
+
"required": true
|
|
21
|
+
},
|
|
22
|
+
"interval": {
|
|
23
|
+
"title": "Polling Time in Milliseconds",
|
|
24
|
+
"description": "Time between each call to the FoxESS API",
|
|
25
|
+
"type": "integer",
|
|
26
|
+
"default": 60000,
|
|
27
|
+
"required": true,
|
|
28
|
+
"minimum": 60000
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RealTimeUsageAccessory = exports.RealTimeType = void 0;
|
|
4
|
+
const minLightLevel = 0.0001;
|
|
5
|
+
var RealTimeType;
|
|
6
|
+
(function (RealTimeType) {
|
|
7
|
+
RealTimeType[RealTimeType["LoadsPower"] = 1] = "LoadsPower";
|
|
8
|
+
RealTimeType[RealTimeType["GenerationPower"] = 2] = "GenerationPower";
|
|
9
|
+
RealTimeType[RealTimeType["FeedInPower"] = 3] = "FeedInPower";
|
|
10
|
+
RealTimeType[RealTimeType["GridConsumptionPower"] = 4] = "GridConsumptionPower";
|
|
11
|
+
})(RealTimeType || (exports.RealTimeType = RealTimeType = {}));
|
|
12
|
+
class RealTimeUsageAccessory {
|
|
13
|
+
constructor(platform, accessory, type) {
|
|
14
|
+
var _a;
|
|
15
|
+
this.platform = platform;
|
|
16
|
+
this.accessory = accessory;
|
|
17
|
+
this.type = type;
|
|
18
|
+
this.currentValue = minLightLevel;
|
|
19
|
+
this.service = (_a = this.accessory.getService(this.platform.Service.LightSensor)) !== null && _a !== void 0 ? _a : this.accessory.addService(this.platform.Service.LightSensor);
|
|
20
|
+
this.inverter = this.accessory.context;
|
|
21
|
+
this.service.setCharacteristic(this.platform.Characteristic.Name, `${this.inverter.deviceSN}-${RealTimeType[type]}`);
|
|
22
|
+
this.service.getCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel)
|
|
23
|
+
.onGet(() => { return this.currentValue; });
|
|
24
|
+
const informationService = this.accessory.getService(this.platform.Service.AccessoryInformation);
|
|
25
|
+
if (informationService === undefined) {
|
|
26
|
+
throw new Error('No information service was provided.');
|
|
27
|
+
}
|
|
28
|
+
informationService
|
|
29
|
+
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'FoxESS')
|
|
30
|
+
.setCharacteristic(this.platform.Characteristic.Model, `${this.inverter.deviceType} (${RealTimeType[type]})`)
|
|
31
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, this.inverter.deviceSN)
|
|
32
|
+
.setCharacteristic(this.platform.Characteristic.HardwareRevision, this.inverter.productType);
|
|
33
|
+
this.platform.log.debug(`Accessory for inverter: ${JSON.stringify(this.inverter)}`);
|
|
34
|
+
}
|
|
35
|
+
update(value) {
|
|
36
|
+
const newValue = this.getValue(value, this.type);
|
|
37
|
+
this.currentValue = Math.max(minLightLevel, newValue);
|
|
38
|
+
this.platform.log.debug('Current Usage', RealTimeType[this.type], newValue);
|
|
39
|
+
this.service.getCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel).updateValue(this.currentValue);
|
|
40
|
+
}
|
|
41
|
+
getValue(value, realTimeType) {
|
|
42
|
+
switch (realTimeType) {
|
|
43
|
+
case RealTimeType.LoadsPower:
|
|
44
|
+
return value.loadsPower;
|
|
45
|
+
case RealTimeType.GenerationPower:
|
|
46
|
+
return value.generationPower;
|
|
47
|
+
case RealTimeType.FeedInPower:
|
|
48
|
+
return value.feedinPower;
|
|
49
|
+
case RealTimeType.GridConsumptionPower:
|
|
50
|
+
return value.gridConsumptionPower;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.RealTimeUsageAccessory = RealTimeUsageAccessory;
|
|
55
|
+
//# sourceMappingURL=realTimeUsage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realTimeUsage.js","sourceRoot":"","sources":["../../src/acc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,QAAQ,YAAY,EAAE,CAAC;YACrB,KAAK,YAAY,CAAC,UAAU;gBAC1B,OAAO,KAAK,CAAC,UAAU,CAAA;YACzB,KAAK,YAAY,CAAC,eAAe;gBAC/B,OAAO,KAAK,CAAC,eAAe,CAAA;YAC9B,KAAK,YAAY,CAAC,WAAW;gBAC3B,OAAO,KAAK,CAAC,WAAW,CAAA;YAC1B,KAAK,YAAY,CAAC,oBAAoB;gBACpC,OAAO,KAAK,CAAC,oBAAoB,CAAA;QACrC,CAAC;IACH,CAAC;CACF;AA7CD,wDA6CC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAllRealTimeData = exports.getRealTimeData = exports.getDeviceList = void 0;
|
|
4
|
+
const getDeviceList_1 = require("./getDeviceList");
|
|
5
|
+
Object.defineProperty(exports, "getDeviceList", { enumerable: true, get: function () { return getDeviceList_1.getDeviceList; } });
|
|
6
|
+
const realTimeData_1 = require("./realTimeData");
|
|
7
|
+
Object.defineProperty(exports, "getRealTimeData", { enumerable: true, get: function () { return realTimeData_1.getRealTimeData; } });
|
|
8
|
+
Object.defineProperty(exports, "getAllRealTimeData", { enumerable: true, get: function () { return realTimeData_1.getAllRealTimeData; } });
|
|
9
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/foxess/api.ts"],"names":[],"mappings":";;;AAAA,mDAA+C;AAEtC,8FAFA,6BAAa,OAEA;AADtB,iDAAoE;AAC5C,gGADf,8BAAe,OACe;AAAE,mGADf,iCAAkB,OACe"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.call = void 0;
|
|
13
|
+
const ts_md5_1 = require("ts-md5");
|
|
14
|
+
function calculateSignature(path, apiKey, timestamp) {
|
|
15
|
+
return ts_md5_1.Md5.hashStr(`${path}\\r\\n${apiKey}\\r\\n${timestamp.toString()}`);
|
|
16
|
+
}
|
|
17
|
+
function call(path, apiKey, request) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const timestamp = Date.now();
|
|
20
|
+
const signature = calculateSignature(path, apiKey, timestamp);
|
|
21
|
+
const response = yield fetch(`https://www.foxesscloud.com${path}`, {
|
|
22
|
+
method: 'POST',
|
|
23
|
+
headers: {
|
|
24
|
+
'Content-Type': 'application/json',
|
|
25
|
+
token: apiKey,
|
|
26
|
+
signature,
|
|
27
|
+
timestamp: timestamp.toString(),
|
|
28
|
+
lang: 'en'
|
|
29
|
+
},
|
|
30
|
+
body: JSON.stringify(request)
|
|
31
|
+
});
|
|
32
|
+
if (response.status !== 200) {
|
|
33
|
+
throw new Error(`Invalid response code: ${response.status}`);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
const json = yield response.text();
|
|
37
|
+
try {
|
|
38
|
+
const result = JSON.parse(json);
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
const mine = `Unable to parse JSON: ${json}\nRoot: `;
|
|
43
|
+
if (e instanceof Error) {
|
|
44
|
+
throw new Error(`${mine}${e.message}\n${e.stack}`);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
throw new Error(`${mine}${e === null || e === void 0 ? void 0 : e.toString()}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
exports.call = call;
|
|
54
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/foxess/base.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAA4B;AAE5B,SAAS,kBAAkB,CAAE,IAAY,EAAE,MAAc,EAAE,SAAiB;IAC1E,OAAO,YAAG,CAAC,OAAO,CAAC,GAAG,IAAI,SAAS,MAAM,SAAS,SAAS,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;AAC3E,CAAC;AAED,SAAsB,IAAI,CAAuB,IAAY,EAAE,MAAc,EAAE,OAAiB;;QAC9F,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QAC5B,MAAM,SAAS,GAAG,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,CAAA;QAC7D,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,8BAA8B,IAAI,EAAE,EAAE;YACjE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,KAAK,EAAE,MAAM;gBACb,SAAS;gBACT,SAAS,EAAE,SAAS,CAAC,QAAQ,EAAE;gBAC/B,IAAI,EAAE,IAAI;aACX;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;SAC9B,CAAC,CAAA;QACF,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,0BAA0B,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;QAC9D,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,GAAW,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;YAC1C,IAAI,CAAC;gBACH,MAAM,MAAM,GAAc,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;gBAC1C,OAAO,MAAM,CAAA;YACf,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,MAAM,IAAI,GAAG,yBAAyB,IAAI,UAAU,CAAA;gBACpD,IAAI,CAAC,YAAY,KAAK,EAAE,CAAC;oBACvB,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,CAAA;gBACpD,CAAC;qBAAM,CAAC;oBACN,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,GAAG,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,QAAQ,EAAE,EAAE,CAAC,CAAA;gBAC5C,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CAAA;AA9BD,oBA8BC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Inverter = void 0;
|
|
4
|
+
var InverterStatus;
|
|
5
|
+
(function (InverterStatus) {
|
|
6
|
+
InverterStatus[InverterStatus["Online"] = 1] = "Online";
|
|
7
|
+
InverterStatus[InverterStatus["Fault"] = 2] = "Fault";
|
|
8
|
+
InverterStatus[InverterStatus["Offline"] = 3] = "Offline";
|
|
9
|
+
})(InverterStatus || (InverterStatus = {}));
|
|
10
|
+
class Inverter {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.deviceSN = '';
|
|
13
|
+
this.moduleSN = '';
|
|
14
|
+
this.plantID = '';
|
|
15
|
+
this.status = InverterStatus.Offline;
|
|
16
|
+
this.hasPV = false;
|
|
17
|
+
this.hasBattery = false;
|
|
18
|
+
this.deviceType = '';
|
|
19
|
+
this.productType = '';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.Inverter = Inverter;
|
|
23
|
+
//# sourceMappingURL=devices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devices.js","sourceRoot":"","sources":["../../src/foxess/devices.ts"],"names":[],"mappings":";;;AAAA,IAAK,cAIJ;AAJD,WAAK,cAAc;IACjB,uDAAU,CAAA;IACV,qDAAS,CAAA;IACT,yDAAW,CAAA;AACb,CAAC,EAJI,cAAc,KAAd,cAAc,QAIlB;AAED,MAAa,QAAQ;IAArB;QACS,aAAQ,GAAW,EAAE,CAAA;QACrB,aAAQ,GAAW,EAAE,CAAA;QACrB,YAAO,GAAW,EAAE,CAAA;QACpB,WAAM,GAAmB,cAAc,CAAC,OAAO,CAAA;QAC/C,UAAK,GAAY,KAAK,CAAA;QACtB,eAAU,GAAY,KAAK,CAAA;QAC3B,eAAU,GAAW,EAAE,CAAA;QACvB,gBAAW,GAAW,EAAE,CAAA;IACjC,CAAC;CAAA;AATD,4BASC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getDeviceList = void 0;
|
|
13
|
+
const base_1 = require("./base");
|
|
14
|
+
class GetDeviceListRequest {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.currentPage = 1;
|
|
17
|
+
this.pageSize = 10;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
class GetDeviceListResponse {
|
|
21
|
+
}
|
|
22
|
+
class GetDeviceListResponsePage {
|
|
23
|
+
constructor() {
|
|
24
|
+
this.pageSize = 0;
|
|
25
|
+
this.total = 0;
|
|
26
|
+
this.data = [];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function getDeviceList(apiKey) {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const response = yield (0, base_1.call)('/op/v0/device/list', apiKey, new GetDeviceListRequest());
|
|
32
|
+
if (response.errno === 0 && response.result !== undefined) {
|
|
33
|
+
return response.result.data;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
throw new Error(`Invalid response code: ${response.errno}`);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
exports.getDeviceList = getDeviceList;
|
|
41
|
+
//# sourceMappingURL=getDeviceList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDeviceList.js","sourceRoot":"","sources":["../../src/foxess/getDeviceList.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,iCAA6B;AAE7B,MAAM,oBAAoB;IAA1B;QACS,gBAAW,GAAW,CAAC,CAAA;QACvB,aAAQ,GAAW,EAAE,CAAA;IAC9B,CAAC;CAAA;AAED,MAAM,qBAAqB;CAG1B;AAED,MAAM,yBAAyB;IAA/B;QACS,aAAQ,GAAW,CAAC,CAAA;QACpB,UAAK,GAAW,CAAC,CAAA;QACjB,SAAI,GAAe,EAAE,CAAA;IAC9B,CAAC;CAAA;AAED,SAAsB,aAAa,CAAE,MAAc;;QACjD,MAAM,QAAQ,GAA0B,MAAM,IAAA,WAAI,EAAC,oBAAoB,EAAE,MAAM,EAAE,IAAI,oBAAoB,EAAE,CAAC,CAAA;QAC5G,IAAI,QAAQ,CAAC,KAAK,KAAK,CAAC,IAAI,QAAQ,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1D,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAA;QAC7B,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,0BAA0B,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;QAC7D,CAAC;IACH,CAAC;CAAA;AAPD,sCAOC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getAllRealTimeData = exports.getRealTimeData = exports.BasicRealTimeData = void 0;
|
|
13
|
+
const base_1 = require("./base");
|
|
14
|
+
const TodayYield = 'todayYield'; // Today Yield (kW)
|
|
15
|
+
const PvPower = 'pvPower'; // pvPower (kW)
|
|
16
|
+
const LoadsPower = 'loadsPower'; // Load Power (kW)
|
|
17
|
+
const GenerationPower = 'generationPower'; // Output Power (kW)
|
|
18
|
+
const FeedInPower = 'feedinPower'; // Feed-in Power (kW)
|
|
19
|
+
const GridConsumptionPower = 'gridConsumptionPower'; // GridConsumption Power (kW)
|
|
20
|
+
class BasicRealTimeData {
|
|
21
|
+
constructor() {
|
|
22
|
+
this.deviceSN = '';
|
|
23
|
+
this.todayYield = 0;
|
|
24
|
+
this.pvPower = 0;
|
|
25
|
+
this.loadsPower = 0;
|
|
26
|
+
this.generationPower = 0;
|
|
27
|
+
this.feedinPower = 0;
|
|
28
|
+
this.gridConsumptionPower = 0;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.BasicRealTimeData = BasicRealTimeData;
|
|
32
|
+
class RealTimeData {
|
|
33
|
+
constructor() {
|
|
34
|
+
this.deviceSN = '';
|
|
35
|
+
this.datas = [];
|
|
36
|
+
this.time = '';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
class RealTimeDataItem {
|
|
40
|
+
constructor() {
|
|
41
|
+
this.variable = '';
|
|
42
|
+
this.unit = '';
|
|
43
|
+
this.name = '';
|
|
44
|
+
this.value = 0;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
class RealTimeDataRequest {
|
|
48
|
+
constructor() {
|
|
49
|
+
this.variables = [
|
|
50
|
+
TodayYield,
|
|
51
|
+
PvPower,
|
|
52
|
+
LoadsPower,
|
|
53
|
+
GenerationPower,
|
|
54
|
+
FeedInPower,
|
|
55
|
+
GridConsumptionPower
|
|
56
|
+
];
|
|
57
|
+
this.sn = '';
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
class RealTimeDataResponse {
|
|
61
|
+
}
|
|
62
|
+
function toBasicData(data) {
|
|
63
|
+
const result = new BasicRealTimeData();
|
|
64
|
+
result.deviceSN = data.deviceSN;
|
|
65
|
+
data.datas.forEach(i => {
|
|
66
|
+
switch (i.variable) {
|
|
67
|
+
case PvPower:
|
|
68
|
+
result.pvPower = i.value;
|
|
69
|
+
break;
|
|
70
|
+
case LoadsPower:
|
|
71
|
+
result.loadsPower = i.value;
|
|
72
|
+
break;
|
|
73
|
+
case GenerationPower:
|
|
74
|
+
result.generationPower = i.value;
|
|
75
|
+
break;
|
|
76
|
+
case FeedInPower:
|
|
77
|
+
result.feedinPower = i.value;
|
|
78
|
+
break;
|
|
79
|
+
case GridConsumptionPower:
|
|
80
|
+
result.gridConsumptionPower = i.value;
|
|
81
|
+
break;
|
|
82
|
+
case TodayYield:
|
|
83
|
+
result.todayYield = i.value;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
function getRealTimeData(apiKey, inverter) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
const request = new RealTimeDataRequest();
|
|
92
|
+
if (inverter !== undefined) {
|
|
93
|
+
request.sn = inverter.deviceSN;
|
|
94
|
+
}
|
|
95
|
+
const response = yield (0, base_1.call)('/op/v0/device/real/query', apiKey, request);
|
|
96
|
+
if (response.errno === 0) {
|
|
97
|
+
if (response.result !== undefined && response.result.length > 0) {
|
|
98
|
+
return toBasicData(response.result[0]);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
throw new Error(`No data returned for inverter: ${inverter.deviceSN}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
throw new Error(`Invalid response code: ${response.errno}`);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
exports.getRealTimeData = getRealTimeData;
|
|
110
|
+
function getAllRealTimeData(apiKey) {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
const response = yield (0, base_1.call)('/op/v0/device/real/query', apiKey, new RealTimeDataRequest());
|
|
113
|
+
if (response.errno === 0 && response.result !== undefined) {
|
|
114
|
+
const result = [];
|
|
115
|
+
response.result.forEach(i => {
|
|
116
|
+
result.push(toBasicData(i));
|
|
117
|
+
});
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
throw new Error(`Invalid response code: ${response.errno}`);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
exports.getAllRealTimeData = getAllRealTimeData;
|
|
126
|
+
//# sourceMappingURL=realTimeData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realTimeData.js","sourceRoot":"","sources":["../../src/foxess/real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__createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
const FoxESS = __importStar(require("./foxess/api"));
|
|
36
|
+
/*
|
|
37
|
+
* Basic example showing how to retrieve data from the FoxESS API.
|
|
38
|
+
*/
|
|
39
|
+
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
const apiKey = process.env.API_KEY;
|
|
41
|
+
if (apiKey === undefined) {
|
|
42
|
+
throw new Error('API_KEY is not set.');
|
|
43
|
+
}
|
|
44
|
+
const inverters = yield FoxESS.getDeviceList(apiKey);
|
|
45
|
+
console.info(`Returned ${inverters.length} inverter(s):`);
|
|
46
|
+
for (const inverter of inverters) {
|
|
47
|
+
console.log(`\t${JSON.stringify(inverter)}:`);
|
|
48
|
+
const data = yield FoxESS.getRealTimeData(apiKey, inverter);
|
|
49
|
+
console.log(JSON.stringify(data));
|
|
50
|
+
}
|
|
51
|
+
}))().catch(e => { console.error(e); });
|
|
52
|
+
//# sourceMappingURL=local.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local.js","sourceRoot":"","sources":["../src/local.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAsC;AAEtC;;EAEE;AACF,CAAC,GAAS,EAAE;IACV,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAA;IAClC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;IACxC,CAAC;IACD,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;IACpD,OAAO,CAAC,IAAI,CAAC,YAAY,SAAS,CAAC,MAAM,eAAe,CAAC,CAAA;IACzD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;QAC7C,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;QAC3D,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;IACnC,CAAC;AACH,CAAC,CAAA,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA,CAAC,CAAC,CAAC,CAAA"}
|