feat: add native Symcon archive trends and explicit room naming
This commit is contained in:
1 parent
bb153490b0
commit
cfc77787a0
28 files changed
+2449
-1250
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,285 @@
|
||||
/*! NextFloor, MIT licence. Includes three.js (MIT) and Lit (BSD-3-Clause); see LICENSE and THIRD_PARTY_NOTICES.md */
|
||||
var B=globalThis,j=B.ShadowRoot&&(B.ShadyCSS===void 0||B.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Z=Symbol(),ht=new WeakMap,H=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==Z)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o,i=this.t;if(j&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=ht.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&ht.set(i,t))}return t}toString(){return this.cssText}},ct=s=>new H(typeof s=="string"?s:s+"",void 0,Z),y=(s,...t)=>{let i=s.length===1?s[0]:t.reduce((r,e,n)=>r+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(e)+s[n+1],s[0]);return new H(i,s,Z)},dt=(s,t)=>{if(j)s.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet);else for(let i of t){let r=document.createElement("style"),e=B.litNonce;e!==void 0&&r.setAttribute("nonce",e),r.textContent=i.cssText,s.appendChild(r)}},F=j?s=>s:s=>s instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return ct(i)})(s):s;var{is:Rt,defineProperty:Ht,getOwnPropertyDescriptor:Ot,getOwnPropertyNames:Lt,getOwnPropertySymbols:Nt,getPrototypeOf:Ut}=Object,V=globalThis,pt=V.trustedTypes,Dt=pt?pt.emptyScript:"",It=V.reactiveElementPolyfillSupport,O=(s,t)=>s,K={toAttribute(s,t){switch(t){case Boolean:s=s?Dt:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,t){let i=s;switch(t){case Boolean:i=s!==null;break;case Number:i=s===null?null:Number(s);break;case Object:case Array:try{i=JSON.parse(s)}catch{i=null}}return i}},ft=(s,t)=>!Rt(s,t),ut={attribute:!0,type:String,converter:K,reflect:!1,useDefault:!1,hasChanged:ft};Symbol.metadata??=Symbol("metadata"),V.litPropertyMetadata??=new WeakMap;var _=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,i=ut){if(i.state&&(i.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((i=Object.create(i)).wrapped=!0),this.elementProperties.set(t,i),!i.noAccessor){let r=Symbol(),e=this.getPropertyDescriptor(t,r,i);e!==void 0&&Ht(this.prototype,t,e)}}static getPropertyDescriptor(t,i,r){let{get:e,set:n}=Ot(this.prototype,t)??{get(){return this[i]},set(o){this[i]=o}};return{get:e,set(o){let h=e?.call(this);n?.call(this,o),this.requestUpdate(t,h,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??ut}static _$Ei(){if(this.hasOwnProperty(O("elementProperties")))return;let t=Ut(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(O("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(O("properties"))){let i=this.properties,r=[...Lt(i),...Nt(i)];for(let e of r)this.createProperty(e,i[e])}let t=this[Symbol.metadata];if(t!==null){let i=litPropertyMetadata.get(t);if(i!==void 0)for(let[r,e]of i)this.elementProperties.set(r,e)}this._$Eh=new Map;for(let[i,r]of this.elementProperties){let e=this._$Eu(i,r);e!==void 0&&this._$Eh.set(e,i)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){let i=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let e of r)i.unshift(F(e))}else t!==void 0&&i.push(F(t));return i}static _$Eu(t,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){let t=new Map,i=this.constructor.elementProperties;for(let r of i.keys())this.hasOwnProperty(r)&&(t.set(r,this[r]),delete this[r]);t.size>0&&(this._$Ep=t)}createRenderRoot(){let t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return dt(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,i,r){this._$AK(t,r)}_$ET(t,i){let r=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,r);if(e!==void 0&&r.reflect===!0){let n=(r.converter?.toAttribute!==void 0?r.converter:K).toAttribute(i,r.type);this._$Em=t,n==null?this.removeAttribute(e):this.setAttribute(e,n),Line truncated
|
||||
\f\r]`,L=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,bt=/-->/g,vt=/>/g,E=RegExp(`>|${Y}(?:([^\\s"'>=/]+)(${Y}*=${Y}*(?:[^
|
||||
\f\r"'\`<>=]|("|')|))|$)`,"g"),$t=/'/g,xt=/"/g,St=/^(?:script|style|textarea|title)$/i,rt=s=>(t,...i)=>({_$litType$:s,strings:t,values:i}),g=rt(1),A=rt(2),Jt=rt(3),T=Symbol.for("lit-noChange"),u=Symbol.for("lit-nothing"),yt=new WeakMap,k=M.createTreeWalker(M,129);function At(s,t){if(!it(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return gt!==void 0?gt.createHTML(t):t}var Vt=(s,t)=>{let i=s.length-1,r=[],e,n=t===2?"<svg>":t===3?"<math>":"",o=L;for(let h=0;h<i;h++){let a=s[h],c,p,d=-1,v=0;for(;v<a.length&&(o.lastIndex=v,p=o.exec(a),p!==null);)v=o.lastIndex,o===L?p[1]==="!--"?o=bt:p[1]!==void 0?o=vt:p[2]!==void 0?(St.test(p[2])&&(e=RegExp("</"+p[2],"g")),o=E):p[3]!==void 0&&(o=E):o===E?p[0]===">"?(o=e??L,d=-1):p[1]===void 0?d=-2:(d=o.lastIndex-p[2].length,c=p[1],o=p[3]===void 0?E:p[3]==='"'?xt:$t):o===xt||o===$t?o=E:o===bt||o===vt?o=L:(o=E,e=void 0);let $=o===E&&s[h+1].startsWith("/>")?" ":"";n+=o===L?a+Bt:d>=0?(r.push(c),a.slice(0,d)+_t+a.slice(d)+S+$):a+S+(d===-2?h:$)}return[At(s,n+(s[i]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),r]},D=class s{constructor({strings:t,_$litType$:i},r){let e;this.parts=[];let n=0,o=0,h=t.length-1,a=this.parts,[c,p]=Vt(t,i);if(this.el=s.createElement(c,r),k.currentNode=this.el.content,i===2||i===3){let d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(e=k.nextNode())!==null&&a.length<h;){if(e.nodeType===1){if(e.hasAttributes())for(let d of e.getAttributeNames())if(d.endsWith(_t)){let v=p[o++],$=e.getAttribute(d).split(S),w=/([.?@])?(.*)/.exec(v);a.push({type:1,index:n,name:w[2],strings:$,ctor:w[1]==="."?G:w[1]==="?"?X:w[1]==="@"?Q:R}),e.removeAttribute(d)}else d.startsWith(S)&&(a.push({type:6,index:n}),e.removeAttribute(d));if(St.test(e.tagName)){let d=e.textContent.split(S),v=d.length-1;if(v>0){e.textContent=W?W.emptyScript:"";for(let $=0;$<v;$++)e.append(d[$],N()),k.nextNode(),a.push({type:2,index:++n});e.append(d[v],N())}}}else if(e.nodeType===8)if(e.data===wt)a.push({type:2,index:n});else{let d=-1;for(;(d=e.data.indexOf(S,d+1))!==-1;)a.push({type:7,index:n}),d+=S.length-1}n++}}static createElement(t,i){let r=M.createElement("template");return r.innerHTML=t,r}};function P(s,t,i=s,r){if(t===T)return t;let e=r!==void 0?i._$Co?.[r]:i._$Cl,n=U(t)?void 0:t._$litDirective$;return e?.constructor!==n&&(e?._$AO?.(!1),n===void 0?e=void 0:(e=new n(s),e._$AT(s,i,r)),r!==void 0?(i._$Co??=[])[r]=e:i._$Cl=e),e!==void 0&&(t=P(s,e._$AS(s,t.values),e,r)),t}var J=class{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){let{el:{content:i},parts:r}=this._$AD,e=(t?.creationScope??M).importNode(i,!0);k.currentNode=e;let n=k.nextNode(),o=0,h=0,a=r[0];for(;a!==void 0;){if(o===a.index){let c;a.type===2?c=new I(n,n.nextSibling,this,t):a.type===1?c=new a.ctor(n,a.name,a.strings,this,t):a.type===6&&(c=new tt(n,this,t)),this._$AV.push(c),a=r[++h]}o!==a?.index&&(n=k.nextNode(),o++)}return k.currentNode=M,e}p(t){let i=0;for(let r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(t,r,i),i+=r.strings.length-2):r._$AI(t[i])),i++}},I=class s{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,i,r,e){this.type=2,this._$AH=u,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=r,this.options=e,this._$Cv=e?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode,i=this._$AM;return i!==void 0&&t?.nodeType===11&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=P(this,t,i),U(t)?t===u||t==null||t===""?(this._$AH!==u&&this._$AR(),this._$AH=u):t!==this._$AH&&t!==T&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):jt(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==u&&U(this._$AH)?this._$AA.nextSibling.data=t:this.T(M.createTextNode(t)),this._$AH=t}$(t){let{values:i,_$litType$:r}=t,e=typeof r=="number"?this._$AC(t):(r.el===void 0&&(r.el=D.createElement(At(r.h,r.h[0]),this.options)),r);if(this._$AH?._$AD===e)this._$AH.p(i);else{let n=new J(e,this),o=n.u(this.options);n.p(i),this.T(o),this._$AH=n}}_$AC(t){let i=yt.get(t.strings);return i===void 0&&yt.set(t.strings,i=new D(t)),i}k(t){it(this._$AH)||(this._$AH=[],this._$AR());let i=this._$AH,r,e=0;for(let n of t)e===i.length?i.push(r=new s(this.O(N()),this.O(N()),this,this.options)):r=i[e],r._$AI(n),e++;e<i.length&&(this._$AR(r&&r._$AB.nextSibling,e),i.length=e)}_$AR(t=this._$AA.nextSibling,i){for(this._$AP?.(!1,!0,i);t!==this._$AB;){let r=mt(t).nextSibling;mt(t).remove(),t=r}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}},R=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,i,r,e,n){this.type=1,this._$AH=u,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=n,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this.Line truncated
|
||||
:host {
|
||||
--nf-text: var(--primary-text-color, #e1e1e1);
|
||||
--nf-muted: var(--secondary-text-color, #9b9b9b);
|
||||
--nf-accent: var(--primary-color, #03a9f4);
|
||||
--nf-accent-text: var(--text-primary-color, #ffffff);
|
||||
--nf-surface: var(--ha-card-background, var(--card-background-color, #1c1c1c));
|
||||
--nf-bg: var(--primary-background-color, #111111);
|
||||
--nf-bg2: var(--secondary-background-color, #1c1c1c);
|
||||
/* floating bars and cards over the 3D view: the card colour, a little see-through */
|
||||
--nf-chrome: color-mix(in srgb, var(--nf-surface) var(--nf-chrome-mix, 84%), transparent);
|
||||
--nf-chrome-solid: var(--nf-surface);
|
||||
--nf-line: var(--divider-color, rgba(255, 255, 255, 0.12));
|
||||
/* quiet fills for buttons and fields, and the tonal accent of an active control */
|
||||
--nf-fill: color-mix(in srgb, var(--nf-text) 7%, transparent);
|
||||
--nf-fill-strong: color-mix(in srgb, var(--nf-text) 13%, transparent);
|
||||
--nf-tonal: color-mix(in srgb, var(--nf-accent) 20%, transparent);
|
||||
--nf-soft: var(--info-color, #4a90e2);
|
||||
--nf-warm: var(--state-light-active-color, #ffa726);
|
||||
--nf-danger: var(--error-color, #db4437);
|
||||
--nf-good: var(--success-color, #43a047);
|
||||
--nf-radius: var(--ha-card-border-radius, 12px);
|
||||
--nf-shadow: var(--ha-card-box-shadow, 0 1px 2px rgba(0, 0, 0, 0.18), 0 6px 20px rgba(0, 0, 0, 0.2));
|
||||
--nf-font: var(--primary-font-family, Roboto, "Noto Sans", system-ui, -apple-system, "Segoe UI", sans-serif);
|
||||
--nf-title-font: var(--nf-font);
|
||||
font-family: var(--nf-font);
|
||||
color: var(--nf-text);
|
||||
}
|
||||
`,ce=y`
|
||||
:host([readable]) {
|
||||
--secondary-text-color: var(--primary-text-color, #e1e1e1);
|
||||
--divider-color: color-mix(in srgb, var(--primary-text-color, #e1e1e1) 40%, transparent);
|
||||
--nf-chrome-mix: 97%;
|
||||
}
|
||||
:host([readable]) nf-room-panel,
|
||||
:host([readable]) .nf-nav,
|
||||
:host([readable]) .nf-overlay {
|
||||
zoom: 1.2;
|
||||
}
|
||||
`,de=y`
|
||||
/* a group of switches: one rounded pill, the active one tinted with the accent */
|
||||
.nf-seg {
|
||||
display: inline-flex;
|
||||
padding: 4px;
|
||||
gap: 2px;
|
||||
border-radius: 999px;
|
||||
background: var(--nf-chrome);
|
||||
box-shadow: var(--nf-shadow);
|
||||
backdrop-filter: blur(10px);
|
||||
}
|
||||
.nf-seg button,
|
||||
.nf-chip {
|
||||
font: inherit;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
border: none;
|
||||
background: none;
|
||||
color: var(--nf-muted);
|
||||
padding: 7px 14px;
|
||||
border-radius: 999px;
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
min-height: 36px;
|
||||
transition:
|
||||
background 0.15s,
|
||||
color 0.15s;
|
||||
}
|
||||
.nf-seg button:hover:not(:disabled),
|
||||
.nf-chip:hover {
|
||||
background: var(--nf-fill);
|
||||
color: var(--nf-text);
|
||||
}
|
||||
/* on a small stage (a small window, a zoomed browser, a dashboard column) the switches at the bottom take less room */
|
||||
@container nf ((max-width: 1360px) or (max-height: 640px)) {
|
||||
:is(.nf-overlay, .nf-card-controls) .nf-seg {
|
||||
padding: 3px;
|
||||
}
|
||||
:is(.nf-overlay, .nf-card-controls) :is(.nf-seg button, .nf-chip) {
|
||||
font-size: 12.5px;
|
||||
padding: 5px 10px;
|
||||
}
|
||||
}
|
||||
.nf-time-slider {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 4px 10px;
|
||||
}
|
||||
.nf-time-slider input {
|
||||
width: 160px;
|
||||
accent-color: var(--nf-accent);
|
||||
}
|
||||
.nf-seg button[aria-pressed="true"],
|
||||
.nf-chip[aria-pressed="true"] {
|
||||
background: color-mix(in srgb, var(--nf-accent) 24%, var(--nf-chrome-solid));
|
||||
color: var(--nf-accent);
|
||||
font-weight: 600;
|
||||
}
|
||||
.nf-seg button:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: default;
|
||||
}
|
||||
/* a single pill, like the chips of the Mushroom cards */
|
||||
.nf-chip {
|
||||
background: var(--nf-chrome);
|
||||
color: var(--nf-text);
|
||||
box-shadow: var(--nf-shadow);
|
||||
backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
button:focus-visible,
|
||||
input:focus-visible,
|
||||
select:focus-visible {
|
||||
outline: 2px solid var(--nf-accent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
/* the round icon badge every row and card starts with */
|
||||
.nf-ico {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex: none;
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
border-radius: 50%;
|
||||
background: var(--nf-tonal);
|
||||
color: var(--nf-accent);
|
||||
--mdc-icon-size: 20px;
|
||||
}
|
||||
.nf-ico.nf-warm {
|
||||
background: color-mix(in srgb, var(--nf-warm) 22%, transparent);
|
||||
color: var(--nf-warm);
|
||||
}
|
||||
.nf-ico.nf-off {
|
||||
background: var(--nf-fill);
|
||||
color: var(--nf-muted);
|
||||
}
|
||||
.nf-btn {
|
||||
font: inherit;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
border: none;
|
||||
background: var(--nf-fill);
|
||||
color: var(--nf-text);
|
||||
border-radius: var(--nf-radius);
|
||||
padding: 7px 14px;
|
||||
cursor: pointer;
|
||||
min-height: 36px;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
.nf-btn:hover {
|
||||
background: var(--nf-fill-strong);
|
||||
}
|
||||
.nf-btn.nf-danger {
|
||||
color: var(--nf-danger);
|
||||
}
|
||||
.nf-btn.nf-primary {
|
||||
background: var(--nf-accent);
|
||||
color: var(--nf-accent-text);
|
||||
}
|
||||
.nf-btn.nf-primary:hover {
|
||||
background: color-mix(in srgb, var(--nf-accent) 88%, var(--nf-text));
|
||||
}
|
||||
.nf-field {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
font-size: 12px;
|
||||
color: var(--nf-muted);
|
||||
}
|
||||
.nf-field input,
|
||||
.nf-field select,
|
||||
.nf-field textarea {
|
||||
font: inherit;
|
||||
font-size: 14px;
|
||||
color: var(--nf-text);
|
||||
background: var(--nf-fill);
|
||||
border: none;
|
||||
border-bottom: 1px solid var(--nf-line);
|
||||
border-radius: 10px 10px 4px 4px;
|
||||
padding: 8px 10px;
|
||||
min-width: 0;
|
||||
}
|
||||
.nf-field input:focus,
|
||||
.nf-field select:focus,
|
||||
.nf-field textarea:focus {
|
||||
border-bottom-color: var(--nf-accent);
|
||||
}
|
||||
.nf-field input[type="range"] {
|
||||
padding: 0;
|
||||
accent-color: var(--nf-accent);
|
||||
}
|
||||
.nf-field select option {
|
||||
background: var(--nf-chrome-solid);
|
||||
color: var(--nf-text);
|
||||
}
|
||||
/* fingers need 40 px */
|
||||
@media (pointer: coarse) {
|
||||
.nf-seg button,
|
||||
.nf-chip,
|
||||
.nf-btn {
|
||||
min-height: 40px;
|
||||
}
|
||||
}
|
||||
`;var kt={auto:"Automatisch",raw:"Rohdaten",minute:"1 Minute","5minutes":"5 Minuten","15minutes":"15 Minuten",hour:"Stunde",day:"Tag",week:"Woche",month:"Monat",year:"Jahr"};function Mt(s,t){let i=new Set;return t.flatMap(r=>{let e=String(s?.states[r]?.attributes.symcon_source_entity||r),n=s?.states[e]?.attributes,o=Number(n?.symcon_id);return!o||!n?.symcon_archive||i.has(o)?[]:(i.add(o),[e])})}function st(s){if(!Number.isFinite(s))return"";let t=new Date(s*1e3);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}T${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function Tt(s,t,i,r){let e=c=>c.trim()&&Number.isFinite(Number(c.replace(",",".")))?Number(c.replace(",",".")):null,n=e(t),o=e(i),h=n??s.reduce((c,p)=>Math.min(c,p),r||!s.length?0:1/0),a=o??s.reduce((c,p)=>Math.max(c,p),r?0:s.length?-1/0:1);if(h===a&&(n===null&&!r&&(h-=Math.max(1,Math.abs(h)*.05)),o===null&&(a+=Math.max(1,Math.abs(a)*.05))),h>=a)throw new Error("Der untere Wertebereich muss kleiner als der obere sein.");return[h,a]}function Ct(s,t){let i=r=>{let e=String(r??"");return`"${/^[=+@\-\t\r]/.test(e)?"'":""}${e.replaceAll('"','""')}"`};return"\uFEFF"+[["Variable","Zeit","Wert","Minimum","Maximum"].join(";"),...s.flatMap(r=>r.points.map(e=>[t[r.entity_id]||r.entity_id,new Date(e.t*1e3).toISOString(),e.v,e.min??"",e.max??""].map(i).join(";")))].join(`\r
|
||||
`)}var ot=class extends x{static properties={text:{attribute:!1}};constructor(){super(),this.text=""}get dialog(){return this.renderRoot.querySelector("dialog")}render(){return g`<button class="info" type="button" aria-label="Information anzeigen" aria-haspopup="dialog" title="Information" @click=${()=>this.dialog?.showModal()}>ⓘ</button>
|
||||
<dialog aria-label="Information" @keydown=${t=>t.stopPropagation()} @click=${t=>{if(t.target!==t.currentTarget)return;let i=this.dialog.getBoundingClientRect();(t.clientX<i.left||t.clientX>i.right||t.clientY<i.top||t.clientY>i.bottom)&&this.dialog?.close()}}>
|
||||
<header><b>Information</b><button class="close" type="button" aria-label="Schließen" @click=${()=>this.dialog?.close()}>×</button></header>
|
||||
<p>${this.text}</p>
|
||||
</dialog>`}static styles=[q,y`
|
||||
:host { display:inline-block; margin:4px 0; vertical-align:middle; }
|
||||
button { font:inherit; cursor:pointer; color:var(--nf-muted); background:transparent; border:1px solid var(--nf-line); border-radius:50%; pointer-events:auto; }
|
||||
.info { width:26px; height:26px; padding:0; font-size:18px; line-height:24px; }
|
||||
button:hover { color:var(--nf-accent); }
|
||||
button:focus-visible { outline:2px solid var(--nf-accent); outline-offset:2px; }
|
||||
dialog { box-sizing:border-box; width:min(560px,calc(100vw - 32px)); max-height:80vh; max-height:80dvh; overflow:auto; padding:18px 22px; border:1px solid var(--nf-line); border-radius:14px; background:var(--nf-chrome-solid); color:var(--nf-text); font:14px/1.5 system-ui,sans-serif; box-shadow:var(--nf-shadow); pointer-events:auto; }
|
||||
dialog::backdrop { background:#050b16a6; }
|
||||
header { display:flex; align-items:center; justify-content:space-between; gap:20px; font-size:16px; }
|
||||
.close { width:30px; height:30px; padding:0; font-size:23px; }
|
||||
p { white-space:pre-wrap; overflow-wrap:anywhere; margin:16px 0 4px; }
|
||||
`]};customElements.get("nf-help-popup")||customElements.define("nf-help-popup",ot);var zt=["#4ec9ff","#ffbe69","#ae9bff","#72deb0","#ff87aa","#ebde72"],C=(s,t)=>String(s.states[t]?.attributes.friendly_name||t),Pt=s=>({variable_not_logged:"Die Variable wird nicht mehr geloggt.",trend_range_too_large_for_resolution:"Bitte f\xFCr diesen Zeitraum eine gr\xF6bere Aufl\xF6sung w\xE4hlen.",invalid_trend_range:"Bitte einen g\xFCltigen Zeitraum w\xE4hlen."})[String(s instanceof Error?s.message:s)]||String(s instanceof Error?s.message:s),at=class extends x{static properties={hass:{attribute:!1},ids:{attribute:!1},label:{attribute:!1},from:{state:!0},to:{state:!0},resolution:{state:!0},chartStyle:{state:!0},field:{state:!0},min:{state:!0},max:{state:!0},zero:{state:!0},band:{state:!0},live:{state:!0},series:{state:!0},hiddenSeries:{state:!0},loading:{state:!0},errors:{state:!0},hover:{state:!0},width:{state:!0},page:{state:!0}};request=0;drag=null;timer;observer;constructor(){super(),this.ids=[],this.label="",this.to=Math.floor(Date.now()/1e3),this.from=this.to-86400,this.resolution="auto",this.chartStyle="auto",this.field="v",this.min="",this.max="",this.zero=!1,this.band=!0,this.live=!1,this.series=[],this.hiddenSeries=new Set,this.loading=!1,this.errors=[],this.hover=null,this.width=900,this.page=0}async open(){await this.updateComplete,this.renderRoot.querySelector("dialog").showModal(),this.observer=new ResizeObserver(([t])=>{this.width=Math.max(280,Math.floor(t.contentRect.width))}),this.observer.observe(this.renderRoot.querySelector(".body")),this.timer=setInterval(()=>{if(this.live&&!this.loading){let t=this.to-this.from;this.to=Math.floor(Date.now()/1e3),this.from=this.to-t,this.load()}},3e4),await this.load()}disconnectedCallback(){super.disconnectedCallback(),++this.request,clearInterval(this.timer),this.observer?.disconnect()}async load(){let t=++this.request,i=this.from,r=this.to;if(this.errors=[],this.series=[],this.hover=null,this.page=0,!Number.isSafeInteger(i)||!Number.isSafeInteger(r)||i<1||r<=i){this.errors=["Das Ende muss nach dem Beginn des Zeitraums liegen."],this.loading=!1;return}this.loading=!0;let e=[],n=[];for(let o=0;o<this.ids.length&&t===this.request;o+=3){let h=this.ids.slice(o,o+3);(await Promise.allSettled(h.map(c=>this.hass.callWS({type:"nextfloor/archive/trend",entity_id:c,start:i,end:r,aggregation:this.resolution})))).forEach((c,p)=>c.status==="fulfilled"?e.push(c.value):n.push(`${C(this.hass,h[p])}: ${Pt(c.reason)}`))}t!==this.request||!this.isConnected||(this.series=e,this.errors=n,this.loading=!1)}range(t,i){this.from=Math.max(1,Math.floor(t)),this.to=Math.max(this.from+1,Math.floor(i)),this.live=!1,this.load()}zoom(t,i=.5){let r=Math.max(60,Math.min(315576e3,(this.to-this.from)*t)),e=this.from+(this.to-this.from)*i;this.range(e-r*i,e+r*(1-i))}stamp(t){return new Date(t*1e3).toLocaleString(this.hass.language,{dateStyle:"short",timeStyle:"medium"})}number(t){return t.toLocaleString(this.hass.language,{maximumFractionDigits:Math.abs(t)<.01&&t!==0?5:2})}unit(t){return String(this.hass.states[t]?.attributes.unit_of_measurement??"")}selected(){return this.series.filter(t=>!this.hiddenSeries.has(t.entity_id))}value(t){let i=this.field==="v"?t.v:t[this.field]??t.v;return typeof i=="number"&&Number.isFinite(i)?i:null}color(t){return zt[this.ids.indexOf(t)%zt.length]}ratio(t){let i=t.currentTarget.getBoundingClientRect();return Math.max(0,Math.min(1,((t.clientX-i.left)/i.width*this.width-64)/(this.width-80)))}exportCsv(){let t=Object.fromEntries(this.ids.map(e=>[e,String(this.hass.states[e]?.attributes.symcon_path||C(this.hass,e))])),i=URL.createObjectURL(new Blob([Ct(this.selected(),t)],{type:"text/csv;charset=utf-8"})),r=document.createElement("a");r.href=i,r.download="Symcon-Trend.csv",r.click(),setTimeout(()=>URL.revokeObjectURL(i),1e3)}plot(t,i){let r=t.flatMap(l=>l.points.flatMap(f=>{let m=this.value(f);return m===null?[]:this.band&&!l.counter?[m,f.min??m,f.max??m]:[m]}));if(!r.length)return g`<p class="note">Keine numerischen Archivwerte in diesem Zeitraum.</p>`;let e,n;try{[e,n]=Tt(r,this.min,this.max,this.zero||this.chartStyle==="bar"||t.some(l=>l.type===0)||this.chartStyle==="auto"&&t.some(l=>l.counter&&l.aggregation!=="raw"))}catch(l){return g`<p role="alert">${Pt(l)}</p>`}let o=64,h=this.width-16,a=14,c=220,p=l=>o+(l-this.from)/(this.to-this.from)*(h-o),d=l=>c-(l-e)/(n-e)*(c-a),v=(l,f=this.field)=>Number(f==="v"?l.v:l[f]??l.v),$=(l,f=this.field)=>{let m=l.points.filter(z=>typeof z.v=="number"),b=this.chartStyle==="step"||this.chartStyle==="auto"&&l.type===0;return m.map((z,lt)=>`${lt?b?`H${p(z.t).toFixed(1)}V`:"L":"M"}${b&<?d(v(z,f)).toFixed(1):`${p(z.t).toFixed(1)},${d(v(z,f)).toFixed(1)}`}`).join("")+(m.length?b?`H${h}`:l.aggregation==="raw"?`L${h},${d(v(m[m.length-1],f)).toFixed(1)}`:"":"")},w=this.width<480?2:5;return g`<section class="chart-group"><h3>${i||"Wert"}</h3><svg class="plot" viewBox=${`0 0 ${this.width} 256`} role="img" aria-label=${`Trend ${i}`} @wheel=${Line truncated
|
||||
@pointerdown=${l=>{this.drag=this.ratio(l),l.currentTarget.setPointerCapture(l.pointerId)}}
|
||||
@pointerup=${l=>{if(this.drag===null)return;let f=this.drag,m=this.ratio(l);if(this.drag=null,Math.abs(f-m)>.02){let b=this.to-this.from;this.range(this.from+b*Math.min(f,m),this.from+b*Math.max(f,m))}}}
|
||||
@pointercancel=${()=>{this.drag=null}} @pointermove=${l=>{this.hover=this.from+(this.to-this.from)*this.ratio(l)}}>
|
||||
<defs><clipPath id="plot-clip"><rect x=${o} y=${a} width=${h-o} height=${c-a}/></clipPath></defs>
|
||||
${[0,1,2,3,4].map(l=>{let f=e+(n-e)*l/4;return A`<line class="grid" x1=${o} x2=${h} y1=${d(f)} y2=${d(f)}/><text x=${o-7} y=${d(f)+4} text-anchor="end">${this.number(f)}</text>`})}
|
||||
${Array.from({length:w},(l,f)=>{let m=this.from+(this.to-this.from)*f/(w-1);return A`<text x=${p(m)} y="244" text-anchor=${f===0?"start":f===w-1?"end":"middle"}>${new Date(m*1e3).toLocaleString(this.hass.language,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}</text>`})}
|
||||
<g clip-path="url(#plot-clip)">${t.map(l=>{let f=this.chartStyle==="bar"||this.chartStyle==="auto"&&l.counter&&l.aggregation!=="raw",m=this.color(l.entity_id);return f?l.points.filter(b=>this.value(b)!==null).map(b=>A`<rect fill=${m} opacity=".65" x=${p(b.t)} y=${Math.min(d(this.value(b)),d(0))} width=${Math.max(1,Math.min(h,p(b.t+Math.max(1,b.d)))-p(b.t)-1)} height=${Math.max(1,Math.abs(d(this.value(b))-d(0)))}/>`):A`${this.band&&l.aggregation!=="raw"&&!l.counter?A`<path d=${$(l,"min")} fill="none" stroke=${m} opacity=".3"/><path d=${$(l,"max")} fill="none" stroke=${m} opacity=".3"/>`:u}<path d=${$(l)} fill="none" stroke=${m} stroke-width="2" vector-effect="non-scaling-stroke"/>${l.points.length===1?A`<circle cx=${p(l.points[0].t)} cy=${d(v(l.points[0]))} r="3" fill=${m}/>`:u}`})}${this.hover!==null?A`<line x1=${p(this.hover)} x2=${p(this.hover)} y1=${a} y2=${c} stroke="currentColor" stroke-dasharray="3 4" opacity=".5"/>`:u}</g>
|
||||
</svg></section>`}table(t){let i=t.flatMap(n=>n.points.map(o=>({id:n.entity_id,...o}))).sort((n,o)=>o.t-n.t),r=Math.max(1,Math.ceil(i.length/100)),e=Math.min(this.page,r-1);return g`<div class="table"><table><thead><tr><th>Zeit</th><th>Variable</th><th>Wert</th></tr></thead><tbody>${i.slice(e*100,(e+1)*100).map(n=>g`<tr><td>${this.stamp(n.t)}</td><td>${C(this.hass,n.id)}</td><td>${typeof n.v=="number"?this.number(n.v):n.v} ${this.unit(n.id)}</td></tr>`)}</tbody></table></div><div class="actions"><button ?disabled=${!e} @click=${()=>{this.page=e-1}}>Zurück</button><span>${e+1} / ${r}</span><button ?disabled=${e>=r-1} @click=${()=>{this.page=e+1}}>Weiter</button></div>`}render(){let t=this.selected(),i=t.length>0&&t.every(e=>e.type===3),r=this.hover===null?"Letzter Wert":this.stamp(this.hover);return g`<dialog aria-label="Variablentrend" @close=${()=>this.remove()} @keydown=${e=>e.stopPropagation()}>
|
||||
<header><div><h2>${this.label||"Variablentrend"}</h2><span>Symcon Archiv</span></div><button aria-label="Schließen" @click=${()=>this.renderRoot.querySelector("dialog")?.close()}>×</button></header>
|
||||
<div class="body"><div class="presets">${[["1 h",3600],["6 h",21600],["24 h",86400],["7 Tage",604800],["30 Tage",2592e3],["1 Jahr",31536e3]].map(([e,n])=>g`<button @click=${()=>{let o=Math.floor(Date.now()/1e3);this.range(o-Number(n),o)}}>${e}</button>`)}</div>
|
||||
<form @submit=${e=>{e.preventDefault(),this.load()}}><div class="fields">
|
||||
<label>Von<input type="datetime-local" .value=${st(this.from)} @change=${e=>{this.from=Math.floor(new Date(e.target.value).getTime()/1e3),this.live=!1,this.load()}}/></label>
|
||||
<label>Bis<input type="datetime-local" .value=${st(this.to)} @change=${e=>{this.to=Math.floor(new Date(e.target.value).getTime()/1e3),this.live=!1,this.load()}}/></label>
|
||||
<label>Auflösung<select .value=${this.resolution} @change=${e=>{this.resolution=e.target.value,this.load()}}>${Object.entries(kt).map(([e,n])=>g`<option value=${e}>${n}</option>`)}</select></label>
|
||||
<button type="submit" ?disabled=${this.loading}>${this.loading?"L\xE4dt \u2026":"Anzeigen"}</button>
|
||||
</div></form>
|
||||
<details class="settings"><summary>Darstellung und Wertebereich</summary><div class="fields">
|
||||
<label>Darstellung<select .value=${this.chartStyle} @change=${e=>{this.chartStyle=e.target.value}}>${Object.entries({auto:"Automatisch",line:"Linie",step:"Stufen",bar:"Balken",table:"Tabelle"}).map(([e,n])=>g`<option value=${e}>${n}</option>`)}</select></label>
|
||||
<label>Aggregierter Wert<select .value=${this.field} @change=${e=>{this.field=e.target.value}}><option value="v">Mittelwert / Verbrauch</option><option value="min">Minimum</option><option value="max">Maximum</option></select></label>
|
||||
<label>Y-Minimum<input type="number" step="any" placeholder="Automatisch" .value=${this.min} @input=${e=>{this.min=e.target.value}}/></label>
|
||||
<label>Y-Maximum<input type="number" step="any" placeholder="Automatisch" .value=${this.max} @input=${e=>{this.max=e.target.value}}/></label>
|
||||
</div><div class="checks"><label><input type="checkbox" .checked=${this.zero} @change=${e=>{this.zero=e.target.checked}}/> Nullpunkt einbeziehen</label><label><input type="checkbox" .checked=${this.band} @change=${e=>{this.band=e.target.checked}}/> Min/Max anzeigen</label></div></details>
|
||||
<div class="actions"><button aria-label="Vorheriger Zeitraum" @click=${()=>this.range(this.from-(this.to-this.from),this.from)}>←</button><button aria-label="Nächster Zeitraum" @click=${()=>this.range(this.to,this.to+(this.to-this.from))}>→</button><button aria-label="Hineinzoomen" @click=${()=>this.zoom(.5)}>+</button><button aria-label="Herauszoomen" @click=${()=>this.zoom(2)}>−</button><button @click=${()=>{this.load()}} ?disabled=${this.loading}>Aktualisieren</button><label><input type="checkbox" .checked=${this.live} @change=${e=>{this.live=e.target.checked}}/> Live (30 s)</label><button @click=${()=>this.exportCsv()} ?disabled=${!t.length}>CSV</button>
|
||||
<nf-help-popup .text=${"Zeitraum und Aufl\xF6sung lesen die originalen Symcon-Archivdaten. Rohdaten zeigen gespeicherte \xC4nderungen; ein zuvor bekannter Wert wird zum Beginn fortgef\xFChrt. Bei Z\xE4hlern sind aggregierte Werte der Verbrauch pro Intervall, bei Messwerten der Mittelwert. Mehrere Variablen werden einzeln dargestellt; unterschiedliche Einheiten erhalten eigene Diagramme. Zoomen: +/\u2212, Mausrad oder im Diagramm einen Zeitraum ziehen. Eigene Y-Grenzen gelten f\xFCr alle Diagramme. Begrenzte Rohdatenabfragen werden gekennzeichnet; w\xE4hle dann einen k\xFCrzeren Zeitraum oder eine Aggregation."}></nf-help-popup>
|
||||
</div>
|
||||
<div class="legend">${this.ids.map(e=>g`<label title=${String(this.hass.states[e]?.attributes.symcon_path||C(this.hass,e))}><input type="checkbox" .checked=${!this.hiddenSeries.has(e)} @change=${n=>{let o=new Set(this.hiddenSeries);n.target.checked?o.delete(e):o.add(e),this.hiddenSeries=o,this.requestUpdate()}}/><i style=${`background:${this.color(e)}`}></i>${C(this.hass,e)}</label>`)}</div>
|
||||
${this.errors.map(e=>g`<p class="error" role="alert">${e}</p>`)}${this.loading?g`<p class="note" role="status">Archivwerte werden geladen …</p>`:u}
|
||||
${t.filter(e=>e.truncated).map(e=>g`<p class="error" role="status">${C(this.hass,e.entity_id)}: Die Abfrage ist auf ${(e.limit??1e4).toLocaleString(this.hass.language)} Einträge begrenzt. Bitte Zeitraum verkürzen oder Auflösung ändern.</p>`)}
|
||||
${t.some(e=>e.counter&&e.aggregation!=="raw")?g`<p class="note">Zähler: Verbrauch pro Intervall</p>`:u}
|
||||
${this.chartStyle==="table"||i?this.table(t):[...new Set(t.filter(e=>e.type!==3).map(e=>this.unit(e.entity_id)))].map(e=>this.plot(t.filter(n=>n.type!==3&&this.unit(n.entity_id)===e),e))}
|
||||
${t.some(e=>e.type===3)&&!i&&this.chartStyle!=="table"?this.table(t.filter(e=>e.type===3)):u}
|
||||
${!this.loading&&t.length&&t.every(e=>!e.points.length)?g`<p class="note">Keine Archivwerte in diesem Zeitraum.</p>`:u}
|
||||
<div class="cursor"><b>${r}</b>${t.map(e=>{let n=e.points.at(-1);if(this.hover!==null){let o=0,h=e.points.length;for(;o<h;){let a=o+h>>>1;e.points[a].t<=this.hover?o=a+1:h=a}n=e.points[o-1]}return g`<span style=${`color:${this.color(e.entity_id)}`}>${C(this.hass,e.entity_id)}: ${n?typeof n.v=="number"?`${this.number(this.value(n))} ${this.unit(e.entity_id)}`:n.v:"\u2013"}</span>`})}</div>
|
||||
</div>
|
||||
</dialog>`}static styles=[q,y`
|
||||
:host{font:14px/1.45 system-ui,sans-serif;color:var(--nf-text)}dialog{box-sizing:border-box;width:min(1080px,calc(100vw - 24px));max-height:92vh;max-height:92dvh;padding:0;border:1px solid var(--nf-line);border-radius:14px;background:var(--nf-chrome-solid,#1c1c1c);color:inherit;box-shadow:var(--nf-shadow);overflow:auto}dialog::backdrop{background:#050b16a8}header{display:flex;justify-content:space-between;align-items:center;gap:16px;padding:16px 20px;border-bottom:1px solid var(--nf-line)}h2{font-size:18px;margin:0}header span,.note{font-size:12px;color:var(--nf-muted)}header button{font-size:23px;width:36px;height:36px;padding:0}.body{padding:16px 20px}.presets,.actions,.checks,.legend,.cursor{display:flex;align-items:center;flex-wrap:wrap;gap:8px;margin:0 0 14px}.fields{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:10px;align-items:end;margin:12px 0}.fields label{display:grid;gap:5px;color:var(--nf-muted);font-size:12px}button,input,select{font:inherit;box-sizing:border-box;color:var(--nf-text)}button,select,input:not([type=checkbox]){border:1px solid var(--nf-line);border-radius:7px;padding:8px;background:var(--nf-fill,#292929);min-width:0}button{cursor:pointer}button:disabled{opacity:.45}button:focus-visible,input:focus-visible,select:focus-visible{outline:2px solid var(--nf-accent);outline-offset:2px}.settings{border:1px solid var(--nf-line);padding:10px 12px;border-radius:9px;margin:12px 0}summary{cursor:pointer}.checks label,.actions label,.legend label{display:flex;align-items:center;gap:6px;font-size:12px}.legend i{display:inline-block;width:10px;height:10px;border-radius:50%;flex-shrink:0}.legend label{max-width:100%;overflow-wrap:anywhere}.plot{display:block;width:100%;touch-action:none;user-select:none}.plot text{fill:var(--nf-muted);font:11px system-ui}.grid{stroke:var(--nf-line)}h3{font-size:12px;color:var(--nf-muted);margin:12px 0 0}.chart-group{margin-bottom:10px}.cursor{font-size:12px;align-items:flex-start}.cursor>b{width:100%;color:var(--nf-muted)}.cursor span{overflow-wrap:anywhere}.error{color:#ffa5a5}.table{overflow:auto;max-height:380px;margin:12px 0}table{width:100%;border-collapse:collapse;font-size:12px}td,th{text-align:left;padding:7px;border-bottom:1px solid var(--nf-line);overflow-wrap:anywhere}td:first-child{white-space:nowrap}th{position:sticky;top:0;background:var(--nf-chrome-solid,#1c1c1c)}@media(max-width:500px){header{padding:12px}.body{padding:10px}.fields{grid-template-columns:repeat(2,minmax(0,1fr))}input[type=datetime-local]{font-size:12px;padding:7px 3px}.actions{gap:6px}.actions button{padding:7px}header h2{font-size:16px}}
|
||||
header{position:sticky;top:0;z-index:2;background:var(--nf-chrome-solid,#1c1c1c)}
|
||||
`]};customElements.get("nf-trend-dialog")||customElements.define("nf-trend-dialog",at);async function ye(s,t,i){let r=Mt(s,t);if(!r.length)return;let e=document.createElement("nf-trend-dialog");Object.assign(e,{hass:s,ids:r,label:i}),document.body.append(e);try{await e.open()}catch(n){throw e.remove(),n}}export{at as NfTrendDialog,ye as openTrend};
|
||||
/*! Bundled license information:
|
||||
|
||||
@lit/reactive-element/css-tag.js:
|
||||
(**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*)
|
||||
|
||||
@lit/reactive-element/reactive-element.js:
|
||||
lit-html/lit-html.js:
|
||||
lit-element/lit-element.js:
|
||||
(**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*)
|
||||
|
||||
lit-html/is-server.js:
|
||||
(**
|
||||
* @license
|
||||
* Copyright 2022 Google LLC
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*)
|
||||
*/
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user