iobroker.mg-saic 0.1.3 → 0.2.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/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  # ioBroker MG/SAIC
2
2
 
3
+
3
4
  [![NPM version](https://img.shields.io/npm/v/iobroker.mg-saic.svg)](https://www.npmjs.com/package/iobroker.mg-saic)
4
- [![Downloads](https://img.shields.io/npm/dm/iobroker.mg-saic.svg)](https://www.npmjs.com/package/iobroker.mg-saic)
5
+ ![Number of Installations](http://iobroker.live/badges/mg-saic-stable.svg)
6
+ ![Number of Installations](http://iobroker.live/badges/mg-saic-installed.svg)
5
7
 
6
8
  <img src="admin/MG.png" alt="MG" width="314">
7
9
 
@@ -15,24 +17,27 @@ For manufacturer information, see [MG Motor](https://www.mgmotor.eu/) and [SAIC
15
17
 
16
18
  - Node.js 22.22.2 or later is required.
17
19
  - ioBroker js-controller 7.2.2 or later is required.
18
- - ioBroker Admin 8.2.0 or later is required.
20
+ - ioBroker Admin 8.3.15 or later is required.
19
21
  - Use an iSmart account that has access to the vehicle. A separate account shared with the vehicle is recommended to avoid interfering with the mobile app session.
20
- - Have the account password ready. The adapter stores it as a protected setting.
22
+ - Create or select a custom Login/Password credential in ioBroker's credential store. Use the iSmart email address or phone number as its login.
21
23
  - Select the region for the account. Available regions are European Union, China, Australia, Brazil, Israel, Turkey, Thailand, and Rest of World. India is not supported.
22
24
 
23
25
  ### Configure the adapter
24
26
 
25
27
  1. Install the adapter and create an instance in ioBroker Admin.
26
- 2. Select the account region and login type (email or phone number).
27
- 3. Enter the account's email address or phone number and password. For phone login, also enter the phone country calling code.
28
- 4. Set the status polling interval >60 seconds. The default is 1800 seconds.
29
- 5. Save the settings and start the instance. Vehicles available to the account appear under `vehicles.<VIN>`.
28
+ 2. Select the account region, login type (email or phone number), and the matching custom Login/Password credential from the credential store. The credential's login must be the iSmart email address or phone number; the password is stored centrally. For phone login, also enter the phone country calling code in the adapter settings.
29
+ 3. Set the status polling interval to 60 seconds or more. The default is 1800 seconds.
30
+ 4. Save the settings and start the instance. Vehicles available to the account appear under `vehicles.<VIN>`.
31
+ Existing vehicle object IDs are reused if the cloud API changes the VIN casing. Device labels use the localized generic vehicle name; the VIN, brand, model, and other available vehicle metadata are provided as read-only states.
32
+
33
+ The adapter does not import previously saved native login or password values. On startup it clears those deprecated fields; configure a central Login/Password credential before the adapter can connect.
30
34
 
31
35
  ## Features
32
36
 
33
37
  - Connects ioBroker to the iSmart cloud service and retrieves vehicle status.
34
38
  - Provides remote controls for supported vehicle functions.
35
39
  - Supports climate, heating, and charging features where available for the vehicle.
40
+ - Omits unrecognized free-form charging text while retaining numeric measurements and validated charging-point identifiers.
36
41
 
37
42
  ## Installation
38
43
 
@@ -40,9 +45,20 @@ The adapter is published on npm and available from ioBroker's Latest adapter rep
40
45
 
41
46
  ## Support
42
47
 
43
- [![Donate](https://camo.githubusercontent.com/ef8c60305542390406855547e32850909812a73c4abada236de22a6dc88b313f/68747470733a2f2f7777772e70617970616c6f626a656374732e636f6d2f64655f44452f44452f692f62746e2f62746e5f646f6e61746543435f4c472e676966)](https://www.paypal.com/donate/?hosted_button_id=3RJQGSJNRSHUJ)
48
+ <a href="https://www.paypal.com/donate/?hosted_button_id=3RJQGSJNRSHUJ">
49
+ <img src=".github/Donate_eng.png" alt="Mit PayPal spenden" width="220">
50
+ </a>
44
51
 
45
52
  ## Changelog
53
+
54
+ ### 0.2.0 (2026-11-28)
55
+
56
+ - (Voodoo2man) Moved iSmart credentials to ioBroker's credential store; existing users must create a new Login/Password credential and re-enter their login details.
57
+
58
+ ### 0.1.4 (2026-11-11)
59
+
60
+ - (Voodoo2man) Corrected command-response validation, status values, charging-field handling, vehicle ID reuse, and cloud polling intervals; removed the non-informative vehicle name state.
61
+
46
62
  ### 0.1.3 (2026-11-08)
47
63
 
48
64
  - (Voodoo2man) Retry startup initialization after temporary cloud login and vehicle-list outages with bounded backoff, prevent false setting writes from triggering remote setting actions, and add the missing region labels in the Admin UI.
@@ -58,19 +74,6 @@ The adapter is published on npm and available from ioBroker's Latest adapter rep
58
74
  - (Voodoo2man) Lowered the minimum Node.js requirement to 22.22.2.
59
75
  - (Voodoo2man) Improved charging datapoint labels and units, enforced safe polling interval limits, and added manufacturer references.
60
76
 
61
- ### 0.1.0 (2026-11-01)
62
-
63
- - (Voodoo2man) Reported real-time charging power in kW using the pack current and voltage.
64
- - (Voodoo2man) Applied confirmed profile-specific charging conversions.
65
- - (Voodoo2man) Calculated available battery energy from battery level and usable capacity.
66
-
67
- ### 0.0.4 (2026-10-24)
68
-
69
- - (Voodoo2man) Corrected GPS coordinates.
70
- - (Voodoo2man) Fixed incorrect datapoint values.
71
- - (Voodoo2man) Removed duplicate and irrelevant datapoints.
72
- - (Voodoo2man) Set min version of admin to 8.2.0, js-controller 7.2.2, node.js 24
73
-
74
77
  Older changelog entries are available in [CHANGELOG_OLD.md](CHANGELOG_OLD.md).
75
78
 
76
79
  ## License
@@ -2,6 +2,8 @@
2
2
  "iSmart account": "iSmart-Konto",
3
3
  "Cloud connection": "Cloud-Verbindung",
4
4
  "Account credentials": "Kontozugangsdaten",
5
+ "iSmart login credential": "iSmart-Anmeldezugang",
6
+ "Select or create a Login/Password credential. The login must match the login type selected above.": "Wählen Sie einen Login/Passwort-Zugang aus oder erstellen Sie einen. Der Login muss zum oben gewählten Anmeldetyp passen.",
5
7
  "Status updates": "Statusaktualisierung",
6
8
  "To avoid possible session interference with the mobile app, use a separate iSmart account for ioBroker where possible. Share the vehicle with that account and grant the permissions needed for your intended use.": "Um mögliche Konflikte mit der mobilen App zu vermeiden, verwenden Sie nach Möglichkeit ein separates iSmart-Konto für ioBroker. Teilen Sie das Fahrzeug mit diesem Konto und erteilen Sie die für die gewünschte Nutzung erforderlichen Berechtigungen.",
7
9
  "Region": "Region",
@@ -16,8 +18,6 @@
16
18
  "Login type": "Anmeldetyp",
17
19
  "Email": "E-Mail",
18
20
  "Phone number": "Telefonnummer",
19
- "Email address or phone number": "E-Mail-Adresse oder Telefonnummer",
20
21
  "Phone country calling code": "Internationale Ländervorwahl",
21
- "Password": "Passwort",
22
22
  "Status polling interval (seconds)": "Status-Abrufintervall (Sekunden)"
23
- }
23
+ }
@@ -2,6 +2,8 @@
2
2
  "iSmart account": "iSmart account",
3
3
  "Cloud connection": "Cloud connection",
4
4
  "Account credentials": "Account credentials",
5
+ "iSmart login credential": "iSmart login credential",
6
+ "Select or create a Login/Password credential. The login must match the login type selected above.": "Select or create a Login/Password credential. The login must match the login type selected above.",
5
7
  "Status updates": "Status updates",
6
8
  "To avoid possible session interference with the mobile app, use a separate iSmart account for ioBroker where possible. Share the vehicle with that account and grant the permissions needed for your intended use.": "To avoid possible session interference with the mobile app, use a separate iSmart account for ioBroker where possible. Share the vehicle with that account and grant the permissions needed for your intended use.",
7
9
  "Region": "Region",
@@ -16,8 +18,6 @@
16
18
  "Login type": "Login type",
17
19
  "Email": "Email",
18
20
  "Phone number": "Phone number",
19
- "Email address or phone number": "Email address or phone number",
20
21
  "Phone country calling code": "Phone country calling code",
21
- "Password": "Password",
22
22
  "Status polling interval (seconds)": "Status polling interval (seconds)"
23
- }
23
+ }
@@ -2,6 +2,8 @@
2
2
  "iSmart account": "Cuenta iSmart",
3
3
  "Cloud connection": "Conexión a la nube",
4
4
  "Account credentials": "Credenciales de la cuenta",
5
+ "iSmart login credential": "Credencial de acceso de iSmart",
6
+ "Select or create a Login/Password credential. The login must match the login type selected above.": "Seleccione o cree una credencial Login/Password. El login debe coincidir con el tipo seleccionado arriba.",
5
7
  "Status updates": "Actualizaciones de estado",
6
8
  "To avoid possible session interference with the mobile app, use a separate iSmart account for ioBroker where possible. Share the vehicle with that account and grant the permissions needed for your intended use.": "Para evitar posibles interferencias de sesión con la aplicación móvil, utiliza una cuenta iSmart independiente para ioBroker siempre que sea posible. Comparte el vehículo con esa cuenta y concede los permisos necesarios para el uso previsto.",
7
9
  "Region": "Región",
@@ -16,8 +18,6 @@
16
18
  "Login type": "Tipo de inicio de sesión",
17
19
  "Email": "Correo electrónico",
18
20
  "Phone number": "Número de teléfono",
19
- "Email address or phone number": "Dirección de correo electrónico o número de teléfono",
20
21
  "Phone country calling code": "Prefijo telefónico internacional",
21
- "Password": "Contraseña",
22
22
  "Status polling interval (seconds)": "Intervalo de consulta del estado (segundos)"
23
23
  }
@@ -2,6 +2,8 @@
2
2
  "iSmart account": "Compte iSmart",
3
3
  "Cloud connection": "Connexion au cloud",
4
4
  "Account credentials": "Identifiants du compte",
5
+ "iSmart login credential": "Identifiant de connexion iSmart",
6
+ "Select or create a Login/Password credential. The login must match the login type selected above.": "Sélectionnez ou créez un identifiant Login/Password. Le login doit correspondre au type choisi ci-dessus.",
5
7
  "Status updates": "Mises à jour du statut",
6
8
  "To avoid possible session interference with the mobile app, use a separate iSmart account for ioBroker where possible. Share the vehicle with that account and grant the permissions needed for your intended use.": "Pour éviter toute interférence de session avec l'application mobile, utilisez si possible un compte iSmart distinct pour ioBroker. Partagez le véhicule avec ce compte et accordez les autorisations nécessaires à l'utilisation souhaitée.",
7
9
  "Region": "Région",
@@ -16,8 +18,6 @@
16
18
  "Login type": "Type de connexion",
17
19
  "Email": "E-mail",
18
20
  "Phone number": "Numéro de téléphone",
19
- "Email address or phone number": "Adresse e-mail ou numéro de téléphone",
20
21
  "Phone country calling code": "Indicatif téléphonique international",
21
- "Password": "Mot de passe",
22
22
  "Status polling interval (seconds)": "Intervalle d'interrogation du statut (secondes)"
23
23
  }
@@ -2,6 +2,8 @@
2
2
  "iSmart account": "Account iSmart",
3
3
  "Cloud connection": "Connessione cloud",
4
4
  "Account credentials": "Credenziali dell'account",
5
+ "iSmart login credential": "Credenziale di accesso iSmart",
6
+ "Select or create a Login/Password credential. The login must match the login type selected above.": "Seleziona o crea una credenziale Login/Password. Il login deve corrispondere al tipo scelto sopra.",
5
7
  "Status updates": "Aggiornamenti dello stato",
6
8
  "To avoid possible session interference with the mobile app, use a separate iSmart account for ioBroker where possible. Share the vehicle with that account and grant the permissions needed for your intended use.": "Per evitare possibili interferenze di sessione con l'app mobile, utilizza, se possibile, un account iSmart separato per ioBroker. Condividi il veicolo con quell'account e concedi le autorizzazioni necessarie per l'uso previsto.",
7
9
  "Region": "Regione",
@@ -16,8 +18,6 @@
16
18
  "Login type": "Tipo di accesso",
17
19
  "Email": "E-mail",
18
20
  "Phone number": "Numero di telefono",
19
- "Email address or phone number": "Indirizzo e-mail o numero di telefono",
20
21
  "Phone country calling code": "Prefisso telefonico internazionale",
21
- "Password": "Password",
22
22
  "Status polling interval (seconds)": "Intervallo di interrogazione dello stato (secondi)"
23
23
  }
@@ -2,6 +2,8 @@
2
2
  "iSmart account": "iSmart-account",
3
3
  "Cloud connection": "Cloudverbinding",
4
4
  "Account credentials": "Accountgegevens",
5
+ "iSmart login credential": "iSmart-inloggegevens",
6
+ "Select or create a Login/Password credential. The login must match the login type selected above.": "Selecteer of maak een Login/Password-referentie. De login moet overeenkomen met het hierboven geselecteerde inlogtype.",
5
7
  "Status updates": "Statusupdates",
6
8
  "To avoid possible session interference with the mobile app, use a separate iSmart account for ioBroker where possible. Share the vehicle with that account and grant the permissions needed for your intended use.": "Gebruik waar mogelijk een apart iSmart-account voor ioBroker om mogelijke sessieproblemen met de mobiele app te voorkomen. Deel het voertuig met dat account en verleen de benodigde rechten voor het beoogde gebruik.",
7
9
  "Region": "Regio",
@@ -16,8 +18,6 @@
16
18
  "Login type": "Aanmeldtype",
17
19
  "Email": "E-mailadres",
18
20
  "Phone number": "Telefoonnummer",
19
- "Email address or phone number": "E-mailadres of telefoonnummer",
20
21
  "Phone country calling code": "Internationale landcode",
21
- "Password": "Wachtwoord",
22
22
  "Status polling interval (seconds)": "Interval voor statusopvraging (seconden)"
23
23
  }
@@ -2,6 +2,8 @@
2
2
  "iSmart account": "Konto iSmart",
3
3
  "Cloud connection": "Połączenie z chmurą",
4
4
  "Account credentials": "Dane logowania do konta",
5
+ "iSmart login credential": "Dane logowania iSmart",
6
+ "Select or create a Login/Password credential. The login must match the login type selected above.": "Wybierz lub utwórz poświadczenie Login/Password. Login musi odpowiadać wybranemu powyżej typowi logowania.",
5
7
  "Status updates": "Aktualizacje statusu",
6
8
  "To avoid possible session interference with the mobile app, use a separate iSmart account for ioBroker where possible. Share the vehicle with that account and grant the permissions needed for your intended use.": "Aby uniknąć możliwych konfliktów sesji z aplikacją mobilną, w miarę możliwości użyj osobnego konta iSmart dla ioBroker. Udostępnij temu kontu pojazd i nadaj uprawnienia wymagane do planowanego użycia.",
7
9
  "Region": "Region",
@@ -16,8 +18,6 @@
16
18
  "Login type": "Typ logowania",
17
19
  "Email": "E-mail",
18
20
  "Phone number": "Numer telefonu",
19
- "Email address or phone number": "Adres e-mail lub numer telefonu",
20
21
  "Phone country calling code": "Międzynarodowy numer kierunkowy kraju",
21
- "Password": "Hasło",
22
22
  "Status polling interval (seconds)": "Interwał pobierania statusu (sekundy)"
23
23
  }
