diff --git a/dist/alarmo-card.js b/dist/alarmo-card.js index f90a8ba..241dff3 100644 --- a/dist/alarmo-card.js +++ b/dist/alarmo-card.js @@ -55,7 +55,7 @@ const ne=e=>t=>"function"==typeof t?((e,t)=>(customElements.define(e,t),t))(e,t) * @license * Copyright 2021 Google LLC * SPDX-License-Identifier: BSD-3-Clause - */var ce;null===(ce=window.HTMLSlotElement)||void 0===ce||ce.prototype.assignedElements;var de=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,he="[^\\s]+",ue=/\[([^]*?)\]/gm;function pe(e,t){for(var i=[],s=0,a=e.length;s-1?s:null}};function ge(e){for(var t=[],i=1;i3?0:(e-e%10!=10?1:0)*e%10]}},ye=ge({},ve),$e=function(e,t){for(void 0===t&&(t=2),e=String(e);e.length0?"-":"+")+$e(100*Math.floor(Math.abs(t)/60)+Math.abs(t)%60,4)},Z:function(e){var t=e.getTimezoneOffset();return(t>0?"-":"+")+$e(Math.floor(Math.abs(t)/60),2)+":"+$e(Math.abs(t)%60,2)}},xe=function(e){return+e-1},ke=[null,"[1-9]\\d?"],Ae=[null,he],Ce=["isPm",he,function(e,t){var i=e.toLowerCase();return i===t.amPm[0]?0:i===t.amPm[1]?1:null}],Se=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(e){var t=(e+"").match(/([+-]|\d\d)/gi);if(t){var i=60*+t[1]+parseInt(t[2],10);return"+"===t[0]?i:-i}return 0}],Ee=(me("monthNamesShort"),me("monthNames"),{default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",isoDate:"YYYY-MM-DD",isoDateTime:"YYYY-MM-DDTHH:mm:ssZ",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"});var Oe,Me,ze=function(e,t,i){if(void 0===t&&(t=Ee.default),void 0===i&&(i={}),"number"==typeof e&&(e=new Date(e)),"[object Date]"!==Object.prototype.toString.call(e)||isNaN(e.getTime()))throw new Error("Invalid Date pass to format");var s=[];t=(t=Ee[t]||t).replace(ue,(function(e,t){return s.push(t),"@@@"}));var a=ge(ge({},ye),i);return(t=t.replace(de,(function(t){return we[t](e,a)}))).replace(/@@@/g,(function(){return s.shift()}))},De=function(){try{(new Date).toLocaleDateString("i")}catch(e){return"RangeError"===e.name}return!1}()?function(e,t){return e.toLocaleDateString(t.language,{year:"numeric",month:"long",day:"numeric"})}:function(e){return ze(e,"mediumDate")},Te=function(){try{(new Date).toLocaleString("i")}catch(e){return"RangeError"===e.name}return!1}()?function(e,t){return e.toLocaleString(t.language,{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit"})}:function(e){return ze(e,"haDateTime")},Ne=function(){try{(new Date).toLocaleTimeString("i")}catch(e){return"RangeError"===e.name}return!1}()?function(e,t){return e.toLocaleTimeString(t.language,{hour:"numeric",minute:"2-digit"})}:function(e){return ze(e,"shortTime")};function je(e){return e.substr(0,e.indexOf("."))}!function(e){e.language="language",e.system="system",e.comma_decimal="comma_decimal",e.decimal_comma="decimal_comma",e.space_comma="space_comma",e.none="none"}(Oe||(Oe={})),function(e){e.language="language",e.system="system",e.am_pm="12",e.twenty_four="24"}(Me||(Me={}));var Pe=function(e,t,i){var s;switch(null==t?void 0:t.number_format){case Oe.comma_decimal:s=["en-US","en"];break;case Oe.decimal_comma:s=["de","es","it"];break;case Oe.space_comma:s=["fr","sv","cs"];break;case Oe.system:s=void 0;break;default:s=null==t?void 0:t.language}if(Number.isNaN=Number.isNaN||function e(t){return"number"==typeof t&&e(t)},!Number.isNaN(Number(e))&&Intl&&(null==t?void 0:t.number_format)!==Oe.none)try{return new Intl.NumberFormat(s,He(e,i)).format(Number(e))}catch(t){return console.error(t),new Intl.NumberFormat(void 0,He(e,i)).format(Number(e))}return e?e.toString():""},He=function(e,t){var i=t||{};if("string"!=typeof e)return i;if(!t||!t.minimumFractionDigits&&!t.maximumFractionDigits){var s=e.indexOf(".")>-1?e.split(".")[1].length:0;i.minimumFractionDigits=s,i.maximumFractionDigits=s}return i};function Ue(e,t,i,s){var a=void 0!==s?s:t.state;if("unknown"===a||"unavailable"===a)return e("state.default."+a);if(t.attributes.unit_of_measurement)return Pe(a,i)+" "+t.attributes.unit_of_measurement;var n=function(e){return je(e.entity_id)}(t);if("input_datetime"===n){var r;if(!t.attributes.has_time)return r=new Date(t.attributes.year,t.attributes.month-1,t.attributes.day),De(r,i);if(!t.attributes.has_date){var o=new Date;return r=new Date(o.getFullYear(),o.getMonth(),o.getDay(),t.attributes.hour,t.attributes.minute),Ne(r,i)}return r=new Date(t.attributes.year,t.attributes.month-1,t.attributes.day,t.attributes.hour,t.attributes.minute),Te(r,i)}return"humidifier"===n&&"on"===a&&t.attributes.humidity?t.attributes.humidity+" %":"counter"===n||"number"===n?Pe(a,i):t.attributes.device_class&&e("component."+n+".state."+t.attributes.device_class+"."+t.state)||e("component."+n+".state._."+t.state)||t.state}var Le=function(e,t,i,s){s=s||{},i=null==i?{}:i;var a=new Event(t,{bubbles:void 0===s.bubbles||s.bubbles,cancelable:Boolean(s.cancelable),composed:void 0===s.composed||s.composed});return a.detail=i,e.dispatchEvent(a),a},Re={alert:"hass:alert",automation:"hass:playlist-play",calendar:"hass:calendar",camera:"hass:video",climate:"hass:thermostat",configurator:"hass:settings",conversation:"hass:text-to-speech",device_tracker:"hass:account",fan:"hass:fan",group:"hass:google-circles-communities",history_graph:"hass:chart-line",homeassistant:"hass:home-assistant",homekit:"hass:home-automation",image_processing:"hass:image-filter-frames",input_boolean:"hass:drawing",input_datetime:"hass:calendar-clock",input_number:"hass:ray-vertex",input_select:"hass:format-list-bulleted",input_text:"hass:textbox",light:"hass:lightbulb",mailbox:"hass:mailbox",notify:"hass:comment-alert",person:"hass:account",plant:"hass:flower",proximity:"hass:apple-safari",remote:"hass:remote",scene:"hass:google-pages",script:"hass:file-document",sensor:"hass:eye",simple_alarm:"hass:bell",sun:"hass:white-balance-sunny",switch:"hass:flash",timer:"hass:timer",updater:"hass:cloud-upload",vacuum:"hass:robot-vacuum",water_heater:"hass:thermometer",weblink:"hass:open-in-new"};function Ye(e,t){if(e in Re)return Re[e];switch(e){case"alarm_control_panel":switch(t){case"armed_home":return"hass:bell-plus";case"armed_night":return"hass:bell-sleep";case"disarmed":return"hass:bell-outline";case"triggered":return"hass:bell-ring";default:return"hass:bell"}case"binary_sensor":return t&&"off"===t?"hass:radiobox-blank":"hass:checkbox-marked-circle";case"cover":return"closed"===t?"hass:window-closed":"hass:window-open";case"lock":return t&&"unlocked"===t?"hass:lock-open":"hass:lock";case"media_player":return t&&"off"!==t&&"idle"!==t?"hass:cast-connected":"hass:cast";case"zwave":switch(t){case"dead":return"hass:emoticon-dead";case"sleeping":return"hass:sleep";case"initializing":return"hass:timer-sand";default:return"hass:z-wave"}default:return console.warn("Unable to find icon for domain "+e+" ("+t+")"),"hass:bookmark"}}var Ie={humidity:"hass:water-percent",illuminance:"hass:brightness-5",temperature:"hass:thermometer",pressure:"hass:gauge",power:"hass:flash",signal_strength:"hass:wifi"},Be={binary_sensor:function(e){var t=e.state&&"off"===e.state;switch(e.attributes.device_class){case"battery":return t?"hass:battery":"hass:battery-outline";case"cold":return t?"hass:thermometer":"hass:snowflake";case"connectivity":return t?"hass:server-network-off":"hass:server-network";case"door":return t?"hass:door-closed":"hass:door-open";case"garage_door":return t?"hass:garage":"hass:garage-open";case"gas":case"power":case"problem":case"safety":case"smoke":return t?"hass:shield-check":"hass:alert";case"heat":return t?"hass:thermometer":"hass:fire";case"light":return t?"hass:brightness-5":"hass:brightness-7";case"lock":return t?"hass:lock":"hass:lock-open";case"moisture":return t?"hass:water-off":"hass:water";case"motion":return t?"hass:walk":"hass:run";case"occupancy":return t?"hass:home-outline":"hass:home";case"opening":return t?"hass:square":"hass:square-outline";case"plug":return t?"hass:power-plug-off":"hass:power-plug";case"presence":return t?"hass:home-outline":"hass:home";case"sound":return t?"hass:music-note-off":"hass:music-note";case"vibration":return t?"hass:crop-portrait":"hass:vibrate";case"window":return t?"hass:window-closed":"hass:window-open";default:return t?"hass:radiobox-blank":"hass:checkbox-marked-circle"}},cover:function(e){var t="closed"!==e.state;switch(e.attributes.device_class){case"garage":return t?"hass:garage-open":"hass:garage";case"door":return t?"hass:door-open":"hass:door-closed";case"shutter":return t?"hass:window-shutter-open":"hass:window-shutter";case"blind":return t?"hass:blinds-open":"hass:blinds";case"window":return t?"hass:window-open":"hass:window-closed";default:return Ye("cover",e.state)}},sensor:function(e){var t=e.attributes.device_class;if(t&&t in Ie)return Ie[t];if("battery"===t){var i=Number(e.state);if(isNaN(i))return"hass:battery-unknown";var s=10*Math.round(i/10);return s>=100?"hass:battery":s<=0?"hass:battery-alert":"hass:battery-"+s}var a=e.attributes.unit_of_measurement;return"°C"===a||"°F"===a?"hass:thermometer":Ye("sensor")},input_datetime:function(e){return e.attributes.has_date?e.attributes.has_time?Ye("input_datetime"):"hass:calendar":"hass:clock"}};const Fe=["1","2","3","4","5","6","7","8","9","","0","clear"];var qe;!function(e){e.Disarmed="disarmed",e.Arming="arming",e.Pending="pending",e.Triggered="triggered",e.ArmedAway="armed_away",e.ArmedHome="armed_home",e.ArmedNight="armed_night",e.ArmedVacation="armed_vacation",e.ArmedCustomBypass="armed_custom_bypass"}(qe||(qe={}));const Ve={[qe.ArmedAway]:"hass:shield-lock",[qe.ArmedHome]:"hass:shield-home",[qe.ArmedNight]:"hass:shield-moon",[qe.ArmedVacation]:"hass:shield-airplane",[qe.ArmedCustomBypass]:"hass:security",[qe.Disarmed]:"hass:shield-off",[qe.Arming]:"hass:shield-outline",[qe.Pending]:"hass:shield-outline",[qe.Triggered]:"hass:bell-ring"};var Ze;!function(e){e.ArmAway="arm_away",e.ArmHome="arm_home",e.ArmNight="arm_night",e.ArmVacation="arm_vacation",e.ArmCustomBypass="arm_custom_bypass",e.Disarm="disarm"}(Ze||(Ze={}));const We={[Ze.ArmAway]:qe.ArmedAway,[Ze.ArmHome]:qe.ArmedHome,[Ze.ArmNight]:qe.ArmedNight,[Ze.ArmVacation]:qe.ArmedVacation,[Ze.ArmCustomBypass]:qe.ArmedCustomBypass,[Ze.Disarm]:qe.Disarmed};var Je;!function(e){e.Arm="arm",e.Trigger="trigger",e.FailedToArm="failed_to_arm",e.CommandNotAllowed="command_not_allowed",e.NoCodeProvided="no_code_provided",e.InvalidCodeProvided="invalid_code_provided",e.TriggerTimeExpired="trigger_time_expired"}(Je||(Je={}));const Ke=["arming","pending"],Ge={type:"",entity:"",name:"",keep_keypad_visible:!1,use_clear_icon:!1,button_scale_actions:1,button_scale_keypad:1,states:{},show_messages:!0},Qe={skip_delay:!1,force:!1};var Xe={heading:"Options for arming",skip_delay:"Skip exit delay",force:"Bypass open sensors"},et={keep_keypad_visible:"Keep the keypad always visible, also when no code input is required.",button_scale_actions:"Scaling factor to apply for resizing the action buttons.",button_scale_keypad:"Scaling factor to apply for resizing the keypad buttons.",use_clear_icon:"Show icon (instead of text) in keypad for clearing code input.",show_messages:"Display diagnostic messages when alarm is triggered or cannot be armed.",available_actions:"Available actions:",action_dialog:{title:"Customize display of action '{action}'",show_button:"Show button for this action",button_label:"Override button label",state_label:"Override state label"}},tt={blocking_sensors:"Could not arm due to the following sensors",triggered_sensors:"Alarm was triggered by the following sensors"},it={arm_options:Xe,editor:et,errors:tt},st=Object.freeze({__proto__:null,arm_options:Xe,editor:et,errors:tt,default:it}),at={heading:"Options pour l'armement",skip_delay:"Ignorer le délai de sortie",force:"Bypasser les capteurs ouverts"},nt={keep_keypad_visible:"Gardez le clavier toujours visible, même lorsqu'aucune saisie de code n'est requise.",button_scale_actions:"Facteur d'échelle à appliquer pour le redimensionnement des boutons des actions.",button_scale_keypad:"Facteur d'échelle à appliquer pour le redimensionnement des boutons du clavier.",use_clear_icon:"Afficher l'icône (au lieu du texte) sur le clavier pour effacer la saisie du code.",show_messages:"Afficher les messages de diagnostic lorsque l'alarme est déclenchée ou ne peut pas être armée.",available_actions:"Actions disponibles:",action_dialog:{title:"Personnaliser l'affichage de l'action '{action}'",show_button:"Afficher le bouton pour cette action",button_label:"Remplacer le libellé du bouton",state_label:"Remplacer l'étiquette d'état"}},rt={blocking_sensors:"Impossible d'armer en raison du(es) capteur(s) suivant(s)",triggered_sensors:"L'alarme a été déclenchée par le(s) capteur(s) suivant(s)"},ot={arm_options:at,editor:nt,errors:rt},lt={heading:"Opciones de armado",skip_delay:"Omitir el retardo de salida",force:"Pasar por alto los sensores abiertos"},ct={keep_keypad_visible:"Mantener el teclado siempre visible, también cuando no se requiere ninguna entrada de código.",button_scale_actions:"Factor de escalado para cambiar el tamaño de los botones de acción.",button_scale_keypad:"Factor de escalado para cambiar el tamaño de los botones del teclado.",use_clear_icon:"Mostrar icono (en lugar de texto) en el teclado para borrar la entrada de código.",show_messages:"Mostrar mensajes de diagnóstico cuando se activa la alarma o no se puede activar.",available_actions:"Acciones disponibles:",action_dialog:{title:"Personalizar la visualización de la acción '{action}'",show_button:"mostrar botón para esta acción",button_label:"Sobrescribir el texto del botón",state_label:"Sobrescribir el texto de estado"}},dt={blocking_sensors:"No se pudo armar debido a los siguientes sensores",triggered_sensors:"La alarma fue disparada por los siguientes sensores"},ht={arm_options:lt,editor:ct,errors:dt},ut={heading:"Opzioni di inserimento",skip_delay:"Ignorare il ritardo di uscita",force:"Bypassare i sensori aperti"},pt={keep_keypad_visible:"Mantenere la tastiera sempre visibile, anche quando nessun codice è richiesto.",button_scale_actions:"Fattore di scala da applicare per ridimensionare i pulsanti di azione.",button_scale_keypad:"Fattore di scala da applicare per ridimensionare i pulsanti della tastiera.",use_clear_icon:"Mostrare l'icona (invece del testo) sulla tastiera per cancellare il codice digitato.",show_messages:"Mostrare messaggi diagnostici quando l'allarme viene attivato o non può essere inserito.",available_actions:"Azioni disponibili:",action_dialog:{title:"Personalizzare la visualizzazione dell'azione '{action}'",show_button:"Mostra il pulsante per questa azione",button_label:"Sovrascrivere l'etichetta del pulsante",state_label:"Sovrascrivere l'etichetta di stato"}},mt={blocking_sensors:"Impossibile inserire l'allarme a causa dei seguenti sensori",triggered_sensors:"L'allarme è stato attivato dai seguenti sensori"},gt={arm_options:ut,editor:pt,errors:mt},_t={heading:"警戒选项",skip_delay:"跳过离开延迟",force:"绕过开放的传感器"},bt={keep_keypad_visible:"保持小键盘总是可见,即使不需要输入密码",button_scale_actions:"调整动作按键大小的缩放系数",button_scale_keypad:"调整小键盘按键大小的缩放系数",use_clear_icon:"在小键盘上显示图标(而不是文字),用于清除密码输入。",show_messages:"当警报被触发或无法警戒时,显示诊断信息。",available_actions:"可用动作:",action_dialog:{title:"自定义动作'{action}'的显示",show_button:"显示此操作的按钮",button_label:"覆盖按钮标签",state_label:"覆盖状态标签"}},ft={blocking_sensors:"由于以下传感器而无法警戒",triggered_sensors:"警报是由以下传感器触发的"},vt={arm_options:_t,editor:bt,errors:ft},yt={fr:Object.freeze({__proto__:null,arm_options:at,editor:nt,errors:rt,default:ot}),en:st,es:Object.freeze({__proto__:null,arm_options:lt,editor:ct,errors:dt,default:ht}),it:Object.freeze({__proto__:null,arm_options:ut,editor:pt,errors:mt,default:gt}),"zh-Hans":Object.freeze({__proto__:null,arm_options:_t,editor:bt,errors:ft,default:vt})};function $t(e,t,i="",s=""){const a=t.replace(/['"]+/g,"").replace("-","_");var n;try{n=e.split(".").reduce((e,t)=>e[t],yt[a])}catch(t){n=e.split(".").reduce((e,t)=>e[t],yt.en)}if(void 0===n&&(n=e.split(".").reduce((e,t)=>e[t],yt.en)),""!==i&&""!==s){Array.isArray(i)||(i=[i]),Array.isArray(s)||(s=[s]);for(let e=0;e{let i={hide:!1,button_label:"",state_label:""};return(t.states||{}).hasOwnProperty(e)&&(i=Object.assign(Object.assign({},i),t.states[e])),i},At=e=>{if(!e)return[];const t=e.attributes.supported_features||0;let i=[];return 2&t&&i.push(Ze.ArmAway),1&t&&i.push(Ze.ArmHome),4&t&&i.push(Ze.ArmNight),32&t&&i.push(Ze.ArmVacation),16&t&&i.push(Ze.ArmCustomBypass),i},Ct=e=>null!==e.attributes.code_format,St=e=>e.callWS({type:"alarmo/entities"}),Et=e=>e.callWS({type:"alarmo/config"});let Ot=class extends se{constructor(){super(...arguments),this._entities=null,this._editAction=null}async firstUpdated(){St(this.hass).then(e=>{this._entities=e.map(e=>e.entity_id)}).catch(e=>{}),this._alarmoConfig=await Et(this.hass)}setConfig(e){!(null==e?void 0:e.button_scale_actions)&&(null==e?void 0:e.button_scale)&&(e=Object.assign(Object.assign({},e),{button_scale_actions:null==e?void 0:e.button_scale})),!(null==e?void 0:e.button_scale_keypad)&&(null==e?void 0:e.button_scale)&&(e=Object.assign(Object.assign({},e),{button_scale_keypad:null==e?void 0:e.button_scale})),this._config=Object.assign({},e)}render(){var e,t,i;if(!this._config||!this.hass||!this._entities)return U``;if(!this._entities.length)return U` + */var ce;null===(ce=window.HTMLSlotElement)||void 0===ce||ce.prototype.assignedElements;var de=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,he="[^\\s]+",ue=/\[([^]*?)\]/gm;function pe(e,t){for(var i=[],s=0,a=e.length;s-1?s:null}};function ge(e){for(var t=[],i=1;i3?0:(e-e%10!=10?1:0)*e%10]}},ye=ge({},ve),$e=function(e,t){for(void 0===t&&(t=2),e=String(e);e.length0?"-":"+")+$e(100*Math.floor(Math.abs(t)/60)+Math.abs(t)%60,4)},Z:function(e){var t=e.getTimezoneOffset();return(t>0?"-":"+")+$e(Math.floor(Math.abs(t)/60),2)+":"+$e(Math.abs(t)%60,2)}},xe=function(e){return+e-1},ke=[null,"[1-9]\\d?"],Ae=[null,he],Ce=["isPm",he,function(e,t){var i=e.toLowerCase();return i===t.amPm[0]?0:i===t.amPm[1]?1:null}],Se=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(e){var t=(e+"").match(/([+-]|\d\d)/gi);if(t){var i=60*+t[1]+parseInt(t[2],10);return"+"===t[0]?i:-i}return 0}],Ee=(me("monthNamesShort"),me("monthNames"),{default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",isoDate:"YYYY-MM-DD",isoDateTime:"YYYY-MM-DDTHH:mm:ssZ",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"});var Oe,Me,ze=function(e,t,i){if(void 0===t&&(t=Ee.default),void 0===i&&(i={}),"number"==typeof e&&(e=new Date(e)),"[object Date]"!==Object.prototype.toString.call(e)||isNaN(e.getTime()))throw new Error("Invalid Date pass to format");var s=[];t=(t=Ee[t]||t).replace(ue,(function(e,t){return s.push(t),"@@@"}));var a=ge(ge({},ye),i);return(t=t.replace(de,(function(t){return we[t](e,a)}))).replace(/@@@/g,(function(){return s.shift()}))},De=function(){try{(new Date).toLocaleDateString("i")}catch(e){return"RangeError"===e.name}return!1}()?function(e,t){return e.toLocaleDateString(t.language,{year:"numeric",month:"long",day:"numeric"})}:function(e){return ze(e,"mediumDate")},Te=function(){try{(new Date).toLocaleString("i")}catch(e){return"RangeError"===e.name}return!1}()?function(e,t){return e.toLocaleString(t.language,{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit"})}:function(e){return ze(e,"haDateTime")},Ne=function(){try{(new Date).toLocaleTimeString("i")}catch(e){return"RangeError"===e.name}return!1}()?function(e,t){return e.toLocaleTimeString(t.language,{hour:"numeric",minute:"2-digit"})}:function(e){return ze(e,"shortTime")};function je(e){return e.substr(0,e.indexOf("."))}!function(e){e.language="language",e.system="system",e.comma_decimal="comma_decimal",e.decimal_comma="decimal_comma",e.space_comma="space_comma",e.none="none"}(Oe||(Oe={})),function(e){e.language="language",e.system="system",e.am_pm="12",e.twenty_four="24"}(Me||(Me={}));var Pe=function(e,t,i){var s;switch(null==t?void 0:t.number_format){case Oe.comma_decimal:s=["en-US","en"];break;case Oe.decimal_comma:s=["de","es","it"];break;case Oe.space_comma:s=["fr","sv","cs"];break;case Oe.system:s=void 0;break;default:s=null==t?void 0:t.language}if(Number.isNaN=Number.isNaN||function e(t){return"number"==typeof t&&e(t)},!Number.isNaN(Number(e))&&Intl&&(null==t?void 0:t.number_format)!==Oe.none)try{return new Intl.NumberFormat(s,He(e,i)).format(Number(e))}catch(t){return console.error(t),new Intl.NumberFormat(void 0,He(e,i)).format(Number(e))}return e?e.toString():""},He=function(e,t){var i=t||{};if("string"!=typeof e)return i;if(!t||!t.minimumFractionDigits&&!t.maximumFractionDigits){var s=e.indexOf(".")>-1?e.split(".")[1].length:0;i.minimumFractionDigits=s,i.maximumFractionDigits=s}return i};function Ue(e,t,i,s){var a=void 0!==s?s:t.state;if("unknown"===a||"unavailable"===a)return e("state.default."+a);if(t.attributes.unit_of_measurement)return Pe(a,i)+" "+t.attributes.unit_of_measurement;var n=function(e){return je(e.entity_id)}(t);if("input_datetime"===n){var r;if(!t.attributes.has_time)return r=new Date(t.attributes.year,t.attributes.month-1,t.attributes.day),De(r,i);if(!t.attributes.has_date){var o=new Date;return r=new Date(o.getFullYear(),o.getMonth(),o.getDay(),t.attributes.hour,t.attributes.minute),Ne(r,i)}return r=new Date(t.attributes.year,t.attributes.month-1,t.attributes.day,t.attributes.hour,t.attributes.minute),Te(r,i)}return"humidifier"===n&&"on"===a&&t.attributes.humidity?t.attributes.humidity+" %":"counter"===n||"number"===n?Pe(a,i):t.attributes.device_class&&e("component."+n+".state."+t.attributes.device_class+"."+t.state)||e("component."+n+".state._."+t.state)||t.state}var Le=function(e,t,i,s){s=s||{},i=null==i?{}:i;var a=new Event(t,{bubbles:void 0===s.bubbles||s.bubbles,cancelable:Boolean(s.cancelable),composed:void 0===s.composed||s.composed});return a.detail=i,e.dispatchEvent(a),a},Re={alert:"hass:alert",automation:"hass:playlist-play",calendar:"hass:calendar",camera:"hass:video",climate:"hass:thermostat",configurator:"hass:settings",conversation:"hass:text-to-speech",device_tracker:"hass:account",fan:"hass:fan",group:"hass:google-circles-communities",history_graph:"hass:chart-line",homeassistant:"hass:home-assistant",homekit:"hass:home-automation",image_processing:"hass:image-filter-frames",input_boolean:"hass:drawing",input_datetime:"hass:calendar-clock",input_number:"hass:ray-vertex",input_select:"hass:format-list-bulleted",input_text:"hass:textbox",light:"hass:lightbulb",mailbox:"hass:mailbox",notify:"hass:comment-alert",person:"hass:account",plant:"hass:flower",proximity:"hass:apple-safari",remote:"hass:remote",scene:"hass:google-pages",script:"hass:file-document",sensor:"hass:eye",simple_alarm:"hass:bell",sun:"hass:white-balance-sunny",switch:"hass:flash",timer:"hass:timer",updater:"hass:cloud-upload",vacuum:"hass:robot-vacuum",water_heater:"hass:thermometer",weblink:"hass:open-in-new"};function Ye(e,t){if(e in Re)return Re[e];switch(e){case"alarm_control_panel":switch(t){case"armed_home":return"hass:bell-plus";case"armed_night":return"hass:bell-sleep";case"disarmed":return"hass:bell-outline";case"triggered":return"hass:bell-ring";default:return"hass:bell"}case"binary_sensor":return t&&"off"===t?"hass:radiobox-blank":"hass:checkbox-marked-circle";case"cover":return"closed"===t?"hass:window-closed":"hass:window-open";case"lock":return t&&"unlocked"===t?"hass:lock-open":"hass:lock";case"media_player":return t&&"off"!==t&&"idle"!==t?"hass:cast-connected":"hass:cast";case"zwave":switch(t){case"dead":return"hass:emoticon-dead";case"sleeping":return"hass:sleep";case"initializing":return"hass:timer-sand";default:return"hass:z-wave"}default:return console.warn("Unable to find icon for domain "+e+" ("+t+")"),"hass:bookmark"}}var Ie={humidity:"hass:water-percent",illuminance:"hass:brightness-5",temperature:"hass:thermometer",pressure:"hass:gauge",power:"hass:flash",signal_strength:"hass:wifi"},Be={binary_sensor:function(e){var t=e.state&&"off"===e.state;switch(e.attributes.device_class){case"battery":return t?"hass:battery":"hass:battery-outline";case"cold":return t?"hass:thermometer":"hass:snowflake";case"connectivity":return t?"hass:server-network-off":"hass:server-network";case"door":return t?"hass:door-closed":"hass:door-open";case"garage_door":return t?"hass:garage":"hass:garage-open";case"gas":case"power":case"problem":case"safety":case"smoke":return t?"hass:shield-check":"hass:alert";case"heat":return t?"hass:thermometer":"hass:fire";case"light":return t?"hass:brightness-5":"hass:brightness-7";case"lock":return t?"hass:lock":"hass:lock-open";case"moisture":return t?"hass:water-off":"hass:water";case"motion":return t?"hass:walk":"hass:run";case"occupancy":return t?"hass:home-outline":"hass:home";case"opening":return t?"hass:square":"hass:square-outline";case"plug":return t?"hass:power-plug-off":"hass:power-plug";case"presence":return t?"hass:home-outline":"hass:home";case"sound":return t?"hass:music-note-off":"hass:music-note";case"vibration":return t?"hass:crop-portrait":"hass:vibrate";case"window":return t?"hass:window-closed":"hass:window-open";default:return t?"hass:radiobox-blank":"hass:checkbox-marked-circle"}},cover:function(e){var t="closed"!==e.state;switch(e.attributes.device_class){case"garage":return t?"hass:garage-open":"hass:garage";case"door":return t?"hass:door-open":"hass:door-closed";case"shutter":return t?"hass:window-shutter-open":"hass:window-shutter";case"blind":return t?"hass:blinds-open":"hass:blinds";case"window":return t?"hass:window-open":"hass:window-closed";default:return Ye("cover",e.state)}},sensor:function(e){var t=e.attributes.device_class;if(t&&t in Ie)return Ie[t];if("battery"===t){var i=Number(e.state);if(isNaN(i))return"hass:battery-unknown";var s=10*Math.round(i/10);return s>=100?"hass:battery":s<=0?"hass:battery-alert":"hass:battery-"+s}var a=e.attributes.unit_of_measurement;return"°C"===a||"°F"===a?"hass:thermometer":Ye("sensor")},input_datetime:function(e){return e.attributes.has_date?e.attributes.has_time?Ye("input_datetime"):"hass:calendar":"hass:clock"}};const Fe=["1","2","3","4","5","6","7","8","9","","0","clear"];var qe;!function(e){e.Disarmed="disarmed",e.Arming="arming",e.Pending="pending",e.Triggered="triggered",e.ArmedAway="armed_away",e.ArmedHome="armed_home",e.ArmedNight="armed_night",e.ArmedVacation="armed_vacation",e.ArmedCustomBypass="armed_custom_bypass"}(qe||(qe={}));const Ve={[qe.ArmedAway]:"hass:shield-lock",[qe.ArmedHome]:"hass:shield-home",[qe.ArmedNight]:"hass:shield-moon",[qe.ArmedVacation]:"hass:shield-airplane",[qe.ArmedCustomBypass]:"hass:security",[qe.Disarmed]:"hass:shield-off",[qe.Arming]:"hass:shield-outline",[qe.Pending]:"hass:shield-outline",[qe.Triggered]:"hass:bell-ring"};var Ze;!function(e){e.ArmAway="arm_away",e.ArmHome="arm_home",e.ArmNight="arm_night",e.ArmVacation="arm_vacation",e.ArmCustomBypass="arm_custom_bypass",e.Disarm="disarm"}(Ze||(Ze={}));const We={[Ze.ArmAway]:qe.ArmedAway,[Ze.ArmHome]:qe.ArmedHome,[Ze.ArmNight]:qe.ArmedNight,[Ze.ArmVacation]:qe.ArmedVacation,[Ze.ArmCustomBypass]:qe.ArmedCustomBypass,[Ze.Disarm]:qe.Disarmed};var Je;!function(e){e.Arm="arm",e.Trigger="trigger",e.FailedToArm="failed_to_arm",e.CommandNotAllowed="command_not_allowed",e.NoCodeProvided="no_code_provided",e.InvalidCodeProvided="invalid_code_provided",e.TriggerTimeExpired="trigger_time_expired"}(Je||(Je={}));const Ke=["arming","pending"],Ge={type:"",entity:"",name:"",keep_keypad_visible:!1,use_clear_icon:!1,button_scale_actions:1,button_scale_keypad:1,states:{},show_messages:!0},Qe={skip_delay:!1,force:!1};var Xe={heading:"Options for arming",skip_delay:"Skip exit delay",force:"Bypass open sensors"},et={keep_keypad_visible:"Keep the keypad always visible, also when no code input is required.",button_scale_actions:"Scaling factor to apply for resizing the action buttons.",button_scale_keypad:"Scaling factor to apply for resizing the keypad buttons.",use_clear_icon:"Show icon (instead of text) in keypad for clearing code input.",show_messages:"Display diagnostic messages when alarm is triggered or cannot be armed.",available_actions:"Available actions:",action_dialog:{title:"Customize display of action '{action}'",show_button:"Show button for this action",button_label:"Override button label",state_label:"Override state label"}},tt={blocking_sensors:"Could not arm due to the following sensors",triggered_sensors:"Alarm was triggered by the following sensors"},it={arm_options:Xe,editor:et,errors:tt},st=Object.freeze({__proto__:null,arm_options:Xe,editor:et,errors:tt,default:it}),at={heading:"Options pour l'armement",skip_delay:"Ignorer le délai de sortie",force:"Bypasser les capteurs ouverts"},nt={keep_keypad_visible:"Gardez le clavier toujours visible, même lorsqu'aucune saisie de code n'est requise.",button_scale_actions:"Facteur d'échelle à appliquer pour le redimensionnement des boutons des actions.",button_scale_keypad:"Facteur d'échelle à appliquer pour le redimensionnement des boutons du clavier.",use_clear_icon:"Afficher l'icône (au lieu du texte) sur le clavier pour effacer la saisie du code.",show_messages:"Afficher les messages de diagnostic lorsque l'alarme est déclenchée ou ne peut pas être armée.",available_actions:"Actions disponibles:",action_dialog:{title:"Personnaliser l'affichage de l'action '{action}'",show_button:"Afficher le bouton pour cette action",button_label:"Remplacer le libellé du bouton",state_label:"Remplacer l'étiquette d'état"}},rt={blocking_sensors:"Impossible d'armer en raison du(es) capteur(s) suivant(s)",triggered_sensors:"L'alarme a été déclenchée par le(s) capteur(s) suivant(s)"},ot={arm_options:at,editor:nt,errors:rt},lt={heading:"Opciones de armado",skip_delay:"Omitir el retardo de salida",force:"Pasar por alto los sensores abiertos"},ct={keep_keypad_visible:"Mantener el teclado siempre visible, también cuando no se requiere ninguna entrada de código.",button_scale_actions:"Factor de escalado para cambiar el tamaño de los botones de acción.",button_scale_keypad:"Factor de escalado para cambiar el tamaño de los botones del teclado.",use_clear_icon:"Mostrar icono (en lugar de texto) en el teclado para borrar la entrada de código.",show_messages:"Mostrar mensajes de diagnóstico cuando se activa la alarma o no se puede activar.",available_actions:"Acciones disponibles:",action_dialog:{title:"Personalizar la visualización de la acción '{action}'",show_button:"mostrar botón para esta acción",button_label:"Sobrescribir el texto del botón",state_label:"Sobrescribir el texto de estado"}},dt={blocking_sensors:"No se pudo armar debido a los siguientes sensores",triggered_sensors:"La alarma fue disparada por los siguientes sensores"},ht={arm_options:lt,editor:ct,errors:dt},ut={heading:"Opzioni di inserimento",skip_delay:"Ignorare il ritardo di uscita",force:"Ignorare i sensori aperti"},pt={keep_keypad_visible:"Mantenere la tastiera sempre visibile, anche quando nessun codice è richiesto.",button_scale_actions:"Fattore di scala da applicare per ridimensionare i pulsanti di azione.",button_scale_keypad:"Fattore di scala da applicare per ridimensionare i pulsanti della tastiera.",use_clear_icon:"Mostrare l'icona (invece del testo) sulla tastiera per cancellare il codice digitato.",show_messages:"Mostrare messaggi diagnostici quando l'allarme viene attivato o non può essere inserito.",available_actions:"Azioni disponibili:",action_dialog:{title:"Personalizzare la visualizzazione dell'azione '{action}'",show_button:"Mostra il pulsante per questa azione",button_label:"Sovrascrivere l'etichetta del pulsante",state_label:"Sovrascrivere l'etichetta di stato"}},mt={blocking_sensors:"Impossibile inserire l'allarme a causa dei seguenti sensori",triggered_sensors:"L'allarme è stato attivato dai seguenti sensori"},gt={arm_options:ut,editor:pt,errors:mt},_t={heading:"警戒选项",skip_delay:"跳过离开延迟",force:"绕过开放的传感器"},bt={keep_keypad_visible:"保持小键盘总是可见,即使不需要输入密码",button_scale_actions:"调整动作按键大小的缩放系数",button_scale_keypad:"调整小键盘按键大小的缩放系数",use_clear_icon:"在小键盘上显示图标(而不是文字),用于清除密码输入。",show_messages:"当警报被触发或无法警戒时,显示诊断信息。",available_actions:"可用动作:",action_dialog:{title:"自定义动作'{action}'的显示",show_button:"显示此操作的按钮",button_label:"覆盖按钮标签",state_label:"覆盖状态标签"}},ft={blocking_sensors:"由于以下传感器而无法警戒",triggered_sensors:"警报是由以下传感器触发的"},vt={arm_options:_t,editor:bt,errors:ft},yt={fr:Object.freeze({__proto__:null,arm_options:at,editor:nt,errors:rt,default:ot}),en:st,es:Object.freeze({__proto__:null,arm_options:lt,editor:ct,errors:dt,default:ht}),it:Object.freeze({__proto__:null,arm_options:ut,editor:pt,errors:mt,default:gt}),"zh-Hans":Object.freeze({__proto__:null,arm_options:_t,editor:bt,errors:ft,default:vt})};function $t(e,t,i="",s=""){const a=t.replace(/['"]+/g,"").replace("-","_");var n;try{n=e.split(".").reduce((e,t)=>e[t],yt[a])}catch(t){n=e.split(".").reduce((e,t)=>e[t],yt.en)}if(void 0===n&&(n=e.split(".").reduce((e,t)=>e[t],yt.en)),""!==i&&""!==s){Array.isArray(i)||(i=[i]),Array.isArray(s)||(s=[s]);for(let e=0;e{let i={hide:!1,button_label:"",state_label:""};return(t.states||{}).hasOwnProperty(e)&&(i=Object.assign(Object.assign({},i),t.states[e])),i},At=e=>{if(!e)return[];const t=e.attributes.supported_features||0;let i=[];return 2&t&&i.push(Ze.ArmAway),1&t&&i.push(Ze.ArmHome),4&t&&i.push(Ze.ArmNight),32&t&&i.push(Ze.ArmVacation),16&t&&i.push(Ze.ArmCustomBypass),i},Ct=e=>null!==e.attributes.code_format,St=e=>e.callWS({type:"alarmo/entities"}),Et=e=>e.callWS({type:"alarmo/config"});let Ot=class extends se{constructor(){super(...arguments),this._entities=null,this._editAction=null}async firstUpdated(){St(this.hass).then(e=>{this._entities=e.map(e=>e.entity_id)}).catch(e=>{}),this._alarmoConfig=await Et(this.hass)}setConfig(e){!(null==e?void 0:e.button_scale_actions)&&(null==e?void 0:e.button_scale)&&(e=Object.assign(Object.assign({},e),{button_scale_actions:null==e?void 0:e.button_scale})),!(null==e?void 0:e.button_scale_keypad)&&(null==e?void 0:e.button_scale)&&(e=Object.assign(Object.assign({},e),{button_scale_keypad:null==e?void 0:e.button_scale})),this._config=Object.assign({},e)}render(){var e,t,i;if(!this._config||!this.hass||!this._entities)return U``;if(!this._entities.length)return U` Could not establish a connection with the alarmo integration. Please check if it is installed and running. @@ -533,7 +533,7 @@ const ne=e=>t=>"function"==typeof t?((e,t)=>(customElements.define(e,t),t))(e,t) .hass=${this.hass} .entity=${this._config.entity} @click=${()=>Le(this,"hass-more-info",{entityId:this._config.entity})} - style="--alarm-state-color: ${(e=>{if(!e||!e.state)return"var(--state-unavailable-color)";const t=e.state;return t==qe.Disarmed?"var(--state-inactive-color)":Object.values(qe).includes(t)?`var(--state-alarm_control_panel-${t}-color)`:"var(--disabled-color)"})(i)}" + style="--alarm-state-color: ${(e=>{if(!e||!e.state)return"var(--state-unavailable-color)";const t=e.state;return t==qe.Disarmed?"var(--state-alarm_control_panel-disarmed-color, var(--state-alarm_control_panel-inactive-color, var(--state-inactive-color)))":Object.values(qe).includes(t)?`var(--state-alarm_control_panel-${t}-color, var(--state-alarm_control_panel-active-color, var(--state-active-color)))`:"var(--disabled-color, var(--state-inactive-color))"})(i)}" > @@ -781,4 +781,4 @@ const ne=e=>t=>"function"==typeof t?((e,t)=>(customElements.define(e,t),t))(e,t) font-weight: 500; font-size: 1.1em; } - `}},t([oe({attribute:!1})],e.AlarmoCard.prototype,"hass",void 0),t([le()],e.AlarmoCard.prototype,"_config",void 0),t([le()],e.AlarmoCard.prototype,"_alarmoConfig",void 0),t([le()],e.AlarmoCard.prototype,"_input",void 0),t([le()],e.AlarmoCard.prototype,"warning",void 0),t([le()],e.AlarmoCard.prototype,"area_id",void 0),t([le()],e.AlarmoCard.prototype,"armOptions",void 0),t([le()],e.AlarmoCard.prototype,"backendConnection",void 0),e.AlarmoCard=t([ne("alarmo-card")],e.AlarmoCard),window.customCards=window.customCards||[],window.customCards.push({type:"alarmo-card",name:"Alarmo Card",description:"Card for operating Alarmo through Lovelace.",preview:!0}),console.info("%c ALARMO-CARD \n%c Version: "+"v1.5.0".padEnd(7," "),"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: dimgray")}({}); + `}},t([oe({attribute:!1})],e.AlarmoCard.prototype,"hass",void 0),t([le()],e.AlarmoCard.prototype,"_config",void 0),t([le()],e.AlarmoCard.prototype,"_alarmoConfig",void 0),t([le()],e.AlarmoCard.prototype,"_input",void 0),t([le()],e.AlarmoCard.prototype,"warning",void 0),t([le()],e.AlarmoCard.prototype,"area_id",void 0),t([le()],e.AlarmoCard.prototype,"armOptions",void 0),t([le()],e.AlarmoCard.prototype,"backendConnection",void 0),e.AlarmoCard=t([ne("alarmo-card")],e.AlarmoCard),window.customCards=window.customCards||[],window.customCards.push({type:"alarmo-card",name:"Alarmo Card",description:"Card for operating Alarmo through Lovelace.",preview:!0}),console.info("%c ALARMO-CARD \n%c Version: "+"v1.5.1".padEnd(7," "),"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: dimgray")}({}); diff --git a/src/const.ts b/src/const.ts index 2caec68..02bfcd7 100755 --- a/src/const.ts +++ b/src/const.ts @@ -1,6 +1,6 @@ import { CardConfig } from './types'; -export const CARD_VERSION = 'v1.5.0'; +export const CARD_VERSION = 'v1.5.1'; export const BUTTONS = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '', '0', 'clear'];