@mxtommy/kip 4.8.2 → 4.8.4
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/CHANGELOG.md +5 -0
- package/package.json +27 -4
- package/public/{chunk-BIYHVfJl.js → chunk-07zHjmg-.js} +1 -1
- package/public/{chunk-NnB8OYZt.js → chunk-0z3nIRXw.js} +1 -1
- package/public/{chunk-CCiqU2uY.js → chunk-B09jfNia.js} +1 -1
- package/public/{chunk-Bq-eHuZV.js → chunk-B0D54iJs.js} +1 -1
- package/public/{chunk-DfGLo6Tb.js → chunk-B0eE4udE.js} +1 -1
- package/public/{chunk-CkfPr-c5.js → chunk-B9nVBlGj.js} +1 -1
- package/public/{chunk-B8zRhoG8.js → chunk-BFpzxIIT.js} +1 -1
- package/public/{chunk-D_wrJJxl.js → chunk-BIb-xYiS.js} +1 -1
- package/public/{chunk-CSpA60X7.js → chunk-BJ-wyixK.js} +1 -1
- package/public/{chunk-Bb1mO304.js → chunk-BLEZOsfR.js} +1 -1
- package/public/{chunk-7lulvsGI.js → chunk-BN7A4g6c.js} +1 -1
- package/public/{chunk-h2q_pbbF.js → chunk-BTOTKeBo.js} +1 -1
- package/public/{chunk-DjavLLpP.js → chunk-BUguZ7cK.js} +1 -1
- package/public/{chunk-B8gfh4xf.js → chunk-BZx964-p.js} +1 -1
- package/public/{chunk-CcvYOops.js → chunk-BeM64etA.js} +1 -1
- package/public/{chunk-DSvdWjO4.js → chunk-BfiyH3nV.js} +1 -1
- package/public/{chunk-B_PiPxb4.js → chunk-BjINKQ03.js} +1 -1
- package/public/{chunk-BdBWqZzL.js → chunk-BpcNrtxJ.js} +1 -1
- package/public/{chunk-C4FGoLDg.js → chunk-BuvyF0y5.js} +1 -1
- package/public/{chunk-DGOvRnAo.js → chunk-C6b8CVno.js} +1 -1
- package/public/{chunk-BgyxBAyq.js → chunk-CCfhzpE8.js} +1 -1
- package/public/{chunk-CoEM_FqS.js → chunk-CHAFm_nM.js} +1 -1
- package/public/{chunk-D0MyVrEL.js → chunk-CIGP2YJm.js} +1 -1
- package/public/{chunk-Bhah8DNM.js → chunk-CLTHuhlN.js} +1 -1
- package/public/{chunk-B6XxnPxk.js → chunk-CLs_NL1y.js} +1 -1
- package/public/{chunk-Cr34s2uQ.js → chunk-COI6IBXH.js} +1 -1
- package/public/{chunk-BxV0O2fU.js → chunk-CQMVIDcp.js} +1 -1
- package/public/{chunk-CHKQxw6E.js → chunk-CXvWM_vF.js} +1 -1
- package/public/{chunk-Di5pPpU7.js → chunk-CYYBxjrc.js} +1 -1
- package/public/{chunk-BW4m3O2L.js → chunk-C_OZJltF.js} +1 -1
- package/public/{chunk-CjsnWLUr.js → chunk-Co2wVrD6.js} +1 -1
- package/public/{chunk-DMhuBqKs.js → chunk-CoCQ3DW2.js} +1 -1
- package/public/{chunk-DMoEBcor.js → chunk-CxPx4NZv.js} +1 -1
- package/public/{chunk-CdSWuWKr.js → chunk-CyVRpGoJ.js} +1 -1
- package/public/{chunk-Dv77RFHm.js → chunk-D-_-GUVr.js} +1 -1
- package/public/{chunk-CU8RPnsi.js → chunk-D1HYfaL_.js} +1 -1
- package/public/{chunk-DBA0eRqb.js → chunk-D2953Rfp.js} +1 -1
- package/public/{chunk-Cu9FE8cB.js → chunk-DIl1k00y.js} +1 -1
- package/public/{chunk-CyURmwWh.js → chunk-DPnbM-aB.js} +1 -1
- package/public/{chunk-8hkXyEzG.js → chunk-DTN-sa1K.js} +1 -1
- package/public/{chunk-C3CwUYvD.js → chunk-DUEKoZhd.js} +1 -1
- package/public/{chunk-COMZv7NY.js → chunk-DmkAKXR1.js} +1 -1
- package/public/{chunk-zg7II0hz.js → chunk-Do8wqING.js} +1 -1
- package/public/{chunk-oPq9Nexl.js → chunk-JhFkJS7i.js} +1 -1
- package/public/{chunk-CJIxuzvd.js → chunk-OeQDZKFO.js} +1 -1
- package/public/{chunk-Bz9bswDl.js → chunk-_zRMMvCu.js} +1 -1
- package/public/{chunk-D-xDPCf7.js → chunk-eQ1pa34Q.js} +1 -1
- package/public/{chunk-DVB9tiW3.js → chunk-ibauGmSP.js} +1 -1
- package/public/{chunk-oZiyAw_P.js → chunk-otzyItXL.js} +1 -1
- package/public/{chunk-B6AwCAvV.js → chunk-q9NoPvcx.js} +1 -1
- package/public/{chunk-B15lj2T8.js → chunk-szQs8fiq.js} +1 -1
- package/public/{chunk-o977r5_s.js → chunk-x7L6DXVK.js} +1 -1
- package/public/index.html +1 -1
- package/public/{main-BNR44HGB.js → main-YKDNK5VZ.js} +4 -4
- package/plugin/history-series.service.js +0 -637
- package/plugin/index.js +0 -1322
- package/plugin/kip-series-contract.js +0 -31
- package/plugin/openApi.json +0 -855
- package/plugin/sqlite-history-storage.service.js +0 -1124
- package/plugin/src/history-series.service.js +0 -634
- package/plugin/src/index.js +0 -1322
- package/plugin/src/kip-series-contract.js +0 -31
- package/plugin/src/openApi.json +0 -855
- package/plugin/src/sqlite-history-storage.service.js +0 -1122
|
@@ -1 +1 @@
|
|
|
1
|
-
import {e as e$1}from'./chunk-CyURmwWh.js';import {g as ge$1}from'./chunk-TakPRI3t.js';import {e9 as a,d1 as Hj,w,du as p,aS as De,bu as ut,aY as xe,D as Dt,$ as $j,v as vt,dx as n$1,F as Fa,dn as ge,a_ as Gp,cv as G,cw as z,J as JD,dC as x,c as $h,cn as wd,_ as _w,B as Bh,e as EE,M as Mw,f as eg,K as Kw,P as Pi,T as TT,u as ul}from'./main-BNR44HGB.js';import {c,e}from'./chunk-D_wrJJxl.js';var pe=["solarSvg"];function he(l,e){l&1&&(Pi(0,"div",3)(1,"div",4),TT(2,"No solar chargers detected"),ul(),Pi(3,"div",5),TT(4,"Check Signal K solar paths or select chargers in widget settings."),ul()());}var te=class l{static SOLAR_DESCRIPTOR=a("widget-solar-charger");static SELF_ROOT_PATH=(()=>{let e=l.SOLAR_DESCRIPTOR?.selfRootPath;if(!e)throw new Error("[WidgetSolarChargerComponent] Descriptor missing or selfRootPath not set; check widget registration.");return e})();static ROOT_PATTERN=`${l.SELF_ROOT_PATH}.*`;id=Hj.required();type=Hj.required();theme=Hj.required();renderMode=Hj(null);static DEFAULT_CONFIG={color:"contrast",ignoreZones:false,solarCharger:{trackedDevices:[],optionsById:{}}};static VIEWBOX_WIDTH=200;static CARD_HEIGHT=100;static CARD_GAP=8;static SOLAR_PANEL_SYMBOL_WIDTH=158.90796;static SOLAR_PANEL_SYMBOL_HEIGHT=94.949027;static SOLAR_PANEL_SCALE=.77;static SOLAR_PANEL_TRANSLATE_X=-36;static SOLAR_PANEL_TRANSLATE_Y=0;static SOLAR_PANEL_X=(135+l.SOLAR_PANEL_TRANSLATE_X)*l.SOLAR_PANEL_SCALE;static SOLAR_PANEL_Y=(0+l.SOLAR_PANEL_TRANSLATE_Y)*l.SOLAR_PANEL_SCALE;static SOLAR_PANEL_WIDTH=l.SOLAR_PANEL_SYMBOL_WIDTH*l.SOLAR_PANEL_SCALE;static SOLAR_PANEL_HEIGHT=l.SOLAR_PANEL_SYMBOL_HEIGHT*l.SOLAR_PANEL_SCALE;static PATH_BATCH_WINDOW_MS=500;runtime=w(p);data=w(De);units=w(ut);destroyRef=w(xe);displayLabel=Dt(()=>{let e=this.visibleSolarUnits();return e.length!==1?"Solar Chargers":this.resolveTitleText(e[0])});labelColor=Dt(()=>{let e=this.theme();return e?c(this.colorRole(),e).dim:"var(--kip-contrast-dim-color)"});svgRef=$j.required("solarSvg");svg;layer;glowFilterId="";renderFrameId=null;pendingRenderSnapshot=null;pathBatchTimerId=null;initialPathPaintDone=false;pendingPathUpdates=new Map;discoveredSolarIds=vt([]);trackedDevices=vt([]);optionsById=vt({});cardMode=vt({displayMode:"full",metrics:["panelVoltage","panelCurrent","voltage","current"]});chargersByKey=vt({});visibleSolarKeys=Dt(()=>{let e=this.trackedDevices();if(e.length)return e.map(a=>a.key);let r=this.chargersByKey(),t=new Set(this.discoveredSolarIds());return Object.keys(r).filter(a=>{let s=r[a];return !!s&&t.has(s.id)}).sort((a,s)=>a.localeCompare(s))});visibleSolarUnits=Dt(()=>{let e=this.visibleSolarKeys(),r=this.chargersByKey();return e.map(t=>r[t]).filter(t=>!!t)});activeDisplayMode=Dt(()=>this.renderMode()??this.cardMode().displayMode??"full");isCompactCardMode=Dt(()=>this.activeDisplayMode()==="compact");colorRole=Dt(()=>this.runtime.options()?.color??"contrast");ignoreZones=Dt(()=>this.runtime.options()?.ignoreZones??false);widgetColors=Dt(()=>{let e=this.theme();return e?c(this.colorRole(),e):null});displayModels=Dt(()=>{let e$1=this.visibleSolarUnits(),r=this.optionsById(),t=this.theme(),a=this.widgetColors(),s=this.ignoreZones()??false,i={};for(let n of e$1){let u=r[n.id]?.arrayRatedPowerW??null,c=n.panelPower??null,g=this.formatPowerAuto(c),m=u&&u>0&&c!=null?Math.max(0,Math.min(1,c/u)):0,d=n.panelPowerState??n.panelCurrentState??null,o=n.currentState??null,p=e(d,a?.dim??"var(--kip-contrast-dim-color)",t,s),T=!s&&(d===n$1.Warn||d===n$1.Alarm||d===n$1.Alert),y=e(o,"var(--kip-contrast-color)",t,s),w=this.resolveMostSevereState(n.voltageState??null,n.temperatureState??null),v=e(w,"var(--kip-contrast-color)",t,s),S=this.resolveMostSevereState(n.panelCurrentState??null,n.panelVoltageState??null,n.panelTemperatureState??null),re=e(S,"var(--kip-contrast-color)",t,s),ae=!s&&(S===n$1.Warn||S===n$1.Alarm||S===n$1.Alert),ne=e(n.loadCurrentState??null,"var(--kip-contrast-color)",t,s),I=this.valueOrDash(n.controllerMode),V=this.isRelayActive(n.load),oe=V?`${this.formatRelayState(n.load)}\xA0\xA0\xA0\xA04.5A${this.formatCurrent(n.loadCurrent)}`.trim():"",se=n.yieldToday!=null?`${this.formatEnergyYield(n.yieldToday)} Today`:"",ie=n.yieldYesterday!=null?`${this.formatEnergyYield(n.yieldYesterday)} Yesterday`:"",le=n.deviceKey??n.id;i[le]={id:n.id,source:n.source??null,deviceKey:n.deviceKey,titleText:this.resolveTitleText(n),panelPowerText:g.value,panelPowerUnitText:g.unit,panelPowerColor:p,panelPowerGlowEnabled:T,chargerCurrentTextColor:y,chargerMetaTextColor:v,panelValuesTextColor:re,panelValuesGlowEnabled:ae,gaugeProgress:m,gaugeSectionText:`${this.formatVoltage(n.panelVoltage)}`+(n.panelCurrent!=null?`, ${this.formatCurrent(n.panelCurrent)}`:"")+(n.panelTemperature!=null?`, ${this.formatTemperature(n.panelTemperature)}`:""),yieldTodayText:se,yieldYesterdayText:ie,chargerSectionCurrent:`${this.formatCurrent(n.current)}`,chargerMode:`${I.charAt(0).toUpperCase()+I.slice(1)} mode`,chargerSectionMetadata:`${n.voltage!=null?this.formatVoltage(n.voltage):""}\xA0\xA0\xA0\xA0${n.temperature!=null?this.formatTemperature(n.temperature):""}`.trim(),relaySectionVisible:V,relaySectionText:oe,relayValuesTextColor:ne};}return i});hasChargers=Dt(()=>this.visibleSolarUnits().length>0);constructor(){Fa(()=>{let r=this.runtime.options();r&&ge(()=>{this.applyConfig(r);});}),Fa(()=>{let r=this.displayModels(),t=this.visibleSolarUnits(),a=this.widgetColors();!this.svg||!a||this.requestRender({solarUnits:t,displayModels:r,widgetColors:a});});let e=this.data.subscribePathTreeWithInitial(l.ROOT_PATTERN);if(e.initial.length){for(let r of e.initial)this.enqueuePathUpdate(r,true);this.flushPendingPathUpdates(),this.initialPathPaintDone=true;}e.live$.pipe(Gp(this.destroyRef)).subscribe(r=>{this.enqueuePathUpdate(r);});}ngAfterViewInit(){this.initializeSvg(),this.requestRender();}ngOnDestroy(){this.pathBatchTimerId!==null&&(clearTimeout(this.pathBatchTimerId),this.pathBatchTimerId=null),this.renderFrameId!==null&&(cancelAnimationFrame(this.renderFrameId),this.renderFrameId=null),this.pendingRenderSnapshot=null;}initializeSvg(){this.svg=ge$1(this.svgRef().nativeElement),this.svg.attr("viewBox",`0 0 ${l.VIEWBOX_WIDTH} ${l.CARD_HEIGHT}`).attr("preserveAspectRatio","xMidYMid meet").attr("role","img").attr("aria-label","Solar Charger View"),this.glowFilterId=`solar-panel-glow-${this.id()}`;let r=this.svg.append("defs").append("filter").attr("id",this.glowFilterId).attr("x","-30%").attr("y","-30%").attr("width","160%").attr("height","160%");r.append("feFlood").attr("class","solar-panel-glow-flood").attr("flood-color","var(--kip-widget-card-background-color)").attr("flood-opacity",.9).attr("result","color"),r.append("feComposite").attr("in","color").attr("in2","SourceGraphic").attr("operator","in").attr("result","coloredGlow"),r.append("feGaussianBlur").attr("in","coloredGlow").attr("stdDeviation",2).attr("result","blur");let t=r.append("feMerge");t.append("feMergeNode").attr("in","blur"),t.append("feMergeNode").attr("in","blur"),t.append("feMergeNode").attr("in","SourceGraphic"),this.layer=this.svg.append("g").attr("class","solar-layer");}applyConfig(e){let r=this.resolveSolarConfig(e);this.trackedDevices.set(r.trackedDevices??[]),this.reprojectSnapshotsToDeviceKeys(r.trackedDevices??[]),this.optionsById.set(r.optionsById??{}),this.cardMode.set(this.normalizeCardMode(r.cardMode));}resolveSolarConfig(e){let r=e.solarCharger,t=this.normalizeTrackedDevices(r?.trackedDevices),a=this.normalizeOptionsById(r?.optionsById);return {trackedDevices:t,optionsById:a,cardMode:this.normalizeCardMode(r?.cardMode)}}normalizeTrackedDevices(e){if(!Array.isArray(e))return [];let r=new Map;return e.forEach(t=>{if(typeof t=="string"){let u=t.trim();if(!u)return;let c=`${u}||default`;r.set(c,{id:u,source:"default",key:c});return}if(!t||typeof t!="object")return;let a=t,s=typeof a.id=="string"?a.id.trim():"",i=typeof a.source=="string"?a.source.trim():"default";if(!s||!i)return;let n=typeof a.key=="string"&&a.key.trim().length>0?a.key.trim():`${s}||${i}`;r.set(n,{id:s,source:i,key:n});}),[...r.values()].sort((t,a)=>t.key.localeCompare(a.key))}reprojectSnapshotsToDeviceKeys(e){if(!e.length)return;let r=new Map;e.forEach(t=>{let a=r.get(t.id)??[];a.push(t.key),r.set(t.id,a);}),this.chargersByKey.update(t=>{let a=t,s=false;return r.forEach((i,n)=>{let u=t[n];if(u){for(let c of i){if(t[c])continue;let g=e.find(m=>m.key===c);s||(a=G({},t),s=true),a[c]=z(G({},u),{source:g?.source??null,deviceKey:c});}s&&a[n]?.deviceKey===void 0&&delete a[n];}}),s?a:t});}normalizeCardMode(e){let r=e&&typeof e=="object"?e:null,t=this.normalizeStringList(r?.metrics);return {displayMode:r?.displayMode==="compact"?"compact":"full",metrics:t.length?t:["panelVoltage","panelCurrent","voltage","current"]}}normalizeStringList(e){if(!Array.isArray(e))return [];let r=new Set;return e.forEach(t=>{if(typeof t!="string")return;let a=t.trim();a.length>0&&r.add(a);}),[...r].sort((t,a)=>t.localeCompare(a))}normalizeOptionsById(e){if(!e||typeof e!="object")return {};let r=Object.entries(e),t={};return r.forEach(([a,s])=>{let i=this.normalizeOptionalString(a);if(!i)return;let n=s?.arrayRatedPowerW;t[i]={arrayRatedPowerW:typeof n=="number"&&Number.isFinite(n)?n:null};}),t}normalizeOptionalString(e){if(typeof e!="string")return null;let r=e.trim();return r.length>0?r:null}enqueuePathUpdate(e,r=false){let t=this.parseSolarPath(e.path);if(!t)return;let{id:a,key:s}=t,i=e.update?.data?.value??null,n=e.update?.state??null,u=`${a}::${s}`;if(this.pendingPathUpdates.set(u,{id:a,key:s,value:i,state:n}),!r){if(!this.initialPathPaintDone){this.initialPathPaintDone=true,this.flushPendingPathUpdates();return}this.pathBatchTimerId===null&&(this.pathBatchTimerId=window.setTimeout(()=>{this.pathBatchTimerId=null,this.flushPendingPathUpdates();},l.PATH_BATCH_WINDOW_MS));}}flushPendingPathUpdates(){if(!this.pendingPathUpdates.size)return;let e=Array.from(this.pendingPathUpdates.values());this.pendingPathUpdates.clear(),new Set(e.map(t=>t.id)).forEach(t=>this.trackDiscoveredSolar(t)),this.chargersByKey.update(t=>{let a=t,s=false,i=this.trackedDevices(),n=i.length>0,u=new Map;n&&i.forEach(c=>{let g=u.get(c.id)??[];g.push(c.key),u.set(c.id,g);});for(let c of e){let g=n?u.get(c.id)??[]:[c.id];for(let m of g){let d=i.find(S=>S.key===m),o=a[m]??{id:c.id,source:d?.source??null,deviceKey:n?m:void 0},p=G({},o),T=this.applyChargerValue(p,c.key,c.value,c.state),y=false,w=this.resolvePowerValue(p.rawBatteryPower,p.voltage,p.current);Object.is(p.power,w)||(p.power=w,y=true);let v=this.resolvePowerValue(p.rawPanelPower,p.panelVoltage,p.panelCurrent);Object.is(p.panelPower,v)||(p.panelPower=v,y=true),!(!T&&!y)&&(s||(a=G({},a),s=true),a[m]=p);}}return s?a:t});}parseSolarPath(e){let r=e.match(/self\.electrical\.solar\.([^.]+)\.(.+)$/);if(!r)return null;let t=r[1],a=r[2],s=this.normalizeSolarMetricKey(a);return {id:t,key:s}}normalizeSolarMetricKey(e){if(e.startsWith("controller."))return e.slice(11);switch(e){case "solar.power":return "panelPower";case "solar.voltage":return "panelVoltage";case "solar.current":return "panelCurrent";case "solar.temperature":return "panelTemperature";case "charge.status":return "controllerMode";default:return e}}trackDiscoveredSolar(e){let r=this.discoveredSolarIds();r.includes(e)||this.discoveredSolarIds.set([...r,e].sort());}applyChargerValue(e,r,t,a){switch(r){case "name":return this.setValue(e,"name",this.toStringValue(t));case "location":return this.setValue(e,"location",this.toStringValue(t));case "associatedBus":return this.setValue(e,"associatedBus",this.toStringValue(t));case "voltage":{let s=this.toNumber(t,"V"),i=!Object.is(e.voltageState??null,a??null);return Object.is(e.voltage,s)&&!i?false:(e.voltage=s,e.voltageState=a,true)}case "current":{let s=this.toNumber(t,"A"),i=!Object.is(e.currentState??null,a??null);return Object.is(e.current,s)&&!i?false:(e.current=s,e.currentState=a,true)}case "power":return this.setPowerPathValue(e,"rawBatteryPower",t);case "temperature":{let s=this.toNumber(t,this.units.getDefaults().Temperature),i=!Object.is(e.temperatureState??null,a??null);return Object.is(e.temperature,s)&&!i?false:(e.temperature=s,e.temperatureState=a,true)}case "chargingAlgorithm":return this.setValue(e,"chargingAlgorithm",this.toStringValue(t));case "chargerRole":return this.setValue(e,"chargerRole",this.toStringValue(t));case "chargingMode":return this.setValue(e,"chargingMode",this.toStringValue(t));case "setpointVoltage":return this.setValue(e,"setpointVoltage",this.toNumber(t,"V"));case "setpointCurrent":return this.setValue(e,"setpointCurrent",this.toNumber(t,"A"));case "controllerMode":return this.setValue(e,"controllerMode",this.toStringValue(t));case "panelVoltage":{let s=this.toNumber(t,"V"),i=!Object.is(e.panelVoltageState??null,a??null);return Object.is(e.panelVoltage,s)&&!i?false:(e.panelVoltage=s,e.panelVoltageState=a,true)}case "panelCurrent":{let s=this.toNumber(t,"A"),i=!Object.is(e.panelCurrentState??null,a??null);return Object.is(e.panelCurrent,s)&&!i?false:(e.panelCurrent=s,e.panelCurrentState=a,true)}case "panelPower":{let s=this.toNumber(t,"W"),i=!Object.is(e.panelPowerState??null,a??null);return Object.is(e.rawPanelPower,s)&&!i?false:(e.rawPanelPower=s,e.panelPowerState=a,true)}case "yieldToday":return this.setValue(e,"yieldToday",this.toNumber(t,"kWh"));case "yieldYesterday":return this.setValue(e,"yieldYesterday",this.toNumber(t,"kWh"));case "panelTemperature":{let s=this.toNumber(t,this.units.getDefaults().Temperature),i=!Object.is(e.panelTemperatureState??null,a??null);return Object.is(e.panelTemperature,s)&&!i?false:(e.panelTemperature=s,e.panelTemperatureState=a,true)}case "load":case "loadState":case "load.state":return this.setValue(e,"load",t);case "loadCurrent":{let s=this.toNumber(t,"A"),i=!Object.is(e.loadCurrentState??null,a??null);return Object.is(e.loadCurrent,s)&&!i?false:(e.loadCurrent=s,e.loadCurrentState=a,true)}default:return false}}setPowerPathValue(e,r,t){let a=this.toNumber(t,"W");return this.setValue(e,r,a)}setValue(e,r,t){return Object.is(e[r],t)?false:(e[r]=t,true)}resolvePowerValue(e,r,t){if(e!=null)return e;if(r!=null&&t!=null)return r*t}requestRender(e){this.svg&&(this.pendingRenderSnapshot=e??this.buildRenderSnapshot(),this.pendingRenderSnapshot&&this.renderFrameId===null&&(this.renderFrameId=requestAnimationFrame(()=>{this.renderFrameId=null;let r=this.pendingRenderSnapshot;this.pendingRenderSnapshot=null,r&&this.render(r);})));}buildRenderSnapshot(){let e=this.widgetColors();return e?{solarUnits:this.visibleSolarUnits(),displayModels:this.displayModels(),widgetColors:e}:null}render(e){if(!this.layer||!this.svg)return;let t=this.isCompactCardMode()?e$1:e$1,a=e.solarUnits.map((o,p)=>({key:o.deviceKey??o.id,model:e.displayModels[o.deviceKey??o.id],y:p*(l.CARD_HEIGHT+l.CARD_GAP)})),s=a.length?a[a.length-1].y+l.CARD_HEIGHT:l.CARD_HEIGHT;this.svg.attr("viewBox",`0 0 ${l.VIEWBOX_WIDTH} ${s}`);let i=this.layer.selectAll("g.solar-card").data(a,o=>o.key),n=i.enter().append("g").attr("class","solar-card");n.append("text").attr("class","solar-charger-title");let u=n.append("text").attr("class","solar-charger-current");u.append("tspan").attr("class","current-metric-value"),u.append("tspan").attr("class","current-metric-unit"),n.append("text").attr("class","solar-charger"),n.append("text").attr("class","solar-charger-meta"),n.append("text").attr("class","solar-relay-label"),n.append("text").attr("class","solar-relay-values"),n.append("text").attr("class","solar-panel-values"),n.append("text").attr("class","solar-yield-label"),n.append("text").attr("class","solar-yield-today"),n.append("text").attr("class","solar-yield-yesterday");let c=n.append("g").attr("class","solar-panel-icon").attr("transform",`translate(${l.SOLAR_PANEL_X}, ${l.SOLAR_PANEL_Y})`);c.append("use").attr("class","solar-panel-bg").attr("href","assets/svg/symbols.svg#solar-panel-cells").attr("x",0).attr("y",0).attr("width",l.SOLAR_PANEL_WIDTH).attr("height",l.SOLAR_PANEL_HEIGHT);let g=c.append("g").attr("class","solar-panel-progress");g.append("defs").append("clipPath").attr("clipPathUnits","objectBoundingBox").attr("id",o=>`solar-panel-clip-${this.id()}-${o.key}`).append("rect").attr("x",0).attr("y",0).attr("height",1).attr("width",0),g.append("use").attr("class","solar-panel-colored").attr("href","assets/svg/symbols.svg#solar-panel-cells").attr("x",0).attr("y",0).attr("width",l.SOLAR_PANEL_WIDTH).attr("height",l.SOLAR_PANEL_HEIGHT).attr("clip-path",o=>`url(#solar-panel-clip-${this.id()}-${o.key})`);let m=n.append("text").attr("class","solar-panel-power");m.append("tspan").attr("class","solar-panel-power-value"),m.append("tspan").attr("class","solar-panel-power-unit");let d=n.merge(i);d.attr("transform",o=>`translate(0, ${o.y})`),e.solarUnits.length>1?d.select("text.solar-charger-title").attr("x",t.titleX).attr("y",t.titleY).attr("font-size",t.titleFontSize).attr("fill","var(--kip-contrast-dim-color)").text(o=>e.displayModels[o.key]?.titleText??this.displayName(o.model)):d.select("text.solar-charger-title").text(""),d.select("text.solar-charger-current").attr("x",t.lineOneX).attr("y",t.lineOneY).attr("font-size",t.lineOneFontSize).attr("fill",o=>o.model.chargerCurrentTextColor),d.select("tspan.current-metric-value").text(o=>o.model.chargerSectionCurrent),d.select("tspan.current-metric-unit").attr("dx",1).attr("font-size",12).attr("fill","var(--kip-contrast-color)").text("A"),d.select("text.solar-charger").attr("x",5).attr("y",40).attr("fill","var(--kip-contrast-color)").attr("font-size",8).attr("opacity",.8).text(o=>o.model.chargerMode),d.select("text.solar-charger-meta").attr("x",t.metaLeftX).attr("y",48).attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",o=>o.model.chargerMetaTextColor).text(o=>o.model.chargerSectionMetadata),d.select("text.solar-relay-label").attr("x",5).attr("y",73).attr("font-size",10).attr("fill","var(--kip-contrast-color)").text(o=>o.model.relaySectionVisible?"Load Output":""),d.select("text.solar-relay-values").attr("x",10).attr("y",83).attr("font-size",t.lineTwoFontSize).attr("fill",o=>o.model.relayValuesTextColor).attr("opacity",o=>o.model.relaySectionVisible?.8:0).text(o=>o.model.relaySectionText),d.select("g.solar-panel-icon").attr("transform",`translate(${l.SOLAR_PANEL_X}, ${l.SOLAR_PANEL_Y})`),d.select("use.solar-panel-bg").attr("color","var(--kip-contrast-dimmer-color)"),d.select("g.solar-panel-progress").each((o,p,T)=>{ge$1(T[p]).select("rect").attr("x",0).attr("y",0).attr("height",1).attr("width",Math.max(0,Math.min(1,o.model.gaugeProgress))),this.debugSolarLayout(o.key,o.model.gaugeProgress);}),d.select("use.solar-panel-colored").attr("color",o=>o.model.panelPowerColor),d.select("text.solar-panel-power").attr("x",137.5).attr("y",t.primaryY).attr("text-anchor","middle").attr("font-size",t.primaryFontSize).attr("font-weight",t.primaryFontWeight).attr("filter",o=>o.model.panelPowerGlowEnabled?`url(#${this.glowFilterId})`:null).attr("fill","var(--kip-contrast-color)"),d.select("tspan.solar-panel-power-value").text(o=>o.model.panelPowerText),d.select("tspan.solar-panel-power-unit").attr("dx",o=>o.model.panelPowerUnitText?1:0).attr("font-size",20).attr("font-weight",500).attr("fill","var(--kip-contrast-color)").attr("opacity",o=>o.model.panelPowerUnitText?1:0).text(o=>o.model.panelPowerUnitText),d.select("text.solar-panel-values").attr("x",137.5).attr("y",60).attr("text-anchor","middle").attr("font-size",10).attr("font-weight",500).attr("opacity",.8).attr("filter",o=>o.model.panelValuesGlowEnabled?`url(#${this.glowFilterId})`:null).attr("fill",o=>o.model.panelValuesTextColor).text(o=>o.model.gaugeSectionText).raise(),d.select("text.solar-yield-label").attr("x",104).attr("y",88).attr("text-anchor","middle").attr("font-size",8).attr("fill","var(--kip-contrast-dim-color)").attr("opacity",.8).text("Yield (kWh):"),d.select("text.solar-yield-today").attr("x",130).attr("y",88).attr("text-anchor","start").attr("font-size",8).attr("fill","var(--kip-contrast-dim-color)").attr("opacity",.8).text(o=>o.model.yieldTodayText),d.select("text.solar-yield-yesterday").attr("x",130).attr("y",97.5).attr("text-anchor","start").attr("font-size",8).attr("fill","var(--kip-contrast-dim-color)").attr("opacity",.8).text(o=>o.model.yieldYesterdayText),i.exit().remove();}displayName(e){return e.name?.trim()||e.id}resolveTitleText(e){return e.name||`Solar ${e.id}`}toNumber(e,r){return e==null||typeof e!="number"?null:this.units.convertToUnit(r,e)??e}isRelayActive(e){if(e==null)return false;if(typeof e=="boolean")return e;if(typeof e=="number")return e>0;let r=e.trim().toLowerCase();return !(!r||r==="off"||r==="false"||r==="0")}toStringValue(e){return typeof e=="string"?e:e==null?null:`${e}`}valueOrDash(e){return e===null?"--":e===void 0?"":e}formatVoltage(e){return e===null?"--":e===void 0?"":`${e.toFixed(1)}V`}formatCurrent(e){return e===null?"--":e===void 0?"":`${e.toFixed(1)}`}formatTemperature(e){return e===null?"--":e===void 0?"":`${e.toFixed(1)} ${this.units.getDefaults().Temperature==="celsius"?"\xB0C":"\xB0F"}`}formatRelayState(e){return e===null?"--":e===void 0?"":typeof e=="boolean"?e?"On":"Off":typeof e=="number"?e>0?"On":"Off":e}formatPowerAuto(e){return e===null?{value:"--",unit:""}:e===void 0?{value:"",unit:""}:Math.abs(e)>=1e3?{value:(e/1e3).toFixed(2),unit:"kW"}:{value:e.toFixed(0),unit:"W"}}formatEnergyYield(e){return e===null?"--":e===void 0?"":`${e.toFixed(2)}`}resolveMostSevereState(...e){let r=null,t={[n$1.Normal]:0,[n$1.Nominal]:1,[n$1.Alert]:2,[n$1.Warn]:3,[n$1.Alarm]:4,[n$1.Emergency]:5};for(let a of e)a&&(!r||t[a]>t[r])&&(r=a);return r}debugSolarLayout(e,r){typeof window<"u"&&window.__KIP_DEBUG_SOLAR_LAYOUT===true&&console.debug("[solar-layout]",{id:e,gaugeProgress:r,panelX:l.SOLAR_PANEL_X,panelY:l.SOLAR_PANEL_Y,panelWidth:l.SOLAR_PANEL_WIDTH,panelHeight:l.SOLAR_PANEL_HEIGHT,clippedWidth:l.SOLAR_PANEL_WIDTH*r});}static \u0275fac=function(r){return new(r||l)};static \u0275cmp=JD({type:l,selectors:[["widget-solar-charger"]],viewQuery:function(r,t){r&1&&eg(t.svgRef,pe,5),r&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],renderMode:[1,"renderMode"]},decls:4,vars:3,consts:[["solarSvg",""],[3,"text","color"],["aria-hidden","false",1,"solar-svg"],[1,"solar-empty"],[1,"solar-empty-title"],[1,"solar-empty-sub"]],template:function(r,t){r&1&&($h(0,"widget-title",1),wd(),$h(1,"svg",2,0),_w(3,he,5,0,"div",3)),r&2&&(Bh("text",t.displayLabel())("color",t.labelColor()),EE(3),Mw(t.hasChargers()?-1:3));},dependencies:[x],styles:["[_nghost-%COMP%]{display:block;height:100%;width:100%;position:relative;overflow:hidden}.solar-svg[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;top:15%;height:85%;width:100%;overflow:hidden;z-index:20;padding:0 10px 10px}.solar-empty[_ngcontent-%COMP%]{position:absolute;inset:0;margin:10px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;text-align:center;color:var(--mat-sys-on-surface);background:color-mix(in srgb,var(--kip-widget-card-background-color) 92%,transparent)}.solar-empty-title[_ngcontent-%COMP%]{font-size:18px;font-weight:600}.solar-empty-sub[_ngcontent-%COMP%]{font-size:14px;opacity:.8}"]})};export{te as WidgetSolarChargerComponent};
|
|
1
|
+
import {e as e$1}from'./chunk-DPnbM-aB.js';import {g as ge$1}from'./chunk-TakPRI3t.js';import {e9 as a,d1 as Hj,w,du as p,aS as De,bu as ut,aY as xe,D as Dt,$ as $j,v as vt,dx as n$1,F as Fa,dn as ge,a_ as Gp,cv as G,cw as z,J as JD,dC as x,c as $h,cn as wd,_ as _w,B as Bh,e as EE,M as Mw,f as eg,K as Kw,P as Pi,T as TT,u as ul}from'./main-YKDNK5VZ.js';import {c,e}from'./chunk-BIb-xYiS.js';var pe=["solarSvg"];function he(l,e){l&1&&(Pi(0,"div",3)(1,"div",4),TT(2,"No solar chargers detected"),ul(),Pi(3,"div",5),TT(4,"Check Signal K solar paths or select chargers in widget settings."),ul()());}var te=class l{static SOLAR_DESCRIPTOR=a("widget-solar-charger");static SELF_ROOT_PATH=(()=>{let e=l.SOLAR_DESCRIPTOR?.selfRootPath;if(!e)throw new Error("[WidgetSolarChargerComponent] Descriptor missing or selfRootPath not set; check widget registration.");return e})();static ROOT_PATTERN=`${l.SELF_ROOT_PATH}.*`;id=Hj.required();type=Hj.required();theme=Hj.required();renderMode=Hj(null);static DEFAULT_CONFIG={color:"contrast",ignoreZones:false,solarCharger:{trackedDevices:[],optionsById:{}}};static VIEWBOX_WIDTH=200;static CARD_HEIGHT=100;static CARD_GAP=8;static SOLAR_PANEL_SYMBOL_WIDTH=158.90796;static SOLAR_PANEL_SYMBOL_HEIGHT=94.949027;static SOLAR_PANEL_SCALE=.77;static SOLAR_PANEL_TRANSLATE_X=-36;static SOLAR_PANEL_TRANSLATE_Y=0;static SOLAR_PANEL_X=(135+l.SOLAR_PANEL_TRANSLATE_X)*l.SOLAR_PANEL_SCALE;static SOLAR_PANEL_Y=(0+l.SOLAR_PANEL_TRANSLATE_Y)*l.SOLAR_PANEL_SCALE;static SOLAR_PANEL_WIDTH=l.SOLAR_PANEL_SYMBOL_WIDTH*l.SOLAR_PANEL_SCALE;static SOLAR_PANEL_HEIGHT=l.SOLAR_PANEL_SYMBOL_HEIGHT*l.SOLAR_PANEL_SCALE;static PATH_BATCH_WINDOW_MS=500;runtime=w(p);data=w(De);units=w(ut);destroyRef=w(xe);displayLabel=Dt(()=>{let e=this.visibleSolarUnits();return e.length!==1?"Solar Chargers":this.resolveTitleText(e[0])});labelColor=Dt(()=>{let e=this.theme();return e?c(this.colorRole(),e).dim:"var(--kip-contrast-dim-color)"});svgRef=$j.required("solarSvg");svg;layer;glowFilterId="";renderFrameId=null;pendingRenderSnapshot=null;pathBatchTimerId=null;initialPathPaintDone=false;pendingPathUpdates=new Map;discoveredSolarIds=vt([]);trackedDevices=vt([]);optionsById=vt({});cardMode=vt({displayMode:"full",metrics:["panelVoltage","panelCurrent","voltage","current"]});chargersByKey=vt({});visibleSolarKeys=Dt(()=>{let e=this.trackedDevices();if(e.length)return e.map(a=>a.key);let r=this.chargersByKey(),t=new Set(this.discoveredSolarIds());return Object.keys(r).filter(a=>{let s=r[a];return !!s&&t.has(s.id)}).sort((a,s)=>a.localeCompare(s))});visibleSolarUnits=Dt(()=>{let e=this.visibleSolarKeys(),r=this.chargersByKey();return e.map(t=>r[t]).filter(t=>!!t)});activeDisplayMode=Dt(()=>this.renderMode()??this.cardMode().displayMode??"full");isCompactCardMode=Dt(()=>this.activeDisplayMode()==="compact");colorRole=Dt(()=>this.runtime.options()?.color??"contrast");ignoreZones=Dt(()=>this.runtime.options()?.ignoreZones??false);widgetColors=Dt(()=>{let e=this.theme();return e?c(this.colorRole(),e):null});displayModels=Dt(()=>{let e$1=this.visibleSolarUnits(),r=this.optionsById(),t=this.theme(),a=this.widgetColors(),s=this.ignoreZones()??false,i={};for(let n of e$1){let u=r[n.id]?.arrayRatedPowerW??null,c=n.panelPower??null,g=this.formatPowerAuto(c),m=u&&u>0&&c!=null?Math.max(0,Math.min(1,c/u)):0,d=n.panelPowerState??n.panelCurrentState??null,o=n.currentState??null,p=e(d,a?.dim??"var(--kip-contrast-dim-color)",t,s),T=!s&&(d===n$1.Warn||d===n$1.Alarm||d===n$1.Alert),y=e(o,"var(--kip-contrast-color)",t,s),w=this.resolveMostSevereState(n.voltageState??null,n.temperatureState??null),v=e(w,"var(--kip-contrast-color)",t,s),S=this.resolveMostSevereState(n.panelCurrentState??null,n.panelVoltageState??null,n.panelTemperatureState??null),re=e(S,"var(--kip-contrast-color)",t,s),ae=!s&&(S===n$1.Warn||S===n$1.Alarm||S===n$1.Alert),ne=e(n.loadCurrentState??null,"var(--kip-contrast-color)",t,s),I=this.valueOrDash(n.controllerMode),V=this.isRelayActive(n.load),oe=V?`${this.formatRelayState(n.load)}\xA0\xA0\xA0\xA04.5A${this.formatCurrent(n.loadCurrent)}`.trim():"",se=n.yieldToday!=null?`${this.formatEnergyYield(n.yieldToday)} Today`:"",ie=n.yieldYesterday!=null?`${this.formatEnergyYield(n.yieldYesterday)} Yesterday`:"",le=n.deviceKey??n.id;i[le]={id:n.id,source:n.source??null,deviceKey:n.deviceKey,titleText:this.resolveTitleText(n),panelPowerText:g.value,panelPowerUnitText:g.unit,panelPowerColor:p,panelPowerGlowEnabled:T,chargerCurrentTextColor:y,chargerMetaTextColor:v,panelValuesTextColor:re,panelValuesGlowEnabled:ae,gaugeProgress:m,gaugeSectionText:`${this.formatVoltage(n.panelVoltage)}`+(n.panelCurrent!=null?`, ${this.formatCurrent(n.panelCurrent)}`:"")+(n.panelTemperature!=null?`, ${this.formatTemperature(n.panelTemperature)}`:""),yieldTodayText:se,yieldYesterdayText:ie,chargerSectionCurrent:`${this.formatCurrent(n.current)}`,chargerMode:`${I.charAt(0).toUpperCase()+I.slice(1)} mode`,chargerSectionMetadata:`${n.voltage!=null?this.formatVoltage(n.voltage):""}\xA0\xA0\xA0\xA0${n.temperature!=null?this.formatTemperature(n.temperature):""}`.trim(),relaySectionVisible:V,relaySectionText:oe,relayValuesTextColor:ne};}return i});hasChargers=Dt(()=>this.visibleSolarUnits().length>0);constructor(){Fa(()=>{let r=this.runtime.options();r&&ge(()=>{this.applyConfig(r);});}),Fa(()=>{let r=this.displayModels(),t=this.visibleSolarUnits(),a=this.widgetColors();!this.svg||!a||this.requestRender({solarUnits:t,displayModels:r,widgetColors:a});});let e=this.data.subscribePathTreeWithInitial(l.ROOT_PATTERN);if(e.initial.length){for(let r of e.initial)this.enqueuePathUpdate(r,true);this.flushPendingPathUpdates(),this.initialPathPaintDone=true;}e.live$.pipe(Gp(this.destroyRef)).subscribe(r=>{this.enqueuePathUpdate(r);});}ngAfterViewInit(){this.initializeSvg(),this.requestRender();}ngOnDestroy(){this.pathBatchTimerId!==null&&(clearTimeout(this.pathBatchTimerId),this.pathBatchTimerId=null),this.renderFrameId!==null&&(cancelAnimationFrame(this.renderFrameId),this.renderFrameId=null),this.pendingRenderSnapshot=null;}initializeSvg(){this.svg=ge$1(this.svgRef().nativeElement),this.svg.attr("viewBox",`0 0 ${l.VIEWBOX_WIDTH} ${l.CARD_HEIGHT}`).attr("preserveAspectRatio","xMidYMid meet").attr("role","img").attr("aria-label","Solar Charger View"),this.glowFilterId=`solar-panel-glow-${this.id()}`;let r=this.svg.append("defs").append("filter").attr("id",this.glowFilterId).attr("x","-30%").attr("y","-30%").attr("width","160%").attr("height","160%");r.append("feFlood").attr("class","solar-panel-glow-flood").attr("flood-color","var(--kip-widget-card-background-color)").attr("flood-opacity",.9).attr("result","color"),r.append("feComposite").attr("in","color").attr("in2","SourceGraphic").attr("operator","in").attr("result","coloredGlow"),r.append("feGaussianBlur").attr("in","coloredGlow").attr("stdDeviation",2).attr("result","blur");let t=r.append("feMerge");t.append("feMergeNode").attr("in","blur"),t.append("feMergeNode").attr("in","blur"),t.append("feMergeNode").attr("in","SourceGraphic"),this.layer=this.svg.append("g").attr("class","solar-layer");}applyConfig(e){let r=this.resolveSolarConfig(e);this.trackedDevices.set(r.trackedDevices??[]),this.reprojectSnapshotsToDeviceKeys(r.trackedDevices??[]),this.optionsById.set(r.optionsById??{}),this.cardMode.set(this.normalizeCardMode(r.cardMode));}resolveSolarConfig(e){let r=e.solarCharger,t=this.normalizeTrackedDevices(r?.trackedDevices),a=this.normalizeOptionsById(r?.optionsById);return {trackedDevices:t,optionsById:a,cardMode:this.normalizeCardMode(r?.cardMode)}}normalizeTrackedDevices(e){if(!Array.isArray(e))return [];let r=new Map;return e.forEach(t=>{if(typeof t=="string"){let u=t.trim();if(!u)return;let c=`${u}||default`;r.set(c,{id:u,source:"default",key:c});return}if(!t||typeof t!="object")return;let a=t,s=typeof a.id=="string"?a.id.trim():"",i=typeof a.source=="string"?a.source.trim():"default";if(!s||!i)return;let n=typeof a.key=="string"&&a.key.trim().length>0?a.key.trim():`${s}||${i}`;r.set(n,{id:s,source:i,key:n});}),[...r.values()].sort((t,a)=>t.key.localeCompare(a.key))}reprojectSnapshotsToDeviceKeys(e){if(!e.length)return;let r=new Map;e.forEach(t=>{let a=r.get(t.id)??[];a.push(t.key),r.set(t.id,a);}),this.chargersByKey.update(t=>{let a=t,s=false;return r.forEach((i,n)=>{let u=t[n];if(u){for(let c of i){if(t[c])continue;let g=e.find(m=>m.key===c);s||(a=G({},t),s=true),a[c]=z(G({},u),{source:g?.source??null,deviceKey:c});}s&&a[n]?.deviceKey===void 0&&delete a[n];}}),s?a:t});}normalizeCardMode(e){let r=e&&typeof e=="object"?e:null,t=this.normalizeStringList(r?.metrics);return {displayMode:r?.displayMode==="compact"?"compact":"full",metrics:t.length?t:["panelVoltage","panelCurrent","voltage","current"]}}normalizeStringList(e){if(!Array.isArray(e))return [];let r=new Set;return e.forEach(t=>{if(typeof t!="string")return;let a=t.trim();a.length>0&&r.add(a);}),[...r].sort((t,a)=>t.localeCompare(a))}normalizeOptionsById(e){if(!e||typeof e!="object")return {};let r=Object.entries(e),t={};return r.forEach(([a,s])=>{let i=this.normalizeOptionalString(a);if(!i)return;let n=s?.arrayRatedPowerW;t[i]={arrayRatedPowerW:typeof n=="number"&&Number.isFinite(n)?n:null};}),t}normalizeOptionalString(e){if(typeof e!="string")return null;let r=e.trim();return r.length>0?r:null}enqueuePathUpdate(e,r=false){let t=this.parseSolarPath(e.path);if(!t)return;let{id:a,key:s}=t,i=e.update?.data?.value??null,n=e.update?.state??null,u=`${a}::${s}`;if(this.pendingPathUpdates.set(u,{id:a,key:s,value:i,state:n}),!r){if(!this.initialPathPaintDone){this.initialPathPaintDone=true,this.flushPendingPathUpdates();return}this.pathBatchTimerId===null&&(this.pathBatchTimerId=window.setTimeout(()=>{this.pathBatchTimerId=null,this.flushPendingPathUpdates();},l.PATH_BATCH_WINDOW_MS));}}flushPendingPathUpdates(){if(!this.pendingPathUpdates.size)return;let e=Array.from(this.pendingPathUpdates.values());this.pendingPathUpdates.clear(),new Set(e.map(t=>t.id)).forEach(t=>this.trackDiscoveredSolar(t)),this.chargersByKey.update(t=>{let a=t,s=false,i=this.trackedDevices(),n=i.length>0,u=new Map;n&&i.forEach(c=>{let g=u.get(c.id)??[];g.push(c.key),u.set(c.id,g);});for(let c of e){let g=n?u.get(c.id)??[]:[c.id];for(let m of g){let d=i.find(S=>S.key===m),o=a[m]??{id:c.id,source:d?.source??null,deviceKey:n?m:void 0},p=G({},o),T=this.applyChargerValue(p,c.key,c.value,c.state),y=false,w=this.resolvePowerValue(p.rawBatteryPower,p.voltage,p.current);Object.is(p.power,w)||(p.power=w,y=true);let v=this.resolvePowerValue(p.rawPanelPower,p.panelVoltage,p.panelCurrent);Object.is(p.panelPower,v)||(p.panelPower=v,y=true),!(!T&&!y)&&(s||(a=G({},a),s=true),a[m]=p);}}return s?a:t});}parseSolarPath(e){let r=e.match(/self\.electrical\.solar\.([^.]+)\.(.+)$/);if(!r)return null;let t=r[1],a=r[2],s=this.normalizeSolarMetricKey(a);return {id:t,key:s}}normalizeSolarMetricKey(e){if(e.startsWith("controller."))return e.slice(11);switch(e){case "solar.power":return "panelPower";case "solar.voltage":return "panelVoltage";case "solar.current":return "panelCurrent";case "solar.temperature":return "panelTemperature";case "charge.status":return "controllerMode";default:return e}}trackDiscoveredSolar(e){let r=this.discoveredSolarIds();r.includes(e)||this.discoveredSolarIds.set([...r,e].sort());}applyChargerValue(e,r,t,a){switch(r){case "name":return this.setValue(e,"name",this.toStringValue(t));case "location":return this.setValue(e,"location",this.toStringValue(t));case "associatedBus":return this.setValue(e,"associatedBus",this.toStringValue(t));case "voltage":{let s=this.toNumber(t,"V"),i=!Object.is(e.voltageState??null,a??null);return Object.is(e.voltage,s)&&!i?false:(e.voltage=s,e.voltageState=a,true)}case "current":{let s=this.toNumber(t,"A"),i=!Object.is(e.currentState??null,a??null);return Object.is(e.current,s)&&!i?false:(e.current=s,e.currentState=a,true)}case "power":return this.setPowerPathValue(e,"rawBatteryPower",t);case "temperature":{let s=this.toNumber(t,this.units.getDefaults().Temperature),i=!Object.is(e.temperatureState??null,a??null);return Object.is(e.temperature,s)&&!i?false:(e.temperature=s,e.temperatureState=a,true)}case "chargingAlgorithm":return this.setValue(e,"chargingAlgorithm",this.toStringValue(t));case "chargerRole":return this.setValue(e,"chargerRole",this.toStringValue(t));case "chargingMode":return this.setValue(e,"chargingMode",this.toStringValue(t));case "setpointVoltage":return this.setValue(e,"setpointVoltage",this.toNumber(t,"V"));case "setpointCurrent":return this.setValue(e,"setpointCurrent",this.toNumber(t,"A"));case "controllerMode":return this.setValue(e,"controllerMode",this.toStringValue(t));case "panelVoltage":{let s=this.toNumber(t,"V"),i=!Object.is(e.panelVoltageState??null,a??null);return Object.is(e.panelVoltage,s)&&!i?false:(e.panelVoltage=s,e.panelVoltageState=a,true)}case "panelCurrent":{let s=this.toNumber(t,"A"),i=!Object.is(e.panelCurrentState??null,a??null);return Object.is(e.panelCurrent,s)&&!i?false:(e.panelCurrent=s,e.panelCurrentState=a,true)}case "panelPower":{let s=this.toNumber(t,"W"),i=!Object.is(e.panelPowerState??null,a??null);return Object.is(e.rawPanelPower,s)&&!i?false:(e.rawPanelPower=s,e.panelPowerState=a,true)}case "yieldToday":return this.setValue(e,"yieldToday",this.toNumber(t,"kWh"));case "yieldYesterday":return this.setValue(e,"yieldYesterday",this.toNumber(t,"kWh"));case "panelTemperature":{let s=this.toNumber(t,this.units.getDefaults().Temperature),i=!Object.is(e.panelTemperatureState??null,a??null);return Object.is(e.panelTemperature,s)&&!i?false:(e.panelTemperature=s,e.panelTemperatureState=a,true)}case "load":case "loadState":case "load.state":return this.setValue(e,"load",t);case "loadCurrent":{let s=this.toNumber(t,"A"),i=!Object.is(e.loadCurrentState??null,a??null);return Object.is(e.loadCurrent,s)&&!i?false:(e.loadCurrent=s,e.loadCurrentState=a,true)}default:return false}}setPowerPathValue(e,r,t){let a=this.toNumber(t,"W");return this.setValue(e,r,a)}setValue(e,r,t){return Object.is(e[r],t)?false:(e[r]=t,true)}resolvePowerValue(e,r,t){if(e!=null)return e;if(r!=null&&t!=null)return r*t}requestRender(e){this.svg&&(this.pendingRenderSnapshot=e??this.buildRenderSnapshot(),this.pendingRenderSnapshot&&this.renderFrameId===null&&(this.renderFrameId=requestAnimationFrame(()=>{this.renderFrameId=null;let r=this.pendingRenderSnapshot;this.pendingRenderSnapshot=null,r&&this.render(r);})));}buildRenderSnapshot(){let e=this.widgetColors();return e?{solarUnits:this.visibleSolarUnits(),displayModels:this.displayModels(),widgetColors:e}:null}render(e){if(!this.layer||!this.svg)return;let t=this.isCompactCardMode()?e$1:e$1,a=e.solarUnits.map((o,p)=>({key:o.deviceKey??o.id,model:e.displayModels[o.deviceKey??o.id],y:p*(l.CARD_HEIGHT+l.CARD_GAP)})),s=a.length?a[a.length-1].y+l.CARD_HEIGHT:l.CARD_HEIGHT;this.svg.attr("viewBox",`0 0 ${l.VIEWBOX_WIDTH} ${s}`);let i=this.layer.selectAll("g.solar-card").data(a,o=>o.key),n=i.enter().append("g").attr("class","solar-card");n.append("text").attr("class","solar-charger-title");let u=n.append("text").attr("class","solar-charger-current");u.append("tspan").attr("class","current-metric-value"),u.append("tspan").attr("class","current-metric-unit"),n.append("text").attr("class","solar-charger"),n.append("text").attr("class","solar-charger-meta"),n.append("text").attr("class","solar-relay-label"),n.append("text").attr("class","solar-relay-values"),n.append("text").attr("class","solar-panel-values"),n.append("text").attr("class","solar-yield-label"),n.append("text").attr("class","solar-yield-today"),n.append("text").attr("class","solar-yield-yesterday");let c=n.append("g").attr("class","solar-panel-icon").attr("transform",`translate(${l.SOLAR_PANEL_X}, ${l.SOLAR_PANEL_Y})`);c.append("use").attr("class","solar-panel-bg").attr("href","assets/svg/symbols.svg#solar-panel-cells").attr("x",0).attr("y",0).attr("width",l.SOLAR_PANEL_WIDTH).attr("height",l.SOLAR_PANEL_HEIGHT);let g=c.append("g").attr("class","solar-panel-progress");g.append("defs").append("clipPath").attr("clipPathUnits","objectBoundingBox").attr("id",o=>`solar-panel-clip-${this.id()}-${o.key}`).append("rect").attr("x",0).attr("y",0).attr("height",1).attr("width",0),g.append("use").attr("class","solar-panel-colored").attr("href","assets/svg/symbols.svg#solar-panel-cells").attr("x",0).attr("y",0).attr("width",l.SOLAR_PANEL_WIDTH).attr("height",l.SOLAR_PANEL_HEIGHT).attr("clip-path",o=>`url(#solar-panel-clip-${this.id()}-${o.key})`);let m=n.append("text").attr("class","solar-panel-power");m.append("tspan").attr("class","solar-panel-power-value"),m.append("tspan").attr("class","solar-panel-power-unit");let d=n.merge(i);d.attr("transform",o=>`translate(0, ${o.y})`),e.solarUnits.length>1?d.select("text.solar-charger-title").attr("x",t.titleX).attr("y",t.titleY).attr("font-size",t.titleFontSize).attr("fill","var(--kip-contrast-dim-color)").text(o=>e.displayModels[o.key]?.titleText??this.displayName(o.model)):d.select("text.solar-charger-title").text(""),d.select("text.solar-charger-current").attr("x",t.lineOneX).attr("y",t.lineOneY).attr("font-size",t.lineOneFontSize).attr("fill",o=>o.model.chargerCurrentTextColor),d.select("tspan.current-metric-value").text(o=>o.model.chargerSectionCurrent),d.select("tspan.current-metric-unit").attr("dx",1).attr("font-size",12).attr("fill","var(--kip-contrast-color)").text("A"),d.select("text.solar-charger").attr("x",5).attr("y",40).attr("fill","var(--kip-contrast-color)").attr("font-size",8).attr("opacity",.8).text(o=>o.model.chargerMode),d.select("text.solar-charger-meta").attr("x",t.metaLeftX).attr("y",48).attr("font-size",t.metaFontSize).attr("opacity",.8).attr("fill",o=>o.model.chargerMetaTextColor).text(o=>o.model.chargerSectionMetadata),d.select("text.solar-relay-label").attr("x",5).attr("y",73).attr("font-size",10).attr("fill","var(--kip-contrast-color)").text(o=>o.model.relaySectionVisible?"Load Output":""),d.select("text.solar-relay-values").attr("x",10).attr("y",83).attr("font-size",t.lineTwoFontSize).attr("fill",o=>o.model.relayValuesTextColor).attr("opacity",o=>o.model.relaySectionVisible?.8:0).text(o=>o.model.relaySectionText),d.select("g.solar-panel-icon").attr("transform",`translate(${l.SOLAR_PANEL_X}, ${l.SOLAR_PANEL_Y})`),d.select("use.solar-panel-bg").attr("color","var(--kip-contrast-dimmer-color)"),d.select("g.solar-panel-progress").each((o,p,T)=>{ge$1(T[p]).select("rect").attr("x",0).attr("y",0).attr("height",1).attr("width",Math.max(0,Math.min(1,o.model.gaugeProgress))),this.debugSolarLayout(o.key,o.model.gaugeProgress);}),d.select("use.solar-panel-colored").attr("color",o=>o.model.panelPowerColor),d.select("text.solar-panel-power").attr("x",137.5).attr("y",t.primaryY).attr("text-anchor","middle").attr("font-size",t.primaryFontSize).attr("font-weight",t.primaryFontWeight).attr("filter",o=>o.model.panelPowerGlowEnabled?`url(#${this.glowFilterId})`:null).attr("fill","var(--kip-contrast-color)"),d.select("tspan.solar-panel-power-value").text(o=>o.model.panelPowerText),d.select("tspan.solar-panel-power-unit").attr("dx",o=>o.model.panelPowerUnitText?1:0).attr("font-size",20).attr("font-weight",500).attr("fill","var(--kip-contrast-color)").attr("opacity",o=>o.model.panelPowerUnitText?1:0).text(o=>o.model.panelPowerUnitText),d.select("text.solar-panel-values").attr("x",137.5).attr("y",60).attr("text-anchor","middle").attr("font-size",10).attr("font-weight",500).attr("opacity",.8).attr("filter",o=>o.model.panelValuesGlowEnabled?`url(#${this.glowFilterId})`:null).attr("fill",o=>o.model.panelValuesTextColor).text(o=>o.model.gaugeSectionText).raise(),d.select("text.solar-yield-label").attr("x",104).attr("y",88).attr("text-anchor","middle").attr("font-size",8).attr("fill","var(--kip-contrast-dim-color)").attr("opacity",.8).text("Yield (kWh):"),d.select("text.solar-yield-today").attr("x",130).attr("y",88).attr("text-anchor","start").attr("font-size",8).attr("fill","var(--kip-contrast-dim-color)").attr("opacity",.8).text(o=>o.model.yieldTodayText),d.select("text.solar-yield-yesterday").attr("x",130).attr("y",97.5).attr("text-anchor","start").attr("font-size",8).attr("fill","var(--kip-contrast-dim-color)").attr("opacity",.8).text(o=>o.model.yieldYesterdayText),i.exit().remove();}displayName(e){return e.name?.trim()||e.id}resolveTitleText(e){return e.name||`Solar ${e.id}`}toNumber(e,r){return e==null||typeof e!="number"?null:this.units.convertToUnit(r,e)??e}isRelayActive(e){if(e==null)return false;if(typeof e=="boolean")return e;if(typeof e=="number")return e>0;let r=e.trim().toLowerCase();return !(!r||r==="off"||r==="false"||r==="0")}toStringValue(e){return typeof e=="string"?e:e==null?null:`${e}`}valueOrDash(e){return e===null?"--":e===void 0?"":e}formatVoltage(e){return e===null?"--":e===void 0?"":`${e.toFixed(1)}V`}formatCurrent(e){return e===null?"--":e===void 0?"":`${e.toFixed(1)}`}formatTemperature(e){return e===null?"--":e===void 0?"":`${e.toFixed(1)} ${this.units.getDefaults().Temperature==="celsius"?"\xB0C":"\xB0F"}`}formatRelayState(e){return e===null?"--":e===void 0?"":typeof e=="boolean"?e?"On":"Off":typeof e=="number"?e>0?"On":"Off":e}formatPowerAuto(e){return e===null?{value:"--",unit:""}:e===void 0?{value:"",unit:""}:Math.abs(e)>=1e3?{value:(e/1e3).toFixed(2),unit:"kW"}:{value:e.toFixed(0),unit:"W"}}formatEnergyYield(e){return e===null?"--":e===void 0?"":`${e.toFixed(2)}`}resolveMostSevereState(...e){let r=null,t={[n$1.Normal]:0,[n$1.Nominal]:1,[n$1.Alert]:2,[n$1.Warn]:3,[n$1.Alarm]:4,[n$1.Emergency]:5};for(let a of e)a&&(!r||t[a]>t[r])&&(r=a);return r}debugSolarLayout(e,r){typeof window<"u"&&window.__KIP_DEBUG_SOLAR_LAYOUT===true&&console.debug("[solar-layout]",{id:e,gaugeProgress:r,panelX:l.SOLAR_PANEL_X,panelY:l.SOLAR_PANEL_Y,panelWidth:l.SOLAR_PANEL_WIDTH,panelHeight:l.SOLAR_PANEL_HEIGHT,clippedWidth:l.SOLAR_PANEL_WIDTH*r});}static \u0275fac=function(r){return new(r||l)};static \u0275cmp=JD({type:l,selectors:[["widget-solar-charger"]],viewQuery:function(r,t){r&1&&eg(t.svgRef,pe,5),r&2&&Kw();},inputs:{id:[1,"id"],type:[1,"type"],theme:[1,"theme"],renderMode:[1,"renderMode"]},decls:4,vars:3,consts:[["solarSvg",""],[3,"text","color"],["aria-hidden","false",1,"solar-svg"],[1,"solar-empty"],[1,"solar-empty-title"],[1,"solar-empty-sub"]],template:function(r,t){r&1&&($h(0,"widget-title",1),wd(),$h(1,"svg",2,0),_w(3,he,5,0,"div",3)),r&2&&(Bh("text",t.displayLabel())("color",t.labelColor()),EE(3),Mw(t.hasChargers()?-1:3));},dependencies:[x],styles:["[_nghost-%COMP%]{display:block;height:100%;width:100%;position:relative;overflow:hidden}.solar-svg[_ngcontent-%COMP%]{display:block;position:absolute;left:0;right:0;top:15%;height:85%;width:100%;overflow:hidden;z-index:20;padding:0 10px 10px}.solar-empty[_ngcontent-%COMP%]{position:absolute;inset:0;margin:10px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;text-align:center;color:var(--mat-sys-on-surface);background:color-mix(in srgb,var(--kip-widget-card-background-color) 92%,transparent)}.solar-empty-title[_ngcontent-%COMP%]{font-size:18px;font-weight:600}.solar-empty-sub[_ngcontent-%COMP%]{font-size:14px;opacity:.8}"]})};export{te as WidgetSolarChargerComponent};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {cv as G}from'./main-
|
|
1
|
+
import {cv as G}from'./main-YKDNK5VZ.js';var r={minDist:230,maxDur:550,minVelocity:1.5,axisDominance:1.8,deadzoneMs:160,purityRatio:.8,lockThreshold:28,directionLockAngle:25,reversalPrimaryThreshold:34};function a$1(n){let e=G(G({},r),n);return `(() => {
|
|
2
2
|
if (window.__kipSwipeInit) return; window.__kipSwipeInit = true;
|
|
3
3
|
const instanceId='${e.instanceId}';
|
|
4
4
|
let pointerId=null; let startX=0; let startY=0; let startT=0; let peakPrimary=0; let peakCross=0; let cancelled=false;
|