From 0195b9f897a4c90f4149323d5178483bcd798d7e Mon Sep 17 00:00:00 2001 From: Raman Gupta <7243222+raman325@users.noreply.github.com> Date: Mon, 1 Apr 2024 03:29:27 -0400 Subject: [PATCH] Small tweaks to UI too --- .../lock_code_manager/binary_sensor.py | 14 +- custom_components/lock_code_manager/entity.py | 9 +- custom_components/lock_code_manager/event.py | 2 - .../lock_code_manager/icons.json | 34 +++++ custom_components/lock_code_manager/sensor.py | 1 - .../lock_code_manager/services.yaml | 6 - .../lock_code_manager/strings.json | 35 +++++ .../lock_code_manager/translations/en.json | 35 +++++ .../www/lock-code-manager-strategy.js | 2 +- ts/generate-view.ts | 137 +++++++++++++----- ts/types.ts | 11 +- ts/util.ts | 3 + ts/view-strategy.ts | 3 +- 13 files changed, 224 insertions(+), 68 deletions(-) create mode 100644 custom_components/lock_code_manager/icons.json create mode 100644 ts/util.ts diff --git a/custom_components/lock_code_manager/binary_sensor.py b/custom_components/lock_code_manager/binary_sensor.py index 4cda5c40..3d2e917d 100644 --- a/custom_components/lock_code_manager/binary_sensor.py +++ b/custom_components/lock_code_manager/binary_sensor.py @@ -256,18 +256,8 @@ def __init__( f"{self._get_uid(ATTR_CODE)}|{lock_entity_id}" ) self._lock = asyncio.Lock() - - key_name = ATTR_IN_SYNC.replace("_", " ") - self._attr_name: str | None = f"{super()._attr_name} {key_name}" self._attr_should_poll = True - @property - def icon(self) -> str | None: - """Return icon.""" - if self.is_on: - return "mdi:sync" - return "mdi:sync-off" - @property def available(self) -> bool: """Return whether binary sensor is available or not.""" @@ -356,6 +346,8 @@ async def _update_state( self.lock.lock.entity_id, self.slot_num, ) + elif self._attr_is_on: + return else: self._attr_is_on = True elif self._get_entity_state(ATTR_ACTIVE) == STATE_OFF: @@ -370,6 +362,8 @@ async def _update_state( self.lock.lock.entity_id, self.slot_num, ) + elif self._attr_is_on: + return else: self._attr_is_on = True diff --git a/custom_components/lock_code_manager/entity.py b/custom_components/lock_code_manager/entity.py index 79d82bdc..dc6b8196 100644 --- a/custom_components/lock_code_manager/entity.py +++ b/custom_components/lock_code_manager/entity.py @@ -69,11 +69,7 @@ def __init__( self._uid_cache: dict[str, str] = {} self._unsub_initial_state: CALLBACK_TYPE | None = None - key_parts = key.lower().split("_") - try: - key_parts[key_parts.index("pin")] = "PIN" - except ValueError: - pass + self._attr_translation_key = key self._attr_device_info = DeviceInfo( identifiers={(DOMAIN, f"{self.entry_id}|{slot_num}")}, @@ -83,7 +79,6 @@ def __init__( via_device=(DOMAIN, self.entry_id), ) - self._attr_name: str | None = " ".join(key_parts) self._attr_unique_id = f"{self.base_unique_id}|{slot_num}|{key}" self._attr_extra_state_attributes: dict[str, int | list[str]] = { ATTR_CODE_SLOT: int(slot_num) @@ -370,8 +365,8 @@ def __init__( connections=lock.device_entry.connections, identifiers=lock.device_entry.identifiers, ) - self._attr_name = f"Code slot {slot_num}" + self._attr_translation_placeholders = {"slot_num": slot_num} self._attr_unique_id = ( f"{self.base_unique_id}|{slot_num}|{self.key}|{lock.lock.entity_id}" ) diff --git a/custom_components/lock_code_manager/event.py b/custom_components/lock_code_manager/event.py index 220a23c3..d1b3822c 100644 --- a/custom_components/lock_code_manager/event.py +++ b/custom_components/lock_code_manager/event.py @@ -49,7 +49,6 @@ class LockCodeManagerCodeSlotEventEntity(BaseLockCodeManagerEntity, EventEntity) _attr_entity_category = None _attr_event_types = [EVENT_PIN_USED] - _attr_icon = "mdi:gesture-tap" _attr_translation_key = EVENT_PIN_USED def __init__( @@ -64,7 +63,6 @@ def __init__( BaseLockCodeManagerEntity.__init__( self, hass, ent_reg, config_entry, slot_num, key ) - self._attr_name = None @callback def _handle_event(self, event: Event) -> None: diff --git a/custom_components/lock_code_manager/icons.json b/custom_components/lock_code_manager/icons.json new file mode 100644 index 00000000..f78c8e69 --- /dev/null +++ b/custom_components/lock_code_manager/icons.json @@ -0,0 +1,34 @@ +{ + "entity": { + "binary_sensor": { + "in_sync": { + "default": "mdi:sync-alert", + "state": { + "off": "mdi:sync-off", + "on": "mdi:sync" + } + } + }, + "event": { + "pin_used": { + "default": "mdi:gesture-tap" + } + }, + "sensor": { + "code": { + "default": "mdi:lock-smart" + } + }, + "text": { + "name": { + "default": "mdi:rename" + }, + "pin": { + "default": "mdi:form-textbox-password" + } + } + }, + "services": { + "hard_refresh_usercodes": "mdi:refresh" + } +} diff --git a/custom_components/lock_code_manager/sensor.py b/custom_components/lock_code_manager/sensor.py index 9b05149c..f3abc85f 100644 --- a/custom_components/lock_code_manager/sensor.py +++ b/custom_components/lock_code_manager/sensor.py @@ -63,7 +63,6 @@ class LockCodeManagerCodeSlotSensorEntity( """Code slot sensor entity for lock code manager.""" _attr_entity_category = EntityCategory.DIAGNOSTIC - _attr_icon = "mdi:lock-smart" def __init__( self, diff --git a/custom_components/lock_code_manager/services.yaml b/custom_components/lock_code_manager/services.yaml index fef0a01a..5cf96c82 100644 --- a/custom_components/lock_code_manager/services.yaml +++ b/custom_components/lock_code_manager/services.yaml @@ -1,11 +1,5 @@ --- hard_refresh_usercodes: - name: Hard Refresh Usercodes - description: > - If Lock Code Manager supports the lock's integration, and the lock's - integration supports it, this will query the lock for all usercodes. This - is potentially useful for integrations that cache data from the lock and a - usercode(s) is configured outside of Home Assistant. target: entity: domain: lock diff --git a/custom_components/lock_code_manager/strings.json b/custom_components/lock_code_manager/strings.json index bc858778..eb60e43a 100644 --- a/custom_components/lock_code_manager/strings.json +++ b/custom_components/lock_code_manager/strings.json @@ -62,8 +62,17 @@ } }, "entity": { + "binary_sensor": { + "active": { + "name": "Code slot {slot_num} active" + }, + "in_sync": { + "name": "Code slot {slot_num} in sync" + } + }, "event": { "pin_used": { + "name": "PIN last used", "state_attributes": { "event_type": { "state": { @@ -72,6 +81,32 @@ } } } + }, + "number": { + "number_of_uses": { + "name": "number of uses" + + } + }, + "sensor": { + "code": { + "name": "Code slot {slot_num} code" + + } + }, + "switch": { + "enabled": { + "name": "enabled" + + } + }, + "text": { + "name": { + "name": "name" + }, + "pin": { + "name": "PIN" + } } }, "options": { diff --git a/custom_components/lock_code_manager/translations/en.json b/custom_components/lock_code_manager/translations/en.json index bc858778..eb60e43a 100644 --- a/custom_components/lock_code_manager/translations/en.json +++ b/custom_components/lock_code_manager/translations/en.json @@ -62,8 +62,17 @@ } }, "entity": { + "binary_sensor": { + "active": { + "name": "Code slot {slot_num} active" + }, + "in_sync": { + "name": "Code slot {slot_num} in sync" + } + }, "event": { "pin_used": { + "name": "PIN last used", "state_attributes": { "event_type": { "state": { @@ -72,6 +81,32 @@ } } } + }, + "number": { + "number_of_uses": { + "name": "number of uses" + + } + }, + "sensor": { + "code": { + "name": "Code slot {slot_num} code" + + } + }, + "switch": { + "enabled": { + "name": "enabled" + + } + }, + "text": { + "name": { + "name": "name" + }, + "pin": { + "name": "PIN" + } } }, "options": { diff --git a/custom_components/lock_code_manager/www/lock-code-manager-strategy.js b/custom_components/lock_code_manager/www/lock-code-manager-strategy.js index b859c183..30c3cc95 100644 --- a/custom_components/lock_code_manager/www/lock-code-manager-strategy.js +++ b/custom_components/lock_code_manager/www/lock-code-manager-strategy.js @@ -1 +1 @@ -var t,e,n,r,i,o;function a(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function s(t){for(var e=1;e=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=r.call(a,"catchLoc"),l=r.call(a,"finallyLoc");if(u&&l){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),C(n),_}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;C(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:L(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),_}},e}function v(t,e,n,r,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void n(t)}s.done?e(u):Promise.resolve(u).then(r,i)}function p(t){return function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function a(t){v(o,r,i,a,s,"next",t)}function s(t){v(o,r,i,a,s,"throw",t)}a(void 0)}))}}function y(t,e,n){return e=w(e),function(t,e){if(e&&("object"===c(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return g(t)}(t,b()?Reflect.construct(e,n||[],w(t).constructor):e.apply(t,n))}function g(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function _(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&$(t,e)}function m(t){var e="function"==typeof Map?new Map:void 0;return m=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return function(t,e,n){if(b())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,e);var i=new(t.bind.apply(t,r));return n&&$(i,n.prototype),i}(t,arguments,w(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),$(n,t)},m(t)}function b(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(b=function(){return!!t})()}function $(t,e){return $=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},$(t,e)}function w(t){return w=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},w(t)}function A(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=k(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function k(t,e){if(t){if("string"==typeof t)return E(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?E(t,e):void 0}}function E(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n0&&(this._$Ep=e)}},{key:"createRenderRoot",value:function(){var t,e=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return function(t,e){if(C)t.adoptedStyleSheets=e.map((function(t){return t instanceof CSSStyleSheet?t:t.styleSheet}));else{var n,r=A(e);try{for(r.s();!(n=r.n()).done;){var i=n.value,o=document.createElement("style"),a=j.litNonce;void 0!==a&&o.setAttribute("nonce",a),o.textContent=i.cssText,t.appendChild(o)}}catch(t){r.e(t)}finally{r.f()}}}(e,this.constructor.elementStyles),e}},{key:"connectedCallback",value:function(){var t,e;null!==(t=this.renderRoot)&&void 0!==t||(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(e=this._$EO)||void 0===e||e.forEach((function(t){var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}},{key:"enableUpdating",value:function(t){}},{key:"disconnectedCallback",value:function(){var t;null===(t=this._$EO)||void 0===t||t.forEach((function(t){var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}},{key:"attributeChangedCallback",value:function(t,e,n){this._$AK(t,n)}},{key:"_$EC",value:function(t,e){var n=this.constructor.elementProperties.get(t),r=this.constructor._$Eu(t,n);if(void 0!==r&&!0===n.reflect){var i,o=(void 0!==(null===(i=n.converter)||void 0===i?void 0:i.toAttribute)?n.converter:q).toAttribute(e,n.type);this._$Em=t,null==o?this.removeAttribute(r):this.setAttribute(r,o),this._$Em=null}}},{key:"_$AK",value:function(t,e){var n=this.constructor,r=n._$Eh.get(t);if(void 0!==r&&this._$Em!==r){var i,o=n.getPropertyOptions(r),a="function"==typeof o.converter?{fromAttribute:o.converter}:void 0!==(null===(i=o.converter)||void 0===i?void 0:i.fromAttribute)?o.converter:q;this._$Em=r,this[r]=a.fromAttribute(e,o.type),this._$Em=null}}},{key:"requestUpdate",value:function(t,e,n){if(void 0!==t){var r,i;if(null!==(r=n)&&void 0!==r||(n=this.constructor.getPropertyOptions(t)),!(null!==(i=n.hasChanged)&&void 0!==i?i:J)(this[t],e))return;this.P(t,e,n)}!1===this.isUpdatePending&&(this._$ES=this._$ET())}},{key:"P",value:function(t,e,n){var r;this._$AL.has(t)||this._$AL.set(t,e),!0===n.reflect&&this._$Em!==t&&(null!==(r=this._$Ej)&&void 0!==r?r:this._$Ej=new Set).add(t)}},{key:"_$ET",value:(n=p(d().mark((function t(){var e;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.isUpdatePending=!0,t.prev=1,t.next=4,this._$ES;case 4:t.next=9;break;case 6:t.prev=6,t.t0=t.catch(1),Promise.reject(t.t0);case 9:if(e=this.scheduleUpdate(),t.t1=null!=e,!t.t1){t.next=14;break}return t.next=14,e;case 14:return t.abrupt("return",!this.isUpdatePending);case 15:case"end":return t.stop()}}),t,this,[[1,6]])}))),function(){return n.apply(this,arguments)})},{key:"scheduleUpdate",value:function(){return this.performUpdate()}},{key:"performUpdate",value:function(){if(this.isUpdatePending){if(!this.hasUpdated){var t;if(null!==(t=this.renderRoot)&&void 0!==t||(this.renderRoot=this.createRenderRoot()),this._$Ep){var e,n=A(this._$Ep);try{for(n.s();!(e=n.n()).done;){var r=f(e.value,2),i=r[0],o=r[1];this[i]=o}}catch(t){n.e(t)}finally{n.f()}this._$Ep=void 0}var a=this.constructor.elementProperties;if(a.size>0){var s,u=A(a);try{for(u.s();!(s=u.n()).done;){var l=f(s.value,2),c=l[0],h=l[1];!0!==h.wrapped||this._$AL.has(c)||void 0===this[c]||this.P(c,this[c],h)}}catch(t){u.e(t)}finally{u.f()}}}var d=!1,v=this._$AL;try{var p;(d=this.shouldUpdate(v))?(this.willUpdate(v),null!==(p=this._$EO)&&void 0!==p&&p.forEach((function(t){var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(v)):this._$EU()}catch(v){throw d=!1,this._$EU(),v}d&&this._$AE(v)}}},{key:"willUpdate",value:function(t){}},{key:"_$AE",value:function(t){var e;null!==(e=this._$EO)&&void 0!==e&&e.forEach((function(t){var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}},{key:"_$EU",value:function(){this._$AL=new Map,this.isUpdatePending=!1}},{key:"updateComplete",get:function(){return this.getUpdateComplete()}},{key:"getUpdateComplete",value:function(){return this._$ES}},{key:"shouldUpdate",value:function(t){return!0}},{key:"update",value:function(t){var e=this;this._$Ej&&(this._$Ej=this._$Ej.forEach((function(t){return e._$EC(t,e[t])}))),this._$EU()}},{key:"updated",value:function(t){}},{key:"firstUpdated",value:function(t){}}],[{key:"addInitializer",value:function(t){var e;this._$Ei(),(null!==(e=this.l)&&void 0!==e?e:this.l=[]).push(t)}},{key:"observedAttributes",get:function(){return this.finalize(),this._$Eh&&h(this._$Eh.keys())}},{key:"createProperty",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:K;if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){var n=Symbol(),r=this.getPropertyDescriptor(t,n,e);void 0!==r&&I(this.prototype,t,r)}}},{key:"getPropertyDescriptor",value:function(t,e,n){var r,i=null!==(r=M(this.prototype,t))&&void 0!==r?r:{get:function(){return this[e]},set:function(t){this[e]=t}},o=i.get,a=i.set;return{get:function(){return null==o?void 0:o.call(this)},set:function(e){var r=null==o?void 0:o.call(this);a.call(this,e),this.requestUpdate(t,r,n)},configurable:!0,enumerable:!0}}},{key:"getPropertyOptions",value:function(t){var e;return null!==(e=this.elementProperties.get(t))&&void 0!==e?e:K}},{key:"_$Ei",value:function(){if(!this.hasOwnProperty(F("elementProperties"))){var t=z(this);t.finalize(),void 0!==t.l&&(this.l=h(t.l)),this.elementProperties=new Map(t.elementProperties)}}},{key:"finalize",value:function(){if(!this.hasOwnProperty(F("finalized"))){if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(F("properties"))){var t,e=this.properties,n=A([].concat(h(H(e)),h(D(e))));try{for(n.s();!(t=n.n()).done;){var r=t.value;this.createProperty(r,e[r])}}catch(t){n.e(t)}finally{n.f()}}var i=this[Symbol.metadata];if(null!==i){var o=litPropertyMetadata.get(i);if(void 0!==o){var a,s=A(o);try{for(s.s();!(a=s.n()).done;){var u=f(a.value,2),l=u[0],c=u[1];this.elementProperties.set(l,c)}}catch(t){s.e(t)}finally{s.f()}}}this._$Eh=new Map;var d,v=A(this.elementProperties);try{for(v.s();!(d=v.n()).done;){var p=f(d.value,2),y=p[0],g=p[1],_=this._$Eu(y,g);void 0!==_&&this._$Eh.set(_,y)}}catch(t){v.e(t)}finally{v.f()}this.elementStyles=this.finalizeStyles(this.styles)}}},{key:"finalizeStyles",value:function(t){var e=[];if(Array.isArray(t)){var n,r=A(new Set(t.flat(1/0).reverse()));try{for(r.s();!(n=r.n()).done;){var i=n.value;e.unshift(R(i))}}catch(t){r.e(t)}finally{r.f()}}else void 0!==t&&e.push(R(t));return e}},{key:"_$Eu",value:function(t,e){var n=e.attribute;return!1===n?void 0:"string"==typeof n?n:"string"==typeof t?t.toLowerCase():void 0}}]);var n}();Y.elementStyles=[],Y.shadowRootOptions={mode:"open"},Y[F("elementProperties")]=new Map,Y[F("finalized")]=new Map,null!=G&&G({ReactiveElement:Y}),(null!==(n=B.reactiveElementVersions)&&void 0!==n?n:B.reactiveElementVersions=[]).push("2.0.4");var Z=globalThis,Q=Z.trustedTypes,X=Q?Q.createPolicy("lit-html",{createHTML:function(t){return t}}):void 0,tt="$lit$",et="lit$".concat((Math.random()+"").slice(9),"$"),nt="?"+et,rt="<".concat(nt,">"),it=document,ot=function(){return it.createComment("")},at=function(t){return null===t||"object"!=c(t)&&"function"!=typeof t},st=Array.isArray,ut="[ \t\n\f\r]",lt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ct=/-->/g,ht=/>/g,ft=RegExp(">|".concat(ut,"(?:([^\\s\"'>=/]+)(").concat(ut,"*=").concat(ut,"*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)"),"g"),dt=/'/g,vt=/"/g,pt=/^(?:script|style|textarea|title)$/i,yt=Symbol.for("lit-noChange"),gt=Symbol.for("lit-nothing"),_t=new WeakMap,mt=it.createTreeWalker(it,129);function bt(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==X?X.createHTML(e):e}var $t=function(t,e){for(var n,r=t.length-1,i=[],o=2===e?"":"",a=lt,s=0;s"===c[0]?(a=null!==(d=n)&&void 0!==d?d:lt,h=-1):void 0===c[1]?h=-2:(h=a.lastIndex-c[2].length,l=c[1],a=void 0===c[3]?ft:'"'===c[3]?vt:dt):a===vt||a===dt?a=ft:a===ct||a===ht?a=lt:(a=ft,n=void 0)}var v=a===ft&&t[s+1].startsWith("/>")?" ":"";o+=a===lt?u+rt:h>=0?(i.push(l),u.slice(0,h)+tt+u.slice(h)+et+v):u+et+(-2===h?s:v)}return[bt(t,o+(t[r]||"")+(2===e?"":"")),i]},wt=function(){return x((function t(e,n){var r,i=e.strings,o=e._$litType$;S(this,t),this.parts=[];var a=0,s=0,u=i.length-1,l=this.parts,c=f($t(i,o),2),d=c[0],v=c[1];if(this.el=t.createElement(d,n),mt.currentNode=this.el.content,2===o){var p=this.el.content.firstChild;p.replaceWith.apply(p,h(p.childNodes))}for(;null!==(r=mt.nextNode())&&l.length0){r.textContent=Q?Q.emptyScript:"";for(var E=0;E2&&void 0!==arguments[2]?arguments[2]:t,u=arguments.length>3?arguments[3]:void 0;if(e===yt)return e;var l=void 0!==u?null===(n=s._$Co)||void 0===n?void 0:n[u]:s._$Cl,c=at(e)?void 0:e._$litDirective$;return(null===(r=l)||void 0===r?void 0:r.constructor)!==c&&(null!==(i=l)&&void 0!==i&&null!==(o=i._$AO)&&void 0!==o&&o.call(i,!1),void 0===c?l=void 0:(l=new c(t))._$AT(t,s,u),void 0!==u?(null!==(a=s._$Co)&&void 0!==a?a:s._$Co=[])[u]=l:s._$Cl=l),void 0!==l&&(e=At(t,l._$AS(t,e.values),l,u)),e}var kt=function(){return x((function t(e,n){S(this,t),this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=n}),[{key:"parentNode",get:function(){return this._$AM.parentNode}},{key:"_$AU",get:function(){return this._$AM._$AU}},{key:"u",value:function(t){var e,n=this._$AD,r=n.el.content,i=n.parts,o=(null!==(e=null==t?void 0:t.creationScope)&&void 0!==e?e:it).importNode(r,!0);mt.currentNode=o;for(var a=mt.nextNode(),s=0,u=0,l=i[0];void 0!==l;){var c;if(s===l.index){var h=void 0;2===l.type?h=new Et(a,a.nextSibling,this,t):1===l.type?h=new l.ctor(a,l.name,l.strings,this,t):6===l.type&&(h=new jt(a,this,t)),this._$AV.push(h),l=i[++u]}s!==(null===(c=l)||void 0===c?void 0:c.index)&&(a=mt.nextNode(),s++)}return mt.currentNode=it,o}},{key:"p",value:function(t){var e,n=0,r=A(this._$AV);try{for(r.s();!(e=r.n()).done;){var i=e.value;void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,n),n+=i.strings.length-2):i._$AI(t[n])),n++}}catch(t){r.e(t)}finally{r.f()}}}])}(),Et=function(){function t(e,n,r,i){var o;S(this,t),this.type=2,this._$AH=gt,this._$AN=void 0,this._$AA=e,this._$AB=n,this._$AM=r,this.options=i,this._$Cv=null===(o=null==i?void 0:i.isConnected)||void 0===o||o}return x(t,[{key:"_$AU",get:function(){var t,e;return null!==(t=null===(e=this._$AM)||void 0===e?void 0:e._$AU)&&void 0!==t?t:this._$Cv}},{key:"parentNode",get:function(){var t,e=this._$AA.parentNode,n=this._$AM;return void 0!==n&&11===(null===(t=e)||void 0===t?void 0:t.nodeType)&&(e=n.parentNode),e}},{key:"startNode",get:function(){return this._$AA}},{key:"endNode",get:function(){return this._$AB}},{key:"_$AI",value:function(t){t=At(this,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:this),at(t)?t===gt||null==t||""===t?(this._$AH!==gt&&this._$AR(),this._$AH=gt):t!==this._$AH&&t!==yt&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):function(t){return st(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator])}(t)?this.k(t):this._(t)}},{key:"S",value:function(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}},{key:"T",value:function(t){this._$AH!==t&&(this._$AR(),this._$AH=this.S(t))}},{key:"_",value:function(t){this._$AH!==gt&&at(this._$AH)?this._$AA.nextSibling.data=t:this.T(it.createTextNode(t)),this._$AH=t}},{key:"$",value:function(t){var e,n=t.values,r=t._$litType$,i="number"==typeof r?this._$AC(t):(void 0===r.el&&(r.el=wt.createElement(bt(r.h,r.h[0]),this.options)),r);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===i)this._$AH.p(n);else{var o=new kt(i,this),a=o.u(this.options);o.p(n),this.T(a),this._$AH=o}}},{key:"_$AC",value:function(t){var e=_t.get(t.strings);return void 0===e&&_t.set(t.strings,e=new wt(t)),e}},{key:"k",value:function(e){st(this._$AH)||(this._$AH=[],this._$AR());var n,r,i=this._$AH,o=0,a=A(e);try{for(a.s();!(r=a.n()).done;){var s=r.value;o===i.length?i.push(n=new t(this.S(ot()),this.S(ot()),this,this.options)):n=i[o],n._$AI(s),o++}}catch(t){a.e(t)}finally{a.f()}o0&&void 0!==arguments[0]?arguments[0]:this._$AA.nextSibling,e=arguments.length>1?arguments[1]:void 0;for(null===(n=this._$AP)||void 0===n||n.call(this,!1,!0,e);t&&t!==this._$AB;){var n,r=t.nextSibling;t.remove(),t=r}}},{key:"setConnected",value:function(t){var e;void 0===this._$AM&&(this._$Cv=t,null===(e=this._$AP)||void 0===e||e.call(this,t))}}])}(),St=function(){return x((function t(e,n,r,i,o){S(this,t),this.type=1,this._$AH=gt,this._$AN=void 0,this.element=e,this.name=n,this._$AM=i,this.options=o,r.length>2||""!==r[0]||""!==r[1]?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=gt}),[{key:"tagName",get:function(){return this.element.tagName}},{key:"_$AU",get:function(){return this._$AM._$AU}},{key:"_$AI",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this,n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,i=this.strings,o=!1;if(void 0===i)t=At(this,t,e,0),(o=!at(t)||t!==this._$AH&&t!==yt)&&(this._$AH=t);else{var a,s,u=t;for(t=i[0],a=0;a1&&void 0!==arguments[1]?arguments[1]:this,0))&&void 0!==e?e:gt)!==yt){var n=this._$AH,r=t===gt&&n!==gt||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,i=t!==gt&&(n===gt||r);r&&this.element.removeEventListener(this.name,this,n),i&&this.element.addEventListener(this.name,this,t),this._$AH=t}}},{key:"handleEvent",value:function(t){var e,n;"function"==typeof this._$AH?this._$AH.call(null!==(e=null===(n=this.options)||void 0===n?void 0:n.host)&&void 0!==e?e:this.element,t):this._$AH.handleEvent(t)}}])}(),jt=function(){return x((function t(e,n,r){S(this,t),this.element=e,this.type=6,this._$AN=void 0,this._$AM=n,this.options=r}),[{key:"_$AU",get:function(){return this._$AM._$AU}},{key:"_$AI",value:function(t){At(this,t)}}])}(),Ct=Z.litHtmlPolyfillSupport;null!=Ct&&Ct(wt,Et),(null!==(r=Z.litHtmlVersions)&&void 0!==r?r:Z.litHtmlVersions=[]).push("3.1.2");var Nt=function(t){function e(){var t;return S(this,e),(t=y(this,e,arguments)).renderOptions={host:g(t)},t._$Do=void 0,t}return _(e,Y),x(e,[{key:"createRenderRoot",value:function(){var t,n,r=l(w(e.prototype),"createRenderRoot",this).call(this);return null!==(n=(t=this.renderOptions).renderBefore)&&void 0!==n||(t.renderBefore=r.firstChild),r}},{key:"update",value:function(t){var n=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),l(w(e.prototype),"update",this).call(this,t),this._$Do=function(t,e,n){var r,i=null!==(r=null==n?void 0:n.renderBefore)&&void 0!==r?r:e,o=i._$litPart$;if(void 0===o){var a,s=null!==(a=null==n?void 0:n.renderBefore)&&void 0!==a?a:null;i._$litPart$=o=new Et(e.insertBefore(ot(),s),s,void 0,null!=n?n:{})}return o._$AI(t),o}(n,this.renderRoot,this.renderOptions)}},{key:"connectedCallback",value:function(){var t;l(w(e.prototype),"connectedCallback",this).call(this),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}},{key:"disconnectedCallback",value:function(){var t;l(w(e.prototype),"disconnectedCallback",this).call(this),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}},{key:"render",value:function(){return yt}}])}();Nt._$litElement$=!0,Nt.finalized=!0,null===(i=globalThis.litElementHydrateSupport)||void 0===i||i.call(globalThis,{LitElement:Nt});var Lt=globalThis.litElementPolyfillSupport;function Tt(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"-",r="àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìıİłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·",i="aaaaaaaaaacccddeeeeeeeegghiiiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz".concat(n),o=new RegExp(r.split("").join("|"),"g");return""===t?e="":(e=t.toString().toLowerCase().replace(o,(function(t){return i.charAt(r.indexOf(t))})).replace(/(\d),(?=\d)/g,"$1").replace(/[^a-z0-9]+/g,n).replace(new RegExp("(".concat(n,")\\1+"),"g"),"$1").replace(new RegExp("^".concat(n,"+")),"").replace(new RegExp("".concat(n,"+$")),""),""===e&&(e="unknown")),e}null==Lt||Lt({LitElement:Nt}),(null!==(o=globalThis.litElementVersions)&&void 0!==o?o:globalThis.litElementVersions=[]).push("4.0.4");var Rt=function(t){function e(){return S(this,e),y(this,e,arguments)}return _(e,Y),x(e,null,[{key:"generate",value:(n=p(d().mark((function t(e,n){var r,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.callWS({domain:"lock_code_manager",type:"config_entries/get"});case 2:if(0!==(r=t.sent).length){t.next=5;break}return t.abrupt("return",{title:"Lock Code Manager",views:[{badges:[],cards:[{content:"# No Lock Code Manager configurations found!",type:"markdown"}],title:"Lock Code Manager"}]});case 5:return t.next=7,Promise.all(r.map((function(t){return{path:Tt(t.title),strategy:{config_entry_id:t.entry_id,include_code_slot_sensors:e.include_code_slot_sensors,include_in_sync_sensors:e.include_in_sync_sensors,type:"custom:lock-code-manager"},title:t.title}})));case 7:return 1===(i=t.sent).length&&i.push({title:"​"}),t.abrupt("return",{title:"Lock Code Manager",views:i});case 10:case"end":return t.stop()}}),t)}))),function(t,e){return n.apply(this,arguments)})}]);var n}(),Ut="code",It="pin_used",Mt="active",Ht="in_sync",Dt=["number_of_uses"],zt={type:"divider"},Bt=["name","enabled","pin",Mt].concat(Dt,[Ht,Ut,It]),Wt="fold-entity-row.js";function Vt(t,e,n,r,i,o){return Gt.apply(this,arguments)}function Gt(){return Gt=p(d().mark((function t(e,n,r,i,o,a){var s,u,l,c,v,p,y,g,_,m;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Promise.all([e.callWS({config_entry_id:n,type:"lock_code_manager/get_slot_calendar_data"}),e.callWS({type:"lovelace/resources"})]);case 2:return s=t.sent,u=f(s,2),l=u[0],c=u[1],v=i.map((function(t){return qt(t)})).sort(Ft),p=Object.keys(l.slots).map((function(t){return parseInt(t,10)})),y=p.map((function(t){return Yt(e,t,v,l)})),g=[].concat(h(l.locks.sort((function(t,e){return t.localeCompare(e)}))),h(v.filter((function(t){return"active"===t.key})).map((function(t){return{entity:t.entity_id,name:"Slot ".concat(t.slotNum.toString()," active"),type:"state-label"}})))),_=c.filter((function(t){return t.url.includes(Wt)})).length>0,m=y.map((function(t){return Kt(t,_,o,a)})),t.abrupt("return",{badges:g,cards:m,panel:!1,path:Tt(r),title:r});case 13:case"end":return t.stop()}}),t)}))),Gt.apply(this,arguments)}function Ft(t,e){return t.slotNume.slotNum?1:Bt.indexOf(t.key)Bt.indexOf(e.key)?1:t.key===e.key&&[It,Ut,Ht].includes(t.key)&&t.lockEntityId=0;--o){var a=this.tryEntries[o],l=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(s&&u){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),C(n),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;C(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:L(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),m}},e}function v(t,e,n,r,i,o,a){try{var l=t[o](a),s=l.value}catch(t){return void n(t)}l.done?e(s):Promise.resolve(s).then(r,i)}function p(t){return function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function a(t){v(o,r,i,a,l,"next",t)}function l(t){v(o,r,i,a,l,"throw",t)}a(void 0)}))}}function y(t,e,n){return e=w(e),function(t,e){if(e&&("object"===c(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return g(t)}(t,b()?Reflect.construct(e,n||[],w(t).constructor):e.apply(t,n))}function g(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function m(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&$(t,e)}function _(t){var e="function"==typeof Map?new Map:void 0;return _=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return function(t,e,n){if(b())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,e);var i=new(t.bind.apply(t,r));return n&&$(i,n.prototype),i}(t,arguments,w(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),$(n,t)},_(t)}function b(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(b=function(){return!!t})()}function $(t,e){return $=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},$(t,e)}function w(t){return w=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},w(t)}function A(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=k(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,l=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){l=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(l)throw o}}}}function k(t,e){if(t){if("string"==typeof t)return E(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?E(t,e):void 0}}function E(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n0&&(this._$Ep=e)}},{key:"createRenderRoot",value:function(){var t,e=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return function(t,e){if(C)t.adoptedStyleSheets=e.map((function(t){return t instanceof CSSStyleSheet?t:t.styleSheet}));else{var n,r=A(e);try{for(r.s();!(n=r.n()).done;){var i=n.value,o=document.createElement("style"),a=j.litNonce;void 0!==a&&o.setAttribute("nonce",a),o.textContent=i.cssText,t.appendChild(o)}}catch(t){r.e(t)}finally{r.f()}}}(e,this.constructor.elementStyles),e}},{key:"connectedCallback",value:function(){var t,e;null!==(t=this.renderRoot)&&void 0!==t||(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(e=this._$EO)||void 0===e||e.forEach((function(t){var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}},{key:"enableUpdating",value:function(t){}},{key:"disconnectedCallback",value:function(){var t;null===(t=this._$EO)||void 0===t||t.forEach((function(t){var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}},{key:"attributeChangedCallback",value:function(t,e,n){this._$AK(t,n)}},{key:"_$EC",value:function(t,e){var n=this.constructor.elementProperties.get(t),r=this.constructor._$Eu(t,n);if(void 0!==r&&!0===n.reflect){var i,o=(void 0!==(null===(i=n.converter)||void 0===i?void 0:i.toAttribute)?n.converter:q).toAttribute(e,n.type);this._$Em=t,null==o?this.removeAttribute(r):this.setAttribute(r,o),this._$Em=null}}},{key:"_$AK",value:function(t,e){var n=this.constructor,r=n._$Eh.get(t);if(void 0!==r&&this._$Em!==r){var i,o=n.getPropertyOptions(r),a="function"==typeof o.converter?{fromAttribute:o.converter}:void 0!==(null===(i=o.converter)||void 0===i?void 0:i.fromAttribute)?o.converter:q;this._$Em=r,this[r]=a.fromAttribute(e,o.type),this._$Em=null}}},{key:"requestUpdate",value:function(t,e,n){if(void 0!==t){var r,i;if(null!==(r=n)&&void 0!==r||(n=this.constructor.getPropertyOptions(t)),!(null!==(i=n.hasChanged)&&void 0!==i?i:J)(this[t],e))return;this.P(t,e,n)}!1===this.isUpdatePending&&(this._$ES=this._$ET())}},{key:"P",value:function(t,e,n){var r;this._$AL.has(t)||this._$AL.set(t,e),!0===n.reflect&&this._$Em!==t&&(null!==(r=this._$Ej)&&void 0!==r?r:this._$Ej=new Set).add(t)}},{key:"_$ET",value:(n=p(d().mark((function t(){var e;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.isUpdatePending=!0,t.prev=1,t.next=4,this._$ES;case 4:t.next=9;break;case 6:t.prev=6,t.t0=t.catch(1),Promise.reject(t.t0);case 9:if(e=this.scheduleUpdate(),t.t1=null!=e,!t.t1){t.next=14;break}return t.next=14,e;case 14:return t.abrupt("return",!this.isUpdatePending);case 15:case"end":return t.stop()}}),t,this,[[1,6]])}))),function(){return n.apply(this,arguments)})},{key:"scheduleUpdate",value:function(){return this.performUpdate()}},{key:"performUpdate",value:function(){if(this.isUpdatePending){if(!this.hasUpdated){var t;if(null!==(t=this.renderRoot)&&void 0!==t||(this.renderRoot=this.createRenderRoot()),this._$Ep){var e,n=A(this._$Ep);try{for(n.s();!(e=n.n()).done;){var r=f(e.value,2),i=r[0],o=r[1];this[i]=o}}catch(t){n.e(t)}finally{n.f()}this._$Ep=void 0}var a=this.constructor.elementProperties;if(a.size>0){var l,s=A(a);try{for(s.s();!(l=s.n()).done;){var u=f(l.value,2),c=u[0],h=u[1];!0!==h.wrapped||this._$AL.has(c)||void 0===this[c]||this.P(c,this[c],h)}}catch(t){s.e(t)}finally{s.f()}}}var d=!1,v=this._$AL;try{var p;(d=this.shouldUpdate(v))?(this.willUpdate(v),null!==(p=this._$EO)&&void 0!==p&&p.forEach((function(t){var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(v)):this._$EU()}catch(v){throw d=!1,this._$EU(),v}d&&this._$AE(v)}}},{key:"willUpdate",value:function(t){}},{key:"_$AE",value:function(t){var e;null!==(e=this._$EO)&&void 0!==e&&e.forEach((function(t){var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}},{key:"_$EU",value:function(){this._$AL=new Map,this.isUpdatePending=!1}},{key:"updateComplete",get:function(){return this.getUpdateComplete()}},{key:"getUpdateComplete",value:function(){return this._$ES}},{key:"shouldUpdate",value:function(t){return!0}},{key:"update",value:function(t){var e=this;this._$Ej&&(this._$Ej=this._$Ej.forEach((function(t){return e._$EC(t,e[t])}))),this._$EU()}},{key:"updated",value:function(t){}},{key:"firstUpdated",value:function(t){}}],[{key:"addInitializer",value:function(t){var e;this._$Ei(),(null!==(e=this.l)&&void 0!==e?e:this.l=[]).push(t)}},{key:"observedAttributes",get:function(){return this.finalize(),this._$Eh&&h(this._$Eh.keys())}},{key:"createProperty",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:K;if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){var n=Symbol(),r=this.getPropertyDescriptor(t,n,e);void 0!==r&&M(this.prototype,t,r)}}},{key:"getPropertyDescriptor",value:function(t,e,n){var r,i=null!==(r=H(this.prototype,t))&&void 0!==r?r:{get:function(){return this[e]},set:function(t){this[e]=t}},o=i.get,a=i.set;return{get:function(){return null==o?void 0:o.call(this)},set:function(e){var r=null==o?void 0:o.call(this);a.call(this,e),this.requestUpdate(t,r,n)},configurable:!0,enumerable:!0}}},{key:"getPropertyOptions",value:function(t){var e;return null!==(e=this.elementProperties.get(t))&&void 0!==e?e:K}},{key:"_$Ei",value:function(){if(!this.hasOwnProperty(F("elementProperties"))){var t=z(this);t.finalize(),void 0!==t.l&&(this.l=h(t.l)),this.elementProperties=new Map(t.elementProperties)}}},{key:"finalize",value:function(){if(!this.hasOwnProperty(F("finalized"))){if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(F("properties"))){var t,e=this.properties,n=A([].concat(h(I(e)),h(D(e))));try{for(n.s();!(t=n.n()).done;){var r=t.value;this.createProperty(r,e[r])}}catch(t){n.e(t)}finally{n.f()}}var i=this[Symbol.metadata];if(null!==i){var o=litPropertyMetadata.get(i);if(void 0!==o){var a,l=A(o);try{for(l.s();!(a=l.n()).done;){var s=f(a.value,2),u=s[0],c=s[1];this.elementProperties.set(u,c)}}catch(t){l.e(t)}finally{l.f()}}}this._$Eh=new Map;var d,v=A(this.elementProperties);try{for(v.s();!(d=v.n()).done;){var p=f(d.value,2),y=p[0],g=p[1],m=this._$Eu(y,g);void 0!==m&&this._$Eh.set(m,y)}}catch(t){v.e(t)}finally{v.f()}this.elementStyles=this.finalizeStyles(this.styles)}}},{key:"finalizeStyles",value:function(t){var e=[];if(Array.isArray(t)){var n,r=A(new Set(t.flat(1/0).reverse()));try{for(r.s();!(n=r.n()).done;){var i=n.value;e.unshift(R(i))}}catch(t){r.e(t)}finally{r.f()}}else void 0!==t&&e.push(R(t));return e}},{key:"_$Eu",value:function(t,e){var n=e.attribute;return!1===n?void 0:"string"==typeof n?n:"string"==typeof t?t.toLowerCase():void 0}}]);var n}();Y.elementStyles=[],Y.shadowRootOptions={mode:"open"},Y[F("elementProperties")]=new Map,Y[F("finalized")]=new Map,null!=G&&G({ReactiveElement:Y}),(null!==(n=B.reactiveElementVersions)&&void 0!==n?n:B.reactiveElementVersions=[]).push("2.0.4");var Z=globalThis,Q=Z.trustedTypes,X=Q?Q.createPolicy("lit-html",{createHTML:function(t){return t}}):void 0,tt="$lit$",et="lit$".concat((Math.random()+"").slice(9),"$"),nt="?"+et,rt="<".concat(nt,">"),it=document,ot=function(){return it.createComment("")},at=function(t){return null===t||"object"!=c(t)&&"function"!=typeof t},lt=Array.isArray,st="[ \t\n\f\r]",ut=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ct=/-->/g,ht=/>/g,ft=RegExp(">|".concat(st,"(?:([^\\s\"'>=/]+)(").concat(st,"*=").concat(st,"*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)"),"g"),dt=/'/g,vt=/"/g,pt=/^(?:script|style|textarea|title)$/i,yt=Symbol.for("lit-noChange"),gt=Symbol.for("lit-nothing"),mt=new WeakMap,_t=it.createTreeWalker(it,129);function bt(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==X?X.createHTML(e):e}var $t=function(t,e){for(var n,r=t.length-1,i=[],o=2===e?"":"",a=ut,l=0;l"===c[0]?(a=null!==(d=n)&&void 0!==d?d:ut,h=-1):void 0===c[1]?h=-2:(h=a.lastIndex-c[2].length,u=c[1],a=void 0===c[3]?ft:'"'===c[3]?vt:dt):a===vt||a===dt?a=ft:a===ct||a===ht?a=ut:(a=ft,n=void 0)}var v=a===ft&&t[l+1].startsWith("/>")?" ":"";o+=a===ut?s+rt:h>=0?(i.push(u),s.slice(0,h)+tt+s.slice(h)+et+v):s+et+(-2===h?l:v)}return[bt(t,o+(t[r]||"")+(2===e?"":"")),i]},wt=function(){return x((function t(e,n){var r,i=e.strings,o=e._$litType$;S(this,t),this.parts=[];var a=0,l=0,s=i.length-1,u=this.parts,c=f($t(i,o),2),d=c[0],v=c[1];if(this.el=t.createElement(d,n),_t.currentNode=this.el.content,2===o){var p=this.el.content.firstChild;p.replaceWith.apply(p,h(p.childNodes))}for(;null!==(r=_t.nextNode())&&u.length0){r.textContent=Q?Q.emptyScript:"";for(var E=0;E2&&void 0!==arguments[2]?arguments[2]:t,s=arguments.length>3?arguments[3]:void 0;if(e===yt)return e;var u=void 0!==s?null===(n=l._$Co)||void 0===n?void 0:n[s]:l._$Cl,c=at(e)?void 0:e._$litDirective$;return(null===(r=u)||void 0===r?void 0:r.constructor)!==c&&(null!==(i=u)&&void 0!==i&&null!==(o=i._$AO)&&void 0!==o&&o.call(i,!1),void 0===c?u=void 0:(u=new c(t))._$AT(t,l,s),void 0!==s?(null!==(a=l._$Co)&&void 0!==a?a:l._$Co=[])[s]=u:l._$Cl=u),void 0!==u&&(e=At(t,u._$AS(t,e.values),u,s)),e}var kt=function(){return x((function t(e,n){S(this,t),this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=n}),[{key:"parentNode",get:function(){return this._$AM.parentNode}},{key:"_$AU",get:function(){return this._$AM._$AU}},{key:"u",value:function(t){var e,n=this._$AD,r=n.el.content,i=n.parts,o=(null!==(e=null==t?void 0:t.creationScope)&&void 0!==e?e:it).importNode(r,!0);_t.currentNode=o;for(var a=_t.nextNode(),l=0,s=0,u=i[0];void 0!==u;){var c;if(l===u.index){var h=void 0;2===u.type?h=new Et(a,a.nextSibling,this,t):1===u.type?h=new u.ctor(a,u.name,u.strings,this,t):6===u.type&&(h=new jt(a,this,t)),this._$AV.push(h),u=i[++s]}l!==(null===(c=u)||void 0===c?void 0:c.index)&&(a=_t.nextNode(),l++)}return _t.currentNode=it,o}},{key:"p",value:function(t){var e,n=0,r=A(this._$AV);try{for(r.s();!(e=r.n()).done;){var i=e.value;void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,n),n+=i.strings.length-2):i._$AI(t[n])),n++}}catch(t){r.e(t)}finally{r.f()}}}])}(),Et=function(){function t(e,n,r,i){var o;S(this,t),this.type=2,this._$AH=gt,this._$AN=void 0,this._$AA=e,this._$AB=n,this._$AM=r,this.options=i,this._$Cv=null===(o=null==i?void 0:i.isConnected)||void 0===o||o}return x(t,[{key:"_$AU",get:function(){var t,e;return null!==(t=null===(e=this._$AM)||void 0===e?void 0:e._$AU)&&void 0!==t?t:this._$Cv}},{key:"parentNode",get:function(){var t,e=this._$AA.parentNode,n=this._$AM;return void 0!==n&&11===(null===(t=e)||void 0===t?void 0:t.nodeType)&&(e=n.parentNode),e}},{key:"startNode",get:function(){return this._$AA}},{key:"endNode",get:function(){return this._$AB}},{key:"_$AI",value:function(t){t=At(this,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:this),at(t)?t===gt||null==t||""===t?(this._$AH!==gt&&this._$AR(),this._$AH=gt):t!==this._$AH&&t!==yt&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):function(t){return lt(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator])}(t)?this.k(t):this._(t)}},{key:"S",value:function(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}},{key:"T",value:function(t){this._$AH!==t&&(this._$AR(),this._$AH=this.S(t))}},{key:"_",value:function(t){this._$AH!==gt&&at(this._$AH)?this._$AA.nextSibling.data=t:this.T(it.createTextNode(t)),this._$AH=t}},{key:"$",value:function(t){var e,n=t.values,r=t._$litType$,i="number"==typeof r?this._$AC(t):(void 0===r.el&&(r.el=wt.createElement(bt(r.h,r.h[0]),this.options)),r);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===i)this._$AH.p(n);else{var o=new kt(i,this),a=o.u(this.options);o.p(n),this.T(a),this._$AH=o}}},{key:"_$AC",value:function(t){var e=mt.get(t.strings);return void 0===e&&mt.set(t.strings,e=new wt(t)),e}},{key:"k",value:function(e){lt(this._$AH)||(this._$AH=[],this._$AR());var n,r,i=this._$AH,o=0,a=A(e);try{for(a.s();!(r=a.n()).done;){var l=r.value;o===i.length?i.push(n=new t(this.S(ot()),this.S(ot()),this,this.options)):n=i[o],n._$AI(l),o++}}catch(t){a.e(t)}finally{a.f()}o0&&void 0!==arguments[0]?arguments[0]:this._$AA.nextSibling,e=arguments.length>1?arguments[1]:void 0;for(null===(n=this._$AP)||void 0===n||n.call(this,!1,!0,e);t&&t!==this._$AB;){var n,r=t.nextSibling;t.remove(),t=r}}},{key:"setConnected",value:function(t){var e;void 0===this._$AM&&(this._$Cv=t,null===(e=this._$AP)||void 0===e||e.call(this,t))}}])}(),St=function(){return x((function t(e,n,r,i,o){S(this,t),this.type=1,this._$AH=gt,this._$AN=void 0,this.element=e,this.name=n,this._$AM=i,this.options=o,r.length>2||""!==r[0]||""!==r[1]?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=gt}),[{key:"tagName",get:function(){return this.element.tagName}},{key:"_$AU",get:function(){return this._$AM._$AU}},{key:"_$AI",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this,n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,i=this.strings,o=!1;if(void 0===i)t=At(this,t,e,0),(o=!at(t)||t!==this._$AH&&t!==yt)&&(this._$AH=t);else{var a,l,s=t;for(t=i[0],a=0;a1&&void 0!==arguments[1]?arguments[1]:this,0))&&void 0!==e?e:gt)!==yt){var n=this._$AH,r=t===gt&&n!==gt||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,i=t!==gt&&(n===gt||r);r&&this.element.removeEventListener(this.name,this,n),i&&this.element.addEventListener(this.name,this,t),this._$AH=t}}},{key:"handleEvent",value:function(t){var e,n;"function"==typeof this._$AH?this._$AH.call(null!==(e=null===(n=this.options)||void 0===n?void 0:n.host)&&void 0!==e?e:this.element,t):this._$AH.handleEvent(t)}}])}(),jt=function(){return x((function t(e,n,r){S(this,t),this.element=e,this.type=6,this._$AN=void 0,this._$AM=n,this.options=r}),[{key:"_$AU",get:function(){return this._$AM._$AU}},{key:"_$AI",value:function(t){At(this,t)}}])}(),Ct=Z.litHtmlPolyfillSupport;null!=Ct&&Ct(wt,Et),(null!==(r=Z.litHtmlVersions)&&void 0!==r?r:Z.litHtmlVersions=[]).push("3.1.2");var Nt=function(t){function e(){var t;return S(this,e),(t=y(this,e,arguments)).renderOptions={host:g(t)},t._$Do=void 0,t}return m(e,Y),x(e,[{key:"createRenderRoot",value:function(){var t,n,r=u(w(e.prototype),"createRenderRoot",this).call(this);return null!==(n=(t=this.renderOptions).renderBefore)&&void 0!==n||(t.renderBefore=r.firstChild),r}},{key:"update",value:function(t){var n=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),u(w(e.prototype),"update",this).call(this,t),this._$Do=function(t,e,n){var r,i=null!==(r=null==n?void 0:n.renderBefore)&&void 0!==r?r:e,o=i._$litPart$;if(void 0===o){var a,l=null!==(a=null==n?void 0:n.renderBefore)&&void 0!==a?a:null;i._$litPart$=o=new Et(e.insertBefore(ot(),l),l,void 0,null!=n?n:{})}return o._$AI(t),o}(n,this.renderRoot,this.renderOptions)}},{key:"connectedCallback",value:function(){var t;u(w(e.prototype),"connectedCallback",this).call(this),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}},{key:"disconnectedCallback",value:function(){var t;u(w(e.prototype),"disconnectedCallback",this).call(this),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}},{key:"render",value:function(){return yt}}])}();Nt._$litElement$=!0,Nt.finalized=!0,null===(i=globalThis.litElementHydrateSupport)||void 0===i||i.call(globalThis,{LitElement:Nt});var Lt=globalThis.litElementPolyfillSupport;function Tt(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"-",r="àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìıİłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·",i="aaaaaaaaaacccddeeeeeeeegghiiiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz".concat(n),o=new RegExp(r.split("").join("|"),"g");return""===t?e="":(e=t.toString().toLowerCase().replace(o,(function(t){return i.charAt(r.indexOf(t))})).replace(/(\d),(?=\d)/g,"$1").replace(/[^a-z0-9]+/g,n).replace(new RegExp("(".concat(n,")\\1+"),"g"),"$1").replace(new RegExp("^".concat(n,"+")),"").replace(new RegExp("".concat(n,"+$")),""),""===e&&(e="unknown")),e}null==Lt||Lt({LitElement:Nt}),(null!==(o=globalThis.litElementVersions)&&void 0!==o?o:globalThis.litElementVersions=[]).push("4.0.4");var Rt=function(t){function e(){return S(this,e),y(this,e,arguments)}return m(e,Y),x(e,null,[{key:"generate",value:(n=p(d().mark((function t(e,n){var r,i;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.callWS({domain:"lock_code_manager",type:"config_entries/get"});case 2:if(0!==(r=t.sent).length){t.next=5;break}return t.abrupt("return",{title:"Lock Code Manager",views:[{badges:[],cards:[{content:"# No Lock Code Manager configurations found!",type:"markdown"}],title:"Lock Code Manager"}]});case 5:return t.next=7,Promise.all(r.map((function(t){return{path:Tt(t.title),strategy:{config_entry_id:t.entry_id,include_code_slot_sensors:e.include_code_slot_sensors,include_in_sync_sensors:e.include_in_sync_sensors,type:"custom:lock-code-manager"},title:t.title}})));case 7:return 1===(i=t.sent).length&&i.push({title:"​"}),t.abrupt("return",{title:"Lock Code Manager",views:i});case 10:case"end":return t.stop()}}),t)}))),function(t,e){return n.apply(this,arguments)})}]);var n}(),Ut="code",Mt="pin_used",Ht="active",It="in_sync",Dt=["number_of_uses"],zt={type:"divider"},Bt=["name","enabled","pin",Ht].concat(Dt,[It,Ut,Mt]),Wt="fold-entity-row.js";function Vt(t,e,n,r,i){return Gt.apply(this,arguments)}function Gt(){return Gt=p(d().mark((function t(e,n,r,i,o){var a,l,s,u,c,v,p,y,g,m;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Promise.all([e.callWS({config_entry_id:n.entry_id,type:"lock_code_manager/get_slot_calendar_data"}),e.callWS({type:"lovelace/resources"})]);case 2:return a=t.sent,l=f(a,2),s=l[0],u=l[1],c=r.map((function(t){return qt(t)})).sort(Ft),v=Object.keys(s.slots).map((function(t){return parseInt(t,10)})),p=v.map((function(t){return Yt(e,t,c,s)})),y=[].concat(h(s.locks.sort((function(t,e){return t.localeCompare(e)}))),h(c.filter((function(t){return"active"===t.key})).map((function(t){return{entity:t.entity_id,name:"Slot ".concat(t.slotNum.toString()," active"),type:"state-label"}})))),g=u.filter((function(t){return t.url.includes(Wt)})).length>0,m=p.map((function(t){return Kt(n,t,g,i,o)})),t.abrupt("return",{badges:y,cards:m,panel:!1,path:Tt(n.title),title:n.title});case 13:case"end":return t.stop()}}),t)}))),Gt.apply(this,arguments)}function Ft(t,e){return t.slotNume.slotNum?1:Bt.indexOf(t.key)Bt.indexOf(e.key)?1:t.key===e.key&&[Mt,Ut,It].includes(t.key)&&t.lockEntityId { + const callData = { + type: 'lock_code_manager/get_config_entry_entities' + }; const [configEntryData, lovelaceResources] = await Promise.all([ hass.callWS({ - config_entry_id: configEntryId, + config_entry_id: configEntry.entry_id, type: 'lock_code_manager/get_slot_calendar_data' }), hass.callWS({ @@ -63,6 +71,7 @@ export async function generateView( const cards = slotMappings.map((slotMapping) => generateSlotCard( + configEntry, slotMapping, useFoldEntityRow, include_code_slot_sensors, @@ -74,8 +83,8 @@ export async function generateView( badges, cards, panel: false, - path: slugify(configEntryTitle), - title: configEntryTitle + path: slugify(configEntry.title), + title: configEntry.title }; } @@ -109,15 +118,34 @@ function createLockCodeManagerEntity(entity: EntityRegistryEntry): LockCodeManag }; } -function generateEntityCards(entities: string[]): { entity: string }[] { - return entities.map((entityId) => { +function generateEntityCards( + configEntry: ConfigEntryJSONFragment, + entities: LockCodeManagerEntityEntry[] +): { entity: string }[] { + return entities.map((entity) => { + if ([IN_SYNC_KEY, CODE_SENSOR_KEY].includes(entity.key)) { + return { + entity: entity.entity_id + }; + } + const name = (entity.name || entity.original_name) + .replace(`Code slot ${entity.slotNum}`, '') + .replace(' ', ' ') + .replace(' ', ' ') + .trim() + .replace(configEntry.title, '') + .replace(' ', ' ') + .replace(' ', ' ') + .trim(); return { - entity: entityId + entity: entity.entity_id, + name: capitalize(name) }; }); } function generateSlotCard( + configEntry: ConfigEntryJSONFragment, slotMapping: SlotMapping, useFoldEntityRow: boolean, include_code_slot_sensors: boolean, @@ -131,31 +159,35 @@ function generateSlotCard( }, { entities: [ - ...generateEntityCards(slotMapping.mainEntityIds), + ...generateEntityCards(configEntry, slotMapping.mainEntities), DIVIDER_CARD, { entity: slotMapping.pinActiveEntity.entity_id, name: 'PIN active' }, { - entity: slotMapping.codeEventEntityId, + entity: slotMapping.codeEventEntity.entity_id, name: 'PIN last used' }, - ...maybeGenerateFoldEntityRowCard( - slotMapping.conditionEntityIds, + ...maybeGenerateFoldEntityRowConditionCard( + configEntry, + slotMapping.conditionEntities, + slotMapping.calendarEntityId, 'Conditions', useFoldEntityRow ), ...(include_in_sync_sensors ? maybeGenerateFoldEntityRowCard( - slotMapping.inSyncEntityIds, + configEntry, + slotMapping.inSyncEntities, 'Locks in sync', useFoldEntityRow ) : []), ...(include_code_slot_sensors ? maybeGenerateFoldEntityRowCard( - slotMapping.codeSensorEntityIds, + configEntry, + slotMapping.codeSensorEntities, 'Code slot sensors', useFoldEntityRow ) @@ -175,49 +207,86 @@ function getSlotMapping( lockCodeManagerEntities: LockCodeManagerEntityEntry[], configEntryData: LockCodeManagerConfigEntryData ): SlotMapping { - const mainEntityIds: string[] = []; - const conditionEntityIds: string[] = []; - const codeSensorEntityIds: string[] = []; - const inSyncEntityIds: string[] = []; - let codeEventEntityId: string; + const mainEntities: LockCodeManagerEntityEntry[] = []; + const conditionEntities: LockCodeManagerEntityEntry[] = []; + const codeSensorEntities: LockCodeManagerEntityEntry[] = []; + const inSyncEntities: LockCodeManagerEntityEntry[] = []; + let codeEventEntity: LockCodeManagerEntityEntry; lockCodeManagerEntities .filter((entity) => entity.slotNum === slotNum) .forEach((entity) => { if (entity.key === CODE_SENSOR_KEY) { - codeSensorEntityIds.push(entity.entity_id); + codeSensorEntities.push(entity); } else if (entity.key === IN_SYNC_KEY) { - inSyncEntityIds.push(entity.entity_id); + inSyncEntities.push(entity); } else if (entity.key === CODE_EVENT_KEY) { - codeEventEntityId = entity.entity_id; + codeEventEntity = entity; } else if (CONDITION_KEYS.includes(entity.key)) { - conditionEntityIds.push(entity.entity_id); + conditionEntities.push(entity); } else if (![ACTIVE_KEY, IN_SYNC_KEY].includes(entity.key)) { - mainEntityIds.push(entity.entity_id); + mainEntities.push(entity); } }); const pinActiveEntity = lockCodeManagerEntities.find( (entity) => entity.slotNum === slotNum && entity.key === ACTIVE_KEY ); - const calendarEntityId = configEntryData.slots[slotNum]; - if (calendarEntityId) conditionEntityIds.unshift(calendarEntityId); + const calendarEntityId: string | null | undefined = configEntryData.slots[slotNum]; return { - codeEventEntityId, - codeSensorEntityIds, - conditionEntityIds, - inSyncEntityIds, - mainEntityIds, + calendarEntityId, + codeEventEntity, + codeSensorEntities, + conditionEntities, + inSyncEntities, + mainEntities, pinActiveEntity, slotNum }; } function maybeGenerateFoldEntityRowCard( - entities: string[], + configEntry: ConfigEntryJSONFragment, + entities: LockCodeManagerEntityEntry[], label: string, useFoldEntityRow: boolean ) { if (entities.length === 0) return []; - const entityCards = generateEntityCards(entities); + const entityCards = generateEntityCards(configEntry, entities); + return useFoldEntityRow + ? [ + DIVIDER_CARD, + { + entities: entityCards, + head: { + label, + type: 'section' + }, + type: 'custom:fold-entity-row' + } + ] + : [ + { + label, + type: 'section' + }, + ...entityCards + ]; +} + +function maybeGenerateFoldEntityRowConditionCard( + configEntry: ConfigEntryJSONFragment, + conditionEntities: LockCodeManagerEntityEntry[], + calendarEntityId: string | null | undefined, + label: string, + useFoldEntityRow: boolean +) { + if (conditionEntities.length === 0 && calendarEntityId == null) return []; + const entityCards = generateEntityCards(configEntry, conditionEntities); + if (calendarEntityId != null) { + entityCards.unshift({ + entity: calendarEntityId + }); + } + return useFoldEntityRow ? [ DIVIDER_CARD, diff --git a/ts/types.ts b/ts/types.ts index bb1332fc..58aaa056 100644 --- a/ts/types.ts +++ b/ts/types.ts @@ -16,11 +16,12 @@ export interface LockCodeManagerDashboardStrategyConfig extends LockCodeManagerS } export interface SlotMapping { - codeEventEntityId: string; - codeSensorEntityIds: string[]; - conditionEntityIds: string[]; - inSyncEntityIds: string[]; - mainEntityIds: string[]; + calendarEntityId: string | null | undefined; + codeEventEntity: LockCodeManagerEntityEntry; + codeSensorEntities: LockCodeManagerEntityEntry[]; + conditionEntities: LockCodeManagerEntityEntry[]; + inSyncEntities: LockCodeManagerEntityEntry[]; + mainEntities: LockCodeManagerEntityEntry[]; pinActiveEntity: LockCodeManagerEntityEntry; slotNum: number; } diff --git a/ts/util.ts b/ts/util.ts new file mode 100644 index 00000000..460e6be1 --- /dev/null +++ b/ts/util.ts @@ -0,0 +1,3 @@ +export function capitalize(str: string): string { + return str.charAt(0).toUpperCase() + str.slice(1); +} diff --git a/ts/view-strategy.ts b/ts/view-strategy.ts index 0101edb5..38f8d315 100644 --- a/ts/view-strategy.ts +++ b/ts/view-strategy.ts @@ -33,8 +33,7 @@ export class LockCodeManagerViewStrategy extends ReactiveElement { }); return generateView( hass, - config_entry.entry_id, - config_entry.title, + config_entry, entities, config.include_code_slot_sensors ?? DEFAULT_INCLUDE_CODE_SLOT_SENSORS, config.include_in_sync_sensors ?? DEFAULT_INCLUDE_IN_SYNC_SENSORS