@@ -2,6 +2,8 @@
2
2
  "iSmart account": "Conta iSmart",
3
3
  "Cloud connection": "Ligação à nuvem",
4
4
  "Account credentials": "Credenciais da conta",
5
+ "iSmart login credential": "Credencial de início de sessão iSmart",
6
+ "Select or create a Login/Password credential. The login must match the login type selected above.": "Selecione ou crie uma credencial Login/Password. O login tem de corresponder ao tipo selecionado acima.",
5
7
  "Status updates": "Atualizações de estado",
6
8
  "To avoid possible session interference with the mobile app, use a separate iSmart account for ioBroker where possible. Share the vehicle with that account and grant the permissions needed for your intended use.": "Para evitar possíveis interferências de sessão com a aplicação móvel, utilize, sempre que possível, uma conta iSmart separada para o ioBroker. Partilhe o veículo com essa conta e conceda as permissões necessárias para a utilização pretendida.",
7
9
  "Region": "Região",
@@ -16,8 +18,6 @@
16
18
  "Login type": "Tipo de início de sessão",
17
19
  "Email": "E-mail",
18
20
  "Phone number": "Número de telefone",
19
- "Email address or phone number": "Endereço de e-mail ou número de telefone",
20
21
  "Phone country calling code": "Indicativo internacional do país",
