Switched icons in custom cards to ha-icon from paper-icons

This commit is contained in:
Martin Bauer 2020-07-14 13:42:58 +00:00
parent da8c19f568
commit 5103532b48
8 changed files with 135 additions and 130 deletions

File diff suppressed because one or more lines are too long

View File

@ -17,5 +17,9 @@
"typescript": "^3.8.3",
"webpack": "^4.42.1",
"webpack-cli": "^3.3.11"
},
"dependencies": {
"@polymer/iron-icons": "^3.0.1",
"@polymer/paper-icon-button": "^3.0.2"
}
}

View File

@ -2,7 +2,8 @@ import {LitElement, html, css, customElement, property, TemplateResult, CSSResul
import {classMap} from "lit-html/directives/class-map";
import {styleMap} from "lit-html/directives/style-map";
import {HomeAssistant} from "./home-assistant-interface";
//import '@polymer/paper-icon-button/paper-icon-button.js';
//import '@polymer/iron-icons/iron-icons.js';
@customElement("room-glance-card")
export class RoomGlanceCard extends LitElement {
@ -84,52 +85,52 @@ export class RoomGlanceCard extends LitElement {
private renderSceneButton(buttonCfg: any) {
return html`
<paper-icon-button
<ha-icon-button
icon="${buttonCfg.icon || "mdi:checkbox-blank"}"
style="color: ${buttonCfg.color || ""};"
title="${buttonCfg.name}"
@click=${this.serviceHandler("scene", "turn_on", {entity_id: buttonCfg.scene})}
></paper-icon-button>
></ha-icon-button>
`;
}
private renderLightControl() {
return html`
<paper-icon-button
<ha-icon-button
icon="mdi:close-circle"
@click=${this.serviceHandler("light", "turn_off")}
></paper-icon-button>
></ha-icon-button>
<paper-icon-button
<ha-icon-button
icon="mdi:chevron-up"
title="Heller"
@click=${this.serviceHandler("dimmer", "dim", {offset: 30})}
></paper-icon-button>
<paper-icon-button
></ha-icon-button>
<ha-icon-button
icon="mdi:chevron-down"
title="Dunkler"
@click=${this.serviceHandler("dimmer", "dim", {offset: -30})}
></paper-icon-button>`;
></ha-icon-button>`;
}
private renderCoverControl() {
return html`
<paper-icon-button
<ha-icon-button
icon="hass:menu"
@click=${this.serviceHandler("cover_half", "set_half")}
></paper-icon-button>
<paper-icon-button
></ha-icon-button>
<ha-icon-button
icon="hass:arrow-up"
@click=${this.serviceHandler("cover", "open_cover")}
></paper-icon-button>
<paper-icon-button
></ha-icon-button>
<ha-icon-button
icon="hass:stop"
@click=${this.serviceHandler("cover", "stop_cover")}
></paper-icon-button>
<paper-icon-button
></ha-icon-button>
<ha-icon-button
icon="hass:arrow-down"
@click=${this.serviceHandler("cover", "close_cover")}
></paper-icon-button>
></ha-icon-button>
`;
}

View File

@ -12,7 +12,7 @@
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
const i=new WeakMap,n=t=>"function"==typeof t&&i.has(t),r=void 0!==window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,o=(t,e,s=null)=>{for(;e!==s;){const s=e.nextSibling;t.removeChild(e),e=s}},a={},l={},c=`{{lit-${String(Math.random()).slice(2)}}}`,h=`\x3c!--${c}--\x3e`,p=new RegExp(`${c}|${h}`),u="$lit$";class d{constructor(t,e){this.parts=[],this.element=e;const s=[],i=[],n=document.createTreeWalker(e.content,133,null,!1);let r=0,o=-1,a=0;const{strings:l,values:{length:h}}=t;for(;a<h;){const t=n.nextNode();if(null!==t){if(o++,1===t.nodeType){if(t.hasAttributes()){const e=t.attributes,{length:s}=e;let i=0;for(let t=0;t<s;t++)_(e[t].name,u)&&i++;for(;i-- >0;){const e=l[a],s=y.exec(e)[2],i=s.toLowerCase()+u,n=t.getAttribute(i);t.removeAttribute(i);const r=n.split(p);this.parts.push({type:"attribute",index:o,name:s,strings:r}),a+=r.length-1}}"TEMPLATE"===t.tagName&&(i.push(t),n.currentNode=t.content)}else if(3===t.nodeType){const e=t.data;if(e.indexOf(c)>=0){const i=t.parentNode,n=e.split(p),r=n.length-1;for(let e=0;e<r;e++){let s,r=n[e];if(""===r)s=m();else{const t=y.exec(r);null!==t&&_(t[2],u)&&(r=r.slice(0,t.index)+t[1]+t[2].slice(0,-u.length)+t[3]),s=document.createTextNode(r)}i.insertBefore(s,t),this.parts.push({type:"node",index:++o})}""===n[r]?(i.insertBefore(m(),t),s.push(t)):t.data=n[r],a+=r}}else if(8===t.nodeType)if(t.data===c){const e=t.parentNode;null!==t.previousSibling&&o!==r||(o++,e.insertBefore(m(),t)),r=o,this.parts.push({type:"node",index:o}),null===t.nextSibling?t.data="":(s.push(t),o--),a++}else{let e=-1;for(;-1!==(e=t.data.indexOf(c,e+1));)this.parts.push({type:"node",index:-1}),a++}}else n.currentNode=i.pop()}for(const t of s)t.parentNode.removeChild(t)}}const _=(t,e)=>{const s=t.length-e.length;return s>=0&&t.slice(s)===e},f=t=>-1!==t.index,m=()=>document.createComment(""),y=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;
const i=new WeakMap,n=t=>"function"==typeof t&&i.has(t),r=void 0!==window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,o=(t,e,s=null)=>{for(;e!==s;){const s=e.nextSibling;t.removeChild(e),e=s}},a={},l={},h=`{{lit-${String(Math.random()).slice(2)}}}`,c=`\x3c!--${h}--\x3e`,p=new RegExp(`${h}|${c}`),u="$lit$";class d{constructor(t,e){this.parts=[],this.element=e;const s=[],i=[],n=document.createTreeWalker(e.content,133,null,!1);let r=0,o=-1,a=0;const{strings:l,values:{length:c}}=t;for(;a<c;){const t=n.nextNode();if(null!==t){if(o++,1===t.nodeType){if(t.hasAttributes()){const e=t.attributes,{length:s}=e;let i=0;for(let t=0;t<s;t++)_(e[t].name,u)&&i++;for(;i-- >0;){const e=l[a],s=y.exec(e)[2],i=s.toLowerCase()+u,n=t.getAttribute(i);t.removeAttribute(i);const r=n.split(p);this.parts.push({type:"attribute",index:o,name:s,strings:r}),a+=r.length-1}}"TEMPLATE"===t.tagName&&(i.push(t),n.currentNode=t.content)}else if(3===t.nodeType){const e=t.data;if(e.indexOf(h)>=0){const i=t.parentNode,n=e.split(p),r=n.length-1;for(let e=0;e<r;e++){let s,r=n[e];if(""===r)s=m();else{const t=y.exec(r);null!==t&&_(t[2],u)&&(r=r.slice(0,t.index)+t[1]+t[2].slice(0,-u.length)+t[3]),s=document.createTextNode(r)}i.insertBefore(s,t),this.parts.push({type:"node",index:++o})}""===n[r]?(i.insertBefore(m(),t),s.push(t)):t.data=n[r],a+=r}}else if(8===t.nodeType)if(t.data===h){const e=t.parentNode;null!==t.previousSibling&&o!==r||(o++,e.insertBefore(m(),t)),r=o,this.parts.push({type:"node",index:o}),null===t.nextSibling?t.data="":(s.push(t),o--),a++}else{let e=-1;for(;-1!==(e=t.data.indexOf(h,e+1));)this.parts.push({type:"node",index:-1}),a++}}else n.currentNode=i.pop()}for(const t of s)t.parentNode.removeChild(t)}}const _=(t,e)=>{const s=t.length-e.length;return s>=0&&t.slice(s)===e},f=t=>-1!==t.index,m=()=>document.createComment(""),y=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=\/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
@ -39,7 +39,7 @@ class g{constructor(t,e,s){this.__parts=[],this.template=t,this.processor=e,this
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/class v{constructor(t,e,s,i){this.strings=t,this.values=e,this.type=s,this.processor=i}getHTML(){const t=this.strings.length-1;let e="",s=!1;for(let i=0;i<t;i++){const t=this.strings[i],n=t.lastIndexOf("\x3c!--");s=(n>-1||s)&&-1===t.indexOf("--\x3e",n+1);const r=y.exec(t);e+=null===r?t+(s?c:h):t.substr(0,r.index)+r[1]+r[2]+u+r[3]+c}return e+=this.strings[t]}getTemplateElement(){const t=document.createElement("template");return t.innerHTML=this.getHTML(),t}}
*/class v{constructor(t,e,s,i){this.strings=t,this.values=e,this.type=s,this.processor=i}getHTML(){const t=this.strings.length-1;let e="",s=!1;for(let i=0;i<t;i++){const t=this.strings[i],n=t.lastIndexOf("\x3c!--");s=(n>-1||s)&&-1===t.indexOf("--\x3e",n+1);const r=y.exec(t);e+=null===r?t+(s?h:c):t.substr(0,r.index)+r[1]+r[2]+u+r[3]+h}return e+=this.strings[t]}getTemplateElement(){const t=document.createElement("template");return t.innerHTML=this.getHTML(),t}}
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
@ -79,7 +79,7 @@ const S=t=>null===t||!("object"==typeof t||"function"==typeof t),b=t=>Array.isAr
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/function V(t){let e=k.get(t.type);void 0===e&&(e={stringsArray:new WeakMap,keyString:new Map},k.set(t.type,e));let s=e.stringsArray.get(t.strings);if(void 0!==s)return s;const i=t.strings.join(c);return void 0===(s=e.keyString.get(i))&&(s=new d(t,t.getTemplateElement()),e.keyString.set(i,s)),e.stringsArray.set(t.strings,s),s}const k=new Map,M=new WeakMap;
*/function V(t){let e=k.get(t.type);void 0===e&&(e={stringsArray:new WeakMap,keyString:new Map},k.set(t.type,e));let s=e.stringsArray.get(t.strings);if(void 0!==s)return s;const i=t.strings.join(h);return void 0===(s=e.keyString.get(i))&&(s=new d(t,t.getTemplateElement()),e.keyString.set(i,s)),e.stringsArray.set(t.strings,s),s}const k=new Map,M=new WeakMap;
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
@ -106,7 +106,7 @@ const S=t=>null===t||!("object"==typeof t||"function"==typeof t),b=t=>Array.isAr
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.0.0");const R=(t,...e)=>new v(t,e,"html",E),U=133;function z(t,e){const{element:{content:s},parts:i}=t,n=document.createTreeWalker(s,U,null,!1);let r=$(i),o=i[r],a=-1,l=0;const c=[];let h=null;for(;n.nextNode();){a++;const t=n.currentNode;for(t.previousSibling===h&&(h=null),e.has(t)&&(c.push(t),null===h&&(h=t)),null!==h&&l++;void 0!==o&&o.index===a;)o.index=null!==h?-1:o.index-l,o=i[r=$(i,r)]}c.forEach(t=>t.parentNode.removeChild(t))}const F=t=>{let e=11===t.nodeType?0:1;const s=document.createTreeWalker(t,U,null,!1);for(;s.nextNode();)e++;return e},$=(t,e=-1)=>{for(let s=e+1;s<t.length;s++){const e=t[s];if(f(e))return s}return-1};
(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.0.0");const R=(t,...e)=>new v(t,e,"html",E),U=133;function z(t,e){const{element:{content:s},parts:i}=t,n=document.createTreeWalker(s,U,null,!1);let r=$(i),o=i[r],a=-1,l=0;const h=[];let c=null;for(;n.nextNode();){a++;const t=n.currentNode;for(t.previousSibling===c&&(c=null),e.has(t)&&(h.push(t),null===c&&(c=t)),null!==c&&l++;void 0!==o&&o.index===a;)o.index=null!==c?-1:o.index-l,o=i[r=$(i,r)]}h.forEach(t=>t.parentNode.removeChild(t))}const F=t=>{let e=11===t.nodeType?0:1;const s=document.createTreeWalker(t,U,null,!1);for(;s.nextNode();)e++;return e},$=(t,e=-1)=>{for(let s=e+1;s<t.length;s++){const e=t[s];if(f(e))return s}return-1};
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
@ -120,7 +120,7 @@ const S=t=>null===t||!("object"==typeof t||"function"==typeof t),b=t=>Array.isAr
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
const q=(t,e)=>`${t}--${e}`;let I=!0;void 0===window.ShadyCSS?I=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),I=!1);const H=t=>e=>{const s=q(e.type,t);let i=k.get(s);void 0===i&&(i={stringsArray:new WeakMap,keyString:new Map},k.set(s,i));let n=i.stringsArray.get(e.strings);if(void 0!==n)return n;const r=e.strings.join(c);if(void 0===(n=i.keyString.get(r))){const s=e.getTemplateElement();I&&window.ShadyCSS.prepareTemplateDom(s,t),n=new d(e,s),i.keyString.set(r,n)}return i.stringsArray.set(e.strings,n),n},D=["html","svg"],L=new Set,B=(t,e,s)=>{L.add(s);const i=t.querySelectorAll("style"),{length:n}=i;if(0===n)return void window.ShadyCSS.prepareTemplateStyles(e.element,s);const r=document.createElement("style");for(let t=0;t<n;t++){const e=i[t];e.parentNode.removeChild(e),r.textContent+=e.textContent}(t=>{D.forEach(e=>{const s=k.get(q(e,t));void 0!==s&&s.keyString.forEach(t=>{const{element:{content:e}}=t,s=new Set;Array.from(e.querySelectorAll("style")).forEach(t=>{s.add(t)}),z(t,s)})})})(s);const o=e.element.content;!function(t,e,s=null){const{element:{content:i},parts:n}=t;if(null==s)return void i.appendChild(e);const r=document.createTreeWalker(i,U,null,!1);let o=$(n),a=0,l=-1;for(;r.nextNode();)for(l++,r.currentNode===s&&(a=F(e),s.parentNode.insertBefore(e,s));-1!==o&&n[o].index===l;){if(a>0){for(;-1!==o;)n[o].index+=a,o=$(n,o);return}o=$(n,o)}}(e,r,o.firstChild),window.ShadyCSS.prepareTemplateStyles(e.element,s);const a=o.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==a)t.insertBefore(a.cloneNode(!0),t.firstChild);else{o.insertBefore(r,o.firstChild);const t=new Set;t.add(r),z(e,t)}};
const q=(t,e)=>`${t}--${e}`;let I=!0;void 0===window.ShadyCSS?I=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),I=!1);const H=t=>e=>{const s=q(e.type,t);let i=k.get(s);void 0===i&&(i={stringsArray:new WeakMap,keyString:new Map},k.set(s,i));let n=i.stringsArray.get(e.strings);if(void 0!==n)return n;const r=e.strings.join(h);if(void 0===(n=i.keyString.get(r))){const s=e.getTemplateElement();I&&window.ShadyCSS.prepareTemplateDom(s,t),n=new d(e,s),i.keyString.set(r,n)}return i.stringsArray.set(e.strings,n),n},D=["html","svg"],L=new Set,B=(t,e,s)=>{L.add(s);const i=t.querySelectorAll("style"),{length:n}=i;if(0===n)return void window.ShadyCSS.prepareTemplateStyles(e.element,s);const r=document.createElement("style");for(let t=0;t<n;t++){const e=i[t];e.parentNode.removeChild(e),r.textContent+=e.textContent}(t=>{D.forEach(e=>{const s=k.get(q(e,t));void 0!==s&&s.keyString.forEach(t=>{const{element:{content:e}}=t,s=new Set;Array.from(e.querySelectorAll("style")).forEach(t=>{s.add(t)}),z(t,s)})})})(s);const o=e.element.content;!function(t,e,s=null){const{element:{content:i},parts:n}=t;if(null==s)return void i.appendChild(e);const r=document.createTreeWalker(i,U,null,!1);let o=$(n),a=0,l=-1;for(;r.nextNode();)for(l++,r.currentNode===s&&(a=F(e),s.parentNode.insertBefore(e,s));-1!==o&&n[o].index===l;){if(a>0){for(;-1!==o;)n[o].index+=a,o=$(n,o);return}o=$(n,o)}}(e,r,o.firstChild),window.ShadyCSS.prepareTemplateStyles(e.element,s);const a=o.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==a)t.insertBefore(a.cloneNode(!0),t.firstChild);else{o.insertBefore(r,o.firstChild);const t=new Set;t.add(r),z(e,t)}};
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
@ -162,7 +162,7 @@ const st=(t,e)=>"method"!==e.kind||!e.descriptor||"value"in e.descriptor?{kind:"
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
(window.litElementVersions||(window.litElementVersions=[])).push("2.0.1");const ot=t=>t.flat?t.flat(1/0):function t(e,s=[]){for(let i=0,n=e.length;i<n;i++){const n=e[i];Array.isArray(n)?t(n,s):s.push(n)}return s}(t);class at extends et{static finalize(){super.finalize(),this._styles=this.hasOwnProperty(JSCompiler_renameProperty("styles",this))?this._getUniqueStyles():this._styles||[]}static _getUniqueStyles(){const t=this.styles,e=[];if(Array.isArray(t)){ot(t).reduceRight((t,e)=>(t.add(e),t),new Set).forEach(t=>e.unshift(t))}else t&&e.push(t);return e}initialize(){super.initialize(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const t=this.constructor._styles;0!==t.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?rt?this.renderRoot.adoptedStyleSheets=t.map(t=>t.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(t.map(t=>t.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(t){super.update(t);const e=this.render();e instanceof v&&this.constructor.render(e,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(t=>{const e=document.createElement("style");e.textContent=t.cssText,this.renderRoot.appendChild(e)}))}render(){}}at.finalized=!0,at.render=(t,e,s)=>{const i=s.scopeName,n=M.has(e),r=I&&11===e.nodeType&&!!e.host&&t instanceof v,a=r&&!L.has(i),l=a?document.createDocumentFragment():e;if(((t,e,s)=>{let i=M.get(e);void 0===i&&(o(e,e.firstChild),M.set(e,i=new C(Object.assign({templateFactory:V},s))),i.appendInto(e)),i.setValue(t),i.commit()})(t,l,Object.assign({templateFactory:H(i)},s)),a){const t=M.get(l);M.delete(l),t.value instanceof g&&B(l,t.value.template,i),o(e,e.firstChild),e.appendChild(l),M.set(e,t)}!n&&r&&window.ShadyCSS.styleElement(e.host)};const lt=(t,e)=>0!=(t.attributes.supported_features&e);class ct{constructor(t,e){this.hass=t,this.stateObj=e,this._attr=e.attributes,this._feat=this._attr.supported_features}get isFullyOpen(){return void 0!==this._attr.current_position?100===this._attr.current_position:"open"===this.stateObj.state}get isFullyClosed(){return void 0!==this._attr.current_position?0===this._attr.current_position:"closed"===this.stateObj.state}get isFullyOpenTilt(){return 100===this._attr.current_tilt_position}get isFullyClosedTilt(){return 0===this._attr.current_tilt_position}get isOpening(){return"opening"===this.stateObj.state}get isClosing(){return"closing"===this.stateObj.state}get supportsOpen(){return lt(this.stateObj,1)}get supportsClose(){return lt(this.stateObj,2)}get supportsSetPosition(){return lt(this.stateObj,4)}get supportsStop(){return lt(this.stateObj,8)}get supportsOpenTilt(){return lt(this.stateObj,16)}get supportsCloseTilt(){return lt(this.stateObj,32)}get supportsStopTilt(){return lt(this.stateObj,64)}get supportsSetTiltPosition(){return lt(this.stateObj,128)}get isTiltOnly(){const t=this.supportsOpen||this.supportsClose||this.supportsStop;return(this.supportsOpenTilt||this.supportsCloseTilt||this.supportsStopTilt)&&!t}openCover(){this.callService("open_cover")}closeCover(){this.callService("close_cover")}stopCover(){this.callService("stop_cover")}openCoverTilt(){this.callService("open_cover_tilt")}closeCoverTilt(){this.callService("close_cover_tilt")}stopCoverTilt(){this.callService("stop_cover_tilt")}setCoverPosition(t){this.callService("set_cover_position",{position:t})}setCoverTiltPosition(t){this.callService("set_cover_tilt_position",{tilt_position:t})}callService(t,e={}){e.entity_id=this.stateObj.entity_id,this.hass.callService("cover",t,e)}}s.d(e,"StateCardCustomCover",function(){return pt});var ht=function(t,e,s,i){var n,r=arguments.length,o=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,s,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(e,s,o):n(e,s))||o);return r>3&&o&&Object.defineProperty(e,s,o),o};let pt=class extends at{constructor(){super(...arguments),this.inDialog=!1}get stateObj(){return this.hass&&this._config?this.hass.states[this._config.entity]:null}setConfig(t){if(!t||!t.entity)throw new Error("Invalid configuration");this._config=t}get entityObj(){if(this.hass&&this.stateObj)return new ct(this.hass,this.stateObj);throw new Error("Trying to get entityObj before setting hass & config")}static getCardSize(){return 1}stateInfoTemplate(){return R`
(window.litElementVersions||(window.litElementVersions=[])).push("2.0.1");const ot=t=>t.flat?t.flat(1/0):function t(e,s=[]){for(let i=0,n=e.length;i<n;i++){const n=e[i];Array.isArray(n)?t(n,s):s.push(n)}return s}(t);class at extends et{static finalize(){super.finalize(),this._styles=this.hasOwnProperty(JSCompiler_renameProperty("styles",this))?this._getUniqueStyles():this._styles||[]}static _getUniqueStyles(){const t=this.styles,e=[];if(Array.isArray(t)){ot(t).reduceRight((t,e)=>(t.add(e),t),new Set).forEach(t=>e.unshift(t))}else t&&e.push(t);return e}initialize(){super.initialize(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const t=this.constructor._styles;0!==t.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?rt?this.renderRoot.adoptedStyleSheets=t.map(t=>t.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(t.map(t=>t.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(t){super.update(t);const e=this.render();e instanceof v&&this.constructor.render(e,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(t=>{const e=document.createElement("style");e.textContent=t.cssText,this.renderRoot.appendChild(e)}))}render(){}}at.finalized=!0,at.render=(t,e,s)=>{const i=s.scopeName,n=M.has(e),r=I&&11===e.nodeType&&!!e.host&&t instanceof v,a=r&&!L.has(i),l=a?document.createDocumentFragment():e;if(((t,e,s)=>{let i=M.get(e);void 0===i&&(o(e,e.firstChild),M.set(e,i=new C(Object.assign({templateFactory:V},s))),i.appendInto(e)),i.setValue(t),i.commit()})(t,l,Object.assign({templateFactory:H(i)},s)),a){const t=M.get(l);M.delete(l),t.value instanceof g&&B(l,t.value.template,i),o(e,e.firstChild),e.appendChild(l),M.set(e,t)}!n&&r&&window.ShadyCSS.styleElement(e.host)};const lt=(t,e)=>0!=(t.attributes.supported_features&e);class ht{constructor(t,e){this.hass=t,this.stateObj=e,this._attr=e.attributes,this._feat=this._attr.supported_features}get isFullyOpen(){return void 0!==this._attr.current_position?100===this._attr.current_position:"open"===this.stateObj.state}get isFullyClosed(){return void 0!==this._attr.current_position?0===this._attr.current_position:"closed"===this.stateObj.state}get isFullyOpenTilt(){return 100===this._attr.current_tilt_position}get isFullyClosedTilt(){return 0===this._attr.current_tilt_position}get isOpening(){return"opening"===this.stateObj.state}get isClosing(){return"closing"===this.stateObj.state}get supportsOpen(){return lt(this.stateObj,1)}get supportsClose(){return lt(this.stateObj,2)}get supportsSetPosition(){return lt(this.stateObj,4)}get supportsStop(){return lt(this.stateObj,8)}get supportsOpenTilt(){return lt(this.stateObj,16)}get supportsCloseTilt(){return lt(this.stateObj,32)}get supportsStopTilt(){return lt(this.stateObj,64)}get supportsSetTiltPosition(){return lt(this.stateObj,128)}get isTiltOnly(){const t=this.supportsOpen||this.supportsClose||this.supportsStop;return(this.supportsOpenTilt||this.supportsCloseTilt||this.supportsStopTilt)&&!t}openCover(){this.callService("open_cover")}closeCover(){this.callService("close_cover")}stopCover(){this.callService("stop_cover")}openCoverTilt(){this.callService("open_cover_tilt")}closeCoverTilt(){this.callService("close_cover_tilt")}stopCoverTilt(){this.callService("stop_cover_tilt")}setCoverPosition(t){this.callService("set_cover_position",{position:t})}setCoverTiltPosition(t){this.callService("set_cover_tilt_position",{tilt_position:t})}callService(t,e={}){e.entity_id=this.stateObj.entity_id,this.hass.callService("cover",t,e)}}s.d(e,"StateCardCustomCover",function(){return pt});var ct=function(t,e,s,i){var n,r=arguments.length,o=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,s,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(e,s,o):n(e,s))||o);return r>3&&o&&Object.defineProperty(e,s,o),o};let pt=class extends at{constructor(){super(...arguments),this.inDialog=!1}get stateObj(){return this.hass&&this._config?this.hass.states[this._config.entity]:null}setConfig(t){if(!t||!t.entity)throw new Error("Invalid configuration");this._config=t}get entityObj(){if(this.hass&&this.stateObj)return new ht(this.hass,this.stateObj);throw new Error("Trying to get entityObj before setting hass & config")}static getCardSize(){return 1}stateInfoTemplate(){return R`
State info template
`}render(){if(!this._config||!this.hass)return R``;const t=this.entityObj,e=this.hass.states[this._config.entity];return e?R`
<style include="iron-flex iron-flex-alignment"></style>
@ -180,28 +180,28 @@ const st=(t,e)=>"method"!==e.kind||!e.descriptor||"value"in e.descriptor?{kind:"
<hui-generic-entity-row .config="${this._config}" .hass="${this.hass}">
<div class="state">
<paper-icon-button
<ha-icon-button
icon="hass:menu"
@click=${this.onHalfOpenTap}
></paper-icon-button>
<paper-icon-button
></ha-icon-button>
<ha-icon-button
icon="hass:arrow-up"
@click=${this.onOpenTap}
.disabled="${this.computeOpenDisabled(e,this.entityObj)}"
></paper-icon-button>
<paper-icon-button
></ha-icon-button>
<ha-icon-button
icon="hass:stop"
@click=${this.onStopTap}
></paper-icon-button>
<paper-icon-button
></ha-icon-button>
<ha-icon-button
icon="hass:arrow-down"
@click=${this.onCloseTap}
.disabled="${this.computeClosedDisabled(e,t)}"
></paper-icon-button>
></ha-icon-button>
</div>
</hui-generic-entity-row>
`:R`
<hui-warning
>Does not work :(</hui-warning
>
`}computeOpenDisabled(t,e){const s=!0===t.attributes.assumed_state;return(e.isFullyOpen||e.isOpening)&&!s}computeClosedDisabled(t,e){const s=!0===t.attributes.assumed_state;return(e.isFullyClosed||e.isClosing)&&!s}onHalfOpenTap(t){const e=this.hass.states[this._config.entity];t.stopPropagation(),this.entityObj.setCoverPosition(e.attributes.half_position)}onOpenTap(t){t.stopPropagation(),this.entityObj.openCover()}onCloseTap(t){t.stopPropagation(),this.entityObj.closeCover()}onStopTap(t){t.stopPropagation(),this.entityObj.stopCover()}};ht([nt()],pt.prototype,"hass",void 0),ht([nt()],pt.prototype,"_config",void 0),ht([nt()],pt.prototype,"stateObj",null),ht([nt()],pt.prototype,"inDialog",void 0),pt=ht([(t=>e=>"function"==typeof e?((t,e)=>(window.customElements.define(t,e),e))(t,e):((t,e)=>{const{kind:s,elements:i}=e;return{kind:s,elements:i,finisher(e){window.customElements.define(t,e)}}})(t,e))("state-card-custom-cover")],pt)}]);
`}computeOpenDisabled(t,e){const s=!0===t.attributes.assumed_state;return(e.isFullyOpen||e.isOpening)&&!s}computeClosedDisabled(t,e){const s=!0===t.attributes.assumed_state;return(e.isFullyClosed||e.isClosing)&&!s}onHalfOpenTap(t){const e=this.hass.states[this._config.entity];t.stopPropagation(),this.entityObj.setCoverPosition(e.attributes.half_position)}onOpenTap(t){t.stopPropagation(),this.entityObj.openCover()}onCloseTap(t){t.stopPropagation(),this.entityObj.closeCover()}onStopTap(t){t.stopPropagation(),this.entityObj.stopCover()}};ct([nt()],pt.prototype,"hass",void 0),ct([nt()],pt.prototype,"_config",void 0),ct([nt()],pt.prototype,"stateObj",null),ct([nt()],pt.prototype,"inDialog",void 0),pt=ct([(t=>e=>"function"==typeof e?((t,e)=>(window.customElements.define(t,e),e))(t,e):((t,e)=>{const{kind:s,elements:i}=e;return{kind:s,elements:i,finisher(e){window.customElements.define(t,e)}}})(t,e))("state-card-custom-cover")],pt)}]);

View File

@ -84,24 +84,24 @@ export class StateCardCustomCover extends LitElement {
<hui-generic-entity-row .config="${this._config}" .hass="${this.hass}">
<div class="state">
<paper-icon-button
<ha-icon-button
icon="hass:menu"
@click=${this.onHalfOpenTap}
></paper-icon-button>
<paper-icon-button
></ha-icon-button>
<ha-icon-button
icon="hass:arrow-up"
@click=${this.onOpenTap}
.disabled="${this.computeOpenDisabled(stateObj, this.entityObj)}"
></paper-icon-button>
<paper-icon-button
></ha-icon-button>
<ha-icon-button
icon="hass:stop"
@click=${this.onStopTap}
></paper-icon-button>
<paper-icon-button
></ha-icon-button>
<ha-icon-button
icon="hass:arrow-down"
@click=${this.onCloseTap}
.disabled="${this.computeClosedDisabled(stateObj, entityObj)}"
></paper-icon-button>
></ha-icon-button>
</div>
</hui-generic-entity-row>
`;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -12,7 +12,7 @@
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
const i=new WeakMap,n=t=>"function"==typeof t&&i.has(t),r=void 0!==window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,o=(t,e,s=null)=>{for(;e!==s;){const s=e.nextSibling;t.removeChild(e),e=s}},a={},l={},c=`{{lit-${String(Math.random()).slice(2)}}}`,h=`\x3c!--${c}--\x3e`,p=new RegExp(`${c}|${h}`),u="$lit$";class d{constructor(t,e){this.parts=[],this.element=e;const s=[],i=[],n=document.createTreeWalker(e.content,133,null,!1);let r=0,o=-1,a=0;const{strings:l,values:{length:h}}=t;for(;a<h;){const t=n.nextNode();if(null!==t){if(o++,1===t.nodeType){if(t.hasAttributes()){const e=t.attributes,{length:s}=e;let i=0;for(let t=0;t<s;t++)_(e[t].name,u)&&i++;for(;i-- >0;){const e=l[a],s=y.exec(e)[2],i=s.toLowerCase()+u,n=t.getAttribute(i);t.removeAttribute(i);const r=n.split(p);this.parts.push({type:"attribute",index:o,name:s,strings:r}),a+=r.length-1}}"TEMPLATE"===t.tagName&&(i.push(t),n.currentNode=t.content)}else if(3===t.nodeType){const e=t.data;if(e.indexOf(c)>=0){const i=t.parentNode,n=e.split(p),r=n.length-1;for(let e=0;e<r;e++){let s,r=n[e];if(""===r)s=m();else{const t=y.exec(r);null!==t&&_(t[2],u)&&(r=r.slice(0,t.index)+t[1]+t[2].slice(0,-u.length)+t[3]),s=document.createTextNode(r)}i.insertBefore(s,t),this.parts.push({type:"node",index:++o})}""===n[r]?(i.insertBefore(m(),t),s.push(t)):t.data=n[r],a+=r}}else if(8===t.nodeType)if(t.data===c){const e=t.parentNode;null!==t.previousSibling&&o!==r||(o++,e.insertBefore(m(),t)),r=o,this.parts.push({type:"node",index:o}),null===t.nextSibling?t.data="":(s.push(t),o--),a++}else{let e=-1;for(;-1!==(e=t.data.indexOf(c,e+1));)this.parts.push({type:"node",index:-1}),a++}}else n.currentNode=i.pop()}for(const t of s)t.parentNode.removeChild(t)}}const _=(t,e)=>{const s=t.length-e.length;return s>=0&&t.slice(s)===e},f=t=>-1!==t.index,m=()=>document.createComment(""),y=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;
const i=new WeakMap,n=t=>"function"==typeof t&&i.has(t),r=void 0!==window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,o=(t,e,s=null)=>{for(;e!==s;){const s=e.nextSibling;t.removeChild(e),e=s}},a={},l={},h=`{{lit-${String(Math.random()).slice(2)}}}`,c=`\x3c!--${h}--\x3e`,p=new RegExp(`${h}|${c}`),u="$lit$";class d{constructor(t,e){this.parts=[],this.element=e;const s=[],i=[],n=document.createTreeWalker(e.content,133,null,!1);let r=0,o=-1,a=0;const{strings:l,values:{length:c}}=t;for(;a<c;){const t=n.nextNode();if(null!==t){if(o++,1===t.nodeType){if(t.hasAttributes()){const e=t.attributes,{length:s}=e;let i=0;for(let t=0;t<s;t++)_(e[t].name,u)&&i++;for(;i-- >0;){const e=l[a],s=y.exec(e)[2],i=s.toLowerCase()+u,n=t.getAttribute(i);t.removeAttribute(i);const r=n.split(p);this.parts.push({type:"attribute",index:o,name:s,strings:r}),a+=r.length-1}}"TEMPLATE"===t.tagName&&(i.push(t),n.currentNode=t.content)}else if(3===t.nodeType){const e=t.data;if(e.indexOf(h)>=0){const i=t.parentNode,n=e.split(p),r=n.length-1;for(let e=0;e<r;e++){let s,r=n[e];if(""===r)s=m();else{const t=y.exec(r);null!==t&&_(t[2],u)&&(r=r.slice(0,t.index)+t[1]+t[2].slice(0,-u.length)+t[3]),s=document.createTextNode(r)}i.insertBefore(s,t),this.parts.push({type:"node",index:++o})}""===n[r]?(i.insertBefore(m(),t),s.push(t)):t.data=n[r],a+=r}}else if(8===t.nodeType)if(t.data===h){const e=t.parentNode;null!==t.previousSibling&&o!==r||(o++,e.insertBefore(m(),t)),r=o,this.parts.push({type:"node",index:o}),null===t.nextSibling?t.data="":(s.push(t),o--),a++}else{let e=-1;for(;-1!==(e=t.data.indexOf(h,e+1));)this.parts.push({type:"node",index:-1}),a++}}else n.currentNode=i.pop()}for(const t of s)t.parentNode.removeChild(t)}}const _=(t,e)=>{const s=t.length-e.length;return s>=0&&t.slice(s)===e},f=t=>-1!==t.index,m=()=>document.createComment(""),y=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=\/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
@ -39,7 +39,7 @@ class g{constructor(t,e,s){this.__parts=[],this.template=t,this.processor=e,this
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/class v{constructor(t,e,s,i){this.strings=t,this.values=e,this.type=s,this.processor=i}getHTML(){const t=this.strings.length-1;let e="",s=!1;for(let i=0;i<t;i++){const t=this.strings[i],n=t.lastIndexOf("\x3c!--");s=(n>-1||s)&&-1===t.indexOf("--\x3e",n+1);const r=y.exec(t);e+=null===r?t+(s?c:h):t.substr(0,r.index)+r[1]+r[2]+u+r[3]+c}return e+=this.strings[t]}getTemplateElement(){const t=document.createElement("template");return t.innerHTML=this.getHTML(),t}}
*/class v{constructor(t,e,s,i){this.strings=t,this.values=e,this.type=s,this.processor=i}getHTML(){const t=this.strings.length-1;let e="",s=!1;for(let i=0;i<t;i++){const t=this.strings[i],n=t.lastIndexOf("\x3c!--");s=(n>-1||s)&&-1===t.indexOf("--\x3e",n+1);const r=y.exec(t);e+=null===r?t+(s?h:c):t.substr(0,r.index)+r[1]+r[2]+u+r[3]+h}return e+=this.strings[t]}getTemplateElement(){const t=document.createElement("template");return t.innerHTML=this.getHTML(),t}}
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
@ -79,7 +79,7 @@ const S=t=>null===t||!("object"==typeof t||"function"==typeof t),b=t=>Array.isAr
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/function V(t){let e=k.get(t.type);void 0===e&&(e={stringsArray:new WeakMap,keyString:new Map},k.set(t.type,e));let s=e.stringsArray.get(t.strings);if(void 0!==s)return s;const i=t.strings.join(c);return void 0===(s=e.keyString.get(i))&&(s=new d(t,t.getTemplateElement()),e.keyString.set(i,s)),e.stringsArray.set(t.strings,s),s}const k=new Map,M=new WeakMap;
*/function V(t){let e=k.get(t.type);void 0===e&&(e={stringsArray:new WeakMap,keyString:new Map},k.set(t.type,e));let s=e.stringsArray.get(t.strings);if(void 0!==s)return s;const i=t.strings.join(h);return void 0===(s=e.keyString.get(i))&&(s=new d(t,t.getTemplateElement()),e.keyString.set(i,s)),e.stringsArray.set(t.strings,s),s}const k=new Map,M=new WeakMap;
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
@ -106,7 +106,7 @@ const S=t=>null===t||!("object"==typeof t||"function"==typeof t),b=t=>Array.isAr
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.0.0");const R=(t,...e)=>new v(t,e,"html",E),U=133;function z(t,e){const{element:{content:s},parts:i}=t,n=document.createTreeWalker(s,U,null,!1);let r=$(i),o=i[r],a=-1,l=0;const c=[];let h=null;for(;n.nextNode();){a++;const t=n.currentNode;for(t.previousSibling===h&&(h=null),e.has(t)&&(c.push(t),null===h&&(h=t)),null!==h&&l++;void 0!==o&&o.index===a;)o.index=null!==h?-1:o.index-l,o=i[r=$(i,r)]}c.forEach(t=>t.parentNode.removeChild(t))}const F=t=>{let e=11===t.nodeType?0:1;const s=document.createTreeWalker(t,U,null,!1);for(;s.nextNode();)e++;return e},$=(t,e=-1)=>{for(let s=e+1;s<t.length;s++){const e=t[s];if(f(e))return s}return-1};
(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.0.0");const R=(t,...e)=>new v(t,e,"html",E),U=133;function z(t,e){const{element:{content:s},parts:i}=t,n=document.createTreeWalker(s,U,null,!1);let r=$(i),o=i[r],a=-1,l=0;const h=[];let c=null;for(;n.nextNode();){a++;const t=n.currentNode;for(t.previousSibling===c&&(c=null),e.has(t)&&(h.push(t),null===c&&(c=t)),null!==c&&l++;void 0!==o&&o.index===a;)o.index=null!==c?-1:o.index-l,o=i[r=$(i,r)]}h.forEach(t=>t.parentNode.removeChild(t))}const F=t=>{let e=11===t.nodeType?0:1;const s=document.createTreeWalker(t,U,null,!1);for(;s.nextNode();)e++;return e},$=(t,e=-1)=>{for(let s=e+1;s<t.length;s++){const e=t[s];if(f(e))return s}return-1};
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
@ -120,7 +120,7 @@ const S=t=>null===t||!("object"==typeof t||"function"==typeof t),b=t=>Array.isAr
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
const q=(t,e)=>`${t}--${e}`;let I=!0;void 0===window.ShadyCSS?I=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),I=!1);const H=t=>e=>{const s=q(e.type,t);let i=k.get(s);void 0===i&&(i={stringsArray:new WeakMap,keyString:new Map},k.set(s,i));let n=i.stringsArray.get(e.strings);if(void 0!==n)return n;const r=e.strings.join(c);if(void 0===(n=i.keyString.get(r))){const s=e.getTemplateElement();I&&window.ShadyCSS.prepareTemplateDom(s,t),n=new d(e,s),i.keyString.set(r,n)}return i.stringsArray.set(e.strings,n),n},D=["html","svg"],L=new Set,B=(t,e,s)=>{L.add(s);const i=t.querySelectorAll("style"),{length:n}=i;if(0===n)return void window.ShadyCSS.prepareTemplateStyles(e.element,s);const r=document.createElement("style");for(let t=0;t<n;t++){const e=i[t];e.parentNode.removeChild(e),r.textContent+=e.textContent}(t=>{D.forEach(e=>{const s=k.get(q(e,t));void 0!==s&&s.keyString.forEach(t=>{const{element:{content:e}}=t,s=new Set;Array.from(e.querySelectorAll("style")).forEach(t=>{s.add(t)}),z(t,s)})})})(s);const o=e.element.content;!function(t,e,s=null){const{element:{content:i},parts:n}=t;if(null==s)return void i.appendChild(e);const r=document.createTreeWalker(i,U,null,!1);let o=$(n),a=0,l=-1;for(;r.nextNode();)for(l++,r.currentNode===s&&(a=F(e),s.parentNode.insertBefore(e,s));-1!==o&&n[o].index===l;){if(a>0){for(;-1!==o;)n[o].index+=a,o=$(n,o);return}o=$(n,o)}}(e,r,o.firstChild),window.ShadyCSS.prepareTemplateStyles(e.element,s);const a=o.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==a)t.insertBefore(a.cloneNode(!0),t.firstChild);else{o.insertBefore(r,o.firstChild);const t=new Set;t.add(r),z(e,t)}};
const q=(t,e)=>`${t}--${e}`;let I=!0;void 0===window.ShadyCSS?I=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),I=!1);const H=t=>e=>{const s=q(e.type,t);let i=k.get(s);void 0===i&&(i={stringsArray:new WeakMap,keyString:new Map},k.set(s,i));let n=i.stringsArray.get(e.strings);if(void 0!==n)return n;const r=e.strings.join(h);if(void 0===(n=i.keyString.get(r))){const s=e.getTemplateElement();I&&window.ShadyCSS.prepareTemplateDom(s,t),n=new d(e,s),i.keyString.set(r,n)}return i.stringsArray.set(e.strings,n),n},D=["html","svg"],L=new Set,B=(t,e,s)=>{L.add(s);const i=t.querySelectorAll("style"),{length:n}=i;if(0===n)return void window.ShadyCSS.prepareTemplateStyles(e.element,s);const r=document.createElement("style");for(let t=0;t<n;t++){const e=i[t];e.parentNode.removeChild(e),r.textContent+=e.textContent}(t=>{D.forEach(e=>{const s=k.get(q(e,t));void 0!==s&&s.keyString.forEach(t=>{const{element:{content:e}}=t,s=new Set;Array.from(e.querySelectorAll("style")).forEach(t=>{s.add(t)}),z(t,s)})})})(s);const o=e.element.content;!function(t,e,s=null){const{element:{content:i},parts:n}=t;if(null==s)return void i.appendChild(e);const r=document.createTreeWalker(i,U,null,!1);let o=$(n),a=0,l=-1;for(;r.nextNode();)for(l++,r.currentNode===s&&(a=F(e),s.parentNode.insertBefore(e,s));-1!==o&&n[o].index===l;){if(a>0){for(;-1!==o;)n[o].index+=a,o=$(n,o);return}o=$(n,o)}}(e,r,o.firstChild),window.ShadyCSS.prepareTemplateStyles(e.element,s);const a=o.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==a)t.insertBefore(a.cloneNode(!0),t.firstChild);else{o.insertBefore(r,o.firstChild);const t=new Set;t.add(r),z(e,t)}};
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
@ -162,7 +162,7 @@ const st=(t,e)=>"method"!==e.kind||!e.descriptor||"value"in e.descriptor?{kind:"
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
(window.litElementVersions||(window.litElementVersions=[])).push("2.0.1");const ot=t=>t.flat?t.flat(1/0):function t(e,s=[]){for(let i=0,n=e.length;i<n;i++){const n=e[i];Array.isArray(n)?t(n,s):s.push(n)}return s}(t);class at extends et{static finalize(){super.finalize(),this._styles=this.hasOwnProperty(JSCompiler_renameProperty("styles",this))?this._getUniqueStyles():this._styles||[]}static _getUniqueStyles(){const t=this.styles,e=[];if(Array.isArray(t)){ot(t).reduceRight((t,e)=>(t.add(e),t),new Set).forEach(t=>e.unshift(t))}else t&&e.push(t);return e}initialize(){super.initialize(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const t=this.constructor._styles;0!==t.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?rt?this.renderRoot.adoptedStyleSheets=t.map(t=>t.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(t.map(t=>t.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(t){super.update(t);const e=this.render();e instanceof v&&this.constructor.render(e,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(t=>{const e=document.createElement("style");e.textContent=t.cssText,this.renderRoot.appendChild(e)}))}render(){}}at.finalized=!0,at.render=(t,e,s)=>{const i=s.scopeName,n=M.has(e),r=I&&11===e.nodeType&&!!e.host&&t instanceof v,a=r&&!L.has(i),l=a?document.createDocumentFragment():e;if(((t,e,s)=>{let i=M.get(e);void 0===i&&(o(e,e.firstChild),M.set(e,i=new C(Object.assign({templateFactory:V},s))),i.appendInto(e)),i.setValue(t),i.commit()})(t,l,Object.assign({templateFactory:H(i)},s)),a){const t=M.get(l);M.delete(l),t.value instanceof g&&B(l,t.value.template,i),o(e,e.firstChild),e.appendChild(l),M.set(e,t)}!n&&r&&window.ShadyCSS.styleElement(e.host)};const lt=(t,e)=>0!=(t.attributes.supported_features&e);class ct{constructor(t,e){this.hass=t,this.stateObj=e,this._attr=e.attributes,this._feat=this._attr.supported_features}get isFullyOpen(){return void 0!==this._attr.current_position?100===this._attr.current_position:"open"===this.stateObj.state}get isFullyClosed(){return void 0!==this._attr.current_position?0===this._attr.current_position:"closed"===this.stateObj.state}get isFullyOpenTilt(){return 100===this._attr.current_tilt_position}get isFullyClosedTilt(){return 0===this._attr.current_tilt_position}get isOpening(){return"opening"===this.stateObj.state}get isClosing(){return"closing"===this.stateObj.state}get supportsOpen(){return lt(this.stateObj,1)}get supportsClose(){return lt(this.stateObj,2)}get supportsSetPosition(){return lt(this.stateObj,4)}get supportsStop(){return lt(this.stateObj,8)}get supportsOpenTilt(){return lt(this.stateObj,16)}get supportsCloseTilt(){return lt(this.stateObj,32)}get supportsStopTilt(){return lt(this.stateObj,64)}get supportsSetTiltPosition(){return lt(this.stateObj,128)}get isTiltOnly(){const t=this.supportsOpen||this.supportsClose||this.supportsStop;return(this.supportsOpenTilt||this.supportsCloseTilt||this.supportsStopTilt)&&!t}openCover(){this.callService("open_cover")}closeCover(){this.callService("close_cover")}stopCover(){this.callService("stop_cover")}openCoverTilt(){this.callService("open_cover_tilt")}closeCoverTilt(){this.callService("close_cover_tilt")}stopCoverTilt(){this.callService("stop_cover_tilt")}setCoverPosition(t){this.callService("set_cover_position",{position:t})}setCoverTiltPosition(t){this.callService("set_cover_tilt_position",{tilt_position:t})}callService(t,e={}){e.entity_id=this.stateObj.entity_id,this.hass.callService("cover",t,e)}}s.d(e,"StateCardCustomCover",function(){return pt});var ht=function(t,e,s,i){var n,r=arguments.length,o=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,s,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(e,s,o):n(e,s))||o);return r>3&&o&&Object.defineProperty(e,s,o),o};let pt=class extends at{constructor(){super(...arguments),this.inDialog=!1}get stateObj(){return this.hass&&this._config?this.hass.states[this._config.entity]:null}setConfig(t){if(!t||!t.entity)throw new Error("Invalid configuration");this._config=t}get entityObj(){if(this.hass&&this.stateObj)return new ct(this.hass,this.stateObj);throw new Error("Trying to get entityObj before setting hass & config")}static getCardSize(){return 1}stateInfoTemplate(){return R`
(window.litElementVersions||(window.litElementVersions=[])).push("2.0.1");const ot=t=>t.flat?t.flat(1/0):function t(e,s=[]){for(let i=0,n=e.length;i<n;i++){const n=e[i];Array.isArray(n)?t(n,s):s.push(n)}return s}(t);class at extends et{static finalize(){super.finalize(),this._styles=this.hasOwnProperty(JSCompiler_renameProperty("styles",this))?this._getUniqueStyles():this._styles||[]}static _getUniqueStyles(){const t=this.styles,e=[];if(Array.isArray(t)){ot(t).reduceRight((t,e)=>(t.add(e),t),new Set).forEach(t=>e.unshift(t))}else t&&e.push(t);return e}initialize(){super.initialize(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const t=this.constructor._styles;0!==t.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?rt?this.renderRoot.adoptedStyleSheets=t.map(t=>t.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(t.map(t=>t.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(t){super.update(t);const e=this.render();e instanceof v&&this.constructor.render(e,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(t=>{const e=document.createElement("style");e.textContent=t.cssText,this.renderRoot.appendChild(e)}))}render(){}}at.finalized=!0,at.render=(t,e,s)=>{const i=s.scopeName,n=M.has(e),r=I&&11===e.nodeType&&!!e.host&&t instanceof v,a=r&&!L.has(i),l=a?document.createDocumentFragment():e;if(((t,e,s)=>{let i=M.get(e);void 0===i&&(o(e,e.firstChild),M.set(e,i=new C(Object.assign({templateFactory:V},s))),i.appendInto(e)),i.setValue(t),i.commit()})(t,l,Object.assign({templateFactory:H(i)},s)),a){const t=M.get(l);M.delete(l),t.value instanceof g&&B(l,t.value.template,i),o(e,e.firstChild),e.appendChild(l),M.set(e,t)}!n&&r&&window.ShadyCSS.styleElement(e.host)};const lt=(t,e)=>0!=(t.attributes.supported_features&e);class ht{constructor(t,e){this.hass=t,this.stateObj=e,this._attr=e.attributes,this._feat=this._attr.supported_features}get isFullyOpen(){return void 0!==this._attr.current_position?100===this._attr.current_position:"open"===this.stateObj.state}get isFullyClosed(){return void 0!==this._attr.current_position?0===this._attr.current_position:"closed"===this.stateObj.state}get isFullyOpenTilt(){return 100===this._attr.current_tilt_position}get isFullyClosedTilt(){return 0===this._attr.current_tilt_position}get isOpening(){return"opening"===this.stateObj.state}get isClosing(){return"closing"===this.stateObj.state}get supportsOpen(){return lt(this.stateObj,1)}get supportsClose(){return lt(this.stateObj,2)}get supportsSetPosition(){return lt(this.stateObj,4)}get supportsStop(){return lt(this.stateObj,8)}get supportsOpenTilt(){return lt(this.stateObj,16)}get supportsCloseTilt(){return lt(this.stateObj,32)}get supportsStopTilt(){return lt(this.stateObj,64)}get supportsSetTiltPosition(){return lt(this.stateObj,128)}get isTiltOnly(){const t=this.supportsOpen||this.supportsClose||this.supportsStop;return(this.supportsOpenTilt||this.supportsCloseTilt||this.supportsStopTilt)&&!t}openCover(){this.callService("open_cover")}closeCover(){this.callService("close_cover")}stopCover(){this.callService("stop_cover")}openCoverTilt(){this.callService("open_cover_tilt")}closeCoverTilt(){this.callService("close_cover_tilt")}stopCoverTilt(){this.callService("stop_cover_tilt")}setCoverPosition(t){this.callService("set_cover_position",{position:t})}setCoverTiltPosition(t){this.callService("set_cover_tilt_position",{tilt_position:t})}callService(t,e={}){e.entity_id=this.stateObj.entity_id,this.hass.callService("cover",t,e)}}s.d(e,"StateCardCustomCover",function(){return pt});var ct=function(t,e,s,i){var n,r=arguments.length,o=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,s,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(e,s,o):n(e,s))||o);return r>3&&o&&Object.defineProperty(e,s,o),o};let pt=class extends at{constructor(){super(...arguments),this.inDialog=!1}get stateObj(){return this.hass&&this._config?this.hass.states[this._config.entity]:null}setConfig(t){if(!t||!t.entity)throw new Error("Invalid configuration");this._config=t}get entityObj(){if(this.hass&&this.stateObj)return new ht(this.hass,this.stateObj);throw new Error("Trying to get entityObj before setting hass & config")}static getCardSize(){return 1}stateInfoTemplate(){return R`
State info template
`}render(){if(!this._config||!this.hass)return R``;const t=this.entityObj,e=this.hass.states[this._config.entity];return e?R`
<style include="iron-flex iron-flex-alignment"></style>
@ -180,28 +180,28 @@ const st=(t,e)=>"method"!==e.kind||!e.descriptor||"value"in e.descriptor?{kind:"
<hui-generic-entity-row .config="${this._config}" .hass="${this.hass}">
<div class="state">
<paper-icon-button
<ha-icon-button
icon="hass:menu"
@click=${this.onHalfOpenTap}
></paper-icon-button>
<paper-icon-button
></ha-icon-button>
<ha-icon-button
icon="hass:arrow-up"
@click=${this.onOpenTap}
.disabled="${this.computeOpenDisabled(e,this.entityObj)}"
></paper-icon-button>
<paper-icon-button
></ha-icon-button>
<ha-icon-button
icon="hass:stop"
@click=${this.onStopTap}
></paper-icon-button>
<paper-icon-button
></ha-icon-button>
<ha-icon-button
icon="hass:arrow-down"
@click=${this.onCloseTap}
.disabled="${this.computeClosedDisabled(e,t)}"
></paper-icon-button>
></ha-icon-button>
</div>
</hui-generic-entity-row>
`:R`
<hui-warning
>Does not work :(</hui-warning
>
`}computeOpenDisabled(t,e){const s=!0===t.attributes.assumed_state;return(e.isFullyOpen||e.isOpening)&&!s}computeClosedDisabled(t,e){const s=!0===t.attributes.assumed_state;return(e.isFullyClosed||e.isClosing)&&!s}onHalfOpenTap(t){const e=this.hass.states[this._config.entity];t.stopPropagation(),this.entityObj.setCoverPosition(e.attributes.half_position)}onOpenTap(t){t.stopPropagation(),this.entityObj.openCover()}onCloseTap(t){t.stopPropagation(),this.entityObj.closeCover()}onStopTap(t){t.stopPropagation(),this.entityObj.stopCover()}};ht([nt()],pt.prototype,"hass",void 0),ht([nt()],pt.prototype,"_config",void 0),ht([nt()],pt.prototype,"stateObj",null),ht([nt()],pt.prototype,"inDialog",void 0),pt=ht([(t=>e=>"function"==typeof e?((t,e)=>(window.customElements.define(t,e),e))(t,e):((t,e)=>{const{kind:s,elements:i}=e;return{kind:s,elements:i,finisher(e){window.customElements.define(t,e)}}})(t,e))("state-card-custom-cover")],pt)}]);
`}computeOpenDisabled(t,e){const s=!0===t.attributes.assumed_state;return(e.isFullyOpen||e.isOpening)&&!s}computeClosedDisabled(t,e){const s=!0===t.attributes.assumed_state;return(e.isFullyClosed||e.isClosing)&&!s}onHalfOpenTap(t){const e=this.hass.states[this._config.entity];t.stopPropagation(),this.entityObj.setCoverPosition(e.attributes.half_position)}onOpenTap(t){t.stopPropagation(),this.entityObj.openCover()}onCloseTap(t){t.stopPropagation(),this.entityObj.closeCover()}onStopTap(t){t.stopPropagation(),this.entityObj.stopCover()}};ct([nt()],pt.prototype,"hass",void 0),ct([nt()],pt.prototype,"_config",void 0),ct([nt()],pt.prototype,"stateObj",null),ct([nt()],pt.prototype,"inDialog",void 0),pt=ct([(t=>e=>"function"==typeof e?((t,e)=>(window.customElements.define(t,e),e))(t,e):((t,e)=>{const{kind:s,elements:i}=e;return{kind:s,elements:i,finisher(e){window.customElements.define(t,e)}}})(t,e))("state-card-custom-cover")],pt)}]);