iobroker.nexowatt-ui 0.8.6 → 0.8.7

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/io-package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "nexowatt-ui",
4
- "version": "0.8.6",
4
+ "version": "0.8.7",
5
5
  "news": {
6
+ "0.8.7": {
7
+ "de": "Version 0.8.7: Hotfix für die EOS-Freischaltung im App-Center. Der App-Center-Runtime-Build ist wieder synchron mit der TypeScript-Quelle und lädt Lizenzdaten über API-/State-Fallbacks, damit gültige EOS-Lizenzen alle Apps anzeigen.",
8
+ "en": "Version 0.8.7: Hotfix for EOS activation in the App Center. The App Center runtime build is synchronized with the TypeScript source again and loads license data through API/state fallbacks so valid EOS licenses show all apps."
9
+ },
6
10
  "0.8.6": {
7
11
  "de": "Version 0.8.6: Hotfix für EOS/HEMS-Freischaltung im App-Center. Die Installer-API liefert Lizenzdaten zusätzlich top-level aus und das App-Center nutzt /api/license/info als No-Cache-Fallback, damit gültige EOS-Lizenzen sofort alle Apps anzeigen.",
8
12
  "en": "Version 0.8.6: Hotfix for EOS/HEMS activation in the App Center. The installer API exposes license data additionally at top level and the App Center uses /api/license/info as a no-cache fallback so valid EOS licenses immediately show all apps."
@@ -26,10 +30,6 @@
26
30
  "0.8.1": {
27
31
  "de": "Version 0.8.1: App-Center zeigt nicht installierte Apps jetzt mit rotem Nein-Status; TypeScript ist weiterhin kanonische Runtime-Quelle. Publish-Fix: TypeScript ist wieder echte devDependency und package-lock nutzt öffentliche npm-Registry-URLs.",
28
32
  "en": "Version 0.8.1: The App Center now shows uninstalled apps with a red No state; TypeScript remains the canonical runtime source. Publish fix: TypeScript is restored as a real devDependency and package-lock uses public npm registry URLs."
29
- },
30
- "0.8.0": {
31
- "de": "Version 0.8.0: TypeScript bleibt kanonische Runtime-Quelle; sichtbares Branding in der Topbar zeigt jetzt nur noch NexoWatt ohne EMS-Zusatz. Service-Worker-/PWA-Version und Brand-Cleanup-Gate ergänzt.",
32
- "en": "Version 0.8.0: TypeScript remains the canonical runtime source; visible topbar branding now shows NexoWatt without the EMS suffix. Service worker/PWA version and brand cleanup gate added."
33
33
  }
34
34
  },
35
35
  "title": "NexoWatt UI",
package/main.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * AUTO-GENERATED RUNTIME FILE - NICHT MANUELL BEARBEITEN.
3
3
  *
4
4
  * Quelle: src-ts/runtime-executables/main.ts
5
- * Quell-Hash: sha256:c9b9115d94e4f07d5b0bd125529bbad8cbad5e409dbda566c72b2dd79cc3ab13
5
+ * Quell-Hash: sha256:55fcb8ffd9f9bcc744d350192fa28441104092d528951ddd2d1f72cd59e9f173
6
6
  * Erzeugung: npm run sync:ts-runtime-executables
7
7
  *
8
8
  * Zweck:
@@ -1844,11 +1844,14 @@ class NexoWattVis extends utils.Adapter {
1844
1844
  */
1845
1845
  async _nwGetConfiguredLicenseKey() {
1846
1846
  const candidates = [];
1847
- try { candidates.push(String((this.config && this.config.licenseKey) || '').trim()); } catch (_e) {}
1847
+ // Prefer the live adapter object over this.config. The Admin tab can update
1848
+ // system.adapter.<instance>.native.licenseKey while the adapter process is still
1849
+ // running; this.config may then still contain the old value until restart.
1848
1850
  try {
1849
1851
  const objKey = await this._nwReadNativeLicenseKeyFromObject();
1850
1852
  if (objKey) candidates.push(objKey);
1851
1853
  } catch (_e) {}
1854
+ try { candidates.push(String((this.config && this.config.licenseKey) || '').trim()); } catch (_e) {}
1852
1855
 
1853
1856
  let sawMasked = false;
1854
1857
  for (const candidate of candidates) {
@@ -2374,6 +2377,10 @@ class NexoWattVis extends utils.Adapter {
2374
2377
  this._nwSystemUuid = await this._nwGetSystemUuid();
2375
2378
  const licenseSource = await this._nwGetConfiguredLicenseKey();
2376
2379
  const entered = licenseSource.key;
2380
+ try {
2381
+ this.config = this.config || {};
2382
+ if (entered && !this._nwLooksLikeMaskedLicenseKey(entered)) this.config.licenseKey = entered;
2383
+ } catch (_e) {}
2377
2384
 
2378
2385
  let info = await this._nwEvaluateLicense(this._nwSystemUuid, entered);
2379
2386
  if (!info.ok && licenseSource.sawMasked && !entered) {
@@ -9354,10 +9361,11 @@ async onReady() {
9354
9361
  if (!this._nwSystemUuid) {
9355
9362
  try { this._nwSystemUuid = await this._nwGetSystemUuid(); } catch (_e) {}
9356
9363
  }
9357
- // 0.8.6: Lizenzstatus vor jeder öffentlichen Lizenzabfrage frisch aus dem gespeicherten Key aufbauen.
9364
+ // 0.8.7: Lizenzstatus vor jeder öffentlichen Lizenzabfrage frisch aus dem gespeicherten Key aufbauen.
9358
9365
  // Dadurch sehen Admin-Seite, App-Center und Backend denselben EOS/HEMS-Status, auch direkt nach dem Speichern.
9359
9366
  try { await this._nwRefreshLicenseFromConfiguredKey(false); } catch (e) { try { this.log.warn('License refresh before /api/license/info failed: ' + (e && e.message ? e.message : e)); } catch (_eLog) {} }
9360
9367
  const info = (this._nwLicenseInfo && typeof this._nwLicenseInfo === 'object') ? this._nwLicenseInfo : {};
9368
+ const featureInfo = this._nwBuildLicenseFeatureInfo();
9361
9369
  const keyInfo = await this._nwGetConfiguredLicenseKey();
9362
9370
  const currentLicenseKey = keyInfo.key;
9363
9371
  const maskedLicenseKey = currentLicenseKey
@@ -9369,10 +9377,11 @@ async onReady() {
9369
9377
  uuid: String(this._nwSystemUuid || ''),
9370
9378
  valid: !!this._nwLicenseOk,
9371
9379
  type: String(info.type || 'none'),
9372
- edition: String(this._nwBuildLicenseFeatureInfo().edition || 'none'),
9373
- editionLabel: String(this._nwBuildLicenseFeatureInfo().editionLabel || ''),
9374
- maxWallboxes: Number(this._nwBuildLicenseFeatureInfo().maxWallboxes || 0),
9375
- features: this._nwBuildLicenseFeatureInfo().features || {},
9380
+ edition: String(featureInfo.edition || 'none'),
9381
+ editionLabel: String(featureInfo.editionLabel || ''),
9382
+ maxWallboxes: Number(featureInfo.maxWallboxes || 0),
9383
+ features: featureInfo.features || {},
9384
+ eosFullAccess: !!featureInfo.eosFullAccess,
9376
9385
  message: String(info.msg || ''),
9377
9386
  expiresAt: Number(info.expiresAt || 0),
9378
9387
  daysRemaining: Number(info.daysRemaining || 0),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.nexowatt-ui",
3
- "version": "0.8.6",
3
+ "version": "0.8.7",
4
4
  "description": "Responsive NexoWatt EMS visualization adapter.",
5
5
  "author": "NexoWatt",
6
6
  "license": "UNLICENSED",
package/www/ems-apps.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * AUTO-GENERATED RUNTIME FILE - NICHT MANUELL BEARBEITEN.
3
3
  *
4
4
  * Quelle: src-ts/runtime-executables/www/ems-apps.ts
5
- * Quell-Hash: sha256:03486e6ba417367e3b8e8cb2f7ae1facd349d8cead226cbed58601cff2e679a0
5
+ * Quell-Hash: sha256:d6804f901d728a96aa309b9ca1956d39cccfbc148388aecb41a476c0a7fa0aaa
6
6
  * Erzeugung: npm run sync:ts-runtime-executables
7
7
  *
8
8
  * Zweck:
@@ -941,8 +941,8 @@
941
941
  const labelHint = String(unwrap(src.editionLabel) || unwrap(src.message) || unwrap(src.msg) || '').trim().toLowerCase();
942
942
  const keyHint = String(unwrap(src.licenseKey) || unwrap(src.licenseKeyMasked) || '').trim().toUpperCase().replace(/[^A-Z0-9]/g, '');
943
943
  let edition = rawEdition === 'eos' ? 'eos' : (rawEdition === 'hems' ? 'hems' : 'none');
944
- if (edition === 'none' && (src.eosFullAccess === true || asBool(src.eosFullAccess) || /eos/.test(labelHint))) edition = 'eos';
945
- if (edition === 'none' && /hems/.test(labelHint)) edition = 'hems';
944
+ if (edition === 'none' && (src.eosFullAccess === true || asBool(src.eosFullAccess) || /\beos\b/.test(labelHint))) edition = 'eos';
945
+ if (edition === 'none' && /\bhems\b/.test(labelHint)) edition = 'hems';
946
946
  if (edition === 'none' && /^NW1TH/.test(keyHint)) edition = 'hems';
947
947
  if (edition === 'none' && /^(NW1E|NW1TE|NW1T|NW1)/.test(keyHint)) edition = 'eos';
948
948
  // /api/license/info uses ok=true for transport success; the license itself is valid=true.
@@ -996,6 +996,56 @@
996
996
  }
997
997
  }
998
998
 
999
+ async function fetchLicenseInfoFromStateFallback() {
1000
+ try {
1001
+ const data = await fetchJson('/api/state?t=' + Date.now(), { cache: 'no-store' });
1002
+ const readVal = (key) => {
1003
+ const rec = data && data[key];
1004
+ return rec && Object.prototype.hasOwnProperty.call(rec, 'value') ? rec.value : undefined;
1005
+ };
1006
+ return normalizeLicenseInfo({
1007
+ valid: readVal('license.valid'),
1008
+ type: readVal('license.type') || 'none',
1009
+ edition: readVal('license.edition') || 'none',
1010
+ editionLabel: readVal('license.edition') || readVal('license.message') || '',
1011
+ featuresJson: readVal('license.featuresJson') || '{}',
1012
+ maxWallboxes: readVal('license.maxWallboxes'),
1013
+ message: readVal('license.message') || '',
1014
+ expiresAt: readVal('license.expiresAt') || 0,
1015
+ daysRemaining: readVal('license.daysRemaining') || 0,
1016
+ });
1017
+ } catch (_e) {
1018
+ return null;
1019
+ }
1020
+ }
1021
+
1022
+ let _licenseLiveRefreshInFlight = false;
1023
+ async function refreshLicenseForAppCenter(reason) {
1024
+ if (_licenseLiveRefreshInFlight) return;
1025
+ _licenseLiveRefreshInFlight = true;
1026
+ try {
1027
+ const before = JSON.stringify(currentLicenseInfo || {});
1028
+ const liveLicense = await fetchLicenseInfoFallback();
1029
+ const stateLicense = _licenseIsUsable(liveLicense) ? null : await fetchLicenseInfoFromStateFallback();
1030
+ const nextLicense = _licenseIsUsable(liveLicense) ? liveLicense : (_licenseIsUsable(stateLicense) ? stateLicense : liveLicense || stateLicense);
1031
+ if (!nextLicense) return;
1032
+ currentConfig = currentConfig && typeof currentConfig === 'object' ? currentConfig : {};
1033
+ currentConfig.license = nextLicense;
1034
+ currentLicenseInfo = normalizeLicenseInfo(nextLicense);
1035
+ const after = JSON.stringify(currentLicenseInfo || {});
1036
+ if (before !== after) {
1037
+ try { buildAppsUI(); } catch (_eBuildApps) {}
1038
+ try { buildEvcsUI(); } catch (_eBuildEvcs) {}
1039
+ try { scheduleValidation(200); } catch (_eValidation) {}
1040
+ if (_licenseEdition() !== 'none') {
1041
+ try { setStatus('Lizenz aktualisiert: ' + _licenseLabel() + '.', 'ok'); } catch (_eStatus) {}
1042
+ }
1043
+ }
1044
+ } finally {
1045
+ _licenseLiveRefreshInFlight = false;
1046
+ }
1047
+ }
1048
+
999
1049
  /**
1000
1050
  * Code-Teil: _decodeShadowDisplayText
1001
1051
  *
@@ -9135,6 +9185,12 @@ function collectAiAdvisorConfigFromUI(base) {
9135
9185
  currentLicenseInfo = normalizeLicenseInfo(currentConfig.license);
9136
9186
 
9137
9187
  // Apps
9188
+ // 0.8.7 Hotfix: Die App-Liste hängt von der Lizenzedition ab. Beim Seitenstart
9189
+ // wurde buildAppsUI() noch mit "Keine Lizenz" gerendert; applyConfigToUI() setzte
9190
+ // danach zwar currentLicenseInfo=EOS/HEMS, baute die Liste aber nicht neu. Dadurch
9191
+ // blieb trotz gültiger EOS-Lizenz "Keine Apps verfügbar" stehen. Deshalb zuerst
9192
+ // die lizenzabhängige App-Struktur neu erzeugen, danach die gespeicherten Toggles setzen.
9193
+ try { buildAppsUI(); } catch (_eBuildApps) {}
9138
9194
  setAppsFromConfig(currentConfig);
9139
9195
 
9140
9196
  // Plant params
@@ -10287,8 +10343,11 @@ function collectAiAdvisorConfigFromUI(base) {
10287
10343
  // sichtbar wird und nicht auf einer alten "Keine Lizenz"-Konfiguration hängen bleibt.
10288
10344
  const configLicense = normalizeLicenseInfo(cfg.license || (data && data.license));
10289
10345
  const liveLicense = await fetchLicenseInfoFallback();
10346
+ const stateLicense = _licenseIsUsable(liveLicense) ? null : await fetchLicenseInfoFromStateFallback();
10290
10347
  if (_licenseIsUsable(liveLicense)) {
10291
10348
  cfg.license = liveLicense;
10349
+ } else if (_licenseIsUsable(stateLicense)) {
10350
+ cfg.license = stateLicense;
10292
10351
  } else if (_licenseIsUsable(configLicense)) {
10293
10352
  cfg.license = configLicense;
10294
10353
  } else {
@@ -12940,4 +12999,14 @@ if (els.ocppAutoDetect) {
12940
12999
  loadConfig().catch(e => setStatus('Laden fehlgeschlagen: ' + (e && e.message ? e.message : e), 'error'));
12941
13000
  backupRefreshInfo().catch(() => {});
12942
13001
 
13002
+ // 0.8.7: Wenn die Lizenz in einem anderen Admin-Tab aktiviert wird, soll das bereits offene
13003
+ // App-Center automatisch von "Keine Lizenz" auf EOS/HEMS umschalten und die Apps wieder anzeigen.
13004
+ window.addEventListener('focus', () => { refreshLicenseForAppCenter('focus').catch(() => {}); });
13005
+ document.addEventListener('visibilitychange', () => {
13006
+ if (!document.hidden) refreshLicenseForAppCenter('visible').catch(() => {});
13007
+ });
13008
+ window.setInterval(() => {
13009
+ if (_licenseEdition() === 'none') refreshLicenseForAppCenter('poll').catch(() => {});
13010
+ }, 5000);
13011
+
12943
13012
  })();
@@ -44,5 +44,5 @@
44
44
  "purpose": "maskable"
45
45
  }
46
46
  ],
47
- "version": "0.8.6"
47
+ "version": "0.8.7"
48
48
  }
package/www/sw.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * AUTO-GENERATED RUNTIME FILE - NICHT MANUELL BEARBEITEN.
3
3
  *
4
4
  * Quelle: src-ts/runtime-executables/www/sw.ts
5
- * Quell-Hash: sha256:48d2d19eb67b2158ae6f17094cb5ea7cc1a7449f6fc0a3ca2453e2f679535754
5
+ * Quell-Hash: sha256:1a6498dd9b059392584dafb189a79ae02ebd9cfa2d3ddfa6d273c862516470c8
6
6
  * Erzeugung: npm run sync:ts-runtime-executables
7
7
  *
8
8
  * Zweck:
@@ -42,7 +42,7 @@
42
42
 
43
43
  // Increment cache name on releases so browser updates JS/HTML reliably.
44
44
  // NOTE: Keep this monotonic to force SW updates on hotfixes.
45
- const CACHE_NAME = 'nexowatt-cache-v307';
45
+ const CACHE_NAME = 'nexowatt-cache-v308';
46
46
 
47
47
  const OFFLINE_URLS = [
48
48
  './',