21
- "Password": "Palavra-passe",
22
22
  "Status polling interval (seconds)": "Intervalo de consulta do estado (segundos)"
23
23
  }
@@ -2,6 +2,8 @@
2
2
  "iSmart account": "Учетная запись iSmart",
3
3
  "Cloud connection": "Подключение к облаку",
4
4
  "Account credentials": "Данные учетной записи",
5
+ "iSmart login credential": "Учетные данные iSmart",
6
+ "Select or create a Login/Password credential. The login must match the login type selected above.": "Выберите или создайте учетные данные типа Login/Password. Логин должен соответствовать выбранному выше типу входа.",
5
7
  "Status updates": "Обновление статуса",
6
8
  "To avoid possible session interference with the mobile app, use a separate iSmart account for ioBroker where possible. Share the vehicle with that account and grant the permissions needed for your intended use.": "Чтобы избежать возможных конфликтов сеанса с мобильным приложением, по возможности используйте отдельную учетную запись iSmart для ioBroker. Предоставьте этой учетной записи доступ к автомобилю и необходимые для использования разрешения.",
7
9
  "Region": "Регион",
@@ -16,8 +18,6 @@
16
18
  "Login type": "Тип входа",
17
19
  "Email": "Электронная почта",
18
20
  "Phone number": "Номер телефона",
