iobroker.eos-admin 9.0.17 → 9.0.18
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/NEXOWATT_EOS_BUILD_INFO.json +12 -14
- package/README.md +5 -3
- package/START_HIER_9.0.18.md +47 -0
- package/adminWww/.vite/manifest.json +39 -39
- package/adminWww/NEXOWATT_EOS_FRONTEND_MANIFEST.json +107 -107
- package/adminWww/assets/{AdapterUpdateDialog-Cpo3dAfY.js → AdapterUpdateDialog-ByJk9Cxj.js} +1 -1
- package/adminWww/assets/{Adapters-n2ukPDdC.js → Adapters-V2JtEPZX.js} +1 -1
- package/adminWww/assets/{ConfigManager-BVZ6_Ebo.js → ConfigManager-BKcdyJnN.js} +1 -1
- package/adminWww/assets/{Enums-CQ6yHG2W.js → Enums-ChbfAWzp.js} +1 -1
- package/adminWww/assets/{Fields-CaJqzoW-.js → Fields-DzaVXEvg.js} +1 -1
- package/adminWww/assets/{Files-DfvpKGa3.js → Files-CRpIXj4X.js} +1 -1
- package/adminWww/assets/{Hosts-3xLBsdG6.js → Hosts-rOgfd2wo.js} +1 -1
- package/adminWww/assets/{Instances-B7hKEhyw.js → Instances-BxLhJ6Pb.js} +1 -1
- package/adminWww/assets/{Intro-BV4kYZdT.js → Intro-BOql527d.js} +1 -1
- package/adminWww/assets/{Logs-DpL9eY69.js → Logs-WUUDY7a4.js} +1 -1
- package/adminWww/assets/{Objects-dN06jhQk.js → Objects-DYaZkCK7.js} +1 -1
- package/adminWww/assets/{Overview-Lip63_ej.js → Overview-C6hiiPbm.js} +1 -1
- package/adminWww/assets/{State-BSO2X_xN.js → State-AH43l7fG.js} +1 -1
- package/adminWww/assets/{UsedResources-DvqzszKI.js → UsedResources-jhsRMH4X.js} +1 -1
- package/adminWww/assets/{Users-Csqd1xA-.js → Users-D9wyLyJ1.js} +1 -1
- package/adminWww/assets/{bootstrap-C3HM8kNL.js → bootstrap-gVLo1K_2.js} +3 -3
- package/adminWww/assets/{hostInit-DdxBUeXQ.js → hostInit-Dt_M-NAC.js} +1 -1
- package/adminWww/assets/{icons-material-D1Tb_725.js → icons-material-DuVW_EUA.js} +1 -1
- package/adminWww/assets/{index-BOujTMyH.js → index-B1cnPkSO.js} +2 -2
- package/adminWww/assets/{installSVGRenderer-BZyrUVAo.js → installSVGRenderer-GvgHjubR.js} +1 -1
- package/adminWww/assets/{mf-entry-bootstrap-0-3418586b.js → mf-entry-bootstrap-0-6b32b635.js} +2 -2
- package/adminWww/index.html +23 -23
- package/adminWww/mf-manifest.json +1 -1
- package/adminWww/mf-stats.json +1 -1
- package/adminWww/remoteEntry-eos-9.0.18.js +12 -0
- package/adminWww/remoteEntry.js +1 -1
- package/build/lib/eosDeviceEmsPlan.js +739 -0
- package/build/lib/eosDeviceEmsPlan.js.map +1 -0
- package/build/lib/eosDeviceEmsService.js +377 -0
- package/build/lib/eosDeviceEmsService.js.map +1 -0
- package/build/lib/eosModuleHost.js +53 -2
- package/build/lib/eosModuleHost.js.map +1 -1
- package/build/lib/eosModuleHttp.js +1 -1
- package/build/lib/eosModuleHttp.js.map +1 -1
- package/build/lib/web.js +15 -0
- package/build/lib/web.js.map +1 -1
- package/docs/reports/unified-9.0.18/ALIAS_V1_COVERAGE.json +5056 -0
- package/docs/reports/unified-9.0.18/ALIAS_V1_VERTRAG.md +257 -0
- package/docs/reports/unified-9.0.18/ANFORDERUNGEN.md +55 -0
- package/docs/reports/unified-9.0.18/CUSTOMER_TARIFF_REVIEW.md +33 -0
- package/docs/reports/unified-9.0.18/GERAETE_EMS_EINRICHTUNG.md +86 -0
- package/docs/reports/unified-9.0.18/INSTALLER_LIFECYCLE_REVIEW.md +29 -0
- package/docs/reports/unified-9.0.18/KUNDENTARIF_EINRICHTUNG.md +27 -0
- package/docs/reports/unified-9.0.18/PRUEFBERICHT.md +87 -0
- package/docs/reports/unified-9.0.18/UNABHAENGIGER_REVIEW.md +63 -0
- package/docs/reports/unified-9.0.18/raw/INDEX.json +331 -0
- package/docs/reports/unified-9.0.18/raw/audit-full.log +345 -0
- package/docs/reports/unified-9.0.18/raw/audit-full.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/audit-runtime.log +23 -0
- package/docs/reports/unified-9.0.18/raw/audit-runtime.result.json +15 -0
- package/docs/reports/unified-9.0.18/raw/backend-final.log +5 -0
- package/docs/reports/unified-9.0.18/raw/backend-final.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/frontend-build.log +152 -0
- package/docs/reports/unified-9.0.18/raw/frontend-build.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/installer-build.log +26 -0
- package/docs/reports/unified-9.0.18/raw/installer-build.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/keygen-source.json +6 -0
- package/docs/reports/unified-9.0.18/raw/lint-final.log +5 -0
- package/docs/reports/unified-9.0.18/raw/lint-final.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/modules-build.log +5 -0
- package/docs/reports/unified-9.0.18/raw/modules-build.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/node22-tests-final.log +9859 -0
- package/docs/reports/unified-9.0.18/raw/node22-tests-final.result.json +13 -0
- package/docs/reports/unified-9.0.18/raw/node22-typecheck-final.log +7 -0
- package/docs/reports/unified-9.0.18/raw/node22-typecheck-final.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/node22-version.log +1 -0
- package/docs/reports/unified-9.0.18/raw/node24-tests-final.log +1663 -0
- package/docs/reports/unified-9.0.18/raw/node24-tests-final.result.json +13 -0
- package/docs/reports/unified-9.0.18/raw/node24-typecheck-final.log +5 -0
- package/docs/reports/unified-9.0.18/raw/node24-typecheck-final.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/node24-version.log +1 -0
- package/docs/reports/unified-9.0.18/raw/sbom-runtime.log +7 -0
- package/docs/reports/unified-9.0.18/raw/sbom-runtime.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/sbom-vendor-check.log +1 -0
- package/docs/reports/unified-9.0.18/raw/sbom-vendor-check.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/ui-docs-check.log +6 -0
- package/docs/reports/unified-9.0.18/raw/ui-docs-check.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/ui-runtime-final.log +7 -0
- package/docs/reports/unified-9.0.18/raw/ui-runtime-final.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/ui-runtime-sync.log +6 -0
- package/docs/reports/unified-9.0.18/raw/ui-runtime-sync.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/ui-sbom-check.log +6 -0
- package/docs/reports/unified-9.0.18/raw/ui-sbom-check.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/ui-sbom-final.log +14 -0
- package/docs/reports/unified-9.0.18/raw/ui-sbom-final.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/ui-secret-final.log +6 -0
- package/docs/reports/unified-9.0.18/raw/ui-secret-final.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/ui-security-final.log +8 -0
- package/docs/reports/unified-9.0.18/raw/ui-security-final.result.json +14 -0
- package/io-package.json +8 -8
- package/modules/devices/admin/alias-contract-v1.json +189 -0
- package/modules/devices/admin/ems-assignment.d.ts +10 -0
- package/modules/devices/admin/ems-assignment.js +194 -0
- package/modules/devices/admin/host-bridge.js +47 -0
- package/modules/devices/admin/index.html +19 -1
- package/modules/devices/admin/index_m.js +73 -1
- package/modules/devices/admin/style.css +15 -0
- package/modules/devices/checks/emsAssignment.check.js +128 -0
- package/modules/devices/eslint.hosted.config.mjs +1 -1
- package/modules/devices/index.js +11 -0
- package/modules/devices/lib/alias-contract-v1.json +189 -0
- package/modules/devices/lib/aliasContract.js +7 -1
- package/modules/devices/lib/device-alias-semantics-v1.json +1605 -0
- package/modules/devices/lib/deviceAliasSemantics.js +109 -0
- package/modules/devices/lib/deviceRuntime.js +3 -0
- package/modules/devices/test/aliasContractV1.test.js +1 -1
- package/modules/devices/test/deviceAliasSemantics.test.js +163 -0
- package/modules/devices/test/emsAssignmentUi.test.js +190 -0
- package/modules/devices/tsconfig.alias-semantics.json +17 -0
- package/modules/devices/tsconfig.ems-ui.json +9 -0
- package/package.json +9 -7
- package/release-manifests/unified/build-environment.cdx.json +6 -6
- package/release-manifests/unified/files.json +194 -85
- package/release-manifests/unified/frontend.cdx.json +6 -6
- package/release-manifests/unified/installer.cdx.json +6 -6
- package/release-manifests/unified/obsolete-admin-assets.json +84 -0
- package/release-manifests/unified/runtime.cdx.json +23 -23
- package/release-manifests/unified/validation.json +15 -15
- package/tools/eos-release-check.cjs +1 -1
- package/tools/eos-release-manifest.cjs +5 -5
- package/ui/docs/security/eslint-reviewed-findings.json +32 -18
- package/ui/ems/datapoints.js +22 -1
- package/ui/ems/modules/tariff-provider.js +232 -54
- package/ui/io-package.json +5 -1
- package/ui/lib/customer-tariff.js +241 -0
- package/ui/lib/installer-lifecycle.js +87 -0
- package/ui/main.js +203 -117
- package/ui/package.json +8 -4
- package/ui/www/customer-tariff.css +21 -0
- package/ui/www/customer-tariff.js +333 -0
- package/ui/www/ems-apps.js +16 -6
- package/ui/www/manifest.webmanifest +2 -2
- package/ui/www/settings.html +45 -0
- package/adminWww/remoteEntry-eos-9.0.17.js +0 -12
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* AUTO-GENERATED RUNTIME FILE - NICHT MANUELL BEARBEITEN.
|
|
8
8
|
*
|
|
9
9
|
* Quelle: src-ts/runtime-executables/ems/modules/tariff-provider.ts
|
|
10
|
-
* Quell-Hash: sha256:
|
|
10
|
+
* Quell-Hash: sha256:871a843c9c2da28fce4f0d53a843062d27a0189302f90787442e56987c55add8
|
|
11
11
|
* Erzeugung: npm run sync:ts-runtime-executables
|
|
12
12
|
*
|
|
13
13
|
* Zweck:
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
'use strict';
|
|
38
38
|
|
|
39
39
|
const { BaseModule } = require('./base');
|
|
40
|
+
const { createHash } = require('node:crypto');
|
|
40
41
|
const {
|
|
41
42
|
fetchProvider,
|
|
42
43
|
splitTodayTomorrow,
|
|
@@ -44,6 +45,35 @@ const {
|
|
|
44
45
|
publicRegistry,
|
|
45
46
|
} = require('../services/tariff-provider-registry');
|
|
46
47
|
|
|
48
|
+
// Only configuration changes hash the normalized configuration, including
|
|
49
|
+
// credentials. The digest is private and is never exposed as a diagnostic.
|
|
50
|
+
function stableConfiguration(value) {
|
|
51
|
+
let nodes = 0;
|
|
52
|
+
const visit = (item, depth) => {
|
|
53
|
+
if (++nodes > 4096 || depth > 16) throw new Error('TARIFF_CONFIGURATION_INVALID');
|
|
54
|
+
if (item === null || ['string', 'boolean', 'number'].includes(typeof item)) return item;
|
|
55
|
+
if (Array.isArray(item)) return item.map(child => visit(child, depth + 1));
|
|
56
|
+
if (!item || typeof item !== 'object') return undefined;
|
|
57
|
+
const entries = [];
|
|
58
|
+
for (const [key, child] of Object.entries(item).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) {
|
|
59
|
+
if (['__proto__', 'prototype', 'constructor'].includes(key)) throw new Error('TARIFF_CONFIGURATION_INVALID');
|
|
60
|
+
entries.push([key, visit(child, depth + 1)]);
|
|
61
|
+
}
|
|
62
|
+
return Object.fromEntries(entries);
|
|
63
|
+
};
|
|
64
|
+
const serialized = JSON.stringify(visit(value, 0));
|
|
65
|
+
if (serialized.length > 262144) throw new Error('TARIFF_CONFIGURATION_INVALID');
|
|
66
|
+
return serialized;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const OPERATIONAL_PRICE_STATES = [
|
|
70
|
+
['tariffProvider.currentPriceEurPerKwh', null],
|
|
71
|
+
['tariffProvider.averagePriceEurPerKwh', null],
|
|
72
|
+
['tariffProvider.pricesTodayJson', '[]'],
|
|
73
|
+
['tariffProvider.pricesTomorrowJson', '[]'],
|
|
74
|
+
['tariffProvider.normalizedJson', '[]'],
|
|
75
|
+
];
|
|
76
|
+
|
|
47
77
|
class TariffProviderModule extends BaseModule {
|
|
48
78
|
constructor(adapter, dpRegistry) {
|
|
49
79
|
super(adapter, dpRegistry);
|
|
@@ -58,6 +88,112 @@ class TariffProviderModule extends BaseModule {
|
|
|
58
88
|
this._lastError = '';
|
|
59
89
|
this._consecutiveErrors = 0;
|
|
60
90
|
this._effectiveRefreshMinutes = 0;
|
|
91
|
+
this._generation = 0;
|
|
92
|
+
this._stopped = false;
|
|
93
|
+
this._publicationTail = Promise.resolve();
|
|
94
|
+
this._invalidationPending = false;
|
|
95
|
+
this._mappingPromise = null;
|
|
96
|
+
this._captureConfiguration();
|
|
97
|
+
this._fencePriceReaders();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
_fencePriceReaders() {
|
|
101
|
+
this._priceReaderFence = { ids: new Set(OPERATIONAL_PRICE_STATES.map(([id]) => `${this.adapter.namespace}.${id}`)) };
|
|
102
|
+
this.adapter._nwTariffInvalidation = this._priceReaderFence;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
_captureConfiguration() {
|
|
106
|
+
const serialized = stableConfiguration(this._cfg());
|
|
107
|
+
const signature = createHash('sha256').update(serialized).digest('hex');
|
|
108
|
+
this._configurationSource = this.adapter?.config?.tariffProvider;
|
|
109
|
+
this._configurationCountry = this.adapter?.config?.countryProfile?.country;
|
|
110
|
+
if (signature === this._configurationSignature) return false;
|
|
111
|
+
this._configurationSignature = signature;
|
|
112
|
+
this._configuration = JSON.parse(serialized);
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
_isCurrent(generation) {
|
|
117
|
+
return !this._stopped && !this.adapter?._nwShuttingDown && generation === this._generation;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Rebind only the tariff readers, including charging-management's direct
|
|
121
|
+
* price keys. Unchanged mappings keep their transformations and caches. */
|
|
122
|
+
async applyTariffMappings() {
|
|
123
|
+
if (this._stopped || !this.dp) return;
|
|
124
|
+
if (this._mappingPromise) await this._mappingPromise;
|
|
125
|
+
const vis = this.adapter.emsEngine?.mm?.modules?.find(entry => entry.key === 'tarifVis')?.instance;
|
|
126
|
+
const dps = this.adapter.config?.datapoints || {};
|
|
127
|
+
const trim = value => typeof value === 'string' ? value.trim() : '';
|
|
128
|
+
const current = vis?._getVisPriceCurrentId?.() || trim(dps.priceCurrent);
|
|
129
|
+
const average = vis?._getVisPriceAverageId?.() || trim(dps.priceAverage);
|
|
130
|
+
const today = vis?._getVisPriceTodayJsonId?.() || trim(dps.priceTodayJson);
|
|
131
|
+
const tomorrow = vis?._getVisPriceTomorrowJsonId?.() || trim(dps.priceTomorrowJson);
|
|
132
|
+
const mappings = [
|
|
133
|
+
['tarif.preisAktuellEurProKwh', current, 'number'], ['priceCurrent', current, 'number'],
|
|
134
|
+
['tarif.preisDurchschnittEurProKwh', average, 'number'], ['priceAverage', average, 'number'],
|
|
135
|
+
['tarif.pricesTodayJson', today, 'string'], ['tarif.pricesTomorrowJson', tomorrow, 'string'],
|
|
136
|
+
];
|
|
137
|
+
const changed = [];
|
|
138
|
+
// Drop all obsolete reader bindings synchronously before the first DB
|
|
139
|
+
// await. A regulation tick can see missing readings, never old curves
|
|
140
|
+
// combined with the first newly registered price.
|
|
141
|
+
for (const [key, objectId, dataType] of mappings) {
|
|
142
|
+
const previous = this.dp.getEntry(key);
|
|
143
|
+
if (previous?.objectId === objectId) continue;
|
|
144
|
+
if (previous) this.dp.remove(key);
|
|
145
|
+
if (objectId) changed.push([key, objectId, dataType]);
|
|
146
|
+
}
|
|
147
|
+
const operation = (async () => {
|
|
148
|
+
for (const [key, objectId, dataType] of changed) {
|
|
149
|
+
if (this._stopped || this.adapter?._nwShuttingDown) return;
|
|
150
|
+
// A canonical €/kWh source never inherits a cent/kWh converter.
|
|
151
|
+
await this.dp.upsert({ key, objectId, dataType, direction: 'in',
|
|
152
|
+
...(dataType === 'number' && objectId.startsWith(`${this.adapter.namespace}.tariffProvider.`)
|
|
153
|
+
? { unit: '€/kWh', scale: 1, offset: 0, invert: false } : {}) });
|
|
154
|
+
}
|
|
155
|
+
})();
|
|
156
|
+
this._mappingPromise = operation;
|
|
157
|
+
try { await operation; }
|
|
158
|
+
finally { if (this._mappingPromise === operation) this._mappingPromise = null; }
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Called by the save/apply path, not a second scheduler or an EMS restart. */
|
|
162
|
+
invalidateConfiguration() {
|
|
163
|
+
if (this._stopped) return Promise.resolve(false);
|
|
164
|
+
const changed = this._captureConfiguration();
|
|
165
|
+
if (!changed && !this._invalidationPending) return Promise.resolve(false);
|
|
166
|
+
this._invalidationPending = true;
|
|
167
|
+
this._fencePriceReaders();
|
|
168
|
+
const generation = ++this._generation;
|
|
169
|
+
this._intervals = [];
|
|
170
|
+
this._lastFetchMs = 0;
|
|
171
|
+
this._lastSuccessMs = 0;
|
|
172
|
+
this._nextFetchMs = 0;
|
|
173
|
+
this._lastCurrentKey = '';
|
|
174
|
+
this._lastPublishedFresh = null;
|
|
175
|
+
this._lastPublishedSuccessMs = null;
|
|
176
|
+
this._lastError = '';
|
|
177
|
+
this._consecutiveErrors = 0;
|
|
178
|
+
this._effectiveRefreshMinutes = 0;
|
|
179
|
+
// Remove the old provider from the actual EMS cache immediately. This
|
|
180
|
+
// also fences any outstanding registry prime read for those exact IDs.
|
|
181
|
+
const now = Date.now();
|
|
182
|
+
for (const [id, value] of OPERATIONAL_PRICE_STATES) {
|
|
183
|
+
const fullId = `${this.adapter.namespace}.${id}`;
|
|
184
|
+
this.dp?.handleStateChange?.(fullId, null);
|
|
185
|
+
const key = this.adapter.keyFromId?.(fullId);
|
|
186
|
+
if (key) this.adapter.updateValue?.(key, value, now);
|
|
187
|
+
}
|
|
188
|
+
const cfg = this._configuration;
|
|
189
|
+
const status = !cfg.enabled ? 'disabled' : cfg.providerId === 'manual-dp' ? 'manual-datapoints' : 'configuration-changed';
|
|
190
|
+
this.adapter._tariffProviderSnapshot = { ts: now, providerId: cfg.providerId, sourceId: cfg.sourceId,
|
|
191
|
+
enabled: cfg.enabled, status, quality: 'missing', fresh: false,
|
|
192
|
+
currentPriceEurPerKwh: null, averagePriceEurPerKwh: null, intervalCount: 0, lastSuccessMs: 0 };
|
|
193
|
+
return this._publish(cfg, now, status, generation).then(() => {
|
|
194
|
+
if (this._isCurrent(generation)) this._invalidationPending = false;
|
|
195
|
+
return true;
|
|
196
|
+
});
|
|
61
197
|
}
|
|
62
198
|
|
|
63
199
|
async init() {
|
|
@@ -114,8 +250,10 @@ class TariffProviderModule extends BaseModule {
|
|
|
114
250
|
};
|
|
115
251
|
}
|
|
116
252
|
|
|
117
|
-
async _set(id, val) {
|
|
118
|
-
|
|
253
|
+
async _set(id, val, generation = this._generation) {
|
|
254
|
+
if (!this._isCurrent(generation)) return;
|
|
255
|
+
try { await this.adapter.setStateAsync(id, { val, ack: true }); }
|
|
256
|
+
catch (_e) { throw new Error('TARIFF_STATE_WRITE_FAILED'); }
|
|
119
257
|
}
|
|
120
258
|
|
|
121
259
|
_providerSourceId(cfg) {
|
|
@@ -181,16 +319,19 @@ class TariffProviderModule extends BaseModule {
|
|
|
181
319
|
return this._nextFetchMs;
|
|
182
320
|
}
|
|
183
321
|
|
|
184
|
-
async _setTariffSettings(cfg) {
|
|
185
|
-
if (!cfg.enabled || cfg.providerId === 'manual-dp' || !cfg.activateTariffLogic) return;
|
|
322
|
+
async _setTariffSettings(cfg, generation = this._generation) {
|
|
323
|
+
if (!this._isCurrent(generation) || !cfg.enabled || cfg.providerId === 'manual-dp' || !cfg.activateTariffLogic) return;
|
|
186
324
|
const ns = String(this.adapter.namespace || `nexowatt-ui.${this.adapter.instance || 0}`);
|
|
187
325
|
try {
|
|
188
326
|
const dynId = `${ns}.settings.dynamicTariff`;
|
|
189
327
|
const modeId = `${ns}.settings.tariffMode`;
|
|
190
328
|
const dyn = await this.adapter.getForeignStateAsync(dynId).catch(() => null);
|
|
329
|
+
if (!this._isCurrent(generation)) return;
|
|
191
330
|
if (!dyn || dyn.val !== true) await this.adapter.setForeignStateAsync(dynId, true, true);
|
|
331
|
+
if (!this._isCurrent(generation)) return;
|
|
192
332
|
if (cfg.automaticMode) {
|
|
193
333
|
const mode = await this.adapter.getForeignStateAsync(modeId).catch(() => null);
|
|
334
|
+
if (!this._isCurrent(generation)) return;
|
|
194
335
|
if (!mode || Number(mode.val) !== 2) await this.adapter.setForeignStateAsync(modeId, 2, true);
|
|
195
336
|
}
|
|
196
337
|
} catch (e) {
|
|
@@ -198,11 +339,20 @@ class TariffProviderModule extends BaseModule {
|
|
|
198
339
|
}
|
|
199
340
|
}
|
|
200
341
|
|
|
201
|
-
|
|
342
|
+
_publish(cfg, nowMs, statusOverride = '', generation = this._generation) {
|
|
343
|
+
const pending = this._publicationTail.then(() => this._publishCurrent(cfg, nowMs, statusOverride, generation));
|
|
344
|
+
this._publicationTail = pending.catch(() => {});
|
|
345
|
+
return pending;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
async _publishCurrent(cfg, nowMs, statusOverride, generation) {
|
|
349
|
+
if (!this._isCurrent(generation)) return;
|
|
350
|
+
const set = (id, val) => this._set(id, val, generation);
|
|
202
351
|
const split = splitTodayTomorrow(this._intervals, nowMs, cfg.timeZone);
|
|
203
352
|
const ca = currentAndAverage(this._intervals, nowMs);
|
|
204
353
|
const staleAge = this._lastSuccessMs ? nowMs - this._lastSuccessMs : Number.POSITIVE_INFINITY;
|
|
205
|
-
const fresh =
|
|
354
|
+
const fresh = cfg.enabled && cfg.providerId !== 'manual-dp' && this._lastSuccessMs > 0
|
|
355
|
+
&& staleAge <= cfg.maxStaleMinutes * 60 * 1000 && Number.isFinite(ca.current);
|
|
206
356
|
const status = statusOverride || (fresh ? 'ok' : (this._intervals.length ? 'stale' : 'waiting'));
|
|
207
357
|
const quality = this._intervals[0] ? String(this._intervals[0].quality || 'unknown') : 'missing';
|
|
208
358
|
// Never refresh the tariff-control datapoints with stale provider data.
|
|
@@ -217,40 +367,39 @@ class TariffProviderModule extends BaseModule {
|
|
|
217
367
|
// Ein echter Erfolg, Intervallwechsel oder Ablauf benötigt neue Preisstates.
|
|
218
368
|
const publishPrices = statusOverride === 'ok' || this._lastCurrentKey !== publishedKey || this._lastPublishedFresh !== fresh;
|
|
219
369
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
if (publishPrices) {
|
|
226
|
-
await this._set('tariffProvider.currentPriceEurPerKwh', current);
|
|
227
|
-
await this._set('tariffProvider.averagePriceEurPerKwh', average);
|
|
370
|
+
// Operational prices/curves are cleared before the new provider label.
|
|
371
|
+
// Consumers inspect numeric values and timestamps, not only fresh=false.
|
|
372
|
+
if (!fresh && publishPrices) {
|
|
373
|
+
await set('tariffProvider.fresh', false);
|
|
374
|
+
for (const [id, value] of OPERATIONAL_PRICE_STATES) await set(id, value);
|
|
228
375
|
}
|
|
376
|
+
|
|
377
|
+
await set('tariffProvider.enabled', cfg.enabled);
|
|
378
|
+
await set('tariffProvider.providerId', cfg.providerId);
|
|
379
|
+
await set('tariffProvider.sourceId', cfg.sourceId);
|
|
380
|
+
await set('tariffProvider.status', status);
|
|
381
|
+
await set('tariffProvider.quality', quality);
|
|
229
382
|
if (fresh && publishPrices) {
|
|
230
|
-
await
|
|
231
|
-
await
|
|
232
|
-
await this._set('tariffProvider.normalizedJson', JSON.stringify(this._intervals));
|
|
233
|
-
} else if (!fresh && publishPrices) {
|
|
234
|
-
// Explicitly clear the operational curves once their provider freshness
|
|
235
|
-
// expires. The in-memory cache remains available for diagnostics, but no
|
|
236
|
-
// new storage/EVCS tariff action may be started from it.
|
|
237
|
-
await this._set('tariffProvider.pricesTodayJson', '[]');
|
|
238
|
-
await this._set('tariffProvider.pricesTomorrowJson', '[]');
|
|
239
|
-
await this._set('tariffProvider.normalizedJson', '[]');
|
|
383
|
+
await set('tariffProvider.currentPriceEurPerKwh', current);
|
|
384
|
+
await set('tariffProvider.averagePriceEurPerKwh', average);
|
|
240
385
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
386
|
+
if (fresh && publishPrices) {
|
|
387
|
+
await set('tariffProvider.pricesTodayJson', JSON.stringify(split.today));
|
|
388
|
+
await set('tariffProvider.pricesTomorrowJson', JSON.stringify(split.tomorrow));
|
|
389
|
+
await set('tariffProvider.normalizedJson', JSON.stringify(this._intervals));
|
|
390
|
+
}
|
|
391
|
+
if (!this._isCurrent(generation)) return;
|
|
392
|
+
await set('tariffProvider.lastUpdate', nowMs);
|
|
244
393
|
if (this._lastPublishedSuccessMs !== this._lastSuccessMs) {
|
|
245
|
-
await
|
|
246
|
-
this.
|
|
394
|
+
await set('tariffProvider.lastSuccess', this._lastSuccessMs || 0);
|
|
395
|
+
if (!this._isCurrent(generation)) return;
|
|
247
396
|
}
|
|
248
|
-
await
|
|
249
|
-
await
|
|
250
|
-
await
|
|
251
|
-
await
|
|
252
|
-
await
|
|
253
|
-
await
|
|
397
|
+
await set('tariffProvider.nextUpdate', this._nextFetchMs || 0);
|
|
398
|
+
await set('tariffProvider.fresh', fresh);
|
|
399
|
+
await set('tariffProvider.error', this._lastError || '');
|
|
400
|
+
await set('tariffProvider.intervalCount', this._intervals.length);
|
|
401
|
+
await set('tariffProvider.effectiveRefreshMinutes', this._effectiveRefreshMinutes || 0);
|
|
402
|
+
await set('tariffProvider.consecutiveErrors', this._consecutiveErrors || 0);
|
|
254
403
|
const snapshot = {
|
|
255
404
|
ts: nowMs,
|
|
256
405
|
enabled: cfg.enabled,
|
|
@@ -272,17 +421,24 @@ class TariffProviderModule extends BaseModule {
|
|
|
272
421
|
consecutiveErrors: this._consecutiveErrors || 0,
|
|
273
422
|
error: this._lastError || '',
|
|
274
423
|
};
|
|
275
|
-
await
|
|
424
|
+
await set('tariffProvider.statusJson', JSON.stringify(snapshot));
|
|
425
|
+
if (!this._isCurrent(generation)) return;
|
|
426
|
+
this._lastCurrentKey = publishedKey;
|
|
427
|
+
this._lastPublishedFresh = fresh;
|
|
428
|
+
this._lastPublishedSuccessMs = this._lastSuccessMs;
|
|
429
|
+
if (this.adapter._nwTariffInvalidation === this._priceReaderFence) delete this.adapter._nwTariffInvalidation;
|
|
276
430
|
try { this.adapter._tariffProviderSnapshot = snapshot; } catch (_e) {}
|
|
277
431
|
}
|
|
278
432
|
|
|
279
433
|
/** Die Registry validiert alle Intervalle vor der Übernahme. Abruffehler
|
|
280
434
|
* behalten den letzten gültigen Stand und dessen Erfolgszeit; _publish
|
|
281
435
|
* setzt nach Ablauf der vorhandenen Frischegrenze die Preise auf null. */
|
|
282
|
-
async _refresh(cfg, nowMs) {
|
|
436
|
+
async _refresh(cfg, nowMs, generation = this._generation) {
|
|
437
|
+
if (!this._isCurrent(generation)) return;
|
|
283
438
|
this._lastFetchMs = nowMs;
|
|
284
439
|
try {
|
|
285
440
|
const result = await fetchProvider(cfg);
|
|
441
|
+
if (!this._isCurrent(generation)) return;
|
|
286
442
|
const intervals = Array.isArray(result && result.intervals) ? result.intervals : [];
|
|
287
443
|
if (!intervals.length) throw new Error('provider_returned_no_intervals');
|
|
288
444
|
// Historische Parser bleiben für Diagnose verwendbar. Erst hier an
|
|
@@ -295,19 +451,35 @@ class TariffProviderModule extends BaseModule {
|
|
|
295
451
|
this._lastError = '';
|
|
296
452
|
this._consecutiveErrors = 0;
|
|
297
453
|
this._scheduleNextFetch(cfg, this._lastSuccessMs, true);
|
|
298
|
-
await this._publish(cfg, this._lastSuccessMs, 'ok');
|
|
454
|
+
await this._publish(cfg, this._lastSuccessMs, 'ok', generation);
|
|
299
455
|
} catch (e) {
|
|
456
|
+
if (!this._isCurrent(generation)) return;
|
|
457
|
+
if (e && e.message === 'TARIFF_STATE_WRITE_FAILED') {
|
|
458
|
+
this._invalidationPending = true;
|
|
459
|
+
await this.invalidateConfiguration();
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
300
462
|
const failedAt = Date.now();
|
|
301
463
|
this._consecutiveErrors += 1;
|
|
302
464
|
this._lastError = String(e && e.message || e || 'provider_error').slice(0, 500);
|
|
303
465
|
this._scheduleNextFetch(cfg, failedAt, false);
|
|
304
466
|
try { this.adapter.log.warn(`[TariffProvider] ${cfg.providerId}: ${this._lastError}`); } catch (_e) {}
|
|
305
|
-
await this._publish(cfg, failedAt, this._intervals.length ? 'degraded' : 'error');
|
|
467
|
+
await this._publish(cfg, failedAt, this._intervals.length ? 'degraded' : 'error', generation);
|
|
306
468
|
}
|
|
307
469
|
}
|
|
308
470
|
|
|
309
471
|
async tick() {
|
|
310
|
-
|
|
472
|
+
if (this._stopped || this.adapter?._nwShuttingDown) return;
|
|
473
|
+
if (this._mappingPromise) await this._mappingPromise;
|
|
474
|
+
// The common 1-s path compares references only; secrets are not hashed
|
|
475
|
+
// on every regulation tick. Save/import explicitly invokes the hook.
|
|
476
|
+
if (this._invalidationPending || this._configurationSource !== this.adapter?.config?.tariffProvider
|
|
477
|
+
|| this._configurationCountry !== this.adapter?.config?.countryProfile?.country) {
|
|
478
|
+
await this.invalidateConfiguration();
|
|
479
|
+
}
|
|
480
|
+
const cfg = this._configuration;
|
|
481
|
+
const generation = this._generation;
|
|
482
|
+
if (!this._isCurrent(generation)) return;
|
|
311
483
|
const nowMs = Date.now();
|
|
312
484
|
if (!cfg.enabled || cfg.providerId === 'manual-dp') {
|
|
313
485
|
this._intervals = [];
|
|
@@ -315,26 +487,32 @@ class TariffProviderModule extends BaseModule {
|
|
|
315
487
|
this._consecutiveErrors = 0;
|
|
316
488
|
this._effectiveRefreshMinutes = 0;
|
|
317
489
|
this._nextFetchMs = 0;
|
|
318
|
-
|
|
319
|
-
await this.
|
|
320
|
-
await this.
|
|
321
|
-
await this._set('tariffProvider.status', cfg.enabled ? 'manual-datapoints' : 'disabled');
|
|
322
|
-
await this._set('tariffProvider.fresh', false);
|
|
323
|
-
await this._set('tariffProvider.currentPriceEurPerKwh', null);
|
|
324
|
-
await this._set('tariffProvider.averagePriceEurPerKwh', null);
|
|
325
|
-
await this._set('tariffProvider.pricesTodayJson', '[]');
|
|
326
|
-
await this._set('tariffProvider.pricesTomorrowJson', '[]');
|
|
327
|
-
await this._set('tariffProvider.normalizedJson', '[]');
|
|
490
|
+
this._lastSuccessMs = 0;
|
|
491
|
+
await this._publish(cfg, nowMs, cfg.enabled ? 'manual-datapoints' : 'disabled', generation);
|
|
492
|
+
await this._publicationTail;
|
|
328
493
|
return;
|
|
329
494
|
}
|
|
330
495
|
|
|
331
|
-
await this._setTariffSettings(cfg);
|
|
496
|
+
await this._setTariffSettings(cfg, generation);
|
|
497
|
+
if (!this._isCurrent(generation)) return;
|
|
332
498
|
if (!this._fetchPromise && (!this._lastFetchMs || nowMs >= this._nextFetchMs || !this._intervals.length)) {
|
|
333
|
-
|
|
499
|
+
const operation = this._refresh(cfg, nowMs, generation).finally(() => {
|
|
500
|
+
if (this._fetchPromise === operation) this._fetchPromise = null;
|
|
501
|
+
});
|
|
502
|
+
this._fetchPromise = operation;
|
|
334
503
|
await this._fetchPromise;
|
|
504
|
+
await this._publicationTail;
|
|
335
505
|
return;
|
|
336
506
|
}
|
|
337
|
-
await this._publish(cfg, nowMs);
|
|
507
|
+
await this._publish(cfg, nowMs, '', generation);
|
|
508
|
+
await this._publicationTail;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
stop() {
|
|
512
|
+
this._stopped = true;
|
|
513
|
+
this._generation++;
|
|
514
|
+
this._intervals = [];
|
|
515
|
+
this._lastSuccessMs = 0;
|
|
338
516
|
}
|
|
339
517
|
}
|
|
340
518
|
|
package/ui/io-package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"common": {
|
|
3
3
|
"name": "nexowatt-ui",
|
|
4
|
-
"version": "9.0.
|
|
4
|
+
"version": "9.0.18",
|
|
5
5
|
"news": {
|
|
6
|
+
"9.0.18": {
|
|
7
|
+
"en": "Automatic supported-device commissioning and explicit EMS/energy-flow roles. Existing mappings and data points are preserved; new control targets require commissioning.",
|
|
8
|
+
"de": "Automatische Zuordnung unterstützter Geräte mit expliziten EMS- und Energiefluss-Rollen. Vorhandene Zuordnungen und Datenpunkte bleiben erhalten; neue Regelziele benötigen eine Inbetriebnahme."
|
|
9
|
+
},
|
|
6
10
|
"9.0.17": {
|
|
7
11
|
"de": "EOS-Sitzungen vom ioBroker Admin getrennt; automatische Änderungen fremder Rechte und Metadaten entfernt; Parallelbetrieb mit Standard-Backitup abgesichert.",
|
|
8
12
|
"en": "Isolate EOS sessions from ioBroker Admin; remove automatic foreign permission and metadata changes; preserve standard Backitup coexistence."
|