iobroker.luxtronik2-controller 1.2.1 → 1.3.1

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,378 @@
1
+ /**
2
+ * <luxtronik-health-monitor>
3
+ * Verdichter-Takt-Tacho, aktive Sperrzeit-Balken und EEPROM-Write-Counter
4
+ * für `@iobroker/web-components`.
5
+ */
6
+ import { LuxtronikBaseCard } from './luxtronik-base.js';
7
+
8
+ const ARC_LEN = Math.PI * 66; // Halbkreis Radius 66
9
+
10
+ const TIMER_DEFS = [
11
+ { key: 'timerDelay', label: 'Einschaltverzögerung', color: '#3b82f6' },
12
+ { key: 'timerVdStand', label: 'VD-Stillstandszeit', color: '#f59e0b' },
13
+ { key: 'timerLockOff', label: 'Sperrzeit AUS', color: '#ef4444' },
14
+ { key: 'timerLockOn', label: 'Sperrzeit EIN', color: '#f97316' },
15
+ { key: 'timerDhwBlock', label: 'WW-Sperr-Timer', color: '#a855f7' },
16
+ { key: 'timerDefrost', label: 'Abtau-Timer', color: '#06b6d4' },
17
+ ];
18
+
19
+ class LuxtronikHealthMonitor extends LuxtronikBaseCard {
20
+ static get stateMap() {
21
+ return {
22
+ hoursVd1: 'Information.05_OperatingHours.hours_compressor1',
23
+ startsVd1: 'Information.05_OperatingHours.starts_compressor1',
24
+ hoursHeating: 'Information.05_OperatingHours.hours_heating',
25
+ hoursWw: 'Information.05_OperatingHours.hours_warmwater',
26
+ hoursZwe1: 'Information.05_OperatingHours.hours_2nd_heat_source1',
27
+ vd1: 'Information.03_Outputs.VD1out',
28
+ timeWpOn: 'Information.04_Timers.Time_WPein_akt',
29
+ timerDelay: 'Information.04_Timers.Timer_EinschVerz',
30
+ timerVdStand: 'Information.04_Timers.Time_VDStd_akt',
31
+ timerLockOff: 'Information.04_Timers.Time_SSPAUS_akt',
32
+ timerLockOn: 'Information.04_Timers.Time_SSPEIN_akt',
33
+ timerDhwBlock: 'Information.04_Timers.Time_SBW_akt',
34
+ timerDefrost: 'Information.04_Timers.Time_AbtIn',
35
+ writesToday: 'Information.12_SystemInfo.write_cycles_today',
36
+ writesTotal: 'Information.12_SystemInfo.write_cycles_total',
37
+ };
38
+ }
39
+
40
+ _parseDurationSec(val) {
41
+ if (val === null || val === undefined || val === '') {
42
+ return 0;
43
+ }
44
+ if (typeof val === 'number' && !isNaN(val)) {
45
+ return Math.max(0, val);
46
+ }
47
+ const s = String(val).trim();
48
+ const parts = s.split(':').map(p => parseInt(p, 10));
49
+ if (parts.some(isNaN)) {
50
+ return 0;
51
+ }
52
+ if (parts.length === 3) {
53
+ return parts[0] * 3600 + parts[1] * 60 + parts[2];
54
+ }
55
+ if (parts.length === 2) {
56
+ return parts[0] * 60 + parts[1];
57
+ }
58
+ return 0;
59
+ }
60
+
61
+ _renderBase() {
62
+ const tpl = document.createElement('template');
63
+ tpl.innerHTML = `
64
+ <style>
65
+ :host {
66
+ --lux-surface: rgba(127, 127, 127, 0.11);
67
+ --lux-border: rgba(127, 127, 127, 0.24);
68
+ --lux-ok: #22c55e;
69
+ --lux-warn: #f59e0b;
70
+ --lux-bad: #ef4444;
71
+ --lux-info: #3b82f6;
72
+ display: block;
73
+ width: 100%;
74
+ height: 100%;
75
+ box-sizing: border-box;
76
+ font-family: inherit;
77
+ color: inherit;
78
+ }
79
+
80
+ .card {
81
+ width: 100%;
82
+ height: 100%;
83
+ box-sizing: border-box;
84
+ display: flex;
85
+ flex-direction: column;
86
+ gap: 10px;
87
+ padding: 12px;
88
+ overflow: auto;
89
+ }
90
+
91
+ .header {
92
+ display: flex;
93
+ justify-content: space-between;
94
+ align-items: center;
95
+ gap: 8px;
96
+ flex-wrap: wrap;
97
+ }
98
+
99
+ .title { font-size: 0.98rem; font-weight: 600; }
100
+ .subtitle { font-size: 0.74rem; opacity: 0.72; }
101
+ .badges { display: flex; gap: 6px; align-items: center; }
102
+
103
+ .pill {
104
+ padding: 2px 8px;
105
+ border-radius: 999px;
106
+ font-size: 0.72rem;
107
+ font-weight: 600;
108
+ background: var(--lux-surface);
109
+ border: 1px solid var(--lux-border);
110
+ }
111
+
112
+ .pill.ok { color: var(--lux-ok); border-color: rgba(34, 197, 94, 0.4); background: rgba(34, 197, 94, 0.14); }
113
+ .pill.warn { color: var(--lux-warn); border-color: rgba(245, 158, 11, 0.45); background: rgba(245, 158, 11, 0.14); }
114
+ .pill.bad { color: var(--lux-bad); border-color: rgba(239, 68, 68, 0.45); background: rgba(239, 68, 68, 0.14); }
115
+ .pill.running { color: var(--lux-info); border-color: rgba(59, 130, 246, 0.45); background: rgba(59, 130, 246, 0.14); }
116
+
117
+ .top-grid {
118
+ display: grid;
119
+ grid-template-columns: minmax(150px, 175px) 1fr;
120
+ gap: 10px;
121
+ align-items: center;
122
+ }
123
+
124
+ .gauge-box {
125
+ background: var(--lux-surface);
126
+ border: 1px solid var(--lux-border);
127
+ border-radius: 10px;
128
+ padding: 8px 8px 4px;
129
+ display: flex;
130
+ flex-direction: column;
131
+ align-items: center;
132
+ }
133
+
134
+ .gauge-svg {
135
+ width: 156px;
136
+ height: 98px;
137
+ display: block;
138
+ }
139
+
140
+ .arc-bg {
141
+ fill: none;
142
+ stroke: rgba(127, 127, 127, 0.22);
143
+ stroke-width: 11;
144
+ stroke-linecap: round;
145
+ }
146
+
147
+ .arc-fg {
148
+ fill: none;
149
+ stroke: var(--lux-ok);
150
+ stroke-width: 11;
151
+ stroke-linecap: round;
152
+ stroke-dasharray: ${ARC_LEN.toFixed(2)};
153
+ stroke-dashoffset: ${ARC_LEN.toFixed(2)};
154
+ transition: stroke-dashoffset 0.45s ease, stroke 0.3s ease;
155
+ }
156
+
157
+ .stats-box {
158
+ background: var(--lux-surface);
159
+ border: 1px solid var(--lux-border);
160
+ border-radius: 10px;
161
+ padding: 9px 11px;
162
+ display: flex;
163
+ flex-direction: column;
164
+ gap: 5px;
165
+ }
166
+
167
+ .row {
168
+ display: flex;
169
+ justify-content: space-between;
170
+ font-size: 0.78rem;
171
+ font-variant-numeric: tabular-nums;
172
+ }
173
+
174
+ .row .lbl { opacity: 0.72; }
175
+ .row .val { font-weight: 600; }
176
+
177
+ .timers-wrap {
178
+ display: flex;
179
+ flex-direction: column;
180
+ gap: 5px;
181
+ }
182
+
183
+ .timers-empty {
184
+ font-size: 0.74rem;
185
+ opacity: 0.65;
186
+ padding: 5px 8px;
187
+ border-radius: 8px;
188
+ background: var(--lux-surface);
189
+ border: 1px dashed var(--lux-border);
190
+ text-align: center;
191
+ }
192
+
193
+ .timer-chip {
194
+ display: flex;
195
+ justify-content: space-between;
196
+ align-items: center;
197
+ gap: 8px;
198
+ padding: 5px 9px;
199
+ border-radius: 8px;
200
+ background: var(--lux-surface);
201
+ border: 1px solid var(--lux-border);
202
+ border-left-width: 3px;
203
+ font-size: 0.76rem;
204
+ font-variant-numeric: tabular-nums;
205
+ }
206
+
207
+ .timer-chip .t-val { font-weight: 700; }
208
+
209
+ .footer {
210
+ margin-top: auto;
211
+ display: flex;
212
+ justify-content: space-between;
213
+ align-items: center;
214
+ flex-wrap: wrap;
215
+ gap: 8px;
216
+ padding-top: 6px;
217
+ border-top: 1px solid var(--lux-border);
218
+ font-size: 0.74rem;
219
+ font-variant-numeric: tabular-nums;
220
+ }
221
+
222
+ .wear-ok { color: var(--lux-ok); font-weight: 700; }
223
+ .wear-warn { color: var(--lux-warn); font-weight: 700; }
224
+ .wear-bad { color: var(--lux-bad); font-weight: 700; }
225
+ </style>
226
+
227
+ <div class="card">
228
+ <div class="header">
229
+ <div>
230
+ <div class="title" data-ref="title">Verdichter & Takte</div>
231
+ <div class="subtitle" data-ref="subtitle">Ø Laufzeit & Sperrzeiten</div>
232
+ </div>
233
+ <div class="badges">
234
+ <span class="pill" data-ref="vdBadge">VD1 Aus</span>
235
+ <span class="pill" data-ref="healthBadge">–</span>
236
+ </div>
237
+ </div>
238
+
239
+ <div class="top-grid">
240
+ <div class="gauge-box">
241
+ <svg class="gauge-svg" viewBox="0 0 164 102">
242
+ <path class="arc-bg" d="M 16 84 A 66 66 0 0 1 148 84" />
243
+ <path class="arc-fg" data-ref="gaugeArc" d="M 16 84 A 66 66 0 0 1 148 84" />
244
+ <text x="82" y="64" text-anchor="middle" font-size="22" font-weight="700" fill="currentColor" data-ref="avgMinVal">–</text>
245
+ <text x="82" y="81" text-anchor="middle" font-size="9.5" font-weight="600" fill="currentColor" opacity="0.68">Ø MIN / TAKT</text>
246
+ <text x="16" y="98" text-anchor="middle" font-size="8.5" fill="currentColor" opacity="0.55">0</text>
247
+ <text x="148" y="98" text-anchor="middle" font-size="8.5" fill="currentColor" opacity="0.55" data-ref="gaugeMaxLbl">60</text>
248
+ </svg>
249
+ </div>
250
+
251
+ <div class="stats-box">
252
+ <div class="row"><span class="lbl">Starts / Stunden</span><span class="val" data-ref="startsHours">–</span></div>
253
+ <div class="row"><span class="lbl">Heizen / WW</span><span class="val" data-ref="splitHours">–</span></div>
254
+ <div class="row"><span class="lbl">Heizstab (ZWE1)</span><span class="val" data-ref="zweHours">–</span></div>
255
+ <div class="row"><span class="lbl">Aktueller Takt</span><span class="val" data-ref="currentRun">–</span></div>
256
+ </div>
257
+ </div>
258
+
259
+ <div class="timers-wrap" data-ref="timersWrap"></div>
260
+
261
+ <div class="footer">
262
+ <span>EEPROM Heute: <span data-ref="writesToday">–</span></span>
263
+ <span>EEPROM Gesamt: <strong data-ref="writesTotal">–</strong></span>
264
+ </div>
265
+ </div>
266
+ `;
267
+ this.shadowRoot.appendChild(tpl.content.cloneNode(true));
268
+ }
269
+
270
+ _updateView() {
271
+ const r = this._refs;
272
+ if (!r.title) {
273
+ return;
274
+ }
275
+
276
+ const v = this._values;
277
+ const hours = this._toNum(v.hoursVd1);
278
+ const starts = this._toNum(v.startsVd1);
279
+ const vd1 = this._toBool(v.vd1);
280
+ const maxMin = Math.max(30, this._toNum(this._settings?.targetMinutes) ?? 60);
281
+
282
+ r.title.textContent = this._settings?.title || 'Verdichter & Takte';
283
+ r.gaugeMaxLbl.textContent = String(Math.round(maxMin));
284
+
285
+ r.vdBadge.textContent = vd1 ? 'VD1 Läuft' : 'VD1 Aus';
286
+ r.vdBadge.className = `pill ${vd1 ? 'running' : ''}`;
287
+
288
+ // Ø Minuten pro Takt berechnen
289
+ if (hours !== null && starts !== null && starts > 0) {
290
+ const avgMin = (hours * 60) / starts;
291
+ const ratio = Math.max(0, Math.min(1, avgMin / maxMin));
292
+ r.avgMinVal.textContent = avgMin.toFixed(1);
293
+ r.gaugeArc.style.strokeDashoffset = (ARC_LEN * (1 - ratio)).toFixed(2);
294
+
295
+ if (avgMin < 20) {
296
+ r.gaugeArc.style.stroke = 'var(--lux-bad)';
297
+ r.healthBadge.textContent = 'Kurztakte';
298
+ r.healthBadge.className = 'pill bad';
299
+ } else if (avgMin < 40) {
300
+ r.gaugeArc.style.stroke = 'var(--lux-warn)';
301
+ r.healthBadge.textContent = 'Mittel';
302
+ r.healthBadge.className = 'pill warn';
303
+ } else {
304
+ r.gaugeArc.style.stroke = 'var(--lux-ok)';
305
+ r.healthBadge.textContent = 'Gesund';
306
+ r.healthBadge.className = 'pill ok';
307
+ }
308
+ } else {
309
+ r.avgMinVal.textContent = '–';
310
+ r.gaugeArc.style.strokeDashoffset = ARC_LEN.toFixed(2);
311
+ r.healthBadge.textContent = '–';
312
+ r.healthBadge.className = 'pill';
313
+ }
314
+
315
+ const startsStr = starts !== null ? Math.round(starts).toLocaleString('de-DE') : '–';
316
+ const hoursStr = hours !== null ? `${Math.round(hours).toLocaleString('de-DE')} h` : '–';
317
+ r.startsHours.textContent = `${startsStr} / ${hoursStr}`;
318
+
319
+ const hHz = this._toNum(v.hoursHeating);
320
+ const hWw = this._toNum(v.hoursWw);
321
+ r.splitHours.textContent = `${hHz !== null ? Math.round(hHz) : '–'} h / ${hWw !== null ? Math.round(hWw) : '–'} h`;
322
+
323
+ const hZwe = this._toNum(v.hoursZwe1);
324
+ r.zweHours.textContent = hZwe !== null ? `${hZwe.toFixed(1)} h` : '–';
325
+ r.currentRun.textContent = vd1 && v.timeWpOn ? String(v.timeWpOn) : 'Inaktiv';
326
+
327
+ // Aktive Sperr- & Stillstands-Timer rendern
328
+ const wrap = r.timersWrap;
329
+ while (wrap.firstChild) {
330
+ wrap.removeChild(wrap.firstChild);
331
+ }
332
+
333
+ let activeCount = 0;
334
+ for (const def of TIMER_DEFS) {
335
+ const raw = v[def.key];
336
+ const sec = this._parseDurationSec(raw);
337
+ if (sec > 0) {
338
+ activeCount++;
339
+ const chip = document.createElement('div');
340
+ chip.className = 'timer-chip';
341
+ chip.style.borderLeftColor = def.color;
342
+
343
+ const lblEl = document.createElement('span');
344
+ lblEl.textContent = def.label;
345
+ const valEl = document.createElement('span');
346
+ valEl.className = 't-val';
347
+ valEl.textContent = String(raw);
348
+
349
+ chip.appendChild(lblEl);
350
+ chip.appendChild(valEl);
351
+ wrap.appendChild(chip);
352
+ }
353
+ }
354
+
355
+ if (activeCount === 0) {
356
+ const empty = document.createElement('div');
357
+ empty.className = 'timers-empty';
358
+ empty.textContent = 'Keine aktiven Sperr- oder Verzögerungstimer';
359
+ wrap.appendChild(empty);
360
+ }
361
+
362
+ // Flash-Wear Anzeige
363
+ const wt = this._toNum(v.writesToday);
364
+ const wtot = this._toNum(v.writesTotal);
365
+ if (wt !== null) {
366
+ r.writesToday.textContent = `${Math.round(wt)} Zyklen`;
367
+ r.writesToday.className = wt === 0 ? 'wear-ok' : wt <= 15 ? 'wear-warn' : 'wear-bad';
368
+ } else {
369
+ r.writesToday.textContent = '–';
370
+ r.writesToday.className = '';
371
+ }
372
+ r.writesTotal.textContent = wtot !== null ? Math.round(wtot).toLocaleString('de-DE') : '–';
373
+ }
374
+ }
375
+
376
+ if (!customElements.get('luxtronik-health-monitor')) {
377
+ customElements.define('luxtronik-health-monitor', LuxtronikHealthMonitor);
378
+ }
@@ -0,0 +1,44 @@
1
+ {
2
+ "manifestVersion": 1,
3
+ "tag": "luxtronik-health-monitor",
4
+ "module": "./luxtronik-health-monitor.js",
5
+ "name": {
6
+ "en": "Luxtronik Compressor Health & Timers",
7
+ "de": "Luxtronik Verdichter-Gesundheit & Takt-Tacho"
8
+ },
9
+ "size": {
10
+ "width": 440,
11
+ "height": 290
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": "Verdichter & Takte",
27
+ "label": {
28
+ "en": "Title",
29
+ "de": "Titel"
30
+ }
31
+ },
32
+ "targetMinutes": {
33
+ "type": "number",
34
+ "default": 60,
35
+ "min": 30,
36
+ "max": 180,
37
+ "label": {
38
+ "en": "Gauge max minutes/cycle",
39
+ "de": "Tacho-Skala Max. Min/Takt"
40
+ }
41
+ }
42
+ }
43
+ }
44
+ }