iobroker.tapo 0.0.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 TA2k <tombox2020@gmail.com>
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,63 @@
1
+ ![Logo](admin/tapo.png)
2
+
3
+ # ioBroker.tapo
4
+
5
+ [![NPM version](https://img.shields.io/npm/v/iobroker.tapo.svg)](https://www.npmjs.com/package/iobroker.tapo)
6
+ [![Downloads](https://img.shields.io/npm/dm/iobroker.tapo.svg)](https://www.npmjs.com/package/iobroker.tapo)
7
+ ![Number of Installations](https://iobroker.live/badges/tapo-installed.svg)
8
+ ![Current version in stable repository](https://iobroker.live/badges/tapo-stable.svg)
9
+ [![Dependency Status](https://img.shields.io/david/TA2k/iobroker.tapo.svg)](https://david-dm.org/TA2k/iobroker.tapo)
10
+
11
+ [![NPM](https://nodei.co/npm/iobroker.tapo.png?downloads=true)](https://nodei.co/npm/iobroker.tapo/)
12
+
13
+ **Tests:** ![Test and Release](https://github.com/TA2k/ioBroker.tapo/workflows/Test%20and%20Release/badge.svg)
14
+
15
+ ## tapo adapter for ioBroker
16
+
17
+ Adapter for TP-Link Tapo
18
+
19
+ based on
20
+ https://github.com/apatsufas/homebridge-tapo-p100
21
+
22
+ ## Loginablauf
23
+
24
+ Die Tapo Mail und Passwort eingeben. Es werden die Geräte via Cloud abgerufen, aber lokal gesteuert.
25
+ Wenn die IP nicht gefunden wird muss sie manuell unter tapo.0.id.ip gesetzt werden.
26
+
27
+ ## Steuern
28
+
29
+ tapo.0.id.remote auf true/false setzen steuert den jeweiligen Befehl. Der Befehl wird lokal an das Gerät gesendet.
30
+
31
+ ## Diskussion und Fragen
32
+
33
+ <https://forum.iobroker.net/topic/57336/test-adapter-tp-link-tapo/>
34
+
35
+ ## Changelog
36
+
37
+ ### 0.0.1
38
+
39
+ - (TA2k) initial release
40
+
41
+ ## License
42
+
43
+ MIT License
44
+
45
+ Copyright (c) 2022 TA2k <tombox2020@gmail.com>
46
+
47
+ Permission is hereby granted, free of charge, to any person obtaining a copy
48
+ of this software and associated documentation files (the "Software"), to deal
49
+ in the Software without restriction, including without limitation the rights
50
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
51
+ copies of the Software, and to permit persons to whom the Software is
52
+ furnished to do so, subject to the following conditions:
53
+
54
+ The above copyright notice and this permission notice shall be included in all
55
+ copies or substantial portions of the Software.
56
+
57
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
58
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
59
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
60
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
61
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
62
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
63
+ SOFTWARE.
@@ -0,0 +1,37 @@
1
+ <html>
2
+ <head>
3
+ <!-- Load ioBroker scripts and styles-->
4
+ <link rel="stylesheet" type="text/css" href="../../css/adapter.css" />
5
+ <link rel="stylesheet" type="text/css" href="../../lib/css/materialize.css" />
6
+
7
+ <script type="text/javascript" src="../../lib/js/jquery-3.2.1.min.js"></script>
8
+ <script type="text/javascript" src="../../socket.io/socket.io.js"></script>
9
+
10
+ <script type="text/javascript" src="../../js/translate.js"></script>
11
+ <script type="text/javascript" src="../../lib/js/materialize.js"></script>
12
+ <script type="text/javascript" src="../../js/adapter-settings.js"></script>
13
+
14
+ <script type="text/javascript">
15
+ // This will be called by the admin adapter when the settings page loads
16
+ function load(settings, onChange) {}
17
+ // This will be called by the admin adapter when the user presses the save button
18
+ function save(callback) {}
19
+ </script>
20
+ </head>
21
+ <body>
22
+ <div class="m adapter-container">
23
+ <div class="col s12 page">
24
+ <div class="row">
25
+ <div class="col s6">
26
+ <img src="tapo.png" class="logo" />
27
+ </div>
28
+ </div>
29
+ <div class="row">
30
+ <div class="col s12">
31
+ <p style="font-weight: bold; font-size: 1.2em; color: red">This adapter version has no support for "Admin 4 UI" configuration. Please switch to "Admin 5" UI</p>
32
+ </div>
33
+ </div>
34
+ </div>
35
+ </div>
36
+ </body>
37
+ </html>
@@ -0,0 +1,77 @@
1
+ {
2
+ "i18n": false,
3
+ "items": {
4
+ "username": {
5
+ "type": "text",
6
+ "label": {
7
+ "en": "App Email",
8
+ "de": "App-E-Mail",
9
+ "ru": "Электронная почта приложения",
10
+ "pt": "Email do aplicativo",
11
+ "nl": "App-e-mail",
12
+ "fr": "Courriel de l'application",
13
+ "it": "E-mail dell'app",
14
+ "es": "Correo electrónico de la aplicación",
15
+ "pl": "E-mail aplikacji",
16
+ "zh-cn": "应用电子邮件"
17
+ },
18
+ "newLine": true,
19
+ "sm": 3
20
+ },
21
+ "password": {
22
+ "type": "password",
23
+ "newLine": true,
24
+ "repeat": false,
25
+ "visible": true,
26
+ "sm": 3,
27
+ "label": {
28
+ "en": "App Password",
29
+ "de": "App-Passwort",
30
+ "ru": "Пароль приложения",
31
+ "pt": "Senha de app",
32
+ "nl": "App-wachtwoord",
33
+ "fr": "Mot de passe de l'application",
34
+ "it": "Password dell'app",
35
+ "es": "Contraseña de la aplicación",
36
+ "pl": "Hasło do aplikacji",
37
+ "zh-cn": "应用密码"
38
+ }
39
+ },
40
+
41
+ "interval": {
42
+ "type": "number",
43
+ "newLine": true,
44
+ "min": 1,
45
+ "sm": 2,
46
+ "label": {
47
+ "en": "Update interval (in seconds)",
48
+ "de": "Updateintervall (in Sekunden)",
49
+ "ru": "Интервал обновления (в секундах)",
50
+ "pt": "Intervalo de atualização (em segundos)",
51
+ "nl": "Update interval (in seconden)",
52
+ "fr": "Intervalle de mise à jour (en secondes)",
53
+ "it": "Intervallo di aggiornamento (in secondi)",
54
+ "es": "Intervalo de actualización (en segundos)",
55
+ "pl": "Update interval (ang.)",
56
+ "zh-cn": "最新间隔(第二期)"
57
+ }
58
+ },
59
+ "mfa": {
60
+ "type": "text",
61
+ "label": {
62
+ "en": "MFA Code",
63
+ "de": "MFA-Code",
64
+ "ru": "MFA код",
65
+ "pt": "Código MFA",
66
+ "nl": "MFA Code",
67
+ "fr": "Code MFA",
68
+ "it": "Codice MFA",
69
+ "es": "MFA Code",
70
+ "pl": "Kodeks",
71
+ "zh-cn": "MFA守则"
72
+ },
73
+ "newLine": true,
74
+ "sm": 3
75
+ }
76
+ }
77
+ }
package/admin/tapo.png ADDED
Binary file
@@ -0,0 +1,279 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var json2iob_exports = {};
26
+ __export(json2iob_exports, {
27
+ default: () => Json2iob
28
+ });
29
+ module.exports = __toCommonJS(json2iob_exports);
30
+ var import_json_bigint = __toESM(require("json-bigint"));
31
+ ({ storeAsString: true });
32
+ class Json2iob {
33
+ constructor(adapter) {
34
+ this.adapter = adapter;
35
+ this.alreadyCreatedObjects = {};
36
+ }
37
+ async parse(path, element, options) {
38
+ try {
39
+ if (element === null || element === void 0) {
40
+ this.adapter.log.debug("Cannot extract empty: " + path);
41
+ return;
42
+ }
43
+ const objectKeys = Object.keys(element);
44
+ if (!options || !options.write) {
45
+ if (!options) {
46
+ options = { write: false };
47
+ } else {
48
+ options["write"] = false;
49
+ }
50
+ }
51
+ if (typeof element === "string" || typeof element === "number") {
52
+ let name = element;
53
+ if (typeof element === "number") {
54
+ name = element.toString();
55
+ }
56
+ if (!this.alreadyCreatedObjects[path]) {
57
+ await this.adapter.setObjectNotExistsAsync(path, {
58
+ type: "state",
59
+ common: {
60
+ name,
61
+ role: this.getRole(element, options.write),
62
+ type: element !== null ? typeof element : "mixed",
63
+ write: options.write,
64
+ read: true
65
+ },
66
+ native: {}
67
+ }).then(() => {
68
+ }).catch((error) => {
69
+ this.adapter.log.error(error);
70
+ });
71
+ }
72
+ this.adapter.setState(path, element, true);
73
+ return;
74
+ }
75
+ if (!this.alreadyCreatedObjects[path]) {
76
+ await this.adapter.setObjectNotExistsAsync(path, {
77
+ type: "channel",
78
+ common: {
79
+ name: options.channelName || "",
80
+ write: false,
81
+ read: true
82
+ },
83
+ native: {}
84
+ }).then(() => {
85
+ options.channelName = void 0;
86
+ }).catch((error) => {
87
+ this.adapter.log.error(error);
88
+ });
89
+ }
90
+ if (Array.isArray(element)) {
91
+ await this.extractArray(element, "", path, options);
92
+ return;
93
+ }
94
+ for (const key of objectKeys) {
95
+ if (this.isJsonString(element[key]) && options.autoCast) {
96
+ element[key] = (0, import_json_bigint.default)({ storeAsString: true }).parse(element[key]);
97
+ }
98
+ if (Array.isArray(element[key])) {
99
+ await this.extractArray(element, key, path, options);
100
+ } else if (element[key] !== null && typeof element[key] === "object") {
101
+ await this.parse(path + "." + key, element[key], options);
102
+ } else {
103
+ if (!this.alreadyCreatedObjects[path + "." + key]) {
104
+ let objectName = key;
105
+ if (options.descriptions && options.descriptions[key]) {
106
+ objectName = options.descriptions[key];
107
+ }
108
+ const type = element[key] !== null ? typeof element[key] : "mixed";
109
+ const common = {
110
+ name: objectName,
111
+ role: this.getRole(element[key], options.write),
112
+ type,
113
+ write: options.write,
114
+ read: true
115
+ };
116
+ await this.adapter.setObjectNotExistsAsync(path + "." + key, {
117
+ type: "state",
118
+ common,
119
+ native: {}
120
+ }).then(() => {
121
+ }).catch((error) => {
122
+ this.adapter.log.error(error);
123
+ });
124
+ }
125
+ this.adapter.setState(path + "." + key, element[key], true);
126
+ }
127
+ }
128
+ } catch (error) {
129
+ this.adapter.log.error("Error extract keys: " + path + " " + JSON.stringify(element));
130
+ this.adapter.log.error(error);
131
+ }
132
+ }
133
+ async extractArray(element, key, path, options) {
134
+ try {
135
+ if (key) {
136
+ element = element[key];
137
+ }
138
+ for (let index in element) {
139
+ const arrayElement = element[index];
140
+ index = parseInt(index) + 1;
141
+ if (index < 10) {
142
+ index = "0" + index;
143
+ }
144
+ let arrayPath = key + index;
145
+ if (typeof arrayElement === "string") {
146
+ await this.parse(path + "." + key + "." + arrayElement, arrayElement, options);
147
+ continue;
148
+ }
149
+ if (typeof arrayElement[Object.keys(arrayElement)[0]] === "string") {
150
+ arrayPath = arrayElement[Object.keys(arrayElement)[0]];
151
+ }
152
+ for (const keyName of Object.keys(arrayElement)) {
153
+ if (keyName.endsWith("Id") && arrayElement[keyName] !== null) {
154
+ if (arrayElement[keyName] && arrayElement[keyName].replace) {
155
+ arrayPath = arrayElement[keyName].replace(/\./g, "");
156
+ } else {
157
+ arrayPath = arrayElement[keyName];
158
+ }
159
+ }
160
+ }
161
+ for (const keyName in Object.keys(arrayElement)) {
162
+ if (keyName.endsWith("Name")) {
163
+ if (arrayElement[keyName] && arrayElement[keyName].replace) {
164
+ arrayPath = arrayElement[keyName].replace(/\./g, "");
165
+ } else {
166
+ arrayPath = arrayElement[keyName];
167
+ }
168
+ }
169
+ }
170
+ if (arrayElement.id) {
171
+ if (arrayElement.id.replace) {
172
+ arrayPath = arrayElement.id.replace(/\./g, "");
173
+ } else {
174
+ arrayPath = arrayElement.id;
175
+ }
176
+ }
177
+ if (arrayElement.name) {
178
+ arrayPath = arrayElement.name.replace(/\./g, "");
179
+ }
180
+ if (arrayElement.label) {
181
+ arrayPath = arrayElement.label.replace(/\./g, "");
182
+ }
183
+ if (arrayElement.labelText) {
184
+ arrayPath = arrayElement.labelText.replace(/\./g, "");
185
+ }
186
+ if (arrayElement.start_date_time) {
187
+ arrayPath = arrayElement.start_date_time.replace(/\./g, "");
188
+ }
189
+ if (options.preferedArrayName && options.preferedArrayName.indexOf("+") !== -1) {
190
+ const preferedArrayNameArray = options.preferedArrayName.split("+");
191
+ if (arrayElement[preferedArrayNameArray[0]]) {
192
+ const element0 = arrayElement[preferedArrayNameArray[0]].replace(/\./g, "").replace(/\ /g, "");
193
+ let element1 = "";
194
+ if (preferedArrayNameArray[1].indexOf("/") !== -1) {
195
+ const subArray = preferedArrayNameArray[1].split("/");
196
+ const subElement = arrayElement[subArray[0]];
197
+ if (subElement && subElement[subArray[1]] !== void 0) {
198
+ element1 = subElement[subArray[1]];
199
+ } else if (arrayElement[subArray[1]] !== void 0) {
200
+ element1 = arrayElement[subArray[1]];
201
+ }
202
+ } else {
203
+ element1 = arrayElement[preferedArrayNameArray[1]].replace(/\./g, "").replace(/\ /g, "");
204
+ }
205
+ arrayPath = element0 + "-" + element1;
206
+ }
207
+ } else if (options.preferedArrayName && options.preferedArrayName.indexOf("/") !== -1) {
208
+ const preferedArrayNameArray = options.preferedArrayName.split("/");
209
+ const subElement = arrayElement[preferedArrayNameArray[0]];
210
+ if (subElement) {
211
+ arrayPath = subElement[preferedArrayNameArray[1]].replace(/\./g, "").replace(/\ /g, "");
212
+ }
213
+ } else if (options.preferedArrayName && arrayElement[options.preferedArrayName]) {
214
+ arrayPath = arrayElement[options.preferedArrayName].replace(/\./g, "");
215
+ }
216
+ if (options.forceIndex) {
217
+ arrayPath = key + index;
218
+ }
219
+ if (!options.forceIndex && Object.keys(arrayElement).length === 2 && typeof Object.keys(arrayElement)[0] === "string" && typeof Object.keys(arrayElement)[1] === "string" && typeof arrayElement[Object.keys(arrayElement)[0]] !== "object" && typeof arrayElement[Object.keys(arrayElement)[1]] !== "object" && arrayElement[Object.keys(arrayElement)[0]] !== "null") {
220
+ let subKey = arrayElement[Object.keys(arrayElement)[0]];
221
+ const subValue = arrayElement[Object.keys(arrayElement)[1]];
222
+ const subName = Object.keys(arrayElement)[0] + " " + Object.keys(arrayElement)[1];
223
+ if (key) {
224
+ subKey = key + "." + subKey;
225
+ }
226
+ if (!this.alreadyCreatedObjects[path + "." + subKey]) {
227
+ await this.adapter.setObjectNotExistsAsync(path + "." + subKey, {
228
+ type: "state",
229
+ common: {
230
+ name: subName,
231
+ role: this.getRole(subValue, options.write),
232
+ type: subValue !== null ? typeof subValue : "mixed",
233
+ write: options.write,
234
+ read: true
235
+ },
236
+ native: {}
237
+ }).then(() => {
238
+ });
239
+ }
240
+ this.adapter.setState(path + "." + subKey, subValue, true);
241
+ continue;
242
+ }
243
+ await this.parse(path + "." + arrayPath, arrayElement, options);
244
+ }
245
+ } catch (error) {
246
+ this.adapter.log.error("Cannot extract array " + path);
247
+ this.adapter.log.error(error);
248
+ }
249
+ }
250
+ isJsonString(str) {
251
+ try {
252
+ JSON.parse(str);
253
+ } catch (e) {
254
+ return false;
255
+ }
256
+ return true;
257
+ }
258
+ getRole(element, write) {
259
+ if (typeof element === "boolean" && !write) {
260
+ return "indicator";
261
+ }
262
+ if (typeof element === "boolean" && write) {
263
+ return "switch";
264
+ }
265
+ if (typeof element === "number" && !write) {
266
+ return "value";
267
+ }
268
+ if (typeof element === "number" && write) {
269
+ return "level";
270
+ }
271
+ if (typeof element === "string") {
272
+ return "text";
273
+ }
274
+ return "state";
275
+ }
276
+ }
277
+ // Annotate the CommonJS export names for ESM import in node:
278
+ 0 && (module.exports = {});
279
+ //# sourceMappingURL=json2iob.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/lib/json2iob.ts"],
4
+ "sourcesContent": ["//v1.5\n/*\noptions:\nwrite //set common write variable to true\nforceIndex //instead of trying to find names for array entries, use the index as the name\nchannelName //set name of the root channel\npreferedArrayName //set key to use this as an array entry name\nautoCast (true false) // make JSON.parse to parse numbers correctly\ndescriptions: Object of names for state keys\n*/\nimport JSONbig from \"json-bigint\";\n({ storeAsString: true });\nexport default class Json2iob {\n adapter: any;\n alreadyCreatedObjects: any;\n constructor(adapter: any) {\n this.adapter = adapter;\n this.alreadyCreatedObjects = {};\n }\n\n async parse(\n path: string,\n element: string | null | undefined,\n options?: {\n [x: string]: any;\n write?: any;\n channelName?: any;\n autoCast?: any;\n descriptions?: any;\n preferedArrayName?: any;\n forceIndex?: any;\n },\n ): Promise<void> {\n try {\n if (element === null || element === undefined) {\n this.adapter.log.debug(\"Cannot extract empty: \" + path);\n return;\n }\n\n const objectKeys = Object.keys(element);\n\n if (!options || !options.write) {\n if (!options) {\n options = { write: false };\n } else {\n options[\"write\"] = false;\n }\n }\n\n if (typeof element === \"string\" || typeof element === \"number\") {\n let name = element;\n if (typeof element === \"number\") {\n name = element.toString();\n }\n if (!this.alreadyCreatedObjects[path]) {\n await this.adapter\n .setObjectNotExistsAsync(path, {\n type: \"state\",\n common: {\n name: name,\n role: this.getRole(element, options.write),\n type: element !== null ? typeof element : \"mixed\",\n write: options.write,\n read: true,\n },\n native: {},\n })\n .then(() => {\n // this.alreadyCreatedObjects[path] = true;\n })\n .catch((error: any) => {\n this.adapter.log.error(error);\n });\n }\n\n this.adapter.setState(path, element, true);\n\n return;\n }\n if (!this.alreadyCreatedObjects[path]) {\n await this.adapter\n .setObjectNotExistsAsync(path, {\n type: \"channel\",\n common: {\n name: options.channelName || \"\",\n write: false,\n read: true,\n },\n native: {},\n })\n .then(() => {\n // this.alreadyCreatedObjects[path] = true;\n options.channelName = undefined;\n })\n .catch((error: any) => {\n this.adapter.log.error(error);\n });\n }\n if (Array.isArray(element)) {\n await this.extractArray(element, \"\", path, options);\n return;\n }\n\n for (const key of objectKeys) {\n if (this.isJsonString(element[key]) && options.autoCast) {\n element[key] = JSONbig({ storeAsString: true }).parse(element[key]);\n }\n\n if (Array.isArray(element[key])) {\n await this.extractArray(element, key, path, options);\n } else if (element[key] !== null && typeof element[key] === \"object\") {\n await this.parse(path + \".\" + key, element[key], options);\n } else {\n if (!this.alreadyCreatedObjects[path + \".\" + key]) {\n let objectName = key;\n if (options.descriptions && options.descriptions[key]) {\n objectName = options.descriptions[key];\n }\n const type = element[key] !== null ? typeof element[key] : \"mixed\";\n const common = {\n name: objectName,\n role: this.getRole(element[key], options.write),\n type: type,\n write: options.write,\n read: true,\n };\n\n await this.adapter\n .setObjectNotExistsAsync(path + \".\" + key, {\n type: \"state\",\n common: common,\n native: {},\n })\n .then(() => {\n // this.alreadyCreatedObjects[path + \".\" + key] = true;\n })\n .catch((error: any) => {\n this.adapter.log.error(error);\n });\n }\n this.adapter.setState(path + \".\" + key, element[key], true);\n }\n }\n } catch (error) {\n this.adapter.log.error(\"Error extract keys: \" + path + \" \" + JSON.stringify(element));\n this.adapter.log.error(error);\n }\n }\n async extractArray(\n element: any,\n key: string,\n path: string,\n options?: {\n [x: string]: any;\n write: any;\n channelName?: any;\n autoCast?: any;\n descriptions?: any;\n preferedArrayName?: any;\n forceIndex?: any;\n },\n ): Promise<void> {\n try {\n if (key) {\n element = element[key];\n }\n for (let index in element) {\n const arrayElement = element[index];\n index = parseInt(index) + 1;\n if (index < 10) {\n index = \"0\" + index;\n }\n let arrayPath = key + index;\n if (typeof arrayElement === \"string\") {\n await this.parse(path + \".\" + key + \".\" + arrayElement, arrayElement, options);\n continue;\n }\n if (typeof arrayElement[Object.keys(arrayElement)[0]] === \"string\") {\n arrayPath = arrayElement[Object.keys(arrayElement)[0]];\n }\n for (const keyName of Object.keys(arrayElement)) {\n if (keyName.endsWith(\"Id\") && arrayElement[keyName] !== null) {\n if (arrayElement[keyName] && arrayElement[keyName].replace) {\n arrayPath = arrayElement[keyName].replace(/\\./g, \"\");\n } else {\n arrayPath = arrayElement[keyName];\n }\n }\n }\n for (const keyName in Object.keys(arrayElement)) {\n if (keyName.endsWith(\"Name\")) {\n if (arrayElement[keyName] && arrayElement[keyName].replace) {\n arrayPath = arrayElement[keyName].replace(/\\./g, \"\");\n } else {\n arrayPath = arrayElement[keyName];\n }\n }\n }\n\n if (arrayElement.id) {\n if (arrayElement.id.replace) {\n arrayPath = arrayElement.id.replace(/\\./g, \"\");\n } else {\n arrayPath = arrayElement.id;\n }\n }\n if (arrayElement.name) {\n arrayPath = arrayElement.name.replace(/\\./g, \"\");\n }\n if (arrayElement.label) {\n arrayPath = arrayElement.label.replace(/\\./g, \"\");\n }\n if (arrayElement.labelText) {\n arrayPath = arrayElement.labelText.replace(/\\./g, \"\");\n }\n if (arrayElement.start_date_time) {\n arrayPath = arrayElement.start_date_time.replace(/\\./g, \"\");\n }\n if (options.preferedArrayName && options.preferedArrayName.indexOf(\"+\") !== -1) {\n const preferedArrayNameArray = options.preferedArrayName.split(\"+\");\n if (arrayElement[preferedArrayNameArray[0]]) {\n const element0 = arrayElement[preferedArrayNameArray[0]].replace(/\\./g, \"\").replace(/\\ /g, \"\");\n let element1 = \"\";\n if (preferedArrayNameArray[1].indexOf(\"/\") !== -1) {\n const subArray = preferedArrayNameArray[1].split(\"/\");\n const subElement = arrayElement[subArray[0]];\n if (subElement && subElement[subArray[1]] !== undefined) {\n element1 = subElement[subArray[1]];\n } else if (arrayElement[subArray[1]] !== undefined) {\n element1 = arrayElement[subArray[1]];\n }\n } else {\n element1 = arrayElement[preferedArrayNameArray[1]].replace(/\\./g, \"\").replace(/\\ /g, \"\");\n }\n arrayPath = element0 + \"-\" + element1;\n }\n } else if (options.preferedArrayName && options.preferedArrayName.indexOf(\"/\") !== -1) {\n const preferedArrayNameArray = options.preferedArrayName.split(\"/\");\n const subElement = arrayElement[preferedArrayNameArray[0]];\n if (subElement) {\n arrayPath = subElement[preferedArrayNameArray[1]].replace(/\\./g, \"\").replace(/\\ /g, \"\");\n }\n } else if (options.preferedArrayName && arrayElement[options.preferedArrayName]) {\n arrayPath = arrayElement[options.preferedArrayName].replace(/\\./g, \"\");\n }\n\n if (options.forceIndex) {\n arrayPath = key + index;\n }\n //special case array with 2 string objects\n if (\n !options.forceIndex &&\n Object.keys(arrayElement).length === 2 &&\n typeof Object.keys(arrayElement)[0] === \"string\" &&\n typeof Object.keys(arrayElement)[1] === \"string\" &&\n typeof arrayElement[Object.keys(arrayElement)[0]] !== \"object\" &&\n typeof arrayElement[Object.keys(arrayElement)[1]] !== \"object\" &&\n arrayElement[Object.keys(arrayElement)[0]] !== \"null\"\n ) {\n let subKey = arrayElement[Object.keys(arrayElement)[0]];\n const subValue = arrayElement[Object.keys(arrayElement)[1]];\n const subName = Object.keys(arrayElement)[0] + \" \" + Object.keys(arrayElement)[1];\n if (key) {\n subKey = key + \".\" + subKey;\n }\n if (!this.alreadyCreatedObjects[path + \".\" + subKey]) {\n await this.adapter\n .setObjectNotExistsAsync(path + \".\" + subKey, {\n type: \"state\",\n common: {\n name: subName,\n role: this.getRole(subValue, options.write),\n type: subValue !== null ? typeof subValue : \"mixed\",\n write: options.write,\n read: true,\n },\n native: {},\n })\n .then(() => {\n // this.alreadyCreatedObjects[path + \".\" + subKey] = true;\n });\n }\n this.adapter.setState(path + \".\" + subKey, subValue, true);\n continue;\n }\n await this.parse(path + \".\" + arrayPath, arrayElement, options);\n }\n } catch (error) {\n this.adapter.log.error(\"Cannot extract array \" + path);\n this.adapter.log.error(error);\n }\n }\n isJsonString(str: string): boolean {\n try {\n JSON.parse(str);\n } catch (e) {\n return false;\n }\n return true;\n }\n getRole(element: string, write: any): string {\n if (typeof element === \"boolean\" && !write) {\n return \"indicator\";\n }\n if (typeof element === \"boolean\" && write) {\n return \"switch\";\n }\n if (typeof element === \"number\" && !write) {\n return \"value\";\n }\n if (typeof element === \"number\" && write) {\n return \"level\";\n }\n if (typeof element === \"string\") {\n return \"text\";\n }\n return \"state\";\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,yBAAoB;AAAA,CACnB,EAAE,eAAe,KAAK;AACvB,MAAO,SAAuB;AAAA,EAG5B,YAAY,SAAc;AACxB,SAAK,UAAU;AACf,SAAK,wBAAwB,CAAC;AAAA,EAChC;AAAA,EAEA,MAAM,MACJ,MACA,SACA,SASe;AACf,QAAI;AACF,UAAI,YAAY,QAAQ,YAAY,QAAW;AAC7C,aAAK,QAAQ,IAAI,MAAM,2BAA2B,IAAI;AACtD;AAAA,MACF;AAEA,YAAM,aAAa,OAAO,KAAK,OAAO;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,cAAM,KAAK,MAAM,OAAO,MAAM,WAAW,cAAc,OAAO;AAAA,MAChE;AAAA,IACF,SAAS,OAAP;AACA,WAAK,QAAQ,IAAI,MAAM,0BAA0B,IAAI;AACrD,WAAK,QAAQ,IAAI,MAAM,KAAK;AAAA,IAC9B;AAAA,EACF;AAAA,EACA,aAAa,KAAsB;AACjC,QAAI;AACF,WAAK,MAAM,GAAG;AAAA,IAChB,SAAS,GAAP;AACA,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AAAA,EACA,QAAQ,SAAiB,OAAoB;AAC3C,QAAI,OAAO,YAAY,aAAa,CAAC,OAAO;AAC1C,aAAO;AAAA,IACT;AACA,QAAI,OAAO,YAAY,aAAa,OAAO;AACzC,aAAO;AAAA,IACT;AACA,QAAI,OAAO,YAAY,YAAY,CAAC,OAAO;AACzC,aAAO;AAAA,IACT;AACA,QAAI,OAAO,YAAY,YAAY,OAAO;AACxC,aAAO;AAAA,IACT;AACA,QAAI,OAAO,YAAY,UAAU;AAC/B,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AACF;",
6
+ "names": ["JSONbig"]
7
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var energyUsage_exports = {};
20
+ __export(energyUsage_exports, {
21
+ EnergyUsage: () => EnergyUsage
22
+ });
23
+ module.exports = __toCommonJS(energyUsage_exports);
24
+ class EnergyUsage {
25
+ }
26
+ // Annotate the CommonJS export names for ESM import in node:
27
+ 0 && (module.exports = {
28
+ EnergyUsage
29
+ });
30
+ //# sourceMappingURL=energyUsage.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/lib/utils/energyUsage.ts"],
4
+ "sourcesContent": ["export class EnergyUsage{\n current_power!: number;\n}"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,YAAW;AAExB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var l510e_exports = {};
26
+ __export(l510e_exports, {
27
+ default: () => L510E
28
+ });
29
+ module.exports = __toCommonJS(l510e_exports);
30
+ var import_p100 = __toESM(require("./p100"));
31
+ class L510E extends import_p100.default {
32
+ constructor(log, ipAddress, email, password, timeout) {
33
+ super(log, ipAddress, email, password, timeout);
34
+ this.log = log;
35
+ this.ipAddress = ipAddress;
36
+ this.email = email;
37
+ this.password = password;
38
+ this.timeout = timeout;
39
+ this.log.debug("Constructing L510E on host: " + ipAddress);
40
+ }
41
+ async getDeviceInfo() {
42
+ return super.getDeviceInfo().then(() => {
43
+ return this.getSysInfo();
44
+ });
45
+ }
46
+ async setBrightness(brightness) {
47
+ const payload = '{"method": "set_device_info","params": {"brightness": ' + brightness + '},"requestTimeMils": ' + Math.round(Date.now() * 1e3) + "};";
48
+ return this.sendRequest(payload);
49
+ }
50
+ setSysInfo(sysInfo) {
51
+ this._lightSysInfo = sysInfo;
52
+ this._lightSysInfo.last_update = Date.now();
53
+ }
54
+ getSysInfo() {
55
+ return this._lightSysInfo;
56
+ }
57
+ }
58
+ // Annotate the CommonJS export names for ESM import in node:
59
+ 0 && (module.exports = {});
60
+ //# sourceMappingURL=l510e.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/lib/utils/l510e.ts"],
4
+ "sourcesContent": ["import { LightSysinfo } from \"./types\";\nimport P100 from \"./p100\";\n\nexport default class L510E extends P100 {\n private _lightSysInfo!: LightSysinfo;\n\n constructor(\n public readonly log: any,\n public readonly ipAddress: string,\n public readonly email: string,\n public readonly password: string,\n public readonly timeout: number\n ) {\n super(log, ipAddress, email, password, timeout);\n this.log.debug(\"Constructing L510E on host: \" + ipAddress);\n }\n\n async getDeviceInfo(): Promise<LightSysinfo> {\n return super.getDeviceInfo().then(() => {\n return this.getSysInfo();\n });\n }\n\n async setBrightness(brightness: number): Promise<boolean> {\n const payload =\n \"{\" +\n '\"method\": \"set_device_info\",' +\n '\"params\": {' +\n '\"brightness\": ' +\n brightness +\n \"},\" +\n '\"requestTimeMils\": ' +\n Math.round(Date.now() * 1000) +\n \"\" +\n \"};\";\n\n return this.sendRequest(payload);\n }\n\n protected setSysInfo(sysInfo: LightSysinfo) {\n this._lightSysInfo = sysInfo;\n this._lightSysInfo.last_update = Date.now();\n }\n\n public getSysInfo(): LightSysinfo {\n return this._lightSysInfo;\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAiB;AAEjB,MAAO,cAA4B,YAAAA,QAAK;AAAA,EAGtC,YACkB,KACA,WACA,OACA,UACA,SAChB;AACA,UAAM,KAAK,WAAW,OAAO,UAAU,OAAO;AAN9B;AACA;AACA;AACA;AACA;AAGhB,SAAK,IAAI,MAAM,iCAAiC,SAAS;AAAA,EAC3D;AAAA,EAEA,MAAM,gBAAuC;AAC3C,WAAO,MAAM,cAAc,EAAE,KAAK,MAAM;AACtC,aAAO,KAAK,WAAW;AAAA,IACzB,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,cAAc,YAAsC;AACxD,UAAM,UACJ,2DAIA,aACA,0BAEA,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI,IAE5B;AAEF,WAAO,KAAK,YAAY,OAAO;AAAA,EACjC;AAAA,EAEU,WAAW,SAAuB;AAC1C,SAAK,gBAAgB;AACrB,SAAK,cAAc,cAAc,KAAK,IAAI;AAAA,EAC5C;AAAA,EAEO,aAA2B;AAChC,WAAO,KAAK;AAAA,EACd;AACF;",
6
+ "names": ["P100"]
7
+ }