- ${"html"===s.type?s:ht(s)}
+ ${s?P`
+
+ ${this._unsafeHTMLorNot(s)}
`:""}
- ${l&&!d?L`
-
- ${"html"===l.type?l:ht(l)}
+ ${l&&!d?P`
+
+ ${this._unsafeHTMLorNot(l)}
`:""}
${d||""} ${this._buildCustomFields(t,e)}
- `}_getIconHtml(t,e,i){const n=this._buildIcon(t,e),r=this._buildEntityPicture(t,e),s=this._buildStyleGeneric(t,e,"entity_picture"),a=this._buildStyleGeneric(t,e,"icon"),o=this._buildStyleGeneric(t,e,"img_cell"),l=this._buildStyleGeneric(t,e,"card"),c=Object.assign({color:i,width:this._config.size,position:this._config.aspect_ratio||l.height?"absolute":"relative"},a),h=Object.assign(Object.assign({},c),s),u=this._buildLiveStream(h);return n||r?L`
-
- ${!n||r||u?"":L`
-
+ ${!d||r||u?"":P`
+ null!=t?t:I)(null==t?void 0:t.state)}
+ style=${gt(c)}
.icon="${n}"
id="icon"
?rotating=${this._rotate(e)}
- >
+ >
`}
${u||""}
- ${r&&!u?L`
+ ${r&&!u?P`
`:""}
- `:void 0}_buildLiveStream(t){return this._config.show_live_stream&&this._config.entity&&"camera"===Me(this._config.entity)?L`
+ `}}_buildLiveStream(t){return this._config.show_live_stream&&this._config.entity&&"camera"===ee(this._config.entity)?P`
- `:void 0}_configFromLLTemplates(t,e){const i=e.template;if(!i)return e;let n,r={};const s=i&&Array.isArray(i)?i:[i];return null==s||s.forEach((e=>{var i;if(!(null===(i=t.config.button_card_templates)||void 0===i?void 0:i[e]))throw new Error(`Button-card template '${e}' is missing!`);const s=this._configFromLLTemplates(t,t.config.button_card_templates[e]);r=Pe(r,s),n=Ae(n,s.state)})),r=Pe(r,e),r.state=Ae(n,e.state),r}setConfig(t){if(!t)throw new Error("Invalid configuration");this._cards={},this._cardsConfig={};const e=function(){let t=document.querySelector("home-assistant");if(t=t&&t.shadowRoot,t=t&&t.querySelector("home-assistant-main"),t=t&&t.shadowRoot,t=t&&t.querySelector("app-drawer-layout partial-panel-resolver, ha-drawer partial-panel-resolver"),t=t&&t.shadowRoot||t,t=t&&t.querySelector("ha-panel-lovelace"),t=t&&t.shadowRoot,t=t&&t.querySelector("hui-root"),t){const e=t.lovelace;return e.current_view=t.___curView,e}return null}()||function(){let t=document.querySelector("hc-main");if(t=t&&t.shadowRoot,t=t&&t.querySelector("hc-lovelace"),t=t&&t.shadowRoot,t=t&&(t.querySelector("hui-view")||t.querySelector("hui-panel-view")),t){const e=t.lovelace;return e.current_view=t.___curView,e}return null}();let i=Xe(t);i=this._configFromLLTemplates(e,i),this._config=Object.assign(Object.assign({type:"custom:button-card",group_expand:!1,hold_action:{action:"none"},double_tap_action:{action:"none"},layout:"vertical",size:"40%",color_type:"icon",show_name:!0,show_state:!1,show_icon:!0,show_units:!0,show_label:!1,show_entity_picture:!1,show_live_stream:!1,card_size:3},i),{default_color:"DUMMY",color_off:"DUMMY",color_on:"DUMMY",lock:Object.assign({enabled:!1,duration:5,unlock:"tap"},i.lock)}),this._config.entity&&qt.has(Me(this._config.entity))?this._config=Object.assign({tap_action:{action:"toggle"}},this._config):this._config=Object.assign({tap_action:{action:"more-info"}},this._config),this._config.default_color="var(--primary-text-color)","icon"!==this._config.color_type?this._config.color_off="var(--card-background-color)":this._config.color_off="var(--paper-item-icon-color)",this._config.color_on="var(--paper-item-icon-active-color)";const n=JSON.stringify(this._config);if(this._entities=[],Array.isArray(this._config.triggers_update)?this._entities=[...this._config.triggers_update]:"string"==typeof this._config.triggers_update&&"all"!==this._config.triggers_update&&this._entities.push(this._config.triggers_update),"all"!==this._config.triggers_update){const t=new RegExp(/states\[\s*('|\\")([a-zA-Z0-9_]+\.[a-zA-Z0-9_]+)\1\s*\]/,"gm"),e=new RegExp(/states\[\s*('|\\")([a-zA-Z0-9_]+\.[a-zA-Z0-9_]+)\1\s*\]/,"m"),i=n.match(t);null==i||i.forEach((t=>{const i=t.match(e);i&&!this._entities.includes(i[2])&&this._entities.push(i[2])}))}this._config.entity&&!this._entities.includes(this._config.entity)&&this._entities.push(this._config.entity),this._expandTriggerGroups();const r=new RegExp("\\[\\[\\[.*\\]\\]\\]","m");this._hasTemplate=!("all"!==this._config.triggers_update||!n.match(r)),this._initial_setup_complete||this._initConnected()}_loopGroup(t){t&&t.forEach((t=>{var e,i;(null===(e=this._hass)||void 0===e?void 0:e.states[t])&&("group"===Me(t)&&(null===(i=this._hass.states[t].attributes)||void 0===i?void 0:i.entity_id)?this._loopGroup(this._hass.states[t].attributes.entity_id):this._entities.includes(t)||this._entities.push(t))}))}_expandTriggerGroups(){var t;this._hass&&(null===(t=this._config)||void 0===t?void 0:t.group_expand)&&this._entities&&this._entities.forEach((t=>{var e,i;"group"===Me(t)&&this._loopGroup(null===(i=null===(e=this._hass)||void 0===e?void 0:e.states[t].attributes)||void 0===i?void 0:i.entity_id)}))}getCardSize(){var t;return(null===(t=this._config)||void 0===t?void 0:t.card_size)||3}_evalActions(t,e){const i=Xe(t),n=t=>t?(Object.keys(t).forEach((e=>{"object"==typeof t[e]?t[e]=n(t[e]):t[e]=this._getTemplateOrValue(this._stateObj,t[e])})),t):t;return i[e]=n(i[e]),!i[e].confirmation&&i.confirmation&&(i[e].confirmation=n(i.confirmation)),i}handleRippleActivate(t){this._ripple.then((e=>e&&e.startPress&&this._rippleHandlers.startPress(t)))}handleRippleDeactivate(){this._ripple.then((t=>t&&t.endPress&&this._rippleHandlers.endPress()))}handleRippleFocus(){this._ripple.then((t=>t&&t.startFocus&&this._rippleHandlers.startFocus()))}handleRippleBlur(){this._ripple.then((t=>t&&t.endFocus&&this._rippleHandlers.endFocus()))}_handleAction(t){var e;if(null===(e=t.detail)||void 0===e?void 0:e.action)switch(t.detail.action){case"tap":this._handleTap();break;case"hold":this._handleHold();break;case"double_tap":this._handleDblTap()}}_handleTap(){const t=this._config;t&&Kt(this,this._hass,this._evalActions(t,"tap_action"),!1,!1)}_handleHold(){const t=this._config;t&&Kt(this,this._hass,this._evalActions(t,"hold_action"),!0,!1)}_handleDblTap(){const t=this._config;t&&Kt(this,this._hass,this._evalActions(t,"double_tap_action"),!1,!0)}_handleUnlockType(t){const e=this._config;e&&e.lock.unlock===t.detail.action&&this._handleLock()}_handleLock(){const t=this.shadowRoot.getElementById("lock");if(!t)return;if(this._config.lock.exemptions){if(!this._hass.user.name||!this._hass.user.id)return;let e=!1;if(this._config.lock.exemptions.forEach((t=>{(!e&&t.user===this._hass.user.id||t.username===this._hass.user.name)&&(e=!0)})),!e)return t.classList.add("invalid"),void window.setTimeout((()=>{t&&t.classList.remove("invalid")}),3e3)}const e=this.shadowRoot.getElementById("overlay");if(e.style.setProperty("pointer-events","none"),t){const e=document.createAttribute("icon");e.value="mdi:lock-open-outline",t.attributes.setNamedItem(e),t.classList.add("hidden")}window.setTimeout((()=>{if(e.style.setProperty("pointer-events",""),t){t.classList.remove("hidden");const e=document.createAttribute("icon");e.value="mdi:lock-outline",t.attributes.setNamedItem(e)}}),1e3*this._config.lock.duration)}_stopPropagation(t){t.stopPropagation()}};var ei,ii,ni;t([K()],ti.prototype,"_hass",void 0),t([K()],ti.prototype,"_config",void 0),t([K()],ti.prototype,"_timeRemaining",void 0),t([(ei="mwc-ripple",(t,e)=>{const i={async get(){return await this.updateComplete,this.renderRoot.querySelector(ei)},enumerable:!0,configurable:!0};return void 0!==e?Q(i,t,e):tt(i,t)})],ti.prototype,"_ripple",void 0),t([(ii={passive:!0},(t,e)=>void 0!==e?((t,e,i)=>{Object.assign(e[i],t)})(ii,t,e):((t,e)=>Object.assign(Object.assign({},e),{finisher(i){Object.assign(i.prototype[e.key],t)}}))(ii,t))],ti.prototype,"handleRippleActivate",null),ti=t([(ni="button-card",t=>"function"==typeof t?((t,e)=>(window.customElements.define(t,e),e))(ni,t):((t,e)=>{const{kind:i,elements:n}=e;return{kind:i,elements:n,finisher(e){window.customElements.define(t,e)}}})(ni,t))],ti);
+ `:void 0}_configFromLLTemplates(t,e){const i=e.template;if(!i)return e;let n,r={};const s=i&&Array.isArray(i)?i:[i];return null==s||s.forEach((e=>{var i;if(!(null===(i=t.config.button_card_templates)||void 0===i?void 0:i[e]))throw new Error(`Button-card template '${e}' is missing!`);const s=this._configFromLLTemplates(t,t.config.button_card_templates[e]);r=ne(r,s),n=re(n,s.state)})),r=ne(r,e),r.state=re(n,e.state),r}setConfig(t){if(!t)throw new Error("Invalid configuration");this._initialSetupComplete&&(this._initialSetupComplete=!1),this._cards={},this._cardsConfig={};const e=function(){let t=document.querySelector("home-assistant");if(t=t&&t.shadowRoot,t=t&&t.querySelector("home-assistant-main"),t=t&&t.shadowRoot,t=t&&t.querySelector("app-drawer-layout partial-panel-resolver, ha-drawer partial-panel-resolver"),t=t&&t.shadowRoot||t,t=t&&t.querySelector("ha-panel-lovelace"),t=t&&t.shadowRoot,t=t&&t.querySelector("hui-root"),t){const e=t.lovelace;return e.current_view=t.___curView,e}return null}()||function(){let t=document.querySelector("hc-main");if(t=t&&t.shadowRoot,t=t&&t.querySelector("hc-lovelace"),t=t&&t.shadowRoot,t=t&&(t.querySelector("hui-view")||t.querySelector("hui-panel-view")),t){const e=t.lovelace;return e.current_view=t.___curView,e}return null}();let i=$i(t);i=this._configFromLLTemplates(e,i),this._config=Object.assign(Object.assign({type:"custom:button-card",group_expand:!1,hold_action:{action:"none"},double_tap_action:{action:"none"},layout:"vertical",size:"40%",color_type:"icon",show_name:!0,show_state:!1,show_icon:!0,show_units:!0,show_label:!1,show_entity_picture:!1,show_live_stream:!1,card_size:3},i),{lock:Object.assign({enabled:!1,duration:5,unlock:"tap"},i.lock)}),this._initialSetupComplete||this._finishSetup()}_loopGroup(t){t&&t.forEach((t=>{var e,i;(null===(e=this._hass)||void 0===e?void 0:e.states[t])&&((null===(i=this._hass.states[t].attributes)||void 0===i?void 0:i.entity_id)?this._loopGroup(this._hass.states[t].attributes.entity_id):this._entities.includes(t)||this._entities.push(t))}))}_expandTriggerGroups(){var t;this._hass&&(null===(t=this._config)||void 0===t?void 0:t.group_expand)&&this._entities&&this._entities.forEach((t=>{var e,i,n,r,s;(null===(n=null===(i=null===(e=this._hass)||void 0===e?void 0:e.states[t])||void 0===i?void 0:i.attributes)||void 0===n?void 0:n.entity_id)&&this._loopGroup(null===(s=null===(r=this._hass)||void 0===r?void 0:r.states[t].attributes)||void 0===s?void 0:s.entity_id)}))}getCardSize(){var t;return(null===(t=this._config)||void 0===t?void 0:t.card_size)||3}_evalActions(t,e){var i,n,r,s,o;const a=$i(t),l=t=>t?(Object.keys(t).forEach((e=>{"object"==typeof t[e]?t[e]=l(t[e]):t[e]=this._getTemplateOrValue(this._stateObj,t[e])})),t):t;return"entity"===(null===(n=null===(i=a[e])||void 0===i?void 0:i.service_data)||void 0===n?void 0:n.entity_id)&&(a[e].service_data.entity_id=t.entity),"entity"===(null===(s=null===(r=a[e])||void 0===r?void 0:r.data)||void 0===s?void 0:s.entity_id)&&(a[e].data.entity_id=t.entity),a[e]=l(a[e]),!a[e].confirmation&&a.confirmation&&(a[e].confirmation=l(a.confirmation)),(null===(o=a[e])||void 0===o?void 0:o.entity)&&(a.entity=a[e].entity),a}handleRippleActivate(t){this._ripple.then((e=>e&&"function"==typeof e.startPress&&this._rippleHandlers.startPress(t)))}handleRippleDeactivate(){this._ripple.then((t=>t&&"function"==typeof t.endPress&&this._rippleHandlers.endPress()))}handleRippleFocus(){this._ripple.then((t=>t&&"function"==typeof t.startFocus&&this._rippleHandlers.startFocus()))}handleRippleBlur(){this._ripple.then((t=>t&&"function"==typeof t.endFocus&&this._rippleHandlers.endFocus()))}_handleAction(t){var e;if(null===(e=t.detail)||void 0===e?void 0:e.action)switch(t.detail.action){case"tap":case"hold":case"double_tap":const e=this._config;if(!e)return;const i=t.detail.action,n=this._evalActions(e,`${i}_action`);(async(t,e,i,n)=>{yt(t,"hass-action",{config:i,action:n})})(this,this._hass,n,i)}}_handleUnlockType(t){const e=this._config;e&&e.lock.unlock===t.detail.action&&this._handleLock()}_handleLock(){var t;const e=this.shadowRoot.getElementById("lock");if(!e)return;if(this._config.lock.exemptions){if(!(null===(t=this._hass.user)||void 0===t?void 0:t.name)||!this._hass.user.id)return;let i=!1;if(this._config.lock.exemptions.forEach((t=>{var e,n;(!i&&t.user===(null===(e=this._hass.user)||void 0===e?void 0:e.id)||t.username===(null===(n=this._hass.user)||void 0===n?void 0:n.name))&&(i=!0)})),!i)return e.classList.add("invalid"),void window.setTimeout((()=>{e&&e.classList.remove("invalid")}),3e3)}const i=this.shadowRoot.getElementById("overlay");if(i.style.setProperty("pointer-events","none"),e){const t=document.createAttribute("icon");t.value="mdi:lock-open-outline",e.attributes.setNamedItem(t),e.classList.add("hidden")}window.setTimeout((()=>{if(i.style.setProperty("pointer-events",""),e){e.classList.remove("hidden");const t=document.createAttribute("icon");t.value="mdi:lock-outline",e.attributes.setNamedItem(t)}}),1e3*this._config.lock.duration)}_stopPropagation(t){t.stopPropagation()}};t([ot()],Ti.prototype,"_hass",void 0),t([ot()],Ti.prototype,"_config",void 0),t([ot()],Ti.prototype,"_timeRemaining",void 0),t([function(t){return at({descriptor:e=>({async get(){var e;return await this.updateComplete,null===(e=this.renderRoot)||void 0===e?void 0:e.querySelector(t)},enumerable:!0,configurable:!0})})}("mwc-ripple")],Ti.prototype,"_ripple",void 0),t([function(t){return at({finisher:(e,i)=>{Object.assign(e.prototype[i],t)}})}({passive:!0})],Ti.prototype,"handleRippleActivate",null),Ti=t([(t=>e=>"function"==typeof e?((t,e)=>(customElements.define(t,e),e))(t,e):((t,e)=>{const{kind:i,elements:n}=e;return{kind:i,elements:n,finisher(e){customElements.define(t,e)}}})(t,e))("button-card")],Ti);
From 2644fa89979f45c2ad7d67fd78a06637cefd6bc6 Mon Sep 17 00:00:00 2001
From: basbruss <68892092+basbruss@users.noreply.github.com>
Date: Thu, 2 Nov 2023 07:18:03 +0100
Subject: [PATCH 8/8] Fix 2023.11.0
`ui.duration.hour` key deleted in frontend
---
.../lovelace/translations/default.yaml | 20 -------------------
1 file changed, 20 deletions(-)
diff --git a/custom_components/ui_lovelace_minimalist/lovelace/translations/default.yaml b/custom_components/ui_lovelace_minimalist/lovelace/translations/default.yaml
index d407d806e..9a56649b0 100644
--- a/custom_components/ui_lovelace_minimalist/lovelace/translations/default.yaml
+++ b/custom_components/ui_lovelace_minimalist/lovelace/translations/default.yaml
@@ -22,26 +22,6 @@ ulm_translation_engine:
return (!not_active.includes(entity.state) && !containsNumbers(entity.state))
}
]]]
- ulm_translation_hour: >
- [[[
- var number = hass.resources[hass['language']]["ui.duration.hour"];
- var matches = number.match(/[^{\}]+(?=})/g);
- var hour = "Hour";
- if (matches) {
- var hour = matches[1];
- }
- return(hour);
- ]]]
- ulm_translation_hours: >
- [[[
- var number = hass.resources[hass['language']]["ui.duration.hour"];
- var matches = number.match(/[^{\}]+(?=})/g);
- var hour = "Hours";
- if (matches) {
- var hour = matches[2];
- }
- return(hour);
- ]]]
ulm_translation_off: "[[[ return hass.resources[hass['language']]['state.default.off']; ]]]"
ulm_translation_on: "[[[ return hass.resources[hass['language']]['state.default.on']; ]]]"
ulm_translation_state: >