iobroker.luxtronik2-controller 1.2.0 → 1.3.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.
@@ -0,0 +1,417 @@
1
+ /**
2
+ * <luxtronik-dhw-tank>
3
+ * Warmwasser-Speicher mit Nachlade-Linie und animiertem ZIP-Countdown-Ring
4
+ * für `@iobroker/web-components`.
5
+ */
6
+ import { LuxtronikBaseCard } from './luxtronik-base.js';
7
+
8
+ const RING_CIRCUMFERENCE = 2 * Math.PI * 38;
9
+
10
+ class LuxtronikDhwTank extends LuxtronikBaseCard {
11
+ static get stateMap() {
12
+ return {
13
+ wwTemp: 'Information.01_Temperatures.Wamwassertemperatur_Ist',
14
+ wwTarget: 'Information.01_Temperatures.Wamwassertemperatur_Soll',
15
+ wwHyst: 'Settings.03_HotWater.hotWaterTemperatureHysteresis',
16
+ wwStatus: 'Information.08_OperatingState.opStateHotWaterString',
17
+ modeCode: 'Information.08_OperatingState.WP_BZ_akt',
18
+ vd1: 'Information.03_Outputs.VD1out',
19
+ zipActive: 'Information.03_Outputs.Virtual_ZIP_Status',
20
+ zipRemaining: 'Information.03_Outputs.Virtual_ZIP_Remaining_Time',
21
+ zipDurationNormal: 'Settings.05_ZIP.zip_aktiv',
22
+ pvBoost: 'Information.17_PV_Surplus.pv_boost_active',
23
+ };
24
+ }
25
+
26
+ static get actionMap() {
27
+ return {
28
+ 'activate-zip': 'Actions.Activate_Zip',
29
+ 'force-ww': 'Actions.Zwangswarmwasser',
30
+ };
31
+ }
32
+
33
+ constructor() {
34
+ super();
35
+ this._zipPeakSec = 0;
36
+ }
37
+
38
+ _renderBase() {
39
+ const tpl = document.createElement('template');
40
+ tpl.innerHTML = `
41
+ <style>
42
+ :host {
43
+ --lux-surface: rgba(127, 127, 127, 0.11);
44
+ --lux-border: rgba(127, 127, 127, 0.24);
45
+ --lux-ww: #3b82f6;
46
+ --lux-hot: #ef4444;
47
+ --lux-warm: #f97316;
48
+ --lux-ok: #22c55e;
49
+ --lux-pv: #eab308;
50
+ display: block;
51
+ width: 100%;
52
+ height: 100%;
53
+ box-sizing: border-box;
54
+ font-family: inherit;
55
+ color: inherit;
56
+ }
57
+
58
+ .card {
59
+ width: 100%;
60
+ height: 100%;
61
+ box-sizing: border-box;
62
+ display: flex;
63
+ flex-direction: column;
64
+ gap: 10px;
65
+ padding: 12px;
66
+ overflow: auto;
67
+ }
68
+
69
+ .header {
70
+ display: flex;
71
+ justify-content: space-between;
72
+ align-items: center;
73
+ gap: 8px;
74
+ }
75
+
76
+ .title { font-size: 0.98rem; font-weight: 600; }
77
+ .badges { display: flex; gap: 6px; align-items: center; }
78
+
79
+ .pill {
80
+ padding: 2px 8px;
81
+ border-radius: 999px;
82
+ font-size: 0.72rem;
83
+ font-weight: 600;
84
+ background: var(--lux-surface);
85
+ border: 1px solid var(--lux-border);
86
+ }
87
+
88
+ .pill.charging { color: var(--lux-ww); border-color: rgba(59, 130, 246, 0.45); background: rgba(59, 130, 246, 0.16); }
89
+ .pill.ok { color: var(--lux-ok); border-color: rgba(34, 197, 94, 0.4); background: rgba(34, 197, 94, 0.14); }
90
+ .pill.pv { color: var(--lux-pv); border-color: rgba(234, 179, 8, 0.45); background: rgba(234, 179, 8, 0.14); }
91
+ .hidden { display: none !important; }
92
+
93
+ .body {
94
+ flex: 1;
95
+ display: grid;
96
+ grid-template-columns: 118px 1fr;
97
+ gap: 12px;
98
+ align-items: center;
99
+ min-height: 0;
100
+ }
101
+
102
+ .tank-wrap {
103
+ display: flex;
104
+ justify-content: center;
105
+ align-items: center;
106
+ height: 100%;
107
+ }
108
+
109
+ .tank-svg {
110
+ width: 112px;
111
+ height: 168px;
112
+ }
113
+
114
+ .side {
115
+ display: flex;
116
+ flex-direction: column;
117
+ gap: 10px;
118
+ align-items: stretch;
119
+ }
120
+
121
+ .metrics {
122
+ background: var(--lux-surface);
123
+ border: 1px solid var(--lux-border);
124
+ border-radius: 10px;
125
+ padding: 8px 10px;
126
+ display: flex;
127
+ flex-direction: column;
128
+ gap: 4px;
129
+ }
130
+
131
+ .row {
132
+ display: flex;
133
+ justify-content: space-between;
134
+ font-size: 0.78rem;
135
+ font-variant-numeric: tabular-nums;
136
+ }
137
+
138
+ .row .lbl { opacity: 0.72; }
139
+ .row .val { font-weight: 600; }
140
+
141
+ .zip-area {
142
+ display: flex;
143
+ align-items: center;
144
+ gap: 10px;
145
+ }
146
+
147
+ .zip-btn {
148
+ position: relative;
149
+ width: 88px;
150
+ height: 88px;
151
+ flex-shrink: 0;
152
+ border: none;
153
+ background: transparent;
154
+ padding: 0;
155
+ cursor: pointer;
156
+ color: inherit;
157
+ display: flex;
158
+ align-items: center;
159
+ justify-content: center;
160
+ }
161
+
162
+ .zip-btn:active { transform: scale(0.96); }
163
+
164
+ .zip-ring {
165
+ position: absolute;
166
+ inset: 0;
167
+ width: 88px;
168
+ height: 88px;
169
+ transform: rotate(-90deg);
170
+ }
171
+
172
+ .ring-bg {
173
+ fill: var(--lux-surface);
174
+ stroke: var(--lux-border);
175
+ stroke-width: 5;
176
+ }
177
+
178
+ .ring-fg {
179
+ fill: none;
180
+ stroke: var(--lux-ww);
181
+ stroke-width: 5;
182
+ stroke-linecap: round;
183
+ stroke-dasharray: ${RING_CIRCUMFERENCE.toFixed(2)};
184
+ stroke-dashoffset: ${RING_CIRCUMFERENCE.toFixed(2)};
185
+ transition: stroke-dashoffset 0.45s linear, stroke 0.25s ease;
186
+ }
187
+
188
+ .zip-btn.active .ring-fg { stroke: var(--lux-ok); }
189
+
190
+ .zip-center {
191
+ position: relative;
192
+ z-index: 1;
193
+ display: flex;
194
+ flex-direction: column;
195
+ align-items: center;
196
+ line-height: 1.15;
197
+ }
198
+
199
+ .zip-title { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.03em; }
200
+ .zip-sub { font-size: 0.78rem; font-weight: 600; opacity: 0.85; font-variant-numeric: tabular-nums; }
201
+
202
+ .side-actions {
203
+ display: flex;
204
+ flex-direction: column;
205
+ gap: 6px;
206
+ flex: 1;
207
+ }
208
+
209
+ .force-btn {
210
+ background: var(--lux-surface);
211
+ color: inherit;
212
+ border: 1px solid var(--lux-border);
213
+ border-radius: 8px;
214
+ padding: 8px 10px;
215
+ font-size: 0.76rem;
216
+ font-weight: 600;
217
+ cursor: pointer;
218
+ }
219
+
220
+ .force-btn:hover {
221
+ border-color: var(--lux-ww);
222
+ background: rgba(59, 130, 246, 0.16);
223
+ }
224
+
225
+ .hint {
226
+ font-size: 0.72rem;
227
+ opacity: 0.7;
228
+ line-height: 1.25;
229
+ }
230
+ </style>
231
+
232
+ <div class="card">
233
+ <div class="header">
234
+ <div class="title" data-ref="title">Warmwasser</div>
235
+ <div class="badges">
236
+ <span class="pill pv hidden" data-ref="pvBadge">PV</span>
237
+ <span class="pill ok" data-ref="statusBadge">–</span>
238
+ </div>
239
+ </div>
240
+
241
+ <div class="body">
242
+ <!-- Grafischer Speicher-Zylinder -->
243
+ <div class="tank-wrap">
244
+ <svg class="tank-svg" viewBox="0 0 116 174">
245
+ <defs>
246
+ <linearGradient id="tankGrad" x1="0" y1="1" x2="0" y2="0">
247
+ <stop offset="0%" stop-color="#2563eb" />
248
+ <stop offset="55%" stop-color="#f97316" />
249
+ <stop offset="100%" stop-color="#ef4444" />
250
+ </linearGradient>
251
+ <clipPath id="tankClip">
252
+ <rect x="14" y="14" width="84" height="146" rx="22" />
253
+ </clipPath>
254
+ </defs>
255
+
256
+ <!-- Speicherhülle Hintergrund -->
257
+ <rect x="14" y="14" width="84" height="146" rx="22" fill="rgba(127,127,127,0.14)" />
258
+
259
+ <!-- Dynamischer Füllstand -->
260
+ <g clip-path="url(#tankClip)">
261
+ <rect x="14" y="160" width="84" height="0" fill="url(#tankGrad)" opacity="0.82" data-ref="tankFill" />
262
+ </g>
263
+
264
+ <!-- Nachlade-Linie (Soll - Hysterese) -->
265
+ <line x1="12" x2="100" y1="110" y2="110" stroke="#93c5fd" stroke-width="1.6" stroke-dasharray="4 3" data-ref="hystLine" />
266
+ <!-- Soll-Linie -->
267
+ <line x1="12" x2="100" y1="44" y2="44" stroke="#ffffff" stroke-width="1.8" opacity="0.85" data-ref="targetLine" />
268
+
269
+ <!-- Speicher-Kontur -->
270
+ <rect x="14" y="14" width="84" height="146" rx="22" fill="none" stroke="currentColor" stroke-opacity="0.32" stroke-width="2" />
271
+
272
+ <!-- Große Ist-Temperatur im Speicher -->
273
+ <text x="56" y="88" text-anchor="middle" font-size="20" font-weight="700" fill="#ffffff" style="text-shadow:0 1px 4px rgba(0,0,0,0.55)" data-ref="wwTemp">–</text>
274
+ <text x="56" y="106" text-anchor="middle" font-size="10" font-weight="600" fill="#ffffff" opacity="0.9" data-ref="reservePct">–</text>
275
+ </svg>
276
+ </div>
277
+
278
+ <!-- Rechte Seite: Kennwerte + ZIP-Countdown-Button -->
279
+ <div class="side">
280
+ <div class="metrics">
281
+ <div class="row"><span class="lbl">Sollwert</span><span class="val" data-ref="wwTarget">–</span></div>
282
+ <div class="row"><span class="lbl">Nachladen ab</span><span class="val" data-ref="rechargeAt">–</span></div>
283
+ <div class="row"><span class="lbl">Reserve</span><span class="val" data-ref="reserveK">–</span></div>
284
+ </div>
285
+
286
+ <div class="zip-area">
287
+ <button class="zip-btn" type="button" data-action="activate-zip" data-ref="zipBtn" title="Zirkulationspumpe starten">
288
+ <svg class="zip-ring" viewBox="0 0 88 88">
289
+ <circle class="ring-bg" cx="44" cy="44" r="38" />
290
+ <circle class="ring-fg" cx="44" cy="44" r="38" data-ref="zipRing" />
291
+ </svg>
292
+ <div class="zip-center">
293
+ <span class="zip-title" data-ref="zipTitle">ZIP</span>
294
+ <span class="zip-sub" data-ref="zipTimer">Start</span>
295
+ </div>
296
+ </button>
297
+
298
+ <div class="side-actions">
299
+ <button class="force-btn" type="button" data-action="force-ww" data-ref="forceBtn">1× Aufheizen</button>
300
+ <div class="hint" data-ref="hintText">Zirkulation bereit</div>
301
+ </div>
302
+ </div>
303
+ </div>
304
+ </div>
305
+ </div>
306
+ `;
307
+ this.shadowRoot.appendChild(tpl.content.cloneNode(true));
308
+ }
309
+
310
+ _tempToY(temp) {
311
+ // Skala 20 °C (unten y=154) bis 65 °C (oben y=20)
312
+ const clamped = Math.max(20, Math.min(65, temp));
313
+ const ratio = (clamped - 20) / (65 - 20);
314
+ return 154 - ratio * 134;
315
+ }
316
+
317
+ _updateView() {
318
+ const r = this._refs;
319
+ if (!r.title) {
320
+ return;
321
+ }
322
+
323
+ const v = this._values;
324
+ const wwIst = this._toNum(v.wwTemp);
325
+ const wwTarget = this._toNum(v.wwTarget);
326
+ const wwHyst = this._toNum(v.wwHyst);
327
+ const rechargeTemp = wwTarget !== null && wwHyst !== null ? wwTarget - wwHyst : null;
328
+
329
+ const isCharging = this._toNum(v.modeCode) === 1 && this._toBool(v.vd1);
330
+ const zipActive = this._toBool(v.zipActive);
331
+ const zipRem = this._toNum(v.zipRemaining) ?? 0;
332
+ const zipBaseDur = this._toNum(v.zipDurationNormal) ?? 120;
333
+
334
+ r.title.textContent = this._settings?.title || 'Warmwasser';
335
+ r.pvBadge.classList.toggle('hidden', !this._toBool(v.pvBoost));
336
+ r.forceBtn.classList.toggle('hidden', this._settings?.showForceButton === false);
337
+
338
+ if (isCharging) {
339
+ r.statusBadge.textContent = 'Lädt aktiv';
340
+ r.statusBadge.className = 'pill charging';
341
+ } else {
342
+ r.statusBadge.textContent = v.wwStatus || 'Bereit';
343
+ r.statusBadge.className = 'pill ok';
344
+ }
345
+
346
+ r.wwTemp.textContent = wwIst === null ? '–' : `${wwIst.toFixed(1)}°`;
347
+ r.wwTarget.textContent = this._fmtTemp(wwTarget);
348
+ r.rechargeAt.textContent = this._fmtTemp(rechargeTemp);
349
+
350
+ if (wwIst !== null && rechargeTemp !== null) {
351
+ const diff = wwIst - rechargeTemp;
352
+ r.reserveK.textContent = diff >= 0 ? `+${diff.toFixed(1)} K` : `${diff.toFixed(1)} K`;
353
+ } else {
354
+ r.reserveK.textContent = '–';
355
+ }
356
+
357
+ // Speicher-Füllstand & Linien im SVG
358
+ if (wwIst !== null) {
359
+ const yFill = this._tempToY(wwIst);
360
+ r.tankFill.setAttribute('y', yFill.toFixed(1));
361
+ r.tankFill.setAttribute('height', Math.max(0, 160 - yFill).toFixed(1));
362
+ } else {
363
+ r.tankFill.setAttribute('y', '160');
364
+ r.tankFill.setAttribute('height', '0');
365
+ }
366
+
367
+ if (wwTarget !== null) {
368
+ const yTarget = this._tempToY(wwTarget);
369
+ r.targetLine.setAttribute('y1', yTarget.toFixed(1));
370
+ r.targetLine.setAttribute('y2', yTarget.toFixed(1));
371
+ r.targetLine.style.opacity = '0.85';
372
+ } else {
373
+ r.targetLine.style.opacity = '0';
374
+ }
375
+
376
+ if (rechargeTemp !== null) {
377
+ const yHyst = this._tempToY(rechargeTemp);
378
+ r.hystLine.setAttribute('y1', yHyst.toFixed(1));
379
+ r.hystLine.setAttribute('y2', yHyst.toFixed(1));
380
+ r.hystLine.style.opacity = '0.85';
381
+ } else {
382
+ r.hystLine.style.opacity = '0';
383
+ }
384
+
385
+ if (wwIst !== null && wwTarget !== null && rechargeTemp !== null && wwTarget > rechargeTemp) {
386
+ const pct = Math.max(0, Math.min(100, ((wwIst - rechargeTemp) / (wwTarget - rechargeTemp)) * 100));
387
+ r.reservePct.textContent = `${pct.toFixed(0)}% Reserve`;
388
+ } else {
389
+ r.reservePct.textContent = '';
390
+ }
391
+
392
+ // ZIP-Countdown-Ring
393
+ if (zipActive && zipRem > 0) {
394
+ if (zipRem > this._zipPeakSec) {
395
+ this._zipPeakSec = zipRem;
396
+ }
397
+ const maxSec = Math.max(this._zipPeakSec, zipBaseDur, 1);
398
+ const frac = Math.max(0, Math.min(1, zipRem / maxSec));
399
+ r.zipRing.style.strokeDashoffset = (RING_CIRCUMFERENCE * (1 - frac)).toFixed(2);
400
+ r.zipBtn.classList.add('active');
401
+ r.zipTitle.textContent = 'ZIP LÄUFT';
402
+ r.zipTimer.textContent = this._fmtSec(zipRem);
403
+ r.hintText.textContent = 'Warmes Wasser liegt gleich an';
404
+ } else {
405
+ this._zipPeakSec = 0;
406
+ r.zipRing.style.strokeDashoffset = RING_CIRCUMFERENCE.toFixed(2);
407
+ r.zipBtn.classList.remove('active');
408
+ r.zipTitle.textContent = 'ZIP';
409
+ r.zipTimer.textContent = 'Start';
410
+ r.hintText.textContent = isCharging ? 'Speicher wird gerade aufgeheizt' : 'Zirkulation bereit';
411
+ }
412
+ }
413
+ }
414
+
415
+ if (!customElements.get('luxtronik-dhw-tank')) {
416
+ customElements.define('luxtronik-dhw-tank', LuxtronikDhwTank);
417
+ }
@@ -0,0 +1,42 @@
1
+ {
2
+ "manifestVersion": 1,
3
+ "tag": "luxtronik-dhw-tank",
4
+ "module": "./luxtronik-dhw-tank.js",
5
+ "name": {
6
+ "en": "Luxtronik Hot Water Tank & ZIP",
7
+ "de": "Luxtronik Warmwasser-Speicher & ZIP"
8
+ },
9
+ "size": {
10
+ "width": 360,
11
+ "height": 250
12
+ },
13
+ "settings": {
14
+ "type": "panel",
15
+ "items": {
16
+ "instance": {
17
+ "type": "instance",
18
+ "adapter": "luxtronik2-controller",
19
+ "label": {
20
+ "en": "Adapter instance",
21
+ "de": "Adapter-Instanz"
22
+ }
23
+ },
24
+ "title": {
25
+ "type": "text",
26
+ "default": "Warmwasser",
27
+ "label": {
28
+ "en": "Title",
29
+ "de": "Titel"
30
+ }
31
+ },
32
+ "showForceButton": {
33
+ "type": "checkbox",
34
+ "default": true,
35
+ "label": {
36
+ "en": "Show 'Heat once' button",
37
+ "de": "'1× Aufheizen'-Button anzeigen"
38
+ }
39
+ }
40
+ }
41
+ }
42
+ }