iobroker.influxdb 3.1.1 → 3.1.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/README.md +1 -1
- package/io-package.json +2 -2
- package/main.js +8 -1
- package/package.json +4 -4
- package/lib/tools.js +0 -99
package/README.md
CHANGED
|
@@ -450,7 +450,7 @@ sendTo('influxdb.0', 'getEnabledDPs', {}, function (result) {
|
|
|
450
450
|
-->
|
|
451
451
|
|
|
452
452
|
## Changelog
|
|
453
|
-
### 3.1.
|
|
453
|
+
### 3.1.2 (2022-05-31)
|
|
454
454
|
* (Apollon77) Workaround an admin issue when testing connection to InfluxDB
|
|
455
455
|
|
|
456
456
|
### 3.1.0 (2022-05-27)
|
package/io-package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"pl": "Logowanie stanów do InfluxDB",
|
|
14
14
|
"zh-cn": "将状态记录到InfluxDB中"
|
|
15
15
|
},
|
|
16
|
-
"version": "3.1.
|
|
16
|
+
"version": "3.1.2",
|
|
17
17
|
"title": "Logging data with InfluxDB",
|
|
18
18
|
"titleLang": {
|
|
19
19
|
"en": "Logging data with InfluxDB",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"zh-cn": "使用InfluxDB记录数据"
|
|
29
29
|
},
|
|
30
30
|
"news": {
|
|
31
|
-
"3.1.
|
|
31
|
+
"3.1.2": {
|
|
32
32
|
"en": "Workaround an admin issue when testing connection to InfluxDB",
|
|
33
33
|
"de": "Umgehung eines Administratorproblems beim Testen der Verbindung zu InfluxDB",
|
|
34
34
|
"ru": "Обход проблемы администратора при тестировании подключения к InfluxDB",
|
package/main.js
CHANGED
|
@@ -13,7 +13,14 @@ const [appName, adapterName] = require('./package.json').name.split('.');
|
|
|
13
13
|
const Aggregate = require('./lib/aggregate.js');
|
|
14
14
|
const dataDir = path.normalize(`${utils.controllerDir}/${require(`${utils.controllerDir}/lib/tools`).getDefaultDataDir()}`);
|
|
15
15
|
const cacheFile = `${dataDir}influxdata.json`;
|
|
16
|
-
|
|
16
|
+
|
|
17
|
+
function isObject(it) {
|
|
18
|
+
// This is necessary because:
|
|
19
|
+
// typeof null === 'object'
|
|
20
|
+
// typeof [] === 'object'
|
|
21
|
+
// [] instanceof Object === true
|
|
22
|
+
return Object.prototype.toString.call(it) === '[object Object]';
|
|
23
|
+
}
|
|
17
24
|
|
|
18
25
|
let adapter;
|
|
19
26
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iobroker.influxdb",
|
|
3
3
|
"description": "Log states in InfluxDB",
|
|
4
|
-
"version": "3.1.
|
|
4
|
+
"version": "3.1.2",
|
|
5
5
|
"author": "bluefox <dogafox@gmail.com>",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"bluefox <dogafox@gmail.com>",
|
|
@@ -29,8 +29,7 @@
|
|
|
29
29
|
"@alcalzone/release-script": "^3.5.9",
|
|
30
30
|
"@alcalzone/release-script-plugin-iobroker": "^3.5.9",
|
|
31
31
|
"@alcalzone/release-script-plugin-license": "^3.5.9",
|
|
32
|
-
"
|
|
33
|
-
"gulp": "^4.0.2",
|
|
32
|
+
"@iobroker/adapter-dev": "^1.0.0",
|
|
34
33
|
"mocha": "^9.2.2",
|
|
35
34
|
"chai": "^4.3.6"
|
|
36
35
|
},
|
|
@@ -53,7 +52,8 @@
|
|
|
53
52
|
"release": "release-script",
|
|
54
53
|
"release-patch": "release-script patch --yes",
|
|
55
54
|
"release-minor": "release-script minor --yes",
|
|
56
|
-
"release-major": "release-script major --yes"
|
|
55
|
+
"release-major": "release-script major --yes",
|
|
56
|
+
"translate": "translate-adapter"
|
|
57
57
|
},
|
|
58
58
|
"license": "MIT"
|
|
59
59
|
}
|
package/lib/tools.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
const axios = require('axios').default;
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Tests whether the given variable is a real object and not an Array
|
|
5
|
-
* @param {any} it The variable to test
|
|
6
|
-
* @returns {it is Record<string, any>}
|
|
7
|
-
*/
|
|
8
|
-
function isObject(it) {
|
|
9
|
-
// This is necessary because:
|
|
10
|
-
// typeof null === 'object'
|
|
11
|
-
// typeof [] === 'object'
|
|
12
|
-
// [] instanceof Object === true
|
|
13
|
-
return Object.prototype.toString.call(it) === '[object Object]';
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Tests whether the given variable is really an Array
|
|
18
|
-
* @param {any} it The variable to test
|
|
19
|
-
* @returns {it is any[]}
|
|
20
|
-
*/
|
|
21
|
-
function isArray(it) {
|
|
22
|
-
if (typeof Array.isArray === 'function') return Array.isArray(it);
|
|
23
|
-
return Object.prototype.toString.call(it) === '[object Array]';
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Translates text to the target language. Automatically chooses the right translation API.
|
|
28
|
-
* @param {string} text The text to translate
|
|
29
|
-
* @param {string} targetLang The target languate
|
|
30
|
-
* @param {string} [yandexApiKey] The yandex API key. You can create one for free at https://translate.yandex.com/developers
|
|
31
|
-
* @returns {Promise<string>}
|
|
32
|
-
*/
|
|
33
|
-
async function translateText(text, targetLang, yandexApiKey) {
|
|
34
|
-
if (targetLang === 'en') {
|
|
35
|
-
return text;
|
|
36
|
-
} else if (!text) {
|
|
37
|
-
return '';
|
|
38
|
-
}
|
|
39
|
-
if (yandexApiKey) {
|
|
40
|
-
return translateYandex(text, targetLang, yandexApiKey);
|
|
41
|
-
} else {
|
|
42
|
-
return translateGoogle(text, targetLang);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Translates text with Yandex API
|
|
48
|
-
* @param {string} text The text to translate
|
|
49
|
-
* @param {string} targetLang The target languate
|
|
50
|
-
* @param {string} apiKey The yandex API key. You can create one for free at https://translate.yandex.com/developers
|
|
51
|
-
* @returns {Promise<string>}
|
|
52
|
-
*/
|
|
53
|
-
async function translateYandex(text, targetLang, apiKey) {
|
|
54
|
-
if (targetLang === 'zh-cn') {
|
|
55
|
-
targetLang = 'zh';
|
|
56
|
-
}
|
|
57
|
-
try {
|
|
58
|
-
const url = `https://translate.yandex.net/api/v1.5/tr.json/translate?key=${apiKey}&text=${encodeURIComponent(text)}&lang=en-${targetLang}`;
|
|
59
|
-
const response = await axios({url, timeout: 15000});
|
|
60
|
-
if (response.data && response.data.text && isArray(response.data.text)) {
|
|
61
|
-
return response.data.text[0];
|
|
62
|
-
}
|
|
63
|
-
throw new Error('Invalid response for translate request');
|
|
64
|
-
} catch (e) {
|
|
65
|
-
throw new Error(`Could not translate to "${targetLang}": ${e}`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Translates text with Google API
|
|
71
|
-
* @param {string} text The text to translate
|
|
72
|
-
* @param {string} targetLang The target languate
|
|
73
|
-
* @returns {Promise<string>}
|
|
74
|
-
*/
|
|
75
|
-
async function translateGoogle(text, targetLang) {
|
|
76
|
-
try {
|
|
77
|
-
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`;
|
|
78
|
-
const response = await axios({url, timeout: 15000});
|
|
79
|
-
if (isArray(response.data)) {
|
|
80
|
-
// we got a valid response
|
|
81
|
-
return response.data[0][0][0];
|
|
82
|
-
}
|
|
83
|
-
throw new Error('Invalid response for translate request');
|
|
84
|
-
} catch (e) {
|
|
85
|
-
if (e.response && e.response.status === 429) {
|
|
86
|
-
throw new Error(
|
|
87
|
-
`Could not translate to "${targetLang}": Rate-limited by Google Translate`
|
|
88
|
-
);
|
|
89
|
-
} else {
|
|
90
|
-
throw new Error(`Could not translate to "${targetLang}": ${e}`);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
module.exports = {
|
|
96
|
-
isArray,
|
|
97
|
-
isObject,
|
|
98
|
-
translateText
|
|
99
|
-
};
|