@chris.guzik/homebridge-isolarcloud 0.0.0-stage → 2.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/CHANGELOG.md +42 -0
- package/LICENSE +21 -0
- package/README.md +84 -2
- package/config.schema.json +104 -0
- package/dist/isolarcloudapi.js +316 -0
- package/dist/isolarcloudapi.js.map +1 -0
- package/dist/platform.js +207 -0
- package/dist/platform.js.map +1 -0
- package/package.json +52 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Changes
|
|
2
|
+
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
- [Change] Published package name as `@chris.guzik/homebridge-isolarcloud`
|
|
6
|
+
- [New] Optional House Usage, Grid Import, Grid Export and Battery tiles (mapped via `fields` config)
|
|
7
|
+
- [New] Homebridge settings UI (`config.schema.json`)
|
|
8
|
+
- [New] Optional Eve Watts characteristic (`eveCharacteristics`)
|
|
9
|
+
- [New] `logRaw` option to discover iSolarCloud field names
|
|
10
|
+
- [Change] Single shared poll (default 60s) updates all tiles in the background
|
|
11
|
+
- [Fix] 0 W no longer triggers HomeKit "illegal value" warnings
|
|
12
|
+
- [Fix] Clearer errors (HTTP status, login failure); removed redundant error handling
|
|
13
|
+
- [Change] Requires Node 18+ (uses built-in fetch)
|
|
14
|
+
- [Cleanup] Removed unused loginkey.pem
|
|
15
|
+
|
|
16
|
+
## 1.5.0
|
|
17
|
+
|
|
18
|
+
- [Fix] Added login to all api calls
|
|
19
|
+
|
|
20
|
+
## 1.4.0
|
|
21
|
+
|
|
22
|
+
- [Fix] Improved error handling and debugging
|
|
23
|
+
|
|
24
|
+
## 1.3.0
|
|
25
|
+
|
|
26
|
+
- [Fix] Addressed new encryption API issue
|
|
27
|
+
|
|
28
|
+
## 1.2.1
|
|
29
|
+
|
|
30
|
+
- [Fix] Added server parameter
|
|
31
|
+
|
|
32
|
+
## 1.1.3
|
|
33
|
+
|
|
34
|
+
- [Fix] Addressed issue with creating the accessory
|
|
35
|
+
|
|
36
|
+
## 1.1.0
|
|
37
|
+
|
|
38
|
+
- [Fix] Converted to TypeScript
|
|
39
|
+
|
|
40
|
+
## 1.0.5
|
|
41
|
+
|
|
42
|
+
- [Fix] Changed lowest lighting level to 1
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 MortJC
|
|
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
CHANGED
|
@@ -1,3 +1,85 @@
|
|
|
1
|
-
#
|
|
1
|
+
# homebridge-isolarcloud
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Homebridge plugin for **Sungrow iSolarCloud**. Shows your solar generation in HomeKit, plus house usage and grid import/export if your plant reports them.
|
|
4
|
+
|
|
5
|
+
> Forked from [MortJC/homebridge-platform-isolarcloud](https://github.com/MortJC/homebridge-platform-isolarcloud) (MIT). Original work by James Carvosso.
|
|
6
|
+
|
|
7
|
+
## How it appears in HomeKit
|
|
8
|
+
|
|
9
|
+
HomeKit has no native solar/energy accessory, so each value is a **light sensor** where **lux = watts** (4,200 lux = 4.2 kW). You can rename tiles and use them in automations (e.g. "when Grid Export is above 2000").
|
|
10
|
+
|
|
11
|
+
| Tile | Created when |
|
|
12
|
+
|---|---|
|
|
13
|
+
| Solar | Always |
|
|
14
|
+
| House Usage | `fields.house` is set |
|
|
15
|
+
| Grid Import | `fields.gridImport` is set |
|
|
16
|
+
| Grid Export | `fields.gridExport` is set |
|
|
17
|
+
| Battery | `fields.battery` is set |
|
|
18
|
+
|
|
19
|
+
Optionally, `eveCharacteristics` adds a real **Watts** reading for the **Eve** app. It is a live value only; there is no history graph.
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
npm install -g @chris.guzik/homebridge-isolarcloud
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Requires Node 18+ and Homebridge 1.6+. Configure it in the Homebridge UI, or edit `config.json`.
|
|
28
|
+
|
|
29
|
+
## Configuration
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"platform": "ISolarCloud",
|
|
34
|
+
"name": "ISolarCloud",
|
|
35
|
+
"server": "Australian",
|
|
36
|
+
"email": "you@example.com",
|
|
37
|
+
"password": "your-password",
|
|
38
|
+
"pollSeconds": 60,
|
|
39
|
+
"eveCharacteristics": false,
|
|
40
|
+
"fields": {
|
|
41
|
+
"house": "",
|
|
42
|
+
"gridImport": "",
|
|
43
|
+
"gridExport": ""
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
| Option | Description |
|
|
49
|
+
|---|---|
|
|
50
|
+
| `server` | `Australian`, `European`, `Chinese` or `International` |
|
|
51
|
+
| `email`, `password` | Your iSolarCloud login |
|
|
52
|
+
| `pollSeconds` | Update interval, minimum 30 (default 60) |
|
|
53
|
+
| `eveCharacteristics` | Add Eve Watts characteristic |
|
|
54
|
+
| `logRaw` | Log all iSolarCloud fields (for setup) |
|
|
55
|
+
| `fields.*` | Field names for the extra tiles (see below) |
|
|
56
|
+
|
|
57
|
+
## Setting up House / Grid tiles
|
|
58
|
+
|
|
59
|
+
Field names depend on your plant, so you map them yourself once:
|
|
60
|
+
|
|
61
|
+
1. Set `"logRaw": true` and restart Homebridge.
|
|
62
|
+
2. Find the log line `RAW getPsDetail result_data = {...}`.
|
|
63
|
+
3. Find the fields holding house, import and export power. Values can be plain numbers or `{ "value": ..., "unit": "kW" }`, and kW is converted to watts automatically. Nested fields use dots, e.g. `"load.value"`.
|
|
64
|
+
4. Put those names under `fields`, set `logRaw` back to `false`, and restart.
|
|
65
|
+
|
|
66
|
+
Check the log carefully before sharing it online, as it may contain names, addresses and plant IDs.
|
|
67
|
+
|
|
68
|
+
If no house or grid fields appear, your plant may not have a meter that reports them, or the data may be on a different iSolarCloud endpoint. Please open an issue.
|
|
69
|
+
|
|
70
|
+
## Notes
|
|
71
|
+
|
|
72
|
+
- Zero values are shown as 0.0001 lux because HomeKit light sensors cannot be exactly 0.
|
|
73
|
+
- Export/import values are shown as positive numbers.
|
|
74
|
+
- This plugin uses the same unofficial web API as the iSolarCloud app and may break if Sungrow changes it.
|
|
75
|
+
- Not affiliated with Sungrow.
|
|
76
|
+
|
|
77
|
+
## Upgrading from 1.x
|
|
78
|
+
|
|
79
|
+
Your existing solar tile is kept. Node 18+ is now required.
|
|
80
|
+
|
|
81
|
+
The npm package is now named `@chris.guzik/homebridge-isolarcloud`. If you installed the previous package name, uninstall it and install this package; keep the Homebridge platform configuration unchanged.
|
|
82
|
+
|
|
83
|
+
## License
|
|
84
|
+
|
|
85
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pluginAlias": "ISolarCloud",
|
|
3
|
+
"pluginType": "platform",
|
|
4
|
+
"singular": true,
|
|
5
|
+
"headerDisplay": "Sungrow iSolarCloud. Enter your login, then (optionally) map House/Grid fields. See the README for how to find them.",
|
|
6
|
+
"schema": {
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"name": {
|
|
10
|
+
"title": "Name",
|
|
11
|
+
"type": "string",
|
|
12
|
+
"default": "ISolarCloud",
|
|
13
|
+
"required": true
|
|
14
|
+
},
|
|
15
|
+
"server": {
|
|
16
|
+
"title": "Server",
|
|
17
|
+
"type": "string",
|
|
18
|
+
"default": "Australian",
|
|
19
|
+
"oneOf": [
|
|
20
|
+
{
|
|
21
|
+
"title": "Australian",
|
|
22
|
+
"enum": [
|
|
23
|
+
"Australian"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"title": "European",
|
|
28
|
+
"enum": [
|
|
29
|
+
"European"
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"title": "Chinese",
|
|
34
|
+
"enum": [
|
|
35
|
+
"Chinese"
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"title": "International",
|
|
40
|
+
"enum": [
|
|
41
|
+
"International"
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"required": true
|
|
46
|
+
},
|
|
47
|
+
"email": {
|
|
48
|
+
"title": "Email",
|
|
49
|
+
"type": "string",
|
|
50
|
+
"format": "email",
|
|
51
|
+
"required": true
|
|
52
|
+
},
|
|
53
|
+
"password": {
|
|
54
|
+
"title": "Password",
|
|
55
|
+
"type": "string",
|
|
56
|
+
"required": true,
|
|
57
|
+
"x-schema-form": {
|
|
58
|
+
"type": "password"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"pollSeconds": {
|
|
62
|
+
"title": "Update interval (seconds)",
|
|
63
|
+
"type": "integer",
|
|
64
|
+
"default": 60,
|
|
65
|
+
"minimum": 30
|
|
66
|
+
},
|
|
67
|
+
"eveCharacteristics": {
|
|
68
|
+
"title": "Add Eve Watts characteristic",
|
|
69
|
+
"type": "boolean",
|
|
70
|
+
"default": false,
|
|
71
|
+
"description": "Shows real Watts in the Eve app. Live value only (no history graph)."
|
|
72
|
+
},
|
|
73
|
+
"logRaw": {
|
|
74
|
+
"title": "Log raw iSolarCloud data (for finding field names)",
|
|
75
|
+
"type": "boolean",
|
|
76
|
+
"default": false,
|
|
77
|
+
"description": "Prints all fields to the log. Turn off afterwards and remove personal details before sharing logs."
|
|
78
|
+
},
|
|
79
|
+
"fields": {
|
|
80
|
+
"title": "Field mapping (optional)",
|
|
81
|
+
"type": "object",
|
|
82
|
+
"description": "Field names from the raw log. Only tiles with a field set are created.",
|
|
83
|
+
"properties": {
|
|
84
|
+
"house": {
|
|
85
|
+
"title": "House usage field",
|
|
86
|
+
"type": "string"
|
|
87
|
+
},
|
|
88
|
+
"gridImport": {
|
|
89
|
+
"title": "Grid import field",
|
|
90
|
+
"type": "string"
|
|
91
|
+
},
|
|
92
|
+
"gridExport": {
|
|
93
|
+
"title": "Grid export field",
|
|
94
|
+
"type": "string"
|
|
95
|
+
},
|
|
96
|
+
"battery": {
|
|
97
|
+
"title": "Battery field",
|
|
98
|
+
"type": "string"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __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
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
+
function step(op) {
|
|
39
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
41
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
42
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
+
switch (op[0]) {
|
|
44
|
+
case 0: case 1: t = op; break;
|
|
45
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
+
default:
|
|
49
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
+
if (t[2]) _.ops.pop();
|
|
54
|
+
_.trys.pop(); continue;
|
|
55
|
+
}
|
|
56
|
+
op = body.call(thisArg, _);
|
|
57
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
62
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
63
|
+
};
|
|
64
|
+
exports.__esModule = true;
|
|
65
|
+
exports.ISolarCloudPowerStationsAPI = exports.ISolarCloudAPI = exports.api = exports.login = exports.generateRandomWord = exports.encryptRSA = exports.decryptAES = exports.encryptAES = exports.randomKey = void 0;
|
|
66
|
+
var crypto_1 = require("crypto");
|
|
67
|
+
var CryptoJS = __importStar(require("crypto-js"));
|
|
68
|
+
var node_rsa_1 = __importDefault(require("node-rsa"));
|
|
69
|
+
var PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCkecphb6vgsBx4LJknKKes-eyj7-RKQ3fikF5B67EObZ3t4moFZyMGuuJPiadYdaxvRqtxyblIlVM7omAasROtKRhtgKwwRxo2a6878qBhTgUVlsqugpI_7ZC9RmO2Rpmr8WzDeAapGANfHN5bVr7G7GYGwIrjvyxMrAVit_oM4wIDAQAB";
|
|
70
|
+
var APP_KEY = "B0455FBE7AA0328DB57B59AA729F05D8";
|
|
71
|
+
var ACCESS_KEY = "9grzgbmxdsp3arfmmgq347xjbza4ysps";
|
|
72
|
+
function randomKey() {
|
|
73
|
+
return "and" + 'q1w2e3r4t5y67'; //randomString(13);
|
|
74
|
+
}
|
|
75
|
+
exports.randomKey = randomKey;
|
|
76
|
+
function encryptAES(data, key) {
|
|
77
|
+
var d = CryptoJS.enc.Utf8.parse(JSON.stringify(data));
|
|
78
|
+
var k = CryptoJS.enc.Utf8.parse(key);
|
|
79
|
+
return CryptoJS.AES.encrypt(d, k, {
|
|
80
|
+
mode: CryptoJS.mode.ECB,
|
|
81
|
+
padding: CryptoJS.pad.Pkcs7
|
|
82
|
+
})
|
|
83
|
+
.ciphertext.toString()
|
|
84
|
+
.toUpperCase();
|
|
85
|
+
}
|
|
86
|
+
exports.encryptAES = encryptAES;
|
|
87
|
+
function decryptAES(data, key) {
|
|
88
|
+
var d = CryptoJS.format.Hex.parse(data);
|
|
89
|
+
var k = CryptoJS.enc.Utf8.parse(key);
|
|
90
|
+
var dec = CryptoJS.AES.decrypt(d, k, {
|
|
91
|
+
mode: CryptoJS.mode.ECB,
|
|
92
|
+
padding: CryptoJS.pad.Pkcs7
|
|
93
|
+
});
|
|
94
|
+
return JSON.parse(CryptoJS.enc.Utf8.stringify(dec));
|
|
95
|
+
}
|
|
96
|
+
exports.decryptAES = decryptAES;
|
|
97
|
+
function encryptRSA(value, publicKey) {
|
|
98
|
+
var key = new node_rsa_1["default"]();
|
|
99
|
+
key.setOptions({ encryptionScheme: "pkcs1" });
|
|
100
|
+
key.importKey(publicKey, "pkcs8-public-pem");
|
|
101
|
+
return key.encrypt(value, "base64");
|
|
102
|
+
}
|
|
103
|
+
exports.encryptRSA = encryptRSA;
|
|
104
|
+
function generateRandomWord(length) {
|
|
105
|
+
var result = '';
|
|
106
|
+
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
107
|
+
for (var i = 0; i < length; i++) {
|
|
108
|
+
result += characters.charAt((0, crypto_1.randomInt)(characters.length));
|
|
109
|
+
}
|
|
110
|
+
return result;
|
|
111
|
+
}
|
|
112
|
+
exports.generateRandomWord = generateRandomWord;
|
|
113
|
+
function login(endpoint, email, password) {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
115
|
+
var body, response;
|
|
116
|
+
return __generator(this, function (_a) {
|
|
117
|
+
switch (_a.label) {
|
|
118
|
+
case 0:
|
|
119
|
+
body = {
|
|
120
|
+
"appkey": APP_KEY,
|
|
121
|
+
"api_key_param": { 'timestamp': Date.now(), 'nonce': generateRandomWord(32) },
|
|
122
|
+
"user_account": email,
|
|
123
|
+
"user_password": password
|
|
124
|
+
};
|
|
125
|
+
return [4 /*yield*/, api(endpoint + "/v1/userService/login", body, '')];
|
|
126
|
+
case 1:
|
|
127
|
+
response = _a.sent();
|
|
128
|
+
if (response['result_msg'] !== 'success') {
|
|
129
|
+
throw new Error('iSolarCloud login failed: ' + response['result_msg']);
|
|
130
|
+
}
|
|
131
|
+
return [2 /*return*/, [response['result_data']['token'], response['result_data']['user_id']]];
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
exports.login = login;
|
|
137
|
+
function api(url, body, userid) {
|
|
138
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
139
|
+
var randomKey, headers, encryptedBody, requestOptions, response, reader, decoder, result, _a, done, value;
|
|
140
|
+
return __generator(this, function (_b) {
|
|
141
|
+
switch (_b.label) {
|
|
142
|
+
case 0:
|
|
143
|
+
randomKey = 'web' + generateRandomWord(13);
|
|
144
|
+
headers = new Headers();
|
|
145
|
+
headers.append("content-type", "application/json;charset=UTF-8");
|
|
146
|
+
headers.append("sys_code", "200");
|
|
147
|
+
headers.append("x-access-key", ACCESS_KEY);
|
|
148
|
+
headers.append("x-random-secret-key", encryptRSA(randomKey, PUBLIC_KEY));
|
|
149
|
+
headers.append("x-limit-obj", encryptRSA(userid, PUBLIC_KEY));
|
|
150
|
+
encryptedBody = encryptAES(body, randomKey);
|
|
151
|
+
requestOptions = {
|
|
152
|
+
method: "POST",
|
|
153
|
+
headers: headers,
|
|
154
|
+
body: encryptedBody
|
|
155
|
+
};
|
|
156
|
+
return [4 /*yield*/, fetch(url, requestOptions)];
|
|
157
|
+
case 1:
|
|
158
|
+
response = _b.sent();
|
|
159
|
+
if (!response.ok) {
|
|
160
|
+
throw new Error('iSolarCloud request failed: HTTP ' + response.status);
|
|
161
|
+
}
|
|
162
|
+
if (!response.body) {
|
|
163
|
+
throw new Error('iSolarCloud returned an empty response');
|
|
164
|
+
}
|
|
165
|
+
reader = response.body.getReader();
|
|
166
|
+
decoder = new TextDecoder('utf-8');
|
|
167
|
+
result = '';
|
|
168
|
+
_b.label = 2;
|
|
169
|
+
case 2:
|
|
170
|
+
if (!true) return [3 /*break*/, 4];
|
|
171
|
+
return [4 /*yield*/, reader.read()];
|
|
172
|
+
case 3:
|
|
173
|
+
_a = _b.sent(), done = _a.done, value = _a.value;
|
|
174
|
+
if (done)
|
|
175
|
+
return [3 /*break*/, 4];
|
|
176
|
+
result += decoder.decode(value, { stream: true });
|
|
177
|
+
return [3 /*break*/, 2];
|
|
178
|
+
case 4: return [2 /*return*/, decryptAES(result, randomKey)];
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
exports.api = api;
|
|
184
|
+
// Reads a value from a dotted path like "curr_power" or "load.value".
|
|
185
|
+
// Handles plain numbers and {value, unit} objects. Returns watts.
|
|
186
|
+
function readWatts(data, path) {
|
|
187
|
+
if (!path)
|
|
188
|
+
return undefined;
|
|
189
|
+
var v = path.split('.').reduce(function (o, k) { return (o == null ? undefined : o[k]); }, data);
|
|
190
|
+
if (v === undefined || v === null)
|
|
191
|
+
return undefined;
|
|
192
|
+
var num;
|
|
193
|
+
var unit = 'W';
|
|
194
|
+
if (typeof v === 'object') {
|
|
195
|
+
num = parseFloat(v['value']);
|
|
196
|
+
unit = v['unit'] || 'W';
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
num = parseFloat(v);
|
|
200
|
+
}
|
|
201
|
+
if (isNaN(num))
|
|
202
|
+
return undefined;
|
|
203
|
+
if (unit === 'kW')
|
|
204
|
+
num *= 1000;
|
|
205
|
+
else if (unit === 'MW')
|
|
206
|
+
num *= 1000000;
|
|
207
|
+
return num;
|
|
208
|
+
}
|
|
209
|
+
var ISolarCloudAPI = /** @class */ (function () {
|
|
210
|
+
function ISolarCloudAPI(log, server, email, password) {
|
|
211
|
+
this.log = log;
|
|
212
|
+
this.server = server;
|
|
213
|
+
this.email = email;
|
|
214
|
+
this.password = password;
|
|
215
|
+
this.server = server;
|
|
216
|
+
switch (this.server) {
|
|
217
|
+
case 'Australian':
|
|
218
|
+
this.endpoint = 'https://augateway.isolarcloud.com';
|
|
219
|
+
break;
|
|
220
|
+
case 'European':
|
|
221
|
+
this.endpoint = 'https://gateway.isolarcloud.eu';
|
|
222
|
+
break;
|
|
223
|
+
case 'Chinese':
|
|
224
|
+
this.endpoint = 'https://gateway.isolarcloud.com';
|
|
225
|
+
break;
|
|
226
|
+
default:
|
|
227
|
+
this.endpoint = 'https://gateway.isolarcloud.com.hk';
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
ISolarCloudAPI.prototype.getPowerStations = function () {
|
|
231
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
232
|
+
var _a, token, userid, body, response;
|
|
233
|
+
var _this = this;
|
|
234
|
+
return __generator(this, function (_b) {
|
|
235
|
+
switch (_b.label) {
|
|
236
|
+
case 0: return [4 /*yield*/, login(this.endpoint, this.email, this.password)];
|
|
237
|
+
case 1:
|
|
238
|
+
_a = _b.sent(), token = _a[0], userid = _a[1];
|
|
239
|
+
body = {
|
|
240
|
+
"appkey": APP_KEY,
|
|
241
|
+
"api_key_param": { 'timestamp': Date.now(), 'nonce': generateRandomWord(32) },
|
|
242
|
+
"user_id": userid,
|
|
243
|
+
"valid_flag": "1,3",
|
|
244
|
+
"lang": "_en_US",
|
|
245
|
+
"token": token
|
|
246
|
+
};
|
|
247
|
+
return [4 /*yield*/, api(this.endpoint + "/v1/powerStationService/getPsList", body, userid)];
|
|
248
|
+
case 2:
|
|
249
|
+
response = _b.sent();
|
|
250
|
+
this.log.debug('getPsList response = ' + JSON.stringify(response));
|
|
251
|
+
if (response['result_msg'] !== 'success') {
|
|
252
|
+
throw new Error('Could not get power stations: ' + response['result_msg']);
|
|
253
|
+
}
|
|
254
|
+
return [2 /*return*/, response['result_data']['pageList'].map(function (item) {
|
|
255
|
+
return new ISolarCloudPowerStationsAPI(_this.log, _this.endpoint, _this.email, _this.password, item['ps_id'].toString(), item['ps_name'], "Unknown", "Unknown", item['ps_status']);
|
|
256
|
+
})];
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
};
|
|
261
|
+
return ISolarCloudAPI;
|
|
262
|
+
}());
|
|
263
|
+
exports.ISolarCloudAPI = ISolarCloudAPI;
|
|
264
|
+
var ISolarCloudPowerStationsAPI = /** @class */ (function () {
|
|
265
|
+
function ISolarCloudPowerStationsAPI(log, endpoint, email, password, id, name, hardware_version, firmware_version, is_connected) {
|
|
266
|
+
this.log = log;
|
|
267
|
+
this.endpoint = endpoint;
|
|
268
|
+
this.email = email;
|
|
269
|
+
this.password = password;
|
|
270
|
+
this.id = id;
|
|
271
|
+
this.name = name;
|
|
272
|
+
this.hardware_version = hardware_version;
|
|
273
|
+
this.firmware_version = firmware_version;
|
|
274
|
+
this.is_connected = is_connected;
|
|
275
|
+
}
|
|
276
|
+
ISolarCloudPowerStationsAPI.prototype.getEnergyFlow = function (fields, logRaw) {
|
|
277
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
278
|
+
var _a, token, userid, body, response, data, result, _i, _b, key;
|
|
279
|
+
return __generator(this, function (_c) {
|
|
280
|
+
switch (_c.label) {
|
|
281
|
+
case 0: return [4 /*yield*/, login(this.endpoint, this.email, this.password)];
|
|
282
|
+
case 1:
|
|
283
|
+
_a = _c.sent(), token = _a[0], userid = _a[1];
|
|
284
|
+
body = {
|
|
285
|
+
"appkey": APP_KEY,
|
|
286
|
+
"api_key_param": { 'timestamp': Date.now(), 'nonce': generateRandomWord(32) },
|
|
287
|
+
"ps_id": this.id,
|
|
288
|
+
"valid_flag": "1,3",
|
|
289
|
+
"lang": "_en_US",
|
|
290
|
+
"token": token
|
|
291
|
+
};
|
|
292
|
+
return [4 /*yield*/, api(this.endpoint + "/v1/powerStationService/getPsDetail", body, userid)];
|
|
293
|
+
case 2:
|
|
294
|
+
response = _c.sent();
|
|
295
|
+
if (response['result_msg'] !== 'success') {
|
|
296
|
+
throw new Error('Could not get power station detail: ' + response['result_msg']);
|
|
297
|
+
}
|
|
298
|
+
data = response['result_data'];
|
|
299
|
+
// Discovery aid: shows every field iSolarCloud returns. Remove personal details before sharing!
|
|
300
|
+
if (logRaw)
|
|
301
|
+
this.log.info('RAW getPsDetail result_data = ' + JSON.stringify(data));
|
|
302
|
+
result = {};
|
|
303
|
+
result['solar'] = readWatts(data, 'curr_power');
|
|
304
|
+
for (_i = 0, _b = Object.keys(fields); _i < _b.length; _i++) {
|
|
305
|
+
key = _b[_i];
|
|
306
|
+
result[key] = readWatts(data, fields[key]);
|
|
307
|
+
}
|
|
308
|
+
return [2 /*return*/, result];
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
};
|
|
313
|
+
return ISolarCloudPowerStationsAPI;
|
|
314
|
+
}());
|
|
315
|
+
exports.ISolarCloudPowerStationsAPI = ISolarCloudPowerStationsAPI;
|
|
316
|
+
//# sourceMappingURL=isolarcloudapi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isolarcloudapi.js","sourceRoot":"","sources":["../src/isolarcloudapi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iCAAmC;AAEnC,kDAAqC;AACrC,sDAA+B;AAE/B,IAAM,UAAU,GAAG,0NAA0N,CAAA;AAC7O,IAAM,OAAO,GAAG,kCAAkC,CAAC;AACnD,IAAM,UAAU,GAAG,kCAAkC,CAAA;AAGrD,SAAgB,SAAS;IACrB,OAAO,KAAK,GAAG,eAAe,CAAC,CAAC,mBAAmB;AACvD,CAAC;AAFD,8BAEC;AAGD,SAAgB,UAAU,CAAI,IAAO,EAAE,GAAW;IAC9C,IAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IACxD,IAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACvC,OAAO,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE;QAC9B,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG;QACvB,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,KAAK;KAC9B,CAAC;SACG,UAAU,CAAC,QAAQ,EAAE;SACrB,WA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K;yBACjB,CAAC;wBAEoB,qBAAM,GAAG,CAAC,IAAI,CAAC,QAAQ,GAAG,qCAAqC,EAAE,IAAI,EAAE,MAAM,CAAC,EAAA;;wBAA9F,QAAQ,GAAQ,SAA8E;wBAEpG,IAAI,QAAQ,CAAC,YAAY,CAAC,KAAK,SAAS,EAAE;4BACtC,MAAM,IAAI,KAAK,CAAC,sCAAsC,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC;yBACpF;wBAEK,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC;wBAErC,gGAAgG;wBAChG,IAAI,MAAM;4BAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,gCAAgC,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;wBAE7E,MAAM,GAA0C,EAAE,CAAC;wBACzD,MAAM,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;wBAChD,WAAqC,EAAnB,KAAA,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAnB,cAAmB,EAAnB,IAAmB,EAAE;4BAA5B,GAAG;4BACV,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;yBAC9C;wBACD,sBAAO,MAAM,EAAC;;;;KACjB;IAEL,kCAAC;AAAD,CAAC,AAzDD,IAyDC;AAzDY,kEAA2B"}
|
package/dist/platform.js
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
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
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var PluginName = require('../package.json').name;
|
|
39
|
+
var PlatformName = 'ISolarCloud';
|
|
40
|
+
var hap;
|
|
41
|
+
var isolarcloudapi_1 = require("./isolarcloudapi");
|
|
42
|
+
// HomeKit's light sensor cannot be 0 (minimum is 0.0001)
|
|
43
|
+
var MIN_LEVEL = 0.0001;
|
|
44
|
+
// Eve app custom "Power Meter" service + "Consumption" (Watts) characteristic
|
|
45
|
+
var EVE_SERVICE_UUID = 'E863F007-079E-48FF-8F27-9C2605A29F52';
|
|
46
|
+
var EVE_WATTS_UUID = 'E863F10D-079E-48FF-8F27-9C2605A29F52';
|
|
47
|
+
var EVE_SUBTYPE = 'eve-power';
|
|
48
|
+
// Extra tiles, created only when a field path is set in config "fields"
|
|
49
|
+
var EXTRA_TILES = [
|
|
50
|
+
{ key: 'house', label: 'House Usage' },
|
|
51
|
+
{ key: 'gridImport', label: 'Grid Import' },
|
|
52
|
+
{ key: 'gridExport', label: 'Grid Export' },
|
|
53
|
+
{ key: 'battery', label: 'Battery' },
|
|
54
|
+
];
|
|
55
|
+
var PlatformISolarCloud = /** @class */ (function () {
|
|
56
|
+
function PlatformISolarCloud(log, config, api) {
|
|
57
|
+
var _this = this;
|
|
58
|
+
this.log = log;
|
|
59
|
+
this.config = config;
|
|
60
|
+
this.api = api;
|
|
61
|
+
this.server = "";
|
|
62
|
+
this.email = "";
|
|
63
|
+
this.password = "";
|
|
64
|
+
this.fields = {};
|
|
65
|
+
this.logRaw = false;
|
|
66
|
+
this.eve = false;
|
|
67
|
+
this.pollSeconds = 60;
|
|
68
|
+
this.accessories = {};
|
|
69
|
+
if (!config || !config["email"] || !config["password"]) {
|
|
70
|
+
this.log.error("Platform config incorrect or missing. Check the config.json file.");
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
this.server = config["server"];
|
|
74
|
+
this.email = config["email"];
|
|
75
|
+
this.password = config["password"];
|
|
76
|
+
this.fields = config["fields"] || {};
|
|
77
|
+
this.logRaw = !!config["logRaw"];
|
|
78
|
+
this.eve = !!config["eveCharacteristics"];
|
|
79
|
+
this.pollSeconds = Math.max(30, Number(config["pollSeconds"]) || 60);
|
|
80
|
+
this.log.info('Starting PlatformISolarCloud using homebridge API', api.version);
|
|
81
|
+
this.api.on("didFinishLaunching", function () { return _this.loadPowerStations(); });
|
|
82
|
+
}
|
|
83
|
+
PlatformISolarCloud.prototype.loadPowerStations = function () {
|
|
84
|
+
var _this = this;
|
|
85
|
+
var iSolarCloudAPI = new isolarcloudapi_1.ISolarCloudAPI(this.log, this.server, this.email, this.password);
|
|
86
|
+
iSolarCloudAPI.getPowerStations()
|
|
87
|
+
.then(function (powerStations) {
|
|
88
|
+
powerStations.forEach(function (powerStation) { return _this.setupPowerStation(powerStation); });
|
|
89
|
+
})["catch"](function (error) { return _this.log.error('Power stations error: ' + error.message); });
|
|
90
|
+
};
|
|
91
|
+
PlatformISolarCloud.prototype.setupPowerStation = function (powerStation) {
|
|
92
|
+
var _this = this;
|
|
93
|
+
var tiles = {};
|
|
94
|
+
// Solar tile keeps the ORIGINAL uuid so existing installs keep their tile
|
|
95
|
+
tiles['solar'] = this.getOrCreateTile(hap.uuid.generate(powerStation.id), powerStation.name);
|
|
96
|
+
EXTRA_TILES.forEach(function (tile) {
|
|
97
|
+
if (_this.fields[tile.key]) {
|
|
98
|
+
var name_1 = powerStation.name + ' ' + tile.label;
|
|
99
|
+
tiles[tile.key] = _this.getOrCreateTile(hap.uuid.generate(powerStation.id + '-' + tile.key), name_1);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
// One shared poll updates every tile (one login + one API call per cycle)
|
|
103
|
+
var pollInProgress = false;
|
|
104
|
+
var poll = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
105
|
+
var values_1, error_1;
|
|
106
|
+
var _this = this;
|
|
107
|
+
return __generator(this, function (_a) {
|
|
108
|
+
switch (_a.label) {
|
|
109
|
+
case 0:
|
|
110
|
+
if (pollInProgress)
|
|
111
|
+
return [2 /*return*/];
|
|
112
|
+
pollInProgress = true;
|
|
113
|
+
_a.label = 1;
|
|
114
|
+
case 1:
|
|
115
|
+
_a.trys.push([1, 3, 4, 5]);
|
|
116
|
+
return [4 /*yield*/, powerStation.getEnergyFlow(this.fields, this.logRaw)];
|
|
117
|
+
case 2:
|
|
118
|
+
values_1 = _a.sent();
|
|
119
|
+
Object.keys(tiles).forEach(function (key) {
|
|
120
|
+
var _a;
|
|
121
|
+
var watts = values_1[key];
|
|
122
|
+
if (watts === undefined) {
|
|
123
|
+
var source = key === 'solar' ? 'curr_power' : "fields.".concat(key);
|
|
124
|
+
_this.log.warn("No value found for \"".concat(key, "\" at \"").concat(source, "\" (enable logRaw to inspect the data)"));
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
_this.log.debug("".concat(powerStation.name, " ").concat(key, " = ").concat(watts, " W"));
|
|
128
|
+
tiles[key].sensor
|
|
129
|
+
.getCharacteristic(hap.Characteristic.CurrentAmbientLightLevel)
|
|
130
|
+
.updateValue(Math.max(Math.abs(watts), MIN_LEVEL));
|
|
131
|
+
(_a = tiles[key].eveWatts) === null || _a === void 0 ? void 0 : _a.updateValue(Math.abs(watts));
|
|
132
|
+
});
|
|
133
|
+
return [3 /*break*/, 5];
|
|
134
|
+
case 3:
|
|
135
|
+
error_1 = _a.sent();
|
|
136
|
+
this.log.error('Energy poll error: ' + (error_1 instanceof Error ? error_1.message : String(error_1)));
|
|
137
|
+
return [3 /*break*/, 5];
|
|
138
|
+
case 4:
|
|
139
|
+
pollInProgress = false;
|
|
140
|
+
return [7 /*endfinally*/];
|
|
141
|
+
case 5: return [2 /*return*/];
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}); };
|
|
145
|
+
poll();
|
|
146
|
+
setInterval(poll, this.pollSeconds * 1000);
|
|
147
|
+
};
|
|
148
|
+
PlatformISolarCloud.prototype.getOrCreateTile = function (uuid, name) {
|
|
149
|
+
var accessory = this.accessories[uuid];
|
|
150
|
+
if (!accessory) {
|
|
151
|
+
this.log.info('Creating new accessory', name);
|
|
152
|
+
accessory = new this.api.platformAccessory(name, uuid);
|
|
153
|
+
this.api.registerPlatformAccessories(PluginName, PlatformName, [accessory]);
|
|
154
|
+
this.accessories[uuid] = accessory;
|
|
155
|
+
}
|
|
156
|
+
accessory.getService(hap.Service.AccessoryInformation)
|
|
157
|
+
.setCharacteristic(hap.Characteristic.Name, name)
|
|
158
|
+
.setCharacteristic(hap.Characteristic.Manufacturer, "iSolarCloud")
|
|
159
|
+
.setCharacteristic(hap.Characteristic.SerialNumber, uuid.substring(0, 8))
|
|
160
|
+
.setCharacteristic(hap.Characteristic.Model, "Power Station")
|
|
161
|
+
.setCharacteristic(hap.Characteristic.FirmwareRevision, "1.0");
|
|
162
|
+
var sensor = accessory.getService(hap.Service.LightSensor);
|
|
163
|
+
if (!sensor) {
|
|
164
|
+
sensor = accessory.addService(hap.Service.LightSensor, name);
|
|
165
|
+
}
|
|
166
|
+
// Allow the full range (1 W up to 100 kW+) and the 0 case
|
|
167
|
+
sensor.getCharacteristic(hap.Characteristic.CurrentAmbientLightLevel)
|
|
168
|
+
.setProps({ minValue: MIN_LEVEL, maxValue: 100000000 })
|
|
169
|
+
.updateValue(MIN_LEVEL);
|
|
170
|
+
var tile = { sensor: sensor };
|
|
171
|
+
if (this.eve) {
|
|
172
|
+
tile.eveWatts = this.getOrCreateEveWatts(accessory, name);
|
|
173
|
+
}
|
|
174
|
+
return tile;
|
|
175
|
+
};
|
|
176
|
+
// Adds Eve's custom Power Meter service so the Eve app shows real Watts
|
|
177
|
+
PlatformISolarCloud.prototype.getOrCreateEveWatts = function (accessory, name) {
|
|
178
|
+
var service = accessory.getServiceById(EVE_SERVICE_UUID, EVE_SUBTYPE);
|
|
179
|
+
if (!service) {
|
|
180
|
+
service = new hap.Service(name + ' Power', EVE_SERVICE_UUID, EVE_SUBTYPE);
|
|
181
|
+
accessory.addService(service);
|
|
182
|
+
}
|
|
183
|
+
var watts = service.getCharacteristic(EVE_WATTS_UUID);
|
|
184
|
+
if (!watts) {
|
|
185
|
+
watts = new hap.Characteristic('Consumption', EVE_WATTS_UUID, {
|
|
186
|
+
format: "float" /* hap.Formats.FLOAT */,
|
|
187
|
+
unit: 'W',
|
|
188
|
+
minValue: 0,
|
|
189
|
+
maxValue: 100000000,
|
|
190
|
+
minStep: 0.1,
|
|
191
|
+
perms: ["pr" /* hap.Perms.PAIRED_READ */, "ev" /* hap.Perms.NOTIFY */]
|
|
192
|
+
});
|
|
193
|
+
service.addCharacteristic(watts);
|
|
194
|
+
}
|
|
195
|
+
return watts;
|
|
196
|
+
};
|
|
197
|
+
PlatformISolarCloud.prototype.configureAccessory = function (accessory) {
|
|
198
|
+
this.log.info('Remembered accessory, configuring handlers', accessory.displayName);
|
|
199
|
+
this.accessories[accessory.UUID] = accessory;
|
|
200
|
+
};
|
|
201
|
+
return PlatformISolarCloud;
|
|
202
|
+
}());
|
|
203
|
+
module.exports = function (api) {
|
|
204
|
+
hap = api.hap;
|
|
205
|
+
api.registerPlatform(PluginName, PlatformName, PlatformISolarCloud);
|
|
206
|
+
};
|
|
207
|
+
//# sourceMappingURL=platform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,IAAM,UAAU,GAAW,OAAO,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC;AAC3D,IAAM,YAAY,GAAG,aAAa,CAAC;AAEnC,IAAI,GAAQ,CAAC;AAOb,mDAA+E;AAE/E,yDAAyD;AACzD,IAAM,SAAS,GAAG,MAAM,CAAC;AAEzB,8EAA8E;AAC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|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Homebridge plugin for Sungrow iSolarCloud: solar, house usage and grid import/export as HomeKit sensors.",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"crypto-js": "^4.2.0",
|
|
7
|
+
"node-rsa": "^1.1.1"
|
|
8
|
+
},
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"@types/node": "^18.19.0",
|
|
11
|
+
"@types/crypto-js": "^4.2.2",
|
|
12
|
+
"@types/node-rsa": "^1.1.4",
|
|
13
|
+
"homebridge": "^1.3.9",
|
|
14
|
+
"rimraf": "^3.0.2",
|
|
15
|
+
"typescript": "^4.5.4"
|
|
16
|
+
},
|
|
17
|
+
"engines": {
|
|
18
|
+
"homebridge": "^1.6.0 || ^2.0.0-beta.0",
|
|
19
|
+
"node": ">=18.0.0"
|
|
20
|
+
},
|
|
21
|
+
"main": "dist/platform.js",
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "rimraf dist && tsc",
|
|
24
|
+
"prepublishOnly": "npm run build",
|
|
25
|
+
"test": "echo \"no tests\" && exit 0"
|
|
26
|
+
},
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/christopherguzik/homebridge-platform-isolarcloud.git"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"homebridge-plugin",
|
|
33
|
+
"homekit",
|
|
34
|
+
"isolarcloud",
|
|
35
|
+
"sungrow",
|
|
36
|
+
"solar",
|
|
37
|
+
"inverter",
|
|
38
|
+
"energy"
|
|
39
|
+
],
|
|
40
|
+
"author": "chris.guzik (forked from James Carvosso)",
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/christopherguzik/homebridge-platform-isolarcloud/issues"
|
|
44
|
+
},
|
|
45
|
+
"homepage": "https://github.com/christopherguzik/homebridge-platform-isolarcloud#readme",
|
|
46
|
+
"displayName": "iSolarCloud Energy",
|
|
47
|
+
"files": [
|
|
48
|
+
"dist",
|
|
49
|
+
"config.schema.json",
|
|
50
|
+
"README.md",
|
|
51
|
+
"CHANGELOG.md",
|
|
52
|
+
"LICENSE"
|
|
53
|
+
]
|
|
54
|
+
}
|