iobroker.zigbee 3.1.2 → 3.1.5
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/README.md +19 -1
- package/admin/admin.js +1020 -729
- package/admin/index_m.html +55 -155
- package/admin/tab_m.html +161 -242
- package/io-package.json +42 -39
- package/lib/DeviceDebug.js +24 -2
- package/lib/binding.js +7 -7
- package/lib/commands.js +319 -255
- package/lib/developer.js +1 -1
- package/lib/devices.js +2 -2
- package/lib/exclude.js +1 -1
- package/lib/exposes.js +54 -24
- package/lib/groups.js +26 -28
- package/lib/localConfig.js +8 -8
- package/lib/networkmap.js +10 -2
- package/lib/statescontroller.js +135 -91
- package/lib/zbDelayedAction.js +4 -4
- package/lib/zbDeviceAvailability.js +32 -33
- package/lib/zbDeviceConfigure.js +7 -0
- package/lib/zbDeviceEvent.js +38 -6
- package/lib/zigbeecontroller.js +98 -46
- package/main.js +43 -57
- package/package.json +6 -9
- package/lib/tools.js +0 -55
package/lib/tools.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const axios = require('axios');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Tests whether the given variable is a real object and not an Array
|
|
7
|
-
* @param {any} it The variable to test
|
|
8
|
-
* @returns {it is Record<string, any>}
|
|
9
|
-
*/
|
|
10
|
-
function isObject(it) {
|
|
11
|
-
// This is necessary because:
|
|
12
|
-
// typeof null === 'object'
|
|
13
|
-
// typeof [] === 'object'
|
|
14
|
-
// [] instanceof Object === true
|
|
15
|
-
return Object.prototype.toString.call(it) === '[object Object]';
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Tests whether the given variable is really an Array
|
|
20
|
-
* @param {any} it The variable to test
|
|
21
|
-
* @returns {it is any[]}
|
|
22
|
-
*/
|
|
23
|
-
function isArray(it) {
|
|
24
|
-
if (Array.isArray != null)
|
|
25
|
-
return Array.isArray(it);
|
|
26
|
-
return Object.prototype.toString.call(it) === '[object Array]';
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Translates text using the Google Translate API
|
|
31
|
-
* @param {string} text The text to translate
|
|
32
|
-
* @param {string} targetLang The target languate
|
|
33
|
-
* @returns {Promise<string>}
|
|
34
|
-
*/
|
|
35
|
-
async function translateText(text, targetLang) {
|
|
36
|
-
if (targetLang === 'en')
|
|
37
|
-
return text;
|
|
38
|
-
try {
|
|
39
|
-
const url = `http://translate.googleapis.com/translate_a/single?client=gtx&sl=en&tl=${targetLang}&dt=t&q=${encodeURIComponent(text)}&ie=UTF-8&oe=UTF-8`;
|
|
40
|
-
const response = await axios({url, timeout: 5000});
|
|
41
|
-
if (isArray(response.data)) {
|
|
42
|
-
// we got a valid response
|
|
43
|
-
return response.data[0][0][0];
|
|
44
|
-
}
|
|
45
|
-
throw new Error('Invalid response for translate request');
|
|
46
|
-
} catch (e) {
|
|
47
|
-
throw new Error(`Could not translate to "${targetLang}": ${e}`);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
module.exports = {
|
|
52
|
-
isArray,
|
|
53
|
-
isObject,
|
|
54
|
-
translateText
|
|
55
|
-
};
|