# ============================================================ # Daikin Cycle ML — Daily Summary Tabbed Card # ============================================================ # # Optional variables (add at top, before type:): # variables: # lang_override: '' # '' = auto | 'nl' | 'en' # default_tab: 'overview' # overview | quality | cycles | duration | events # default_window: 7 # 7 | 15 | 30 # chart_height: 280 # pixels # show_hints: true # false = hide hint notes # # Requires HACS frontend cards: # stack-in-card, mushroom-template-card, button-card, card-mod # ============================================================ type: custom:stack-in-card card_mod: style: | ha-card { border: 2px solid #0097E0; border-radius: 16px; background: var(--ha-card-background, var(--card-background-color, #FFFFFF)); box-shadow: 0 8px 24px rgba(0, 151, 224, 0.18); overflow: visible; } cards: # --- HEADER: the same for every Daikin Cycle ML card (#427) --- - type: custom:button-card variables: &dcm lang_override: '' # '' = auto (HA language, then integration language) | en | nl | fr theme_override: auto # auto (follows the HA dark mode) | light | dark show_help: true # false = hide the explanation notes default_tab: overview # overview | quality | cycles | duration | events default_window: 7 # 7 | 15 | 30 days chart_height: 280 # pixels show_name: false show_icon: false triggers_update: all styles: card: - background: none - box-shadow: none - border: none - border-radius: 14px 14px 0 0 - padding: 0 grid: - grid-template-areas: '"content"' - grid-template-columns: 1fr custom_fields: content: - width: 100% custom_fields: content: | [[[ /* DCM-COMMON-BEGIN (#427) shared by every Daikin Cycle ML card: language, theme, header. Do not edit in a card: edit tools/card_common.js and run tools/sync_card_common.py */ var DCM = (function () { var V = (typeof variables !== 'undefined' && variables) ? variables : {}; var H = (typeof hass !== 'undefined' && hass) ? hass : {}; var S = (typeof states !== 'undefined' && states) ? states : {}; var find = function (tk, sfx) { var ids = Object.keys(S), i, j, k, E = H.entities || {}; for (i = 0; i < ids.length; i++) { if (ids[i].indexOf('sensor.') !== 0) continue; for (j = 0; j < sfx.length; j++) { if (ids[i].slice(-sfx[j].length - 1) === '_' + sfx[j]) return ids[i]; } } for (k in E) { if (E[k] && E[k].platform === 'daikin_cycle_ml' && E[k].translation_key === tk && S[k]) return k; } return null; }; var A = function (id) { return (id && S[id] && S[id].attributes) ? S[id].attributes : {}; }; var csA = A(find('cycle_state', ['cycle_state', 'cyclus_status', 'etat_du_cycle'])); var spA = A(find('hp_specs', ['hp_specs', 'wp_specs', 'caracteristiques_de_la_pac'])); /* language: lang_override, then the HA language, then the integration language, then English */ var LS = ['en', 'nl', 'fr']; var ov = String(V.lang_override || '').toLowerCase(); var ha = String(H.language || '').toLowerCase().slice(0, 2); var cl = String(csA.configured_language || '').toLowerCase(); var lang = LS.indexOf(ov) >= 0 ? ov : (LS.indexOf(ha) >= 0 ? ha : (LS.indexOf(cl) >= 0 ? cl : 'en')); /* theme: auto follows the HA dark mode; light / dark force it */ var th = String(V.theme_override || 'auto').toLowerCase(); var dark = th === 'dark' ? true : (th === 'light' ? false : !!(H.themes && H.themes.darkMode)); var P = dark ? { bg: '#1B1F24', bg2: '#232A33', bg3: '#1E3448', hd1: '#1E3448', hd2: '#15283A', text: '#E6F0FA', text2: '#90CAF9', muted: '#B0BEC5', border: 'rgba(79,195,247,0.35)', accent: '#4FC3F7', good: '#66BB6A', warn: '#FFA726', bad: '#EF5350' } : { bg: '#FFFFFF', bg2: '#F5FAFD', bg3: '#E3F2FD', hd1: '#E3F2FD', hd2: '#BBDEFB', text: '#0D47A1', text2: '#1565C0', muted: '#546E7A', border: 'rgba(0,151,224,0.25)', accent: '#0097E0', good: '#2E7D32', warn: '#E65100', bad: '#C62828' }; /* light colours of the cards -> dark mode (light backgrounds dark, dark text light) */ var MAP = { '#FFFFFF': P.bg, '#F5FAFD': P.bg2, '#F5FAFE': P.bg2, '#E6F4FB': P.bg2, '#E8F2FB': P.bg2, '#EAF2F8': P.bg2, '#E3F2FD': P.bg3, '#D6ECF7': P.bg3, '#DCEBFA': P.bg3, '#BBDEFB': '#1F4A6B', '#D6EAF8': P.bg3, '#E1F5FE': P.bg3, '#AED6F1': '#1F4A6B', '#FFF3E0': '#3A2A12', '#FFF8EC': '#3A2A12', '#FDEAD0': '#3A2A12', '#FFEBEE': '#3A1D1D', '#FDECEA': '#3A1D1D', '#FBD0C8': '#3A1D1D', '#E8F5E9': '#1C3324', '#EAFAF1': '#1C3324', '#D5F5E3': '#1C3324', '#F3E5F5': '#2E2236', '#0D47A1': P.text, '#003366': P.text, '#001B3D': P.text, '#003A70': P.text, '#00539F': '#BBDEFB', '#005A9C': '#BBDEFB', '#1565C0': P.text2, '#1976D2': '#64B5F6', '#546E7A': P.muted, '#5D6D7E': P.muted, '#7F8C8D': '#9EADB5', '#95A5A6': '#9EADB5', '#37474F': '#CFD8DC', '#444444': '#CFD8DC', '#000000': '#ECEFF1', '#94A3B8': '#78909C', '#6A1B9A': '#CE93D8', '#2E7D32': '#4CAF50', '#1E8449': '#81C784', '#C62828': '#E53935', '#E65100': '#FB8C00', '#7D4F00': '#FFCC80', '#8B1A1A': '#EF9A9A', '#7A0008': '#EF9A9A' }; var paint = function (html) { if (!dark || typeof html !== 'string') return html; return html .replace(/(background(?:-color)?\s*:\s*)(#fff\b|white\b)/gi, '$1' + P.bg) .replace(/(<(?:rect|circle|ellipse|path)\b[^>]*?\sfill=")(white|#fff|#ffffff)(")/gi, '$1' + P.bg2 + '$3') .replace(/rgba\(\s*255\s*,\s*255\s*,\s*255\s*,\s*([0-9.]+)\s*\)/g, function (m, a) { return 'rgba(255,255,255,' + Math.min(0.08, parseFloat(a) * 0.1).toFixed(3) + ')'; }) .replace(/#[0-9a-fA-F]{6}\b/g, function (m) { return MAP[m.toUpperCase()] || m; }); }; var T3 = function (o) { return (o && typeof o === 'object') ? (o[lang] || o.en || '') : String(o || ''); }; var model = spA.model ? String(spA.model).toUpperCase() : ''; var meta = [spA.family, spA.kw ? spA.kw + ' kW' : '', spA.refrigerant].filter(function (x) { return x && String(x) !== 'None'; }).join(' · '); /* one header for every card: icon, title + model, subtitle + family / kW / refrigerant */ var header = function (icon, title, sub) { return '
' + '
' + icon + '
' + '
' + '
' + T3(title) + (model ? ' · ' + model : '') + '
' + '
' + T3(sub) + (meta ? ' · ' + meta : '') + '
' + '
'; }; return { lang: lang, dark: dark, P: P, paint: paint, header: header, T3: T3, V: V, model: model, showHelp: V.show_help !== false && V.show_hints !== false }; })(); /* DCM-COMMON-END */ return DCM.header("📅", {en: "Daily summary", nl: "Dagoverzicht", fr: "Résumé quotidien"}, {en: "Cycles · duration · quality · events", nl: "Cycli · duur · kwaliteit · events", fr: "Cycles · durée · qualité · événements"}); ]]] - type: custom:button-card variables: *dcm show_name: false show_icon: false triggers_update: all tap_action: action: javascript javascript: | [[[ try { const card = this; const root = card.shadowRoot || card.getRootNode?.() || card; const chart = root.querySelector('.pa-chart'); if (!chart) return; const existingPopup = chart.querySelector('.pa-popup'); if (existingPopup) { const hovered = Array.from(root.querySelectorAll(':hover, :active')); for (const h of hovered) { if (h.closest && h.closest('.pa-popup')) { if (chart.__paTimer) { clearTimeout(chart.__paTimer); chart.__paTimer = null; } existingPopup.classList.add('pa-popup-out'); setTimeout(() => { if (existingPopup.parentNode) existingPopup.parentNode.removeChild(existingPopup); }, 200); return; } } } let candidates = Array.from(root.querySelectorAll(':hover, :active')).reverse(); if (!candidates.length) candidates = Array.from(root.querySelectorAll('[data-pa-action]')).reverse(); for (const el of candidates) { if (!el || !el.dataset) continue; const action = el.dataset.paAction; if (!action) continue; if (action === 'tab') { card.__paState = card.__paState || {}; card.__paState.tab = el.dataset.paArg; if (card.update) card.update(); return; } if (action === 'win') { card.__paState = card.__paState || {}; card.__paState.win = parseInt(el.dataset.paArg, 10); if (card.update) card.update(); return; } if (action === 'detail') { if (window.__paShowPopup) window.__paShowPopup(el, card); return; } if (action === 'close-popup') { const popup = el.closest('.pa-popup') || el; if (popup && popup.parentNode) { if (chart.__paTimer) { clearTimeout(chart.__paTimer); chart.__paTimer = null; } popup.classList.add('pa-popup-out'); setTimeout(() => { if (popup.parentNode) popup.parentNode.removeChild(popup); }, 200); } return; } } } catch(e) { console.warn('[PA]', e); } ]]] hold_action: action: none double_tap_action: action: none styles: card: - background: none - box-shadow: none - border: none - padding: 6px 6px 2px 6px - overflow: visible grid: - grid-template-areas: '"content"' - grid-template-columns: 1fr custom_fields: content: - width: 100% - pointer-events: auto custom_fields: content: | [[[ /* DCM-COMMON-BEGIN (#427) shared by every Daikin Cycle ML card: language, theme, header. Do not edit in a card: edit tools/card_common.js and run tools/sync_card_common.py */ var DCM = (function () { var V = (typeof variables !== 'undefined' && variables) ? variables : {}; var H = (typeof hass !== 'undefined' && hass) ? hass : {}; var S = (typeof states !== 'undefined' && states) ? states : {}; var find = function (tk, sfx) { var ids = Object.keys(S), i, j, k, E = H.entities || {}; for (i = 0; i < ids.length; i++) { if (ids[i].indexOf('sensor.') !== 0) continue; for (j = 0; j < sfx.length; j++) { if (ids[i].slice(-sfx[j].length - 1) === '_' + sfx[j]) return ids[i]; } } for (k in E) { if (E[k] && E[k].platform === 'daikin_cycle_ml' && E[k].translation_key === tk && S[k]) return k; } return null; }; var A = function (id) { return (id && S[id] && S[id].attributes) ? S[id].attributes : {}; }; var csA = A(find('cycle_state', ['cycle_state', 'cyclus_status', 'etat_du_cycle'])); var spA = A(find('hp_specs', ['hp_specs', 'wp_specs', 'caracteristiques_de_la_pac'])); /* language: lang_override, then the HA language, then the integration language, then English */ var LS = ['en', 'nl', 'fr']; var ov = String(V.lang_override || '').toLowerCase(); var ha = String(H.language || '').toLowerCase().slice(0, 2); var cl = String(csA.configured_language || '').toLowerCase(); var lang = LS.indexOf(ov) >= 0 ? ov : (LS.indexOf(ha) >= 0 ? ha : (LS.indexOf(cl) >= 0 ? cl : 'en')); /* theme: auto follows the HA dark mode; light / dark force it */ var th = String(V.theme_override || 'auto').toLowerCase(); var dark = th === 'dark' ? true : (th === 'light' ? false : !!(H.themes && H.themes.darkMode)); var P = dark ? { bg: '#1B1F24', bg2: '#232A33', bg3: '#1E3448', hd1: '#1E3448', hd2: '#15283A', text: '#E6F0FA', text2: '#90CAF9', muted: '#B0BEC5', border: 'rgba(79,195,247,0.35)', accent: '#4FC3F7', good: '#66BB6A', warn: '#FFA726', bad: '#EF5350' } : { bg: '#FFFFFF', bg2: '#F5FAFD', bg3: '#E3F2FD', hd1: '#E3F2FD', hd2: '#BBDEFB', text: '#0D47A1', text2: '#1565C0', muted: '#546E7A', border: 'rgba(0,151,224,0.25)', accent: '#0097E0', good: '#2E7D32', warn: '#E65100', bad: '#C62828' }; /* light colours of the cards -> dark mode (light backgrounds dark, dark text light) */ var MAP = { '#FFFFFF': P.bg, '#F5FAFD': P.bg2, '#F5FAFE': P.bg2, '#E6F4FB': P.bg2, '#E8F2FB': P.bg2, '#EAF2F8': P.bg2, '#E3F2FD': P.bg3, '#D6ECF7': P.bg3, '#DCEBFA': P.bg3, '#BBDEFB': '#1F4A6B', '#D6EAF8': P.bg3, '#E1F5FE': P.bg3, '#AED6F1': '#1F4A6B', '#FFF3E0': '#3A2A12', '#FFF8EC': '#3A2A12', '#FDEAD0': '#3A2A12', '#FFEBEE': '#3A1D1D', '#FDECEA': '#3A1D1D', '#FBD0C8': '#3A1D1D', '#E8F5E9': '#1C3324', '#EAFAF1': '#1C3324', '#D5F5E3': '#1C3324', '#F3E5F5': '#2E2236', '#0D47A1': P.text, '#003366': P.text, '#001B3D': P.text, '#003A70': P.text, '#00539F': '#BBDEFB', '#005A9C': '#BBDEFB', '#1565C0': P.text2, '#1976D2': '#64B5F6', '#546E7A': P.muted, '#5D6D7E': P.muted, '#7F8C8D': '#9EADB5', '#95A5A6': '#9EADB5', '#37474F': '#CFD8DC', '#444444': '#CFD8DC', '#000000': '#ECEFF1', '#94A3B8': '#78909C', '#6A1B9A': '#CE93D8', '#2E7D32': '#4CAF50', '#1E8449': '#81C784', '#C62828': '#E53935', '#E65100': '#FB8C00', '#7D4F00': '#FFCC80', '#8B1A1A': '#EF9A9A', '#7A0008': '#EF9A9A' }; var paint = function (html) { if (!dark || typeof html !== 'string') return html; return html .replace(/(background(?:-color)?\s*:\s*)(#fff\b|white\b)/gi, '$1' + P.bg) .replace(/(<(?:rect|circle|ellipse|path)\b[^>]*?\sfill=")(white|#fff|#ffffff)(")/gi, '$1' + P.bg2 + '$3') .replace(/rgba\(\s*255\s*,\s*255\s*,\s*255\s*,\s*([0-9.]+)\s*\)/g, function (m, a) { return 'rgba(255,255,255,' + Math.min(0.08, parseFloat(a) * 0.1).toFixed(3) + ')'; }) .replace(/#[0-9a-fA-F]{6}\b/g, function (m) { return MAP[m.toUpperCase()] || m; }); }; var T3 = function (o) { return (o && typeof o === 'object') ? (o[lang] || o.en || '') : String(o || ''); }; var model = spA.model ? String(spA.model).toUpperCase() : ''; var meta = [spA.family, spA.kw ? spA.kw + ' kW' : '', spA.refrigerant].filter(function (x) { return x && String(x) !== 'None'; }).join(' · '); /* one header for every card: icon, title + model, subtitle + family / kW / refrigerant */ var header = function (icon, title, sub) { return '
' + '
' + icon + '
' + '
' + '
' + T3(title) + (model ? ' · ' + model : '') + '
' + '
' + T3(sub) + (meta ? ' · ' + meta : '') + '
' + '
'; }; return { lang: lang, dark: dark, P: P, paint: paint, header: header, T3: T3, V: V, model: model, showHelp: V.show_help !== false && V.show_hints !== false }; })(); /* DCM-COMMON-END */ return DCM.paint((function () { var _DEC = (function(){ try { var _lc = (typeof hass !== 'undefined' && hass && hass.locale) ? hass.locale : {}; var _nf = _lc.number_format; if (_nf === 'comma_decimal' || _nf === 'none') return '.'; if (_nf === 'decimal_comma' || _nf === 'space_comma') return ','; var _l = String(_lc.language || (typeof hass !== 'undefined' && hass && hass.language) || 'en'); return (1.5).toLocaleString(_l).indexOf(',') >= 0 ? ',' : '.'; } catch (e) { return '.'; } })(); /* #427: decimal separator from the HA number format */ try { var card = this; card.__paRegistry = card.__paRegistry || {}; card.__paSeq = 0; var CFG = (typeof variables !== 'undefined' && variables) ? variables : {}; var cfgTab = String(CFG.default_tab || 'overview'); var cfgWin = parseInt(CFG.default_window, 10) || 7; var cfgChartH = parseInt(CFG.chart_height, 10) || 280; var cfgShowHints = DCM.showHelp; var cfgLangOvr = String(CFG.lang_override || '').toLowerCase(); var REGISTRY = { daily_summary: ['daily_summary_recent','recent_dagoverzicht','resume_des_derniers_jours'], hp_specs: ['hp_specs','wp_specs','caracteristiques_de_la_pac'], cycle_state: ['cycle_state','cyclus_status','etat_du_cycle'], current_cycle: ['current_cycle','huidige_cyclus','cycle_en_cours'], last_cycle: ['last_cycle','laatste_cyclus','dernier_cycle'], starts_today: ['compressor_starts_today','compressorstarts_vandaag','demarrages_compresseur_aujourd_hui'], runtime_buh: ['runtime_buh_today','buh_bedrijfstijd_vandaag','marche_appoint_aujourd_hui'], runtime_compressor: ['runtime_compressor_today','compressorbedrijfstijd_vandaag','marche_compresseur_aujourd_hui'], defrost_count: ['defrost_count_today','ontdooiingen_vandaag','degivrages_aujourd_hui'], defrost_duration: ['defrost_duration_today','ontdooiingsduur_vandaag','duree_de_degivrage_aujourd_hui'], duty_cycle: ['duty_cycle_today','duty_cycle_vandaag','taux_de_marche_aujourd_hui'], cop_today: ['cop_today','cop_vandaag','cop_chauffage_du_jour'], cycles_today: ['cycles_today','cycli_vandaag','cycles_aujourd_hui'], source_health: ['source_health','bron_gezondheid','fraicheur_de_la_source'], quality_today: ['quality_today','kwaliteit_vandaag','qualite_du_jour'], hybrid_mode: ['hybrid_mode','mode_hybride'], boiler_contribution: ['boiler_contribution_today_pct','part_de_la_chaudiere_aujourd_hui'], boiler_efficiency: ['boiler_efficiency_cop','rendement_chaudiere_cop'] }; var _DCM_TK = {"daily_summary_recent":"daily_summary_recent","hp_specs":"hp_specs","cycle_state":"cycle_state","current_cycle":"current_cycle","last_cycle":"last_cycle","compressor_starts_today":"compressor_starts_today","runtime_buh_today":"runtime_buh_today","runtime_compressor_today":"runtime_compressor_today","defrost_count_today":"defrost_count_today","defrost_duration_today":"defrost_duration_today","duty_cycle_today":"duty_cycle_today","cop_today":"cop_today","cycles_today":"cycles_today","source_health":"source_health","quality_today":"quality_today","hybrid_mode":"hybrid_mode","boiler_contribution_today_pct":"boiler_contribution_today_pct","boiler_efficiency_cop":"boiler_efficiency_cop"}; /* #347 entity resolver: en suffix -> translation_key */ var resolveEntity = function(role){ var names = REGISTRY[role]; if(!names) return null; var all = Object.keys(states).filter(function(e){ return e.indexOf('sensor.') === 0; }); var preferred = all.filter(function(e){ return e.indexOf('daikin_cycle_ml') !== -1; }); var i, j; for(i=0; i' + '⚠️ Daikin Cycle ML entities niet gevonden. Controleer of de integratie draait.
' + 'Gezocht: sensor.*_daily_summary_recent / *_recent_dagoverzicht + *cycle_state / *cyclus_status
' + 'Gevonden sensors met daikin_cycle_ml: ' + Object.keys(states).filter(function(e){ return e.indexOf('daikin_cycle_ml')!==-1 && e.indexOf('sensor.')===0; }).length + ''; } var hasV = function(v){ return v!==null && v!==undefined && v!=='' && String(v)!=='None' && String(v)!=='unknown' && String(v)!=='unavailable'; }; var v1 = function(v){ if(!hasV(v)||isNaN(parseFloat(v))||!isFinite(parseFloat(v)))return '—'; return Number(v).toFixed(1).replace('.', _DEC); }; var vI = function(v){ if(!hasV(v)||isNaN(parseFloat(v)))return '—'; return Math.round(parseFloat(v)).toString(); }; var attr = function(id,n,d){ try{ if(!id)return d; var a=states[id] && states[id].attributes; if(!a)return d; var v=a[n]; if(v===undefined||v===null||String(v)==='None')return d; return v; } catch(e){ return d; } }; var aN = function(id,n,d){ var v=attr(id,n,null); if(v===null)return d; var x=parseFloat(v); return isNaN(x)?d:x; }; var weekday = function(iso){ if(!iso) return ''; try{ var d = new Date(iso + 'T12:00:00'); return ['zo','ma','di','wo','do','vr','za'][d.getDay()]; }catch(e){ return ''; } }; var weekdayEn = function(iso){ if(!iso) return ''; try{ var d = new Date(iso + 'T12:00:00'); return (LANG==='fr'?['dim','lun','mar','mer','jeu','ven','sam']:['Sun','Mon','Tue','Wed','Thu','Fri','Sat'])[d.getDay()]; }catch(e){ return ''; } }; var fmtDay = function(iso){ if(!iso) return '—'; var p=String(iso).split('-'); return p.length>=3 ? p[2]+'/'+p[1] : iso; }; var fmtBigMin = function(m){ if(!hasV(m)) return '—'; var n = Number(m); if(n >= 1440) return Math.round(n/1440)+(LANG==='fr'?' j':'d'); if(n >= 120) return Math.round(n/60)+'h'; if(n >= 60) return (n/60).toFixed(1).replace('.', _DEC)+'h'; return Math.round(n)+'m'; }; var fmtBigHours = function(h){ if(!hasV(h)) return '—'; var n = Number(h); if(n >= 24*7) return Math.round(n/24)+(LANG==='fr'?' j':'d'); if(n >= 24) return Math.round(n)+'h'; if(n >= 10) return n.toFixed(0)+'h'; if(n >= 1) return n.toFixed(1).replace('.', _DEC)+'h'; return Math.round(n*60)+'m'; }; var fmtSec = function(s){ if (!isFinite(s) || s <= 0) return '0m'; if (s < 60) return Math.round(s)+'s'; var m = Math.round(s/60); if (m < 60) return m+'m'; return (m/60).toFixed(1).replace('.', _DEC)+'h'; }; var qColor = function(q){ return q===null||q===undefined?'var(--secondary-text-color, #546E7A)':(q>=70?'#2E7D32':q>=40?'#E65100':'#C62828'); }; var TXT_HALO = 'paint-order="stroke fill" stroke="white" stroke-width="2.5" stroke-opacity="0.9" stroke-linejoin="round"'; var C = { heating:'#E63946', dhw:'#4FC3F7', cooling:'#1976D2', buh:'#E65100', defrost:'#1976D2', quality:'#2E7D32', gem:'#6A1B9A', total:'var(--secondary-text-color, #546E7A)' }; var CBG = { heating:'rgba(230,57,70,0.1)', dhw:'rgba(79,195,247,0.1)', cooling:'rgba(25,118,210,0.1)', buh:'rgba(230,81,0,0.1)', defrost:'rgba(25,118,210,0.1)', quality:'rgba(46,125,50,0.1)', gem:'rgba(106,27,154,0.1)', total:'rgba(128,128,128,0.1)' }; var QGOOD='#2E7D32', QMID='#E65100', QLOW='#C62828'; var haLang = (typeof hass !== 'undefined' && hass && hass.language) ? String(hass.language).toLowerCase() : ''; var cfgLang = String(attr(STATE,'configured_language','en')).toLowerCase(); var LANG = DCM.lang; /* #427: shared language rule */ /* FR-I18N (azsono03) */ var FRM={" cycles in IDEAL zone":" cycles dans la zone IDÉALE"," cycles in PENDULUM zone":" cycles dans la zone TROP COURTE"," cycles over ":" cycles sur ","24h vs 7d":"24 h / 7 j","30d":"30 j","365d":"365 j","Last 7d":"7 derniers jours","SHORT 20-60m":"COURT 20-60 min","GOOD 60-180m":"BON 60-180 min","LONG >180m":"LONG >180 min","40-70 mid":"40-70 moyen","<40 low":"<40 faible","ACTION REQUIRED":"ACTION REQUISE","ATTENTION":"ATTENTION","AVG DURATION":"DURÉE MOY.","Average quality ":"Qualité moyenne ","Average quality low (":"Qualité moyenne faible (","Avg duration":"Durée moy.","Avg off":"Arrêt moy.","Avg quality":"Qualité moy.","Avg ratio":"Taux moy.","Avg/day":"Moy./jour","BUH":"Appoint","BUH >":"Appoint >","Band":"Plage","Best day":"Meilleur jour","Boiler COP":"COP chaudière","Bucket":"Tranche","CARNOT EFF.":"RENDEMENT CARNOT","COMPRESSOR":"COMPRESSEUR","COOLING":"RAFRAÎCHISSEMENT","COP":"COP","COP TODAY":"COP DU JOUR","COP TREND":"TENDANCE COP","COP above datasheet reference":"COP au-dessus de la fiche technique","CYCLES PER DAY":"CYCLES PAR JOUR","CYCLES/DAY":"CYCLES/JOUR","Comfort":"Confort","Compressor off":"Compresseur arrêté","Contribution":"Part","Cool":"Froid","Cooling":"Rafraîchissement","Cycles":"Cycles","Cycles per day":"Cycles par jour","DEFROST":"DÉGIVRAGE","DEFROST IMPACT":"EFFET DES DÉGIVRAGES","DHW":"ECS","DURATION/DAY":"DURÉE/JOUR","Days":"Jours","Defrost":"Dégivrage","Duration":"Durée","Duration per day":"Durée par jour","Duty":"Taux de marche","ELEC":"ÉLEC","ELECTRICAL":"ÉLECTRIQUE","EMITTER":"RADIATEURS","ENERGY TODAY":"ÉNERGIE DU JOUR","Elapsed":"Écoulé","Energy":"Énergie","Event counts per day":"Événements par jour","Event ratio per day":"Taux d'événements par jour","Good days":"Bons jours","Good ratio":"Taux de bons cycles","HEAT BALANCE":"BILAN DE CHALEUR","HEAT PUMP":"PAC","HEATING":"CHAUFFAGE","HEATING OFF":"CHAUFFAGE COUPÉ","HP → EMITTER":"PAC → RADIATEURS","Heat":"Chauffage","Heating":"Chauffage","IDLE":"À L'ARRÊT","IN":"ENTRÉE","INFO":"INFO","Insufficient data":"Pas assez de données","LWT":"Départ","LWT NOW":"DÉPART ACTUEL","LWT OPT":"DÉPART OPTIMAL","Last defrost":"Dernier dégivrage","Last: ":"Dernier : ","Live cycle · COP · quality · alerts":"Cycle en direct · COP · qualité · alertes","Longest":"Le plus long","Longest day":"Jour le plus long","Low days":"Jours faibles","MAX LWT":"DÉPART MAX","MIN LWT":"DÉPART MIN","MODES":"MODES","Max day":"Jour max","Mid days":"Jours moyens","Mode":"Mode","Month":"Mois","No COP data":"Pas de COP","No data":"Pas de données","OUT":"SORTIE","OUTDOOR TEMPERATURE (°C)":"TEMPÉRATURE EXTÉRIEURE (°C)","Outdoor":"Extérieur","PENDULUM <20m":"TROP COURT <20 min","Phase":"Phase","Power":"Puissance","QUALITY":"QUALITÉ","Quality":"Qualité","Quality dropping (":"Qualité en baisse (","Quality per day":"Qualité par jour","Quality rising (+":"Qualité en hausse (+","RPS":"tr/s","RUNNING":"EN MARCHE","Range":"Plage","Reliability":"Fiabilité","Runs":"Cycles","Runtime":"Durée de marche","SAVINGS":"ÉCONOMIE","SPF SEASON":"SPF SAISON","STANDBY":"EN ATTENTE","SUPPLY LWT (°C)":"DÉPART D'EAU (°C)","Samples":"Échantillons","Savings":"Économie","Share":"Part","Short runs":"Cycles courts","Since midnight":"Depuis minuit","Source":"Source","Span":"Période","Starts":"Démarrages","Starts today":"Démarrages du jour","State":"État","Step":"Pas","Sum":"Somme","System performing normally":"Le système fonctionne normalement","THERM":"CHALEUR","THERMAL":"CHALEUR","THERMAL SPLIT":"RÉPARTITION DE LA CHALEUR","Today":"Aujourd'hui","Total":"Total","Total BUH":"Appoint total","Total defrost":"Dégivrage total","Total runtime":"Marche totale","Trends":"Tendances","VS DATASHEET":"VS FICHE TECHNIQUE","WEEK TREND":"TENDANCE SEMAINE","Week":"Semaine","Worst day":"Pire jour","Y-axis max":"Échelle max","Year":"Année","act":"act.","active":"active","ago":"plus tôt","avg":"moy.","buckets":"tranches","cycles":"cycles","datasheet":"fiche technique","day":"jour","defrost <":"dégivrage <","demand":"demande","duration":"durée","events":"événements","heating OFF >":"chauffage coupé >","high":"élevé","in bucket":"dans la tranche","insufficient buckets":"pas assez de tranches","last":"dernier","low":"faible","max":"max","min":"min","month":"mois","more":"de plus","nominal":"normal","nominal COP":"COP nominal","of cycles":"des cycles","outdoor":"extérieur","per day":"par jour","samples":"échantillons","state":"état","supply":"départ","today":"aujourd'hui","total":"total","week":"semaine","Ø duration":"Ø durée","Ø/cycle":"Ø/cycle","← 💧 RETURN":"← 💧 RETOUR","≥70 good":"≥70 bon","⏮️ Last cycle":"⏮️ Dernier cycle","⏱️ DURATION":"⏱️ DURÉE","♻️ Hydraulic circuit":"♻️ Circuit hydraulique","⚠ BUH ASSIST":"⚠ APPOINT","⚡ BUH":"⚡ Appoint","⚡ EVENTS":"⚡ ÉVÉNEMENTS","✅ System OK — no active warnings":"✅ Système OK — aucune alerte active","❄ DEFROST":"❄ DÉGIVRAGE","❄ Defrost":"❄ Dégivrage","⭐ QUALITY":"⭐ QUALITÉ","🎯 COP":"🎯 COP","🎯 COP Efficiency":"🎯 Efficacité COP","🎯 Cycles vs Duration":"🎯 Cycles / durée","🎯 SCATTER":"🎯 NUAGE","💡 COP = efficiency · ~ref = approximate datasheet comparison (A7/W35) · duration/cycle trends per day":"💡 COP = efficacité · ~réf = comparaison approximative avec la fiche (A7/W35) · tendances durée/cycles par jour","💡 Cycle = continuous compressor run · <15m = inefficient cycling · >48h = safety limit":"💡 Cycle = marche continue du compresseur · <15 min = cycles trop courts · >48 h = limite de sécurité","💡 Duration = total compressor runtime per day · split per mode · ⚠ = clipped":"💡 Durée = marche totale du compresseur par jour · par mode · ⚠ = tronqué","💡 Higher COP = better · Q = quality 0-100 · Alerts on top = action":"💡 COP élevé = mieux · Q = qualité 0-100 · Alertes en haut = à traiter","💡 Ratio = events per cycle × 100 · green = nominal (15%) · red = elevated (35%)":"💡 Taux = événements par cycle × 100 · vert = normal (15 %) · rouge = élevé (35 %)","💡 Tap a bar for details — buckets by avg cycle duration per mode":"💡 Toucher une barre pour le détail — tranches par durée moyenne de cycle et par mode","💡 Tap a dot for details — X: cycles/day · Y: avg duration · color: quality":"💡 Toucher un point pour le détail — X : cycles/jour · Y : durée moy. · couleur : qualité","💡 Tap a dot or stat for day details":"💡 Toucher un point ou une valeur pour le détail du jour","💡 Tap an item for details":"💡 Toucher un élément pour le détail","📅 Today":"📅 Aujourd'hui","📈 Heating curve advice":"📈 Conseil de loi d'eau","📈 Regression":"📈 Régression","📊 Cycle duration distribution":"📊 Répartition des durées de cycle","📊 DISTRIBUTION":"📊 RÉPARTITION","📊 OVERVIEW":"📊 VUE D'ENSEMBLE","📊 historical":"📊 historique","🔄 CYCLES":"🔄 CYCLES","🔍 auto-discovery":"🔍 détection auto","🔥 SUPPLY →":"🔥 DÉPART →"," below datasheet":" sous la fiche technique"," well above target":" bien au-dessus de l'objectif","% week":" % / semaine","BUH active":"Appoint en marche","COP dropping ":"COP en baisse ","COP heating ":"COP chauffage ","COP low":"COP bas","DHW cycling":"Cycles d'eau chaude","High cycle rate":"Fréquence de cycles élevée","Missing attributes":"Valeurs manquantes","Pendulum/day":"Cycles trop fréquents/jour","Pendulum/hour":"Cycles trop fréquents/heure","Previous: BUH":"Précédent : appoint","Previous: defrost":"Précédent : dégivrage","SPF ":"SPF ","Setpoint oscillation":"Consigne instable","Short off-time":"Arrêt court","Short run":"Marche courte","Source stale":"Source muette","Too many cycles (target ":"Trop de cycles (objectif ","Update available":"Mise à jour disponible","is_stale flag":"Source en retard"}; var FR=function(x){ return (LANG==='fr' && typeof x==='string' && Object.prototype.hasOwnProperty.call(FRM,x)) ? FRM[x] : x; }; var FRO=function(o){ if(typeof o==='string') return Object.prototype.hasOwnProperty.call(FRM,o)?FRM[o]:o; if(o&&typeof o==='object'){ var r=Array.isArray(o)?[]:{}; for(var k in o){ r[k]=FRO(o[k]); } return r; } return o; }; var I18N = { tab_overview:{nl:'📊 OVERZICHT', en:'📊 OVERVIEW'}, tab_quality: {nl:'⭐ KWALITEIT', en:'⭐ QUALITY'}, tab_cycles: {nl:'🔄 CYCLI', en:'🔄 CYCLES'}, tab_duration:{nl:'⏱️ DUUR', en:'⏱️ DURATION'}, tab_events: {nl:'⚡ EVENTS', en:'⚡ EVENTS'}, best: {nl:'Beste dag', en:'Best day'}, worst: {nl:'Slechtste dag', en:'Worst day'}, qual_chart: {nl:'Kwaliteit per dag', en:'Quality per day'}, cycles_chart:{nl:'Cycli per dag', en:'Cycles per day'}, dur_chart: {nl:'Duur per dag', en:'Duration per day'}, ev_chart: {nl:'Events per dag', en:'Event counts per day'}, ev_ratio: {nl:'Event-ratio per dag', en:'Event ratio per day'}, q_good: {nl:'≥70 goed', en:'≥70 good'}, q_mid: {nl:'40-70 midden', en:'40-70 mid'}, q_low: {nl:'<40 laag', en:'<40 low'}, leg_heat: {nl:'Verwarming', en:'Heating'}, leg_dhw: {nl:'DHW', en:'DHW'}, leg_cool: {nl:'Koeling', en:'Cooling'}, leg_buh: {nl:'BUH', en:'BUH'}, leg_defr: {nl:'Defrost', en:'Defrost'}, no_data: {nl:'Geen data', en:'No data'}, n_overview:{nl:'💡 Tik op een element voor details', en:'💡 Tap an item for details'}, n_quality: {nl:'💡 Tik op een punt of stat voor dag-details', en:'💡 Tap a dot or stat for day details'}, n_cycles: {nl:'💡 Cyclus = continue compressor-run · <15m = inefficiënt pendelen · >48u = veiligheidslimiet', en:'💡 Cycle = continuous compressor run · <15m = inefficient cycling · >48h = safety limit'}, n_duration:{nl:'💡 Duur = totale compressor-runtime per dag · splits per modus · ⚠ = geclipt', en:'💡 Duration = total compressor runtime per day · split per mode · ⚠ = clipped'}, n_events: {nl:'💡 Ratio = events per cyclus × 100 · groen = nominaal (15%) · rood = verhoogd (35%)', en:'💡 Ratio = events per cycle × 100 · green = nominal (15%) · red = elevated (35%)'}, r_quality: {nl:'Kwaliteit', en:'Quality'}, r_cycles: {nl:'Cycli', en:'Cycles'}, r_avgdur: {nl:'Ø duur', en:'Ø duration'}, r_avgdur2: {nl:'Gem duur', en:'Avg duration'}, r_maxdur: {nl:'Langste dag', en:'Longest day'}, r_totaldur:{nl:'Totale duur', en:'Total runtime'}, r_buh: {nl:'⚡ BUH', en:'⚡ BUH'}, r_defrost: {nl:'❄ Defrost', en:'❄ Defrost'}, r_avgq: {nl:'Gem kwaliteit', en:'Avg quality'}, r_total: {nl:'Totaal', en:'Total'}, r_sum: {nl:'Som', en:'Sum'}, r_avgday: {nl:'Gem/dag', en:'Avg/day'}, r_maxday: {nl:'Max dag', en:'Max day'}, r_avgcyc: {nl:'Ø/cyclus', en:'Ø/cycle'}, r_cap: {nl:'Y-as max', en:'Y-axis max'}, r_starts: {nl:'Starts vandaag', en:'Starts today'}, r_days_good:{nl:'Goede dagen', en:'Good days'}, r_days_mid:{nl:'Midden dagen', en:'Mid days'}, r_days_low:{nl:'Slechte dagen', en:'Low days'}, r_totalbuh:{nl:'Tot BUH', en:'Total BUH'}, r_totaldef:{nl:'Tot defrost', en:'Total defrost'}, r_avgratio:{nl:'Gem ratio', en:'Avg ratio'}, r_lastdef: {nl:'Laatste defrost', en:'Last defrost'}, r_duty: {nl:'Bedrijfstijd', en:'Duty'}, r_range: {nl:'Periode', en:'Range'}, r_worst: {nl:'Slechtste dag', en:'Worst day'}, r_best: {nl:'Beste dag', en:'Best day'}, r_mode: {nl:'Modus', en:'Mode'}, r_n_days: {nl:'Dagen', en:'Days'}, r_span: {nl:'Tijdsduur', en:'Span'}, p_modes: {nl:'MODI', en:'MODES'}, p_step: {nl:'Step', en:'Step'}, p_energy: {nl:'Energie', en:'Energy'}, p_band: {nl:'Band', en:'Band'}, p_runtime: {nl:'Runtime', en:'Runtime'}, p_elapsed: {nl:'Verstreken', en:'Elapsed'}, hybrid_mode: {nl:'Modus', en:'Mode'}, boiler_contrib: {nl:'Bijdrage', en:'Contribution'}, boiler_cop: {nl:'Boiler COP', en:'Boiler COP'} }; var t = function(k){ var e=I18N[k]; if(!e) return k; if(LANG==='fr') return e.fr || FR(e.en || e.nl); return e[LANG] || e.en || e.nl; }; var wd = function(iso){ return LANG==='nl' ? weekday(iso) : weekdayEn(iso); }; /* POPUP SYSTEM */ if (!window.__paShowPopup) { window.__paShowPopup = function(el, cardEl){ try { var chart = el.closest('.pa-chart'); if (!chart) return; var host = chart.querySelector('.pa-popup-host'); if (!host) return; var pid = el.getAttribute('data-pa-pid'); if (!pid) return; var registry = cardEl.__paRegistry || {}; var payload = registry[pid]; if (!payload) return; var now = Date.now(); if (chart.__paLastTap && (now - chart.__paLastTap) < 200) return; chart.__paLastTap = now; var oldPops = host.querySelectorAll('.pa-popup'); for (var i = 0; i < oldPops.length; i++) if (oldPops[i].parentNode) oldPops[i].parentNode.removeChild(oldPops[i]); if (chart.__paTimer) { clearTimeout(chart.__paTimer); chart.__paTimer = null; } var pop = document.createElement('div'); pop.className = 'pa-popup'; pop.setAttribute('data-pa-action','close-popup'); var html = '
' + payload.title + '✕
'; if (payload.items && payload.items.length) { for (var j = 0; j < payload.items.length; j++) { var it = payload.items[j]; if (it.hl) { html += '
' + it.k + '' + it.v + '
'; } else { html += '
' + it.k + '' + it.v + '
'; } } } if (payload.modes && payload.modes.length) { html += '
' + (LANG==='nl'?'MODI':FR('MODES')) + '
'; for (var mi = 0; mi < payload.modes.length; mi++) { var md = payload.modes[mi]; var qStr = (md.q === null || md.q === undefined) ? '—' : md.q; html += '
' + '' + md.icon + '' + '' + md.cycles + '×' + '' + md.dur + '' + 'Q' + qStr + '' + '
'; } html += '
'; } html += '
'; pop.innerHTML = html; pop.style.visibility = 'hidden'; host.appendChild(pop); var chartRect = chart.getBoundingClientRect(); var rect; try { rect = el.getBoundingClientRect(); } catch(e){ rect = null; } var pw = pop.offsetWidth || 260, ph = pop.offsetHeight || 200; var ex = 0, ey = 40, ew = 100, eh = 20; if (rect && rect.width > 0) { ex = rect.left - chartRect.left; ey = rect.top - chartRect.top; ew = rect.width; eh = rect.height; } else { ex = chartRect.width / 2 - 60; } var GAP = 12, MARGIN = 8; var left = ex + ew/2 - pw/2; if (left < MARGIN) left = MARGIN; if (left + pw > chartRect.width - MARGIN) left = chartRect.width - pw - MARGIN; var placeAbove = (ey - GAP - ph) >= MARGIN; var top; if (placeAbove) { top = ey - GAP - ph; pop.classList.add('popup-above'); } else { var belowTop = ey + eh + GAP; if (belowTop + ph <= chartRect.height - MARGIN) { top = belowTop; pop.classList.add('popup-below'); } else { top = Math.max(MARGIN, ey - GAP - ph); pop.classList.add('popup-clamped'); } } pop.style.left = left + 'px'; pop.style.top = top + 'px'; pop.style.visibility = 'visible'; pop.addEventListener('click', function(ev){ ev.stopImmediatePropagation(); ev.stopPropagation(); ev.preventDefault(); if (chart.__paTimer) { clearTimeout(chart.__paTimer); chart.__paTimer = null; } pop.classList.add('pa-popup-out'); setTimeout(function(){ if (pop.parentNode) pop.parentNode.removeChild(pop); }, 220); }, true); chart.__paTimer = setTimeout(function(){ if (pop && pop.parentNode) { pop.classList.add('pa-popup-out'); setTimeout(function(){ if (pop.parentNode) pop.parentNode.removeChild(pop); }, 250); } chart.__paTimer = null; }, 4000); } catch(e){ console.warn('[PA popup]', e); } }; } var rawDays = attr(SUMMARY, 'days', []); if(!Array.isArray(rawDays)) rawDays = []; var EVENTS_BY_DAY = attr(SUMMARY, 'events_by_day', {}) || {}; var specModel = attr(SPECS, 'model', null); var specFamily = attr(SPECS, 'family', null); var specKw = aN(SPECS, 'kw', null); var specConfigured = attr(SPECS, 'configured', false); var byDate = {}; for(var ri = 0; ri < rawDays.length; ri++){ var rd = rawDays[ri]; var dayKey = rd.day; if(!dayKey) continue; if(!byDate[dayKey]){ byDate[dayKey] = { day: dayKey, cycles:0, dur_min:0, dur_max:0, quality_sum:0, quality_weight:0, buh:0, defrost:0, modes:{ heating:{cycles:0,dur:0,quality:null}, dhw:{cycles:0,dur:0,quality:null}, cooling:{cycles:0,dur:0,quality:null} } }; } var de = byDate[dayKey]; de.cycles += (rd.cycles || 0); de.dur_min += (rd.dur_min || 0); if(hasV(rd.dur_max) && parseFloat(rd.dur_max) > de.dur_max) de.dur_max = parseFloat(rd.dur_max); if(hasV(rd.quality_avg)){ var qVal = parseFloat(rd.quality_avg); if(isFinite(qVal)){ var w = Math.max(1, rd.cycles || 0); de.quality_sum += qVal * w; de.quality_weight += w; } } de.buh += (rd.buh || 0); de.defrost += (rd.defrost || 0); var mkey = rd.mode || 'unknown'; if(de.modes[mkey]){ de.modes[mkey].cycles += (rd.cycles || 0); de.modes[mkey].dur += (rd.dur_min || 0); if (hasV(rd.quality_avg)) { var mq = parseFloat(rd.quality_avg); if (isFinite(mq)) de.modes[mkey].quality = mq; } } } var daysAll = Object.keys(byDate).map(function(k){ var de = byDate[k]; de.quality_avg = de.quality_weight > 0 ? de.quality_sum / de.quality_weight : null; de.dur_avg = de.cycles > 0 ? de.dur_min / de.cycles : 0; var evD = EVENTS_BY_DAY[de.day]; /* #400: real per-day events (same source as Today block) */ if (evD) { if (hasV(evD.defrost_events) && evD.defrost_events > de.defrost) de.defrost = parseFloat(evD.defrost_events); if (hasV(evD.buh_min) && evD.buh_min > 0 && de.buh < 1) de.buh = 1; } return de; }).sort(function(a,b){ return a.day < b.day ? -1 : 1; }); var ps = card.__paState = card.__paState || {}; if (!ps.tab || ['overview','quality','cycles','duration','events'].indexOf(ps.tab) === -1) ps.tab = cfgTab; if (!ps.win || [7,15,30].indexOf(ps.win) === -1) ps.win = cfgWin; var activeTab = ps.tab; var activeWin = String(ps.win); var registerPayload = function(payload){ card.__paSeq++; var id = 'p' + card.__paSeq; card.__paRegistry[id] = payload; return id; }; var buildDayPayload = function(d){ var items = [ { k:t('r_quality'), v:(d.quality_avg===null?'—':vI(d.quality_avg)+'%'), c:qColor(d.quality_avg), hl:true }, { k:t('r_cycles'), v:String(d.cycles), c:'var(--primary-text-color, #0D47A1)' }, { k:t('r_avgdur2'), v:(d.cycles>0?fmtBigMin(d.dur_min/d.cycles):'—'), c:'var(--primary-text-color, #0D47A1)' }, { k:t('r_maxdur'), v:fmtBigMin(d.dur_max), c:'var(--primary-text-color, #0D47A1)' }, { k:t('r_totaldur'), v:fmtBigMin(d.dur_min), c:'var(--primary-text-color, #0D47A1)' }, { k:t('r_buh'), v:String(d.buh||0), c:(d.buh>0?'#E65100':'var(--disabled-text-color, #94a3b8)') }, { k:t('r_defrost'), v:String(d.defrost||0), c:(d.defrost>0?'#1976D2':'var(--disabled-text-color, #94a3b8)') } ]; var modes = []; var mmap = { heating:{ic:'🔥', col:C.heating, nm:(LANG==='nl'?'Verwarming':FR('Heating'))}, dhw:{ic:'🚿', col:C.dhw, nm:FR('DHW')}, cooling:{ic:'🧊', col:C.cooling, nm:(LANG==='nl'?'Koeling':FR('Cooling'))} }; Object.keys(d.modes).forEach(function(mk){ var m = d.modes[mk]; if (m.cycles > 0) { modes.push({ icon: mmap[mk].ic, col: mmap[mk].col, name: mmap[mk].nm, cycles: m.cycles, dur: fmtBigMin(m.dur), q: (m.quality===null||m.quality===undefined) ? '—' : vI(m.quality), qc: qColor(m.quality) }); } }); return registerPayload({ title: wd(d.day)+' '+fmtDay(d.day), items: items, modes: modes }); }; var statStrip = function(items){ var s = '
'; for (var i=0;i' + '
'+it.l+'
' + '
'+it.v+'
' + '
'; } s += ''; return s; }; var buildOverview = function(sub, winKey){ var wTotCycles = sub.reduce(function(a,d){ return a+d.cycles; }, 0); var wHours = sub.reduce(function(a,d){ return a+d.dur_min; }, 0) / 60; var qVals = sub.filter(function(d){ return d.quality_avg !== null; }).map(function(d){ return d.quality_avg; }); var wQ = qVals.length > 0 ? qVals.reduce(function(a,v){ return a+v; },0)/qVals.length : null; var byQ = sub.filter(function(d){ return d.quality_avg!==null; }).slice().sort(function(a,b){ return b.quality_avg - a.quality_avg; }); var best = byQ.length > 0 ? byQ[0] : null; var worst = byQ.length > 1 ? byQ[byQ.length-1] : null; var modeTotals = { heating:0, dhw:0, cooling:0 }; var modeDurs = { heating:0, dhw:0, cooling:0 }; sub.forEach(function(d){ modeTotals.heating += d.modes.heating.cycles; modeTotals.dhw += d.modes.dhw.cycles; modeTotals.cooling += d.modes.cooling.cycles; modeDurs.heating += d.modes.heating.dur; modeDurs.dhw += d.modes.dhw.dur; modeDurs.cooling += d.modes.cooling.dur; }); var ringR = 46, ringStroke = 10, ringSize = 120; var cx = ringSize/2, cy = ringSize/2; var circ = 2 * Math.PI * ringR; var qPct = wQ===null ? 0 : Math.max(0, Math.min(100, wQ)); var dashLen = circ * (qPct/100); var ringCol = qColor(wQ); var ringSvg = ''; ringSvg += ''; ringSvg += ''; ringSvg += ''+(wQ===null?'—':vI(wQ)+'%')+''; ringSvg += ''+t('r_avgq').toUpperCase()+''; ringSvg += ''; var modeTotal = modeTotals.heating + modeTotals.dhw + modeTotals.cooling; var barHtml = ''; if (modeTotal > 0) { var hPct = (modeTotals.heating/modeTotal)*100; var dPct = (modeTotals.dhw/modeTotal)*100; var cPct = (modeTotals.cooling/modeTotal)*100; barHtml = '
'; if (modeTotals.heating > 0) barHtml += '
'+modeTotals.heating+'
'; if (modeTotals.dhw > 0) barHtml += '
'+modeTotals.dhw+'
'; if (modeTotals.cooling > 0) barHtml += '
'+modeTotals.cooling+'
'; barHtml += '
'; barHtml += '
'; if (modeTotals.heating > 0) barHtml += ''+t('leg_heat')+' '+Math.round(hPct)+'%'; if (modeTotals.dhw > 0) barHtml += ''+t('leg_dhw')+' '+Math.round(dPct)+'%'; if (modeTotals.cooling > 0) barHtml += ''+t('leg_cool')+' '+Math.round(cPct)+'%'; barHtml += '
'; } var modelDisplay; if (specConfigured && specModel) modelDisplay = specModel.toUpperCase(); else if (specModel === 'custom' || specModel === 'basisprofiel') modelDisplay = 'CUSTOM'; else if (specModel) modelDisplay = specModel.toUpperCase(); else modelDisplay = '—'; var heroPid = registerPayload({ title: t('r_range'), items: [ { k:t('r_n_days'), v:String(sub.length) }, { k:t('r_total'), v:String(wTotCycles), hl:true }, { k:t('r_totaldur'), v:fmtBigHours(wHours) }, { k:t('r_avgq'), v:(wQ===null?'—':vI(wQ)+'%'), c:qColor(wQ) }, { k:t('r_best'), v:(best?wd(best.day)+' '+fmtDay(best.day)+' · '+vI(best.quality_avg)+'%':'—'), c:QGOOD }, { k:t('r_worst'), v:(worst?wd(worst.day)+' '+fmtDay(worst.day)+' · '+vI(worst.quality_avg)+'%':'—'), c:QLOW } ], modes: [ { icon:'🔥', col:C.heating, name:t('leg_heat'), cycles:modeTotals.heating, dur:fmtBigMin(modeDurs.heating), q:'—', qc:'var(--disabled-text-color, #94a3b8)' }, { icon:'🚿', col:C.dhw, name:FR('DHW'), cycles:modeTotals.dhw, dur:fmtBigMin(modeDurs.dhw), q:'—', qc:'var(--disabled-text-color, #94a3b8)' }, { icon:'🧊', col:C.cooling, name:t('leg_cool'), cycles:modeTotals.cooling, dur:fmtBigMin(modeDurs.cooling), q:'—', qc:'var(--disabled-text-color, #94a3b8)' } ] }); var h = ''; h += '
'; h += '
'; h += '
'; h += '
🌡️
'; h += '
'; h += '
DAIKIN CYCLE ML
'; h += '
'+modelDisplay+'
'; var hybridStr = IS_HYBRID ? ' · 🔥 ' + (String((states[HYBRID_MODE] || {}).state) || 'Hybrid') : ''; h += '
'+(specFamily||'—')+(specKw?' · '+vI(specKw)+' kW':'') + hybridStr + '
'; h += '
'; h += '
'+ringSvg+'
'; h += '
'; h += '
'; h += ''+String(wTotCycles)+(LANG==='nl'?' cycli · ':' cycles · ')+fmtBigHours(wHours)+''; h += ''+fmtDay(sub[0].day)+' → '+fmtDay(sub[sub.length-1].day)+''; h += '
'; if (barHtml) h += '
'+barHtml+'
'; h += '
'; if (best || worst) { h += '
'; var bwCard = function(icon, lbl, d, col){ if (!d) return '
—
'; var qc = qColor(d.quality_avg); var pid = buildDayPayload(d); return '
' + '
'+icon+' '+lbl+'
' + '
'+wd(d.day)+' '+fmtDay(d.day)+'
' + '
'+(d.quality_avg===null?'—':vI(d.quality_avg)+'%')+'' + ''+d.cycles+'c · '+fmtBigMin(d.dur_min)+'
' + '
'; }; h += bwCard('🏆', t('best'), best, QGOOD); h += bwCard('⚠️', t('worst'), worst, QLOW); h += '
'; } h += '
'; h += '
📈 '+(LANG==='nl'?'Trends':FR('Trends'))+''+sub.length+(LANG==='fr'?' j':'d')+'
'; h += buildSpark(sub); h += '
'; return h; }; var buildSpark = function(sub){ var sparkW = 460, sparkH = 78; var panW = 143, panGap = 15; var panH = 48; var data = [ { title:(LANG==='nl'?'KWALITEIT':FR('QUALITY')), color:C.quality, bg:CBG.quality, data:sub.map(function(d){ return d.quality_avg; }), yMin:0, yMax:100, fmt:function(v){ return Math.round(v)+'%'; } }, { title:(LANG==='nl'?'CYCLI/DAG':FR('CYCLES/DAY')), color:C.heating, bg:CBG.heating, data:sub.map(function(d){ return d.cycles; }), yMin:0, yMax:null, fmt:function(v){ return String(Math.round(v)); } }, { title:(LANG==='nl'?'DUUR/DAG':FR('DURATION/DAY')), color:C.cooling, bg:CBG.cooling, data:sub.map(function(d){ return d.dur_min/60; }), yMin:0, yMax:null, fmt:function(v){ return v<10 ? v.toFixed(1).replace('.', _DEC)+'h' : Math.round(v)+'h'; } } ]; var s = ''; for (var pi=0; pi 0 ? Math.max.apply(null, vals) : 1; var dMin = vals.length > 0 ? Math.min.apply(null, vals) : 0; if (p.yMin !== null) dMin = p.yMin; if (p.yMax !== null) dMax = p.yMax; var range = dMax - dMin; if (range<=0) range=1; var yMax = dMax + range*0.1; var yMin = Math.max(p.yMin!==null?p.yMin:0, dMin - range*0.1); if (yMax - yMin <= 0) yMax = yMin + 1; var xStep = w / Math.max(1, p.data.length - 1); var xAt = function(i){ return x0 + i*xStep; }; var yAt = function(v){ return y1 - ((v - yMin)/(yMax - yMin)) * hgt; }; s += ''; s += ''+p.title+''; var pathD='', first=null, last=null, started=false; for (var si=0; si'; s += ''; for (var si2=0; si2'; s += ''; s += ''; s += ''; } } var lastV = p.data[p.data.length-1]; var curTxt = (hasV(lastV) && isFinite(parseFloat(lastV))) ? p.fmt(parseFloat(lastV)) : '—'; s += ''+curTxt+''; } s += ''; return s; }; var buildQuality = function(sub){ var numDays = sub.length; var qVals = sub.filter(function(d){ return d.quality_avg !== null; }).map(function(d){ return d.quality_avg; }); var avgQ = qVals.length > 0 ? qVals.reduce(function(a,v){ return a+v; },0)/qVals.length : null; var minQ = qVals.length > 0 ? Math.min.apply(null, qVals) : 0; var yMin = minQ >= 70 ? 60 : (minQ >= 50 ? 40 : 0); var yMax = 100; var qcH = cfgChartH, qcW = 460; var qcPadL = 44, qcPadR = 14, qcPadT = 30, qcPadB = 46; var plotW = qcW - qcPadL - qcPadR; var plotH = qcH - qcPadT - qcPadB; var slot = plotW / Math.max(1, numDays); var xAt = function(i){ return qcPadL + i*slot + slot/2; }; var yAt = function(v){ var pct = (Math.max(yMin, Math.min(yMax, v)) - yMin) / (yMax - yMin); return qcPadT + plotH - pct*plotH; }; var labelEvery = Math.max(1, Math.ceil(numDays / 12)); var s = ''; s += ''; if (yMin <= 70) s += ''; if (yMin < 70 && yMin < 40) s += ''; if (yMin < 40) s += ''; var step = (yMax - yMin) / 4; for (var gi=0; gi<=4; gi++){ var gv = yMin + step*gi, gy = yAt(gv); s += ''; s += ''+Math.round(gv)+''; } if (avgQ !== null){ var aY = yAt(avgQ); s += ''; } var pts = []; for (var pi=0; pi= 2){ var lineD = ''; for (var li=0; li'; s += ''; } for (var vi=0; vi'; s += ''; if (isLatest) s += ''; s += ''; s += ''; s += ''; if (numDays <= 21) s += ''+vI(pt.q)+''; } for (var xi=0; xi'+wd(sub[xi].day)+''; if (numDays <= 21) s += ''+fmtDay(sub[xi].day)+''; } } s += ''; s += ''; s += ''; var good = 0, mid = 0, low = 0; sub.forEach(function(d){ if (d.quality_avg === null) return; if (d.quality_avg >= 70) good++; else if (d.quality_avg >= 40) mid++; else low++; }); var stats = statStrip([ {l:t('r_avgq'), v:(avgQ===null?'—':vI(avgQ)+'%'), c:qColor(avgQ)}, {l:t('r_days_good'), v:String(good), c:QGOOD}, {l:t('r_days_mid'), v:String(mid), c:QMID}, {l:t('r_days_low'), v:String(low), c:QLOW} ]); return { chart: s, stats: stats }; }; var buildCycles = function(sub){ var numDays = sub.length; var cH = 320, cW = 460; var cPadL = 44, cPadR = 14, cPadT = 30, cPadB = 46; var plotW = cW - cPadL - cPadR; var plotH = cH - cPadT - cPadB; var barW = Math.max(6, Math.min(50, (plotW / Math.max(1,numDays)) * 0.72)); var slot = plotW / Math.max(1, numDays); var xAt = function(i){ return cPadL + i*slot + (slot-barW)/2; }; var maxCy = Math.max.apply(null, sub.map(function(d){ return d.cycles; })) || 1; var yMax = maxCy <= 4 ? 4 : Math.ceil(maxCy/2)*2; var yAt = function(v){ return cPadT + plotH - (v/yMax)*plotH; }; var labelEvery = Math.max(1, Math.ceil(numDays / 12)); var s = ''; for (var gi=0; gi<=4; gi++){ var gv = Math.round(yMax*gi/4), gy = yAt(gv); s += ''; s += ''+gv+''; } for (var i=0; i'; s += ''; if (hCh>0) s += ''; if (dCh>0) s += ''; if (cCh>0) s += ''; s += ''; if (numDays<=21 && d.cycles>0) s += ''+d.cycles+''; if (i % labelEvery === 0 || i === numDays-1){ s += ''+wd(d.day)+''; if (numDays<=21) s += ''+fmtDay(d.day)+''; } } s += ''; s += ''; s += ''; var totalCy = sub.reduce(function(a,d){ return a+d.cycles; }, 0); var maxDay = sub.reduce(function(a,d){ return Math.max(a, d.cycles); }, 0); var avgDay = sub.length > 0 ? totalCy / sub.length : 0; var startsId = resolveEntity('starts_today'); var starts = startsId ? (parseFloat((states[startsId] || {}).state) || 0) : 0; var stats = statStrip([ {l:t('r_total'), v:String(totalCy), c:'var(--primary-text-color, #0D47A1)'}, {l:t('r_avgday'), v:v1(avgDay), c:'var(--secondary-text-color, #1565C0)'}, {l:t('r_maxday'), v:String(maxDay), c:C.heating}, {l:t('r_starts'), v:String(starts), c:(starts>0?C.heating:'var(--disabled-text-color, #94a3b8)')} ]); return { chart: s, stats: stats }; }; var buildDuration = function(sub){ var numDays = sub.length; var cH = 320, cW = 460; var cPadL = 46, cPadR = 14, cPadT = 30, cPadB = 46; var plotW = cW - cPadL - cPadR; var plotH = cH - cPadT - cPadB; var realDur = sub.filter(function(d){ return d.dur_min>0 && d.dur_min<=1440; }).map(function(d){ return d.dur_min/60; }).sort(function(a,b){ return a-b; }); var p95 = realDur.length > 0 ? realDur[Math.floor(realDur.length*0.95)] : 4; var maxReal = realDur.length > 0 ? realDur[realDur.length-1] : 4; var cap = Math.max(4, Math.min(24, Math.ceil(Math.max(p95*1.15, 4)))); if (maxReal<=24 && maxReal<=cap*1.3) cap = Math.max(4, Math.ceil(maxReal)); var barW = Math.max(6, Math.min(50, (plotW/numDays)*0.72)); var slot = plotW / Math.max(1, numDays); var xAt = function(i){ return cPadL + i*slot + (slot-barW)/2; }; var yAt = function(v){ return cPadT + plotH - (Math.min(v, cap)/cap)*plotH; }; var labelEvery = Math.max(1, Math.ceil(numDays / 12)); var s = ''; for (var gi=0; gi<=4; gi++){ var gv = cap*gi/4, gy = yAt(gv); var lbl = gv<1 ? gv.toFixed(1).replace('.', _DEC) : Math.round(gv).toString(); s += ''; s += ''+lbl+'h'; } for (var i=0; i cap; var displayH = Math.min(hours, cap); var hTotal = (displayH/cap)*plotH; var x = xAt(i), yBase = cPadT + plotH; var hH = d.modes.heating.dur/60; var hD = d.modes.dhw.dur/60; var hC = d.modes.cooling.dur/60; var totalH = hH + hD + hC; var scale = totalH > 0 ? displayH/totalH : 0; var hPx = ((hH*scale)/cap)*plotH; var dPx = ((hD*scale)/cap)*plotH; var cPx = ((hC*scale)/cap)*plotH; var pid = buildDayPayload(d); s += ''; s += ''; if (hPx>0) s += ''; if (dPx>0) s += ''; if (cPx>0) s += ''; if (clipped) s += ''; s += ''; if (numDays<=21 && hours>0){ var ltxt = hours<1 ? vI(hours*60)+'m' : hours.toFixed(1).replace('.', _DEC)+'h'; s += ''+(clipped?'⚠':'')+ltxt+''; } if (i % labelEvery === 0 || i === numDays-1){ s += ''+wd(d.day)+''; if (numDays<=21) s += ''+fmtDay(d.day)+''; } } s += ''; s += ''; s += ''; var totCy = sub.reduce(function(a,d){ return a+d.cycles; }, 0); var totDur = sub.reduce(function(a,d){ return a+d.dur_min; }, 0); var avgCyc = totCy > 0 ? totDur / totCy : 0; var maxDur = sub.reduce(function(a,d){ return Math.max(a, d.dur_min); }, 0); var stats = statStrip([ {l:t('r_totaldur'), v:fmtBigHours(totDur/60), c:'var(--primary-text-color, #0D47A1)'}, {l:t('r_avgcyc'), v:fmtBigMin(avgCyc), c:'var(--secondary-text-color, #1565C0)'}, {l:t('r_maxdur'), v:fmtBigMin(maxDur), c:C.cooling}, {l:t('r_cap'), v:cap+'h', c:'var(--disabled-text-color, #94a3b8)'} ]); return { chart: s, stats: stats }; }; var buildEvents = function(sub){ var numDays = sub.length; var labelEvery = Math.max(1, Math.ceil(numDays / 12)); var ID_BUH = resolveEntity('runtime_buh'); var ID_DEFCNT = resolveEntity('defrost_count'); var ID_DEFDUR = resolveEntity('defrost_duration'); var ID_DUTY = resolveEntity('duty_cycle'); var ID_STARTS = resolveEntity('starts_today'); var buhSec = ID_BUH ? (parseFloat((states[ID_BUH] || {}).state) || 0) : 0; var buhKwh = aN(ID_BUH, 'buh_energy_kwh_est', 0); var buhS1 = aN(ID_BUH, 'step1_s', 0); var buhS2 = aN(ID_BUH, 'step2_s', 0); var defCnt = ID_DEFCNT ? (parseFloat((states[ID_DEFCNT] || {}).state) || 0) : 0; var defAvg = aN(ID_DEFDUR, 'avg_duration_s', 0); var defLast = aN(ID_DEFCNT, 'last_defrost_ts', 0); var dutyPct = ID_DUTY ? (parseFloat((states[ID_DUTY] || {}).state) || 0) : 0; var dutyBand = ID_DUTY ? String(attr(ID_DUTY, 'band', '') || '') : ''; var startsT = ID_STARTS ? (parseFloat((states[ID_STARTS] || {}).state) || 0) : 0; var dutyCol = dutyBand === 'nominal' ? QGOOD : (dutyBand === 'low' ? 'var(--primary-color, #0097E0)' : (dutyBand === 'high' ? QMID : (dutyBand === 'saturated' ? QLOW : 'var(--disabled-text-color, #94a3b8)'))); var buhCol = buhSec > 0 ? C.buh : 'var(--disabled-text-color, #94a3b8)'; var defCol = defCnt > 0 ? C.defrost : 'var(--disabled-text-color, #94a3b8)'; var dutyLabel = dutyBand === 'nominal' ? (LANG==='nl'?'nominaal':FR('nominal')) : dutyBand === 'low' ? (LANG==='nl'?'laag':FR('low')) : dutyBand === 'high' ? (LANG==='nl'?'hoog':FR('high')) : dutyBand === 'saturated' ? (LANG==='nl'?'verzadigd':(LANG==='fr'?'saturé':'saturated')) : '—'; var buhPid = registerPayload({ title: '⚡ BUH · '+(LANG==='nl'?'vandaag':FR('today')), items: [ { k:t('r_totaldur'), v:fmtSec(buhSec), hl:true }, { k:t('p_step')+' 1', v:fmtSec(buhS1) }, { k:t('p_step')+' 2', v:fmtSec(buhS2) }, { k:t('p_energy'), v:v1(buhKwh)+' kWh', c:C.buh }, { k:t('r_span'), v:(LANG==='nl'?'Sinds 00:00':FR('Since midnight')) } ] }); var defPid = registerPayload({ title: '❄ '+FR('Defrost')+' · '+(LANG==='nl'?'vandaag':FR('today')), items: [ { k:t('r_cycles'), v:defCnt+'×', c:C.defrost, hl:true }, { k:t('r_avgdur2'), v:fmtSec(defAvg) }, { k:t('r_lastdef'), v:(defLast>0?fmtSec(Date.now()/1000-defLast)+' '+(LANG==='nl'?'geleden':FR('ago')):'—') } ] }); var dutyPid = registerPayload({ title: '⚙ '+t('r_duty')+' · '+(LANG==='nl'?'vandaag':FR('today')), items: [ { k:t('r_duty'), v:v1(dutyPct)+'%', c:dutyCol, hl:true }, { k:t('p_band'), v:dutyLabel, c:dutyCol }, { k:t('p_runtime'), v:fmtSec(aN(ID_DUTY,'runtime_s',0)) }, { k:t('p_elapsed'), v:fmtSec(aN(ID_DUTY,'elapsed_s',0)) } ] }); var startsPid = registerPayload({ title: '🔄 '+(LANG==='nl'?'Starts':FR('Starts')), items: [ { k:t('r_starts'), v:String(startsT), hl:true } ] }); var tile = function(icon, lbl, val, sub2, col, pid){ return '
' + '
'+icon+'
' + '
'+lbl+'
' + '
'+val+'
' + '
'+sub2+'
' + '
'; }; var buhSub = (buhS1>0||buhS2>0) ? ('S1 '+fmtSec(buhS1)+' · S2 '+fmtSec(buhS2)) : '—'; var defSub = defCnt > 0 ? ('Ø '+fmtSec(defAvg)) : '—'; var today = '
'; today += '
🔥 '+(LANG==='nl'?'Vandaag':FR('Today'))+'live
'; today += '
'; today += tile('⚡', FR('BUH'), fmtSec(buhSec), buhSub + ' · ' + v1(buhKwh)+' kWh', buhCol, buhPid); today += tile('❄', FR('Defrost'), defCnt+'×', defSub, defCol, defPid); today += tile('⚙', t('r_duty'), v1(dutyPct)+'%', dutyLabel, dutyCol, dutyPid); today += tile('🔄', FR('Starts'), String(startsT), LANG==='nl'?'vandaag':FR('today'), startsT > 0 ? 'var(--secondary-text-color, #1565C0)' : 'var(--disabled-text-color, #94a3b8)', startsPid); if (IS_HYBRID) { var boilerPct = BOILER_CONTRIB ? (parseFloat((states[BOILER_CONTRIB] || {}).state) || 0) : 0; var boilerCop = BOILER_EFF ? (parseFloat((states[BOILER_EFF] || {}).state) || 0) : 0; var boilerMode = HYBRID_MODE ? String((states[HYBRID_MODE] || {}).state) : 'Hybrid'; var bPid = registerPayload({ title: '🔥 ' + t('hybrid_mode') + ' · ' + (LANG==='nl'?'vandaag':FR('today')), items: [ { k:t('hybrid_mode'), v:boilerMode, hl:true, c:'#E65100' }, { k:t('boiler_contrib'), v:v1(boilerPct)+'%' }, { k:t('boiler_cop'), v:v1(boilerCop) } ] }); var bCol = boilerPct > 0 ? '#E65100' : 'var(--disabled-text-color, #94a3b8)'; today += tile('🔥', 'Boiler', v1(boilerPct)+'%', 'COP ' + v1(boilerCop), bCol, bPid); } today += '
'; var cW = 460, cH = 190; var cPadL = 70, cPadR = 14, cPadT = 24, cPadB = 40; var plotW = cW - cPadL - cPadR; var slot = plotW / Math.max(1, numDays); var xAt = function(i){ return cPadL + i*slot + slot/2; }; var rowH = 42; var badgeW = Math.min(slot*0.55, 38); var badgeH = 26; var hasB = sub.some(function(d){ return d.buh>0; }); var hasD = sub.some(function(d){ return d.defrost>0; }); var countsSvg = ''; if (!hasB && !hasD){ countsSvg = '
'+t('no_data')+'
'; } else { var maxTot = Math.max.apply(null, sub.map(function(d){ return (d.buh||0) + (d.defrost||0); })) || 1; countsSvg = ''; /* BUH row */ if (hasB){ countsSvg += ''; countsSvg += '⚡ '+t('leg_buh')+''; } /* Defrost row */ if (hasD){ var yD = cPadT + rowH; countsSvg += ''; countsSvg += '❄ '+t('leg_defr')+''; } /* Total row */ var yT = cPadT + rowH*2; countsSvg += ''; countsSvg += '∑ '+t('r_total')+''; /* Badges per day */ for (var ci=0; ci 0){ countsSvg += ''; countsSvg += ''; countsSvg += ''+d.buh+''; countsSvg += ''; } else if (hasB){ countsSvg += '·'; } if (hasD && d.defrost > 0){ var yD2 = cPadT + rowH; countsSvg += ''; countsSvg += ''; countsSvg += ''+d.defrost+''; countsSvg += ''; } else if (hasD){ var yD3 = cPadT + rowH; countsSvg += '·'; } if (total > 0){ var yT2 = cPadT + rowH*2; var wRatio = Math.max(0.35, total / maxTot); var wFill = badgeW * wRatio; countsSvg += ''; countsSvg += ''; countsSvg += ''; countsSvg += ''+total+''; countsSvg += ''; } else { var yT4 = cPadT + rowH*2; countsSvg += '·'; } if (ci % labelEvery === 0 || ci === numDays-1){ countsSvg += ''+wd(d.day)+''; } } countsSvg += ''; } /* ratio chart (unchanged) */ var rW = 460, rH = 240; var rPadL = 46, rPadR = 14, rPadT = 30, rPadB = 60; var rPlotW = rW - rPadL - rPadR; var rPlotH = rH - rPadT - rPadB; var rSlot = rPlotW / Math.max(1, numDays); var rBarW = Math.max(6, Math.min(42, rSlot * 0.72)); var rX = function(i){ return rPadL + i*rSlot + (rSlot - rBarW)/2; }; var rY = function(v){ return rPadT + rPlotH - (Math.max(0, Math.min(100, v))/100) * rPlotH; }; var rateSvg = ''; for (var gi=0; gi<=4; gi++){ var gv = 25*gi, gy = rY(gv); rateSvg += ''; rateSvg += ''+gv+'%'; } var tRef = rY(15); rateSvg += ''; var tRef2 = rY(35); rateSvg += ''; for (var ri=0; ri'; rateSvg += ''; if (hDef > 0) rateSvg += ''; if (hBuh > 0) rateSvg += ''; rateSvg += ''; if (numDays <= 21 && (buhPct + defPct) > 0){ rateSvg += ''+vI(buhPct+defPct)+'%'; } if (ri % labelEvery === 0 || ri === numDays-1){ rateSvg += ''+wd(dd.day)+''; if (numDays <= 21) rateSvg += ''+fmtDay(dd.day)+''; } } rateSvg += ''; rateSvg += ''; rateSvg += ''; var totB = sub.reduce(function(a,d){ return a+d.buh; }, 0); var totD = sub.reduce(function(a,d){ return a+d.defrost; }, 0); var totC = sub.reduce(function(a,d){ return a+d.cycles; }, 0); var avgRatio = totC > 0 ? ((totB + totD) / totC * 100) : 0; var lastDefStr = '—'; if (defLast > 0){ var nowS = Date.now()/1000; var diffS = nowS - defLast; if (diffS < 3600) lastDefStr = Math.round(diffS/60)+'m'; else if (diffS < 86400) lastDefStr = Math.round(diffS/3600)+'h'; else lastDefStr = Math.round(diffS/86400)+(LANG==='fr'?' j':'d'); } var stats = statStrip([ {l:t('r_totalbuh'), v:String(totB), c:C.buh}, {l:t('r_totaldef'), v:String(totD), c:C.defrost}, {l:t('r_avgratio'), v:vI(avgRatio)+'%', c:(avgRatio<=15?QGOOD:(avgRatio<=35?QMID:QLOW))}, {l:t('r_lastdef'), v:lastDefStr, c:'var(--secondary-text-color, #546E7A)'} ]); return { today: today, counts: countsSvg, ratio: rateSvg, stats: stats, hasB: hasB, hasD: hasD }; }; var chip = function(col, bg, label){ return '' + ''+label+''; }; var chipRow = function(arr, extra){ var s = '
'; for (var i=0; i'; s += '
'; return s; }; var buildView = function(winSize){ var sub = daysAll.slice(-winSize); if (sub.length === 0) return '
⏳ '+t('no_data')+'
'; var h = '
'; h += '
'; h += buildOverview(sub, 'w'+winSize); if (cfgShowHints) h += '
'+t('n_overview')+'
'; h += '
'; var q = buildQuality(sub); h += '
'; h += '
'; h += '
⭐ '+t('qual_chart')+''+sub.length+(LANG==='fr'?' j':'d')+'
'; h += q.chart; h += q.stats; h += chipRow([ {col:QGOOD, bg:'rgba(46,125,50,0.1)', label:t('q_good')}, {col:QMID, bg:'rgba(230,81,0,0.1)', label:t('q_mid')}, {col:QLOW, bg:'rgba(198,40,40,0.1)', label:t('q_low')} ], ''); if (cfgShowHints) h += '
'+t('n_quality')+'
'; h += '
'; var c = buildCycles(sub); h += '
'; h += '
'; h += '
🔄 '+t('cycles_chart')+''+sub.length+(LANG==='fr'?' j':'d')+'
'; h += c.chart; h += c.stats; h += chipRow([ {col:C.heating, bg:CBG.heating, label:t('leg_heat')}, {col:C.dhw, bg:CBG.dhw, label:t('leg_dhw')}, {col:C.cooling, bg:CBG.cooling, label:t('leg_cool')} ], ''); if (cfgShowHints) h += '
'+t('n_cycles')+'
'; h += '
'; var du = buildDuration(sub); h += '
'; h += '
'; h += '
⏱️ '+t('dur_chart')+''+sub.length+(LANG==='fr'?' j':'d')+'
'; h += du.chart; h += du.stats; h += chipRow([ {col:C.heating, bg:CBG.heating, label:t('leg_heat')}, {col:C.dhw, bg:CBG.dhw, label:t('leg_dhw')}, {col:C.cooling, bg:CBG.cooling, label:t('leg_cool')} ], ''); if (cfgShowHints) h += '
'+t('n_duration')+'
'; h += '
'; var ev = buildEvents(sub); h += '
'; h += ev.today; h += '
'; h += '
📊 '+t('ev_chart')+''+sub.length+(LANG==='fr'?' j':'d')+'
'; h += ev.counts; var evChips = []; if (ev.hasB) evChips.push({col:C.buh, bg:CBG.buh, label:'⚡ '+t('leg_buh')}); if (ev.hasD) evChips.push({col:C.defrost, bg:CBG.defrost, label:'❄ '+t('leg_defr')}); evChips.push({col:C.total, bg:CBG.total, label:'∑ '+t('r_total')}); h += chipRow(evChips, ''); h += '
'; h += '
'; h += '
📈 '+t('ev_ratio')+'% '+(LANG==='nl'?'van cycli':FR('of cycles'))+'
'; h += ev.ratio; h += ev.stats; h += chipRow([ {col:C.defrost, bg:CBG.defrost, label:'❄ '+t('leg_defr')}, {col:C.buh, bg:CBG.buh, label:'⚡ '+t('leg_buh')}, {col:QGOOD, bg:'rgba(46,125,50,0.1)', label:'-- 15%'}, {col:QLOW, bg:'rgba(198,40,40,0.1)', label:'-- 35%'} ], ''); if (cfgShowHints) h += '
'+t('n_events')+'
'; h += '
'; h += '
'; return h; }; var tabs = [ {id:'overview', label:t('tab_overview')}, {id:'quality', label:t('tab_quality')}, {id:'cycles', label:t('tab_cycles')}, {id:'duration', label:t('tab_duration')}, {id:'events', label:t('tab_events')} ]; var tabBar = '
'; for (var ti=0; ti'+td.label+'
'; } tabBar += ''; var winGroup = '
'; [7,15,30].forEach(function(w){ var act = (String(w) === activeWin) ? ' pa-active' : ''; winGroup += '
'+w+(LANG==='fr'?' j':'d')+'
'; }); winGroup += '
'; var actions = '
'+winGroup+'
'; var css = ''; var r = '
'; r += css; r += tabBar; r += actions; r += buildView(7); r += buildView(15); r += buildView(30); r += '
'; r += '
'; r += '
'; return r; } catch(e) { return '
⚠️ Summary error: ' + (e && e.message ? e.message : e) + '
'; } }).call(this)); ]]]