iobroker.nexowatt-ui 0.7.37 → 0.7.38

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.
@@ -100,10 +100,21 @@ class AiAdvisorModule extends BaseModule {
100
100
  : {};
101
101
  const cats = (c.categories && typeof c.categories === 'object') ? c.categories : {};
102
102
  const minPriority = String(c.minPriority || 'info').trim().toLowerCase();
103
+ let customerEnabled = true;
104
+ try {
105
+ const rec = this.adapter && this.adapter.stateCache ? this.adapter.stateCache['settings.aiAdvisorEnabled'] : null;
106
+ customerEnabled = bool(rec && Object.prototype.hasOwnProperty.call(rec, 'value') ? rec.value : true, true);
107
+ } catch (_e) {
108
+ customerEnabled = true;
109
+ }
110
+ const configuredEnabled = c.enabled !== false;
111
+ const showOnLiveCfg = (c.showInLive !== undefined) ? c.showInLive : c.showOnLive;
103
112
  return {
104
- enabled: c.enabled !== false,
113
+ enabled: configuredEnabled && customerEnabled,
114
+ customerEnabled,
115
+ configuredEnabled,
105
116
  advisoryOnly: true,
106
- showInLive: c.showInLive !== false,
117
+ showInLive: showOnLiveCfg !== false,
107
118
  // App-Center writes intervalSec/exportHighW/importHighW/pvForecastHighW.
108
119
  // Keep legacy/canonical aliases as well so older configs remain valid.
109
120
  minIntervalSec: clamp(num(c.minIntervalSec ?? c.intervalSec, 60), 10, 3600),
@@ -170,6 +181,8 @@ class AiAdvisorModule extends BaseModule {
170
181
  await mk('aiAdvisor.enabled', 'KI-Energieberater aktiv', 'boolean', 'indicator');
171
182
  await mk('aiAdvisor.advisoryOnly', 'Nur Beratung, keine Schaltentscheidungen', 'boolean', 'indicator');
172
183
  await mk('aiAdvisor.showInLive', 'In LIVE anzeigen', 'boolean', 'indicator');
184
+ // Compatibility alias: App-Center and older VIS builds used "showOnLive".
185
+ await mk('aiAdvisor.showOnLive', 'In LIVE anzeigen', 'boolean', 'indicator');
173
186
  await mk('aiAdvisor.status', 'Status', 'string', 'text');
174
187
  await mk('aiAdvisor.severity', 'Höchste Priorität / Severity', 'string', 'text');
175
188
  await mk('aiAdvisor.headline', 'Kurz-Hinweis', 'string', 'text');
@@ -632,10 +645,11 @@ class AiAdvisorModule extends BaseModule {
632
645
  await this._set('aiAdvisor.enabled', false);
633
646
  await this._set('aiAdvisor.advisoryOnly', true);
634
647
  await this._set('aiAdvisor.showInLive', cfg.showInLive !== false);
648
+ await this._set('aiAdvisor.showOnLive', cfg.showInLive !== false);
635
649
  await this._set('aiAdvisor.status', 'disabled');
636
650
  await this._set('aiAdvisor.severity', 'neutral');
637
651
  await this._set('aiAdvisor.headline', 'KI-Energieberater deaktiviert');
638
- await this._set('aiAdvisor.summary', 'Die beratende KI ist im App-Center deaktiviert.');
652
+ await this._set('aiAdvisor.summary', cfg.customerEnabled === false ? 'Die beratende KI ist in den Kundeneinstellungen deaktiviert.' : 'Die beratende KI ist im App-Center deaktiviert.');
639
653
  await this._set('aiAdvisor.count', 0);
640
654
  await this._set('aiAdvisor.score', 0);
641
655
  await this._set('aiAdvisor.topTitle', '');
@@ -677,6 +691,7 @@ class AiAdvisorModule extends BaseModule {
677
691
  await this._set('aiAdvisor.enabled', true);
678
692
  await this._set('aiAdvisor.advisoryOnly', true);
679
693
  await this._set('aiAdvisor.showInLive', cfg.showInLive !== false);
694
+ await this._set('aiAdvisor.showOnLive', cfg.showInLive !== false);
680
695
  await this._set('aiAdvisor.status', 'ok');
681
696
  await this._set('aiAdvisor.severity', severity);
682
697
  await this._set('aiAdvisor.headline', headline);
package/io-package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "nexowatt-ui",
4
- "version": "0.7.37",
4
+ "version": "0.7.38",
5
5
  "news": {
6
6
  "0.7.31": {
7
7
  "en": "Added advisory AI energy optimizer: a new App-Center “AI Optimization” app, advisor-only EMS module, aiAdvisor.* runtime states, configurable categories/thresholds, and a LIVE dashboard recommendation card. The UI adapter only produces optimization suggestions; no automatic switching decisions are executed.",
@@ -1971,7 +1971,7 @@
1971
1971
  }
1972
1972
  },
1973
1973
  "instanceObjects": [],
1974
- "version": "0.7.36",
1974
+ "version": "0.7.38",
1975
1975
  "news": {
1976
1976
  "0.7.28": {
1977
1977
  "en": "Peak-Shaving App-Center tab added: installers can now configure standard, atypical HLZF, hybrid or monitoring modes directly in the UI.",
package/main.js CHANGED
@@ -1436,6 +1436,9 @@ class NexoWattVis extends utils.Adapter {
1436
1436
  // Used in live views (e.g. Speicherfarm) and monitoring/notifications.
1437
1437
  deviceStaleTimeoutSec: { type: 'number', role: 'value.interval', def: 300 },
1438
1438
 
1439
+ // Kundencockpit: KI-Energieberater kann vom Betreiber ein-/ausgeschaltet werden.
1440
+ aiAdvisorEnabled: { type: 'boolean', role: 'state', def: true },
1441
+
1439
1442
  dynamicTariff: { type: 'boolean', role: 'state', def: false },
1440
1443
  storagePower: { type: 'number', role: 'value.power', def: 1000 },
1441
1444
  price: { type: 'number', role: 'value', def: 0.25 },
@@ -7542,6 +7545,11 @@ async onReady() {
7542
7545
  </html>`);
7543
7546
  });
7544
7547
 
7548
+ // --- Static UI pages ---------------------------------------------------
7549
+ app.get(['/storagefarm.html','/storagefarm','/speicherfarm.html','/speicherfarm'], (_req, res) => {
7550
+ res.sendFile(path.join(__dirname, 'www', 'storagefarm.html'));
7551
+ });
7552
+
7545
7553
  app.get('/', (_req, res) => {
7546
7554
  res.sendFile(path.join(__dirname, 'www', 'index.html'));
7547
7555
  });
@@ -11393,6 +11401,7 @@ app.get(['/logic.html','/logic'], (req, res) => {
11393
11401
  res.sendFile(path.join(__dirname, 'www', 'evcs.html'));
11394
11402
  });
11395
11403
 
11404
+
11396
11405
  // --- EVCS report page ---
11397
11406
  app.get(['/evcs-report.html','/evcs-report'], (req, res) => {
11398
11407
  const qs = (req && req.url && req.url.includes('?')) ? req.url.slice(req.url.indexOf('?')) : '';
@@ -14194,6 +14203,20 @@ settingsConfig: {
14194
14203
  }
14195
14204
 
14196
14205
 
14206
+ // Customer-facing KI-Energieberater toggle.
14207
+ // Store this as local VIS state so the customer can decide without opening installer/admin config.
14208
+ if (scope === 'settings' && String(key) === 'aiAdvisorEnabled') {
14209
+ const b = !!value;
14210
+ try {
14211
+ await this.setStateAsync('settings.aiAdvisorEnabled', { val: b, ack: false });
14212
+ try { this.updateValue('settings.aiAdvisorEnabled', b, Date.now()); } catch (_e) {}
14213
+ return res.json({ ok: true });
14214
+ } catch (e) {
14215
+ this.log.warn('set error (aiAdvisorEnabled): ' + (e && e.message ? e.message : e));
14216
+ return res.status(500).json({ ok: false, error: 'internal error' });
14217
+ }
14218
+ }
14219
+
14197
14220
  // Installer-only scopes (protect RFID whitelist + installer settings)
14198
14221
  if ((scope === 'installer' || scope === 'rfid') && authEnabled && protectWrites) {
14199
14222
  const s = req.nwSession;
@@ -16270,6 +16293,9 @@ return res.json(out);
16270
16293
  'notifyInverters',
16271
16294
  'notifyHardCurtailment',
16272
16295
  'notifyRecovery',
16296
+ 'deviceStaleTimeoutSec',
16297
+ // Customer cockpit settings
16298
+ 'aiAdvisorEnabled',
16273
16299
  // Tariff/charging settings
16274
16300
  'dynamicTariff','storagePower','price','priority','tariffMode',
16275
16301
  // PV Saisonprofil (Quartale)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.nexowatt-ui",
3
- "version": "0.7.37",
3
+ "version": "0.7.38",
4
4
  "description": "Responsive NexoWatt EMS visualization adapter.",
5
5
  "author": "NexoWatt",
6
6
  "license": "Proprietary License (NPL) v1.0",
package/www/app.js CHANGED
@@ -2722,6 +2722,7 @@ function initSettingsPanel(){
2722
2722
  };
2723
2723
 
2724
2724
  // UI-Update immer ausführen
2725
+ try { syncToggleButtonsForInputId('s_aiAdvisorEnabled'); } catch (_e) {}
2725
2726
  updateWeatherVisibility();
2726
2727
  updateWeatherModeUi();
2727
2728
 
@@ -3071,6 +3072,18 @@ function bindInputValue(el, stateKey) {
3071
3072
  if (!Number.isFinite(val)) val = 0;
3072
3073
  } else val = el.value;
3073
3074
 
3075
+ try {
3076
+ if (stateKey) {
3077
+ if (!state || typeof state !== 'object') state = {};
3078
+ const prev = state[stateKey] && typeof state[stateKey] === 'object' ? state[stateKey] : {};
3079
+ state[stateKey] = Object.assign({}, prev, { value: val, ts: Date.now(), ack: false });
3080
+ window.latestState = state;
3081
+ }
3082
+ if (scope === 'settings' && key === 'aiAdvisorEnabled') {
3083
+ try { updateAiAdvisorLiveUi(); } catch (_e) {}
3084
+ }
3085
+ } catch (_e) {}
3086
+
3074
3087
  try {
3075
3088
  await fetch('/api/set', {
3076
3089
  method: 'POST',
@@ -6136,13 +6149,20 @@ function updateAiAdvisorLiveUi() {
6136
6149
  const card = document.getElementById('aiAdvisorLiveCard');
6137
6150
  if (!card) return;
6138
6151
 
6152
+ // Endkunden-Schalter aus den Einstellungen: Der Kunde entscheidet,
6153
+ // ob der KI-Energieberater im Kundencockpit aktiv/sichtbar ist.
6154
+ const customerEnabled = _nwAiAdvisorBool('settings.aiAdvisorEnabled', true);
6155
+ const emsCfg = (window.__nwEmsCfg && typeof window.__nwEmsCfg === 'object') ? window.__nwEmsCfg : {};
6156
+ const appCenterEnabled = (emsCfg.aiAdvisorEnabled === undefined || emsCfg.aiAdvisorEnabled === null)
6157
+ ? true
6158
+ : !(emsCfg.aiAdvisorEnabled === false || emsCfg.aiAdvisorEnabled === 0 || String(emsCfg.aiAdvisorEnabled).toLowerCase() === 'false');
6139
6159
  const enabled = _nwAiAdvisorBool('aiAdvisor.enabled', false);
6140
- const showOnLive = _nwAiAdvisorBool('aiAdvisor.showOnLive', true);
6160
+ const showInLive = _nwAiAdvisorBool('aiAdvisor.showInLive', _nwAiAdvisorBool('aiAdvisor.showOnLive', true));
6141
6161
  const status = String(_nwAiAdvisorStateValue('aiAdvisor.status', '') || '');
6142
- const suggestions = _nwAiAdvisorParseSuggestions();
6162
+ const suggestions = (customerEnabled && appCenterEnabled) ? _nwAiAdvisorParseSuggestions() : [];
6143
6163
  const top = suggestions[0] || null;
6144
6164
 
6145
- const shouldShow = !!(enabled && showOnLive && (top || status));
6165
+ const shouldShow = !!(appCenterEnabled && customerEnabled && enabled && showInLive && (top || status));
6146
6166
  card.classList.toggle('hidden', !shouldShow);
6147
6167
  if (!shouldShow) return;
6148
6168
 
package/www/ems-apps.js CHANGED
@@ -885,7 +885,7 @@ function _collectFlowPowerDpIsWFromUI() {
885
885
  const cfg = (currentConfig && currentConfig.aiAdvisor && typeof currentConfig.aiAdvisor === 'object') ? currentConfig.aiAdvisor : {};
886
886
  const cats = (cfg.categories && typeof cfg.categories === 'object') ? cfg.categories : {};
887
887
 
888
- _aiSetCheckbox(els.aiAdvisorShowOnLive, cfg.showOnLive, true);
888
+ _aiSetCheckbox(els.aiAdvisorShowOnLive, (cfg.showInLive !== undefined ? cfg.showInLive : cfg.showOnLive), true);
889
889
  _aiSetNumberInput(els.aiAdvisorIntervalSec, cfg.intervalSec, 60);
890
890
  _aiSetNumberInput(els.aiAdvisorMaxSuggestions, cfg.maxSuggestions, 4);
891
891
  if (els.aiAdvisorMinPriority) {
@@ -921,6 +921,7 @@ function _collectFlowPowerDpIsWFromUI() {
921
921
  out.mode = 'advisor';
922
922
  out.advisoryOnly = true;
923
923
  out.showOnLive = els.aiAdvisorShowOnLive ? !!els.aiAdvisorShowOnLive.checked : true;
924
+ out.showInLive = out.showOnLive;
924
925
  out.intervalSec = n(els.aiAdvisorIntervalSec, 60, 10, 3600);
925
926
  out.maxSuggestions = n(els.aiAdvisorMaxSuggestions, 4, 1, 10);
926
927
  out.minPriority = els.aiAdvisorMinPriority ? String(els.aiAdvisorMinPriority.value || 'info').toLowerCase() : 'info';
@@ -43,5 +43,6 @@
43
43
  "type": "image/png",
44
44
  "purpose": "maskable"
45
45
  }
46
- ]
47
- }
46
+ ],
47
+ "version": "0.7.38"
48
+ }
package/www/settings.html CHANGED
@@ -93,6 +93,18 @@
93
93
  Hier liegen allgemeine Frontend-Einstellungen und die Wetter-App. Weitere Themen findest du links sauber in eigenen Seiten.
94
94
  </div>
95
95
 
96
+ <div class="nw-settings-section-title">KI‑Energieberater</div>
97
+ <label class="row"><span>KI‑Berater im LIVE-Dashboard</span>
98
+ <div class="nw-evcs-mode-buttons nw-evcs-mode-buttons-2 nw-toggle" data-toggle-for="s_aiAdvisorEnabled">
99
+ <button type="button" data-value="false">Aus</button>
100
+ <button type="button" data-value="true">An</button>
101
+ </div>
102
+ <input type="checkbox" class="nw-toggle-hidden" id="s_aiAdvisorEnabled" data-scope="settings" data-key="aiAdvisorEnabled" checked>
103
+ </label>
104
+ <small class="muted nw-settings-help" style="display:block;margin-top:6px;color:var(--muted)">
105
+ Der Kunde entscheidet hier selbst, ob die Hinweisbox „KI‑Energieberater“ im LIVE-Dashboard aktiv ist. Aus bedeutet: keine Berater-Kachel im Kundencockpit.
106
+ </small>
107
+
96
108
  <div class="nw-settings-section-title">Wetter</div>
97
109
  <label class="row"><span>Wetter-App</span>
98
110
  <div class="nw-evcs-mode-buttons nw-evcs-mode-buttons-2 nw-toggle" data-toggle-for="s_weather_enabled">
package/www/sw.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Increment cache name on releases so browser updates JS/HTML reliably.
2
2
  // NOTE: Keep this monotonic to force SW updates on hotfixes.
3
- const CACHE_NAME = 'nexowatt-cache-v204';
3
+ const CACHE_NAME = 'nexowatt-cache-v206';
4
4
 
5
5
  const OFFLINE_URLS = [
6
6
  './',