19
- "Email address or phone number": "Адрес электронной почты или номер телефона",
20
21
  "Phone country calling code": "Международный телефонный код страны",
21
- "Password": "Пароль",
22
22
  "Status polling interval (seconds)": "Интервал опроса статуса (секунды)"
23
23
  }
@@ -2,6 +2,8 @@
2
2
  "iSmart account": "Обліковий запис iSmart",
3
3
  "Cloud connection": "Підключення до хмари",
4
4
  "Account credentials": "Облікові дані облікового запису",
5
+ "iSmart login credential": "Облікові дані iSmart",
6
+ "Select or create a Login/Password credential. The login must match the login type selected above.": "Виберіть або створіть облікові дані Login/Password. Логін має відповідати вибраному вище типу входу.",
5
7
  "Status updates": "Оновлення стану",
6
8
  "To avoid possible session interference with the mobile app, use a separate iSmart account for ioBroker where possible. Share the vehicle with that account and grant the permissions needed for your intended use.": "Щоб уникнути можливих конфліктів сеансів із мобільним застосунком, за можливості використовуйте окремий обліковий запис iSmart для ioBroker. Надайте йому доступ до автомобіля та необхідні для використання дозволи.",
7
9
  "Region": "Регіон",
@@ -16,8 +18,6 @@
16
18
  "Login type": "Тип входу",
17
19
  "Email": "Електронна пошта",
18
20
  "Phone number": "Номер телефону",
19
- "Email address or phone number": "Адреса електронної пошти або номер телефону",
20
21
  "Phone country calling code": "Міжнародний телефонний код країни",
21
- "Password": "Пароль",
22
22
  "Status polling interval (seconds)": "Інтервал опитування стану (секунди)"
23
23
  }
@@ -2,6 +2,8 @@
2
2
  "iSmart account": "iSmart 账户",
3
3
  "Cloud connection": "云连接",
4
4
  "Account credentials": "账户凭据",
5
+ "iSmart login credential": "iSmart 登录凭据",
6
+ "Select or create a Login/Password credential. The login must match the login type selected above.": "选择或创建 Login/Password 凭据。登录名必须与上方选择的登录类型相匹配。",
5
7
  "Status updates": "状态更新",
6
8
  "To avoid possible session interference with the mobile app, use a separate iSmart account for ioBroker where possible. Share the vehicle with that account and grant the permissions needed for your intended use.": "为避免与手机应用的会话发生冲突,请尽可能为 ioBroker 使用单独的 iSmart 账户。将车辆共享给该账户,并授予预期用途所需的权限。",
7
9
  "Region": "地区",
@@ -16,8 +18,6 @@
16
18
  "Login type": "登录类型",
17
19
  "Email": "电子邮箱",
18
20
  "Phone number": "电话号码",
19
- "Email address or phone number": "电子邮箱地址或电话号码",
20
21
  "Phone country calling code": "国际电话区号",
21
- "Password": "密码",
22
22
  "Status polling interval (seconds)": "状态轮询间隔(秒)"
23
23
  }
@@ -68,10 +68,20 @@
68
68
  "xs": 12,
69
69
  "sm": 12
70
70
  },
71
- "accountIdentifier": {
72
- "type": "text",
73
- "label": "Email address or phone number",
74
- "maxLength": 254,
71
+ "_credentialHelp": {
72
+ "type": "staticText",
73
+ "text": "Select or create a Login/Password credential. The login must match the login type selected above.",
74
+ "xs": 12,
75
+ "sm": 12,
76
+ "md": 12,
77
+ "lg": 12,
78
+ "xl": 12
79
+ },
80
+ "credentialId": {
81
+ "type": "credential",
82
+ "label": "iSmart login credential",
83
+ "credentialType": "custom",
84
+ "disableCreation": false,
75
85
  "xs": 12,
76
86
  "sm": 12,
77
87
  "md": 6,
@@ -89,16 +99,6 @@
89
99
  "lg": 6,
90
100
  "xl": 6
91
101
  },
92
- "password": {
93
- "type": "password",
94
- "label": "Password",
95
- "visible": false,
96
- "xs": 12,
97
- "sm": 12,
98
- "md": 6,
99
- "lg": 6,
100
- "xl": 6
101
- },
102
102
  "_statusHeader": {
103
103
  "type": "header",
104
104
  "text": "Status updates",
package/build/config.js CHANGED
@@ -42,15 +42,12 @@ function validateConfig(config) {
42
42
  if (config.accountType !== "email" && config.accountType !== "phone") {
43
43
  errors.push("Login type must be email or phone");
44
44
  }
45
- if (!((_b = config.accountIdentifier) == null ? void 0 : _b.trim())) {
46
- errors.push("Email address or phone number is required");
45
+ if (!((_b = config.credentialId) == null ? void 0 : _b.trim())) {
46
+ errors.push("An ioBroker Login/Password credential is required");
47
47
  }
48
48
  if (config.accountType === "phone" && !((_c = config.phoneCountryCode) == null ? void 0 : _c.trim())) {
49
49
  errors.push("Phone country calling code is required");
50
50
  }
51
- if (!config.password) {
52
- errors.push("Password is required");
53
- }
54
51
  return errors;
55
52
  }
56
53
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/config.ts"],
4
- "sourcesContent": ["import { isIndiaRegion, resolveSaicRegion } from './regions';\n\n/** Settings entered for one iSmart account and backend. */\nexport interface MgSaicConfig {\n\t/** Automatic status polling interval in seconds. */\n\tpollIntervalSeconds?: number;\n\t/** Backend region code. */\n\tregion?: string;\n\t/** Whether the account identifier is an email address or phone number. */\n\taccountType?: string;\n\t/** Email address or phone number used to sign in. */\n\taccountIdentifier?: string;\n\t/** International calling code when using a phone account. */\n\tphoneCountryCode?: string;\n\t/** Account password, decrypted by ioBroker for the adapter process. */\n\tpassword?: string;\n}\n\nexport const DEFAULT_POLL_INTERVAL_SECONDS = 1800;\nexport const MAX_POLL_INTERVAL_SECONDS = 2_147_483;\n\n/**\n * Returns configuration problems without logging any credential values.\n *\n * @param config The instance's native configuration.\n */\nexport function validateConfig(config: MgSaicConfig): string[] {\n\tconst errors: string[] = [];\n\tif (\n\t\tconfig.pollIntervalSeconds !== undefined &&\n\t\t(!Number.isInteger(config.pollIntervalSeconds) ||\n\t\t\tconfig.pollIntervalSeconds < 60 ||\n\t\t\tconfig.pollIntervalSeconds > MAX_POLL_INTERVAL_SECONDS)\n\t) {\n\t\terrors.push(`Polling interval must be an integer between 60 and ${MAX_POLL_INTERVAL_SECONDS} seconds`);\n\t}\n\tif (!config.region?.trim()) {\n\t\terrors.push('Region/backend code is required');\n\t} else if (isIndiaRegion(config.region)) {\n\t\terrors.push('India TAP connectivity is not implemented yet');\n\t} else if (!resolveSaicRegion(config.region)) {\n\t\terrors.push('Unsupported SAIC region');\n\t}\n\tif (config.accountType !== 'email' && config.accountType !== 'phone') {\n\t\terrors.push('Login type must be email or phone');\n\t}\n\tif (!config.accountIdentifier?.trim()) {\n\t\terrors.push('Email address or phone number is required');\n\t}\n\tif (config.accountType === 'phone' && !config.phoneCountryCode?.trim()) {\n\t\terrors.push('Phone country calling code is required');\n\t}\n\tif (!config.password) {\n\t\terrors.push('Password is required');\n\t}\n\treturn errors;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAiD;AAkB1C,MAAM,gCAAgC;AACtC,MAAM,4BAA4B;AAOlC,SAAS,eAAe,QAAgC;AA1B/D;AA2BC,QAAM,SAAmB,CAAC;AAC1B,MACC,OAAO,wBAAwB,WAC9B,CAAC,OAAO,UAAU,OAAO,mBAAmB,KAC5C,OAAO,sBAAsB,MAC7B,OAAO,sBAAsB,4BAC7B;AACD,WAAO,KAAK,sDAAsD,yBAAyB,UAAU;AAAA,EACtG;AACA,MAAI,GAAC,YAAO,WAAP,mBAAe,SAAQ;AAC3B,WAAO,KAAK,iCAAiC;AAAA,EAC9C,eAAW,8BAAc,OAAO,MAAM,GAAG;AACxC,WAAO,KAAK,+CAA+C;AAAA,EAC5D,WAAW,KAAC,kCAAkB,OAAO,MAAM,GAAG;AAC7C,WAAO,KAAK,yBAAyB;AAAA,EACtC;AACA,MAAI,OAAO,gBAAgB,WAAW,OAAO,gBAAgB,SAAS;AACrE,WAAO,KAAK,mCAAmC;AAAA,EAChD;AACA,MAAI,GAAC,YAAO,sBAAP,mBAA0B,SAAQ;AACtC,WAAO,KAAK,2CAA2C;AAAA,EACxD;AACA,MAAI,OAAO,gBAAgB,WAAW,GAAC,YAAO,qBAAP,mBAAyB,SAAQ;AACvE,WAAO,KAAK,wCAAwC;AAAA,EACrD;AACA,MAAI,CAAC,OAAO,UAAU;AACrB,WAAO,KAAK,sBAAsB;AAAA,EACnC;AACA,SAAO;AACR;",
4
+ "sourcesContent": ["import { isIndiaRegion, resolveSaicRegion } from './regions';\n\n/** Settings entered for one iSmart account and backend. */\nexport interface MgSaicConfig {\n\t/** Automatic status polling interval in seconds. */\n\tpollIntervalSeconds?: number;\n\t/** Backend region code. */\n\tregion?: string;\n\t/** Whether the account identifier is an email address or phone number. */\n\taccountType?: string;\n\t/** Selected custom Login/Password credential in ioBroker's credential store. */\n\tcredentialId?: string;\n\t/** International calling code when using a phone account. */\n\tphoneCountryCode?: string;\n}\n\nexport const DEFAULT_POLL_INTERVAL_SECONDS = 1800;\nexport const MAX_POLL_INTERVAL_SECONDS = 2_147_483;\n\n/**\n * Returns configuration problems without logging any credential values.\n *\n * @param config The instance's native configuration.\n */\nexport function validateConfig(config: MgSaicConfig): string[] {\n\tconst errors: string[] = [];\n\tif (\n\t\tconfig.pollIntervalSeconds !== undefined &&\n\t\t(!Number.isInteger(config.pollIntervalSeconds) ||\n\t\t\tconfig.pollIntervalSeconds < 60 ||\n\t\t\tconfig.pollIntervalSeconds > MAX_POLL_INTERVAL_SECONDS)\n\t) {\n\t\terrors.push(`Polling interval must be an integer between 60 and ${MAX_POLL_INTERVAL_SECONDS} seconds`);\n\t}\n\tif (!config.region?.trim()) {\n\t\terrors.push('Region/backend code is required');\n\t} else if (isIndiaRegion(config.region)) {\n\t\terrors.push('India TAP connectivity is not implemented yet');\n\t} else if (!resolveSaicRegion(config.region)) {\n\t\terrors.push('Unsupported SAIC region');\n\t}\n\tif (config.accountType !== 'email' && config.accountType !== 'phone') {\n\t\terrors.push('Login type must be email or phone');\n\t}\n\tif (!config.credentialId?.trim()) {\n\t\terrors.push('An ioBroker Login/Password credential is required');\n\t}\n\tif (config.accountType === 'phone' && !config.phoneCountryCode?.trim()) {\n\t\terrors.push('Phone country calling code is required');\n\t}\n\treturn errors;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAiD;AAgB1C,MAAM,gCAAgC;AACtC,MAAM,4BAA4B;AAOlC,SAAS,eAAe,QAAgC;AAxB/D;AAyBC,QAAM,SAAmB,CAAC;AAC1B,MACC,OAAO,wBAAwB,WAC9B,CAAC,OAAO,UAAU,OAAO,mBAAmB,KAC5C,OAAO,sBAAsB,MAC7B,OAAO,sBAAsB,4BAC7B;AACD,WAAO,KAAK,sDAAsD,yBAAyB,UAAU;AAAA,EACtG;AACA,MAAI,GAAC,YAAO,WAAP,mBAAe,SAAQ;AAC3B,WAAO,KAAK,iCAAiC;AAAA,EAC9C,eAAW,8BAAc,OAAO,MAAM,GAAG;AACxC,WAAO,KAAK,+CAA+C;AAAA,EAC5D,WAAW,KAAC,kCAAkB,OAAO,MAAM,GAAG;AAC7C,WAAO,KAAK,yBAAyB;AAAA,EACtC;AACA,MAAI,OAAO,gBAAgB,WAAW,OAAO,gBAAgB,SAAS;AACrE,WAAO,KAAK,mCAAmC;AAAA,EAChD;AACA,MAAI,GAAC,YAAO,iBAAP,mBAAqB,SAAQ;AACjC,WAAO,KAAK,mDAAmD;AAAA,EAChE;AACA,MAAI,OAAO,gBAAgB,WAAW,GAAC,YAAO,qBAAP,mBAAyB,SAAQ;AACvE,WAAO,KAAK,wCAAwC;AAAA,EACrD;AACA,SAAO;AACR;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,53 @@
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 credentials_exports = {};
20
+ __export(credentials_exports, {
21
+ clearDeprecatedNativeCredentials: () => clearDeprecatedNativeCredentials,
22
+ getLoginPasswordCredential: () => getLoginPasswordCredential
23
+ });
24
+ module.exports = __toCommonJS(credentials_exports);
25
+ function getLoginPasswordCredential(credential, getCredentialForm) {
26
+ if (credential.type !== "custom" || !credential.values || typeof credential.values !== "object") {
27
+ throw new Error("A custom Login/Password credential is required");
28
+ }
29
+ const values = credential.values;
30
+ if (getCredentialForm(values) !== "login" || typeof values.login !== "string" || !values.login.trim() || typeof values.password !== "string" || !values.password) {
31
+ throw new Error("The selected credential must contain a login and password");
32
+ }
33
+ return { accountIdentifier: values.login.trim(), password: values.password };
34
+ }
35
+ async function clearDeprecatedNativeCredentials(config, updateConfig) {
36
+ if (!config.accountIdentifier && !config.password) {
37
+ return true;
38
+ }
39
+ try {
40
+ await updateConfig({ accountIdentifier: "", password: "" });
41
+ config.accountIdentifier = "";
42
+ config.password = "";
43
+ return true;
44
+ } catch {
45
+ return false;
46
+ }
47
+ }
48
+ // Annotate the CommonJS export names for ESM import in node:
49
+ 0 && (module.exports = {
50
+ clearDeprecatedNativeCredentials,
51
+ getLoginPasswordCredential
52
+ });
53
+ //# sourceMappingURL=credentials.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/credentials.ts"],
4
+ "sourcesContent": ["/** Login values supplied by a central ioBroker credential. */\nexport interface AccountLoginCredential {\n\t/** iSmart email address or phone number. */\n\taccountIdentifier: string;\n\t/** Password from the central credential store. */\n\tpassword: string;\n}\n\ninterface CredentialInfo {\n\ttype: string;\n\tvalues: unknown;\n}\n\n/**\n * Extracts the login and password from an ioBroker custom Login/Password credential.\n *\n * @param credential Credential returned by ioBroker's credential API.\n * @param getCredentialForm Resolves the form type for custom credentials.\n */\nexport function getLoginPasswordCredential(\n\tcredential: CredentialInfo,\n\tgetCredentialForm: (values: Record<string, unknown>) => string,\n): AccountLoginCredential {\n\tif (credential.type !== 'custom' || !credential.values || typeof credential.values !== 'object') {\n\t\tthrow new Error('A custom Login/Password credential is required');\n\t}\n\tconst values = credential.values as Record<string, unknown>;\n\tif (\n\t\tgetCredentialForm(values) !== 'login' ||\n\t\ttypeof values.login !== 'string' ||\n\t\t!values.login.trim() ||\n\t\ttypeof values.password !== 'string' ||\n\t\t!values.password\n\t) {\n\t\tthrow new Error('The selected credential must contain a login and password');\n\t}\n\treturn { accountIdentifier: values.login.trim(), password: values.password };\n}\n\n/**\n * Clears deprecated native login fields only after their empty values are persisted.\n *\n * @param config The adapter's native instance configuration.\n * @param updateConfig Persists the cleared legacy values.\n * @returns Whether the legacy values are cleared or already absent.\n */\nexport async function clearDeprecatedNativeCredentials(\n\tconfig: Record<string, unknown>,\n\tupdateConfig: (changes: { accountIdentifier: string; password: string }) => Promise<unknown>,\n): Promise<boolean> {\n\tif (!config.accountIdentifier && !config.password) {\n\t\treturn true;\n\t}\n\ttry {\n\t\tawait updateConfig({ accountIdentifier: '', password: '' });\n\t\tconfig.accountIdentifier = '';\n\t\tconfig.password = '';\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBO,SAAS,2BACf,YACA,mBACyB;AACzB,MAAI,WAAW,SAAS,YAAY,CAAC,WAAW,UAAU,OAAO,WAAW,WAAW,UAAU;AAChG,UAAM,IAAI,MAAM,gDAAgD;AAAA,EACjE;AACA,QAAM,SAAS,WAAW;AAC1B,MACC,kBAAkB,MAAM,MAAM,WAC9B,OAAO,OAAO,UAAU,YACxB,CAAC,OAAO,MAAM,KAAK,KACnB,OAAO,OAAO,aAAa,YAC3B,CAAC,OAAO,UACP;AACD,UAAM,IAAI,MAAM,2DAA2D;AAAA,EAC5E;AACA,SAAO,EAAE,mBAAmB,OAAO,MAAM,KAAK,GAAG,UAAU,OAAO,SAAS;AAC5E;AASA,eAAsB,iCACrB,QACA,cACmB;AACnB,MAAI,CAAC,OAAO,qBAAqB,CAAC,OAAO,UAAU;AAClD,WAAO;AAAA,EACR;AACA,MAAI;AACH,UAAM,aAAa,EAAE,mBAAmB,IAAI,UAAU,GAAG,CAAC;AAC1D,WAAO,oBAAoB;AAC3B,WAAO,WAAW;AAClB,WAAO;AAAA,EACR,QAAQ;AACP,WAAO;AAAA,EACR;AACD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,37 @@
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 initialization_retry_exports = {};
20
+ __export(initialization_retry_exports, {
21
+ calculateInitializationRetryDelayMs: () => calculateInitializationRetryDelayMs
22
+ });
23
+ module.exports = __toCommonJS(initialization_retry_exports);
24
+ const INITIALIZATION_RETRY_DELAY_MS = 6e4;
25
+ const MAX_INITIALIZATION_RETRY_DELAY_MS = 5 * INITIALIZATION_RETRY_DELAY_MS;
26
+ function calculateInitializationRetryDelayMs(retryCount) {
27
+ const attempts = Math.max(1, retryCount);
28
+ if (attempts <= 3) {
29
+ return INITIALIZATION_RETRY_DELAY_MS * attempts;
30
+ }
31
+ return MAX_INITIALIZATION_RETRY_DELAY_MS;
32
+ }
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ calculateInitializationRetryDelayMs
36
+ });
37
+ //# sourceMappingURL=initialization-retry.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/initialization-retry.ts"],
4
+ "sourcesContent": ["const INITIALIZATION_RETRY_DELAY_MS = 60_000;\nconst MAX_INITIALIZATION_RETRY_DELAY_MS = 5 * INITIALIZATION_RETRY_DELAY_MS;\n\n/**\n * Returns the bounded delay before retrying initialization.\n *\n * @param retryCount Number of initialization failures.\n * @returns Retry delay in milliseconds.\n */\nexport function calculateInitializationRetryDelayMs(retryCount: number): number {\n\tconst attempts = Math.max(1, retryCount);\n\tif (attempts <= 3) {\n\t\treturn INITIALIZATION_RETRY_DELAY_MS * attempts;\n\t}\n\treturn MAX_INITIALIZATION_RETRY_DELAY_MS;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAAM,gCAAgC;AACtC,MAAM,oCAAoC,IAAI;AAQvC,SAAS,oCAAoC,YAA4B;AAC/E,QAAM,WAAW,KAAK,IAAI,GAAG,UAAU;AACvC,MAAI,YAAY,GAAG;AAClB,WAAO,gCAAgC;AAAA,EACxC;AACA,SAAO;AACR;",
6
+ "names": []
7
+ }