iobroker.easee 2.0.0-alpha.0 → 2.0.0-alpha.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/README.md CHANGED
@@ -38,7 +38,7 @@ This adapter would not have been possible without the great work of @Newan (http
38
38
  Placeholder for the next version (at the beginning of the line):
39
39
  ### **WORK IN PROGRESS**
40
40
  -->
41
- ### 2.0.0-alpha.0 (2026-10-17)
41
+ ### 2.0.0-alpha.1 (2026-10-17)
42
42
  - (mcm1957) Adapter has been migrated into the iobroker-community-adapter-organisation
43
43
  - (iobroker-bot) Adapter requires node.js >= 22 now.
44
44
  - (copilot) Adapter requires js-controller >= 7.2.2 now
@@ -59,6 +59,7 @@ This adapter would not have been possible without the great work of @Newan (http
59
59
  ### 1.0.7
60
60
  * (Newan) Changed login URL
61
61
 
62
+
62
63
  [Older changelogs can be found there](CHANGELOG_OLD.md)
63
64
 
64
65
  ## Donation
package/io-package.json CHANGED
@@ -1,8 +1,21 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "easee",
4
- "version": "2.0.0-alpha.0",
4
+ "version": "2.0.0-alpha.1",
5
5
  "news": {
6
+ "2.0.0-alpha.1": {
7
+ "en": "Adapter has been migrated into the iobroker-community-adapter-organisation\nAdapter requires node.js >= 22 now.\nAdapter requires js-controller >= 7.2.2 now\nAdapter requires admin >= 7.7.22 now",
8
+ "de": "Adapter wurde in die Iobroker-Community-Adapter-Organisation migriert\nAdapter benötigt jetzt node.js >= 22.\nAdapter benötigt jetzt JS-Controller >= 7.2.2\nAdapter benötigt jetzt admin >= 7.7.22",
9
+ "ru": "Адаптер перенесен в организацию iobroker-community-adapter\nТеперь для адаптера требуется файл node.js >= 22.\nДля адаптера теперь требуется js-контроллер >= 7.2.2\nДля адаптера теперь требуется администратор >= 7.7.22",
10
+ "pt": "O adaptador foi migrado para o iobroker-community-adapter-organization\nO adaptador exige node.js >= 2.\nO adaptador exige js-controller >= 7.2.2\nAgora o adaptador exige admin >= 7.7.2",
11
+ "nl": "De adapter is gemigreerd naar de iobroker-community-adapter-organisatie\nVoor de adapter is nu node.js >= 22 nodig.\nVoor de adapter is nu een js-controller >= 7.2.2 vereist\nAdapter vereist nu admin >= 7.7.22",
12
+ "fr": "L'adaptateur a été migré vers l'organisation iobroker-community-adapter-organisation\nAdapter nécessite node.js >= 22.\nAdapter nécessite JS-Controller >= 7.2.2\nAdapter nécessite admin >= 7.7.22",
13
+ "it": "Adapter è stato migrato nella comunità iobroker di iobroker\nAdapter richiede node.js >= 2 ora.\nAdapter richiede js-controller >= 7.2.2 ora\nAdapter richiede admin >= 7.7.2 ora",
14
+ "es": "El adaptador se ha migrado a la organización iobroker-comunidad-adaptador\nEl adaptador necesita node.js >= 22 ahora.\nEl adaptador ahora requiere js-controller >= 7.2.2\nEl adaptador necesita admin >= 7.7.22 ahora",
15
+ "pl": "Adapter został przeniesiony do organizacji iobroker-community-adapter-organization\nAdapter wymaga teraz node.js >= 22.\nAdapter wymaga kontrolera js->= 7.2.2 teraz\nAdapter wymaga administratora >= 7.7.22 teraz",
16
+ "uk": "Адаптер перенесено в організацію адаптера спільноти iobroker\nТепер адаптер вимагає node.js >= 22.\nАдаптер вимагає js-контролера >= 7.2.2 зараз\nАдаптер вимагає адміністратора >= 7.7.22 зараз",
17
+ "zh-cn": "适配器已迁移到 iobroker 社区适配器组织\n适配器现在需要 node.js >= 22。\n适配器现在需要 js-controller >= 7.2.2\n适配器现在需要管理员 >= 7.7.22"
18
+ },
6
19
  "2.0.0-alpha.0": {
7
20
  "en": "Adapter has been migrated into the iobroker-community-adapter-organisation\nAdapter requires node.js >= 22 now.\nAdapter requires js-controller >= 7.2.2 now\nAdapter requires admin >= 7.7.22 now",
8
21
  "de": "Adapter wurde in die Iobroker-Community-Adapter-Organisation migriert\nAdapter benötigt jetzt node.js >= 22.\nAdapter benötigt jetzt JS-Controller >= 7.2.2\nAdapter benötigt jetzt admin >= 7.7.22",
package/lib/tools.js CHANGED
@@ -2,84 +2,96 @@ const axios = require("axios").default;
2
2
 
3
3
  /**
4
4
  * Tests whether the given variable is a real object and not an Array
5
+ *
5
6
  * @param {any} it The variable to test
6
7
  * @returns {it is Record<string, any>} True if the variable is an object, false otherwise
7
8
  */
8
9
  function isObject(it) {
9
- return Object.prototype.toString.call(it) === '[object Object]';
10
+ return Object.prototype.toString.call(it) === "[object Object]";
10
11
  }
11
12
 
12
13
  /**
13
14
  * Tests whether the given variable is really an Array
15
+ *
14
16
  * @param {any} it The variable to test
15
17
  * @returns {it is any[]} True if the variable is an array, false otherwise
16
18
  */
17
19
  function isArray(it) {
18
- return Array.isArray(it);
20
+ return Array.isArray(it);
19
21
  }
20
22
 
21
23
  /**
22
24
  * Translates text to the target language. Automatically chooses the right translation API.
25
+ *
23
26
  * @param {string} text The text to translate
24
27
  * @param {string} targetLang The target language
25
28
  * @param {string} [yandexApiKey] The yandex API key. You can create one for free at https://translate.yandex.com/developers
26
29
  * @returns {Promise<string>} The translated text
27
30
  */
28
31
  async function translateText(text, targetLang, yandexApiKey) {
29
- if (!text) return '';
30
- if (targetLang === 'en') return text;
32
+ if (!text) {
33
+ return "";
34
+ }
35
+ if (targetLang === "en") {
36
+ return text;
37
+ }
31
38
 
32
- return yandexApiKey
33
- ? translateYandex(text, targetLang, yandexApiKey)
34
- : translateGoogle(text, targetLang);
39
+ return yandexApiKey
40
+ ? translateYandex(text, targetLang, yandexApiKey)
41
+ : translateGoogle(text, targetLang);
35
42
  }
36
43
 
37
44
  /**
38
45
  * Translates text with Yandex API
46
+ *
39
47
  * @param {string} text The text to translate
40
48
  * @param {string} targetLang The target language
41
49
  * @param {string} apiKey The yandex API key. You can create one for free at https://translate.yandex.com/developers
42
50
  * @returns {Promise<string>} The translated text
43
51
  */
44
52
  async function translateYandex(text, targetLang, apiKey) {
45
- if (targetLang === 'zh-cn') targetLang = 'zh';
53
+ if (targetLang === "zh-cn") {
54
+ targetLang = "zh";
55
+ }
46
56
 
47
- const url = `https://translate.yandex.net/api/v1.5/tr.json/translate?key=${apiKey}&text=${encodeURIComponent(text)}&lang=en-${targetLang}`;
48
- try {
49
- const response = await axios.get(url, { timeout: 15000 });
50
- if (response.data?.text && isArray(response.data.text)) {
51
- return response.data.text[0];
52
- }
53
- throw new Error('Invalid response for translate request');
54
- } catch (e) {
55
- throw new Error(`Could not translate to "${targetLang}": ${e.message}`);
57
+ const url = `https://translate.yandex.net/api/v1.5/tr.json/translate?key=${apiKey}&text=${encodeURIComponent(text)}&lang=en-${targetLang}`;
58
+ try {
59
+ const response = await axios.get(url, { timeout: 15000 });
60
+ if (response.data?.text && isArray(response.data.text)) {
61
+ return response.data.text[0];
56
62
  }
63
+ throw new Error("Invalid response for translate request");
64
+ } catch (e) {
65
+ throw new Error(`Could not translate to "${targetLang}": ${e.message}`);
66
+ }
57
67
  }
58
68
 
59
69
  /**
60
70
  * Translates text with Google API
71
+ *
61
72
  * @param {string} text The text to translate
62
73
  * @param {string} targetLang The target language
63
74
  * @returns {Promise<string>} The translated text
64
75
  */
65
76
  async function translateGoogle(text, targetLang) {
66
- 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`;
67
- try {
68
- const response = await axios.get(url, { timeout: 15000 });
69
- if (isArray(response.data)) {
70
- return response.data[0][0][0];
71
- }
72
- throw new Error('Invalid response for translate request');
73
- } catch (e) {
74
- const errorMessage = e.response?.status === 429
75
- ? `Rate-limited by Google Translate`
76
- : e.message;
77
- throw new Error(`Could not translate to "${targetLang}": ${errorMessage}`);
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
+ try {
79
+ const response = await axios.get(url, { timeout: 15000 });
80
+ if (isArray(response.data)) {
81
+ return response.data[0][0][0];
78
82
  }
83
+ throw new Error("Invalid response for translate request");
84
+ } catch (e) {
85
+ const errorMessage =
86
+ e.response?.status === 429
87
+ ? `Rate-limited by Google Translate`
88
+ : e.message;
89
+ throw new Error(`Could not translate to "${targetLang}": ${errorMessage}`);
90
+ }
79
91
  }
80
92
 
81
93
  module.exports = {
82
- isArray,
83
- isObject,
84
- translateText
94
+ isArray,
95
+ isObject,
96
+ translateText,
85
97
  };