iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
2 lines • 8.53 kB
JavaScript
export const __webpack_ids__=["20353"];export const __webpack_modules__={87707:function(i,t,e){e.d(t,{Q:()=>a});const a=i=>!(!i.detail.selected||"property"!==i.detail.source)&&(i.currentTarget.selected=!1,!0)},5318:function(i,t,e){e.d(t,{AG:()=>s,Gg:()=>c,KL:()=>v,Md:()=>f,_2:()=>y,_K:()=>l,b2:()=>_,dA:()=>r,h6:()=>b,hA:()=>h,hH:()=>u,kJ:()=>$,r3:()=>d});var a=e(47194),n=e(14473),o=e(63318);const s=(i,t)=>i.callWS({type:"device_automation/action/list",device_id:t}),c=(i,t)=>i.callWS({type:"device_automation/condition/list",device_id:t}),d=(i,t)=>i.callWS({type:"device_automation/trigger/list",device_id:t}).then((i=>(0,n.W9)(i))),l=(i,t)=>i.callWS({type:"device_automation/action/capabilities",action:t}),r=(i,t)=>i.callWS({type:"device_automation/condition/capabilities",condition:t}),h=(i,t)=>i.callWS({type:"device_automation/trigger/capabilities",trigger:t}),p=["device_id","domain","entity_id","type","subtype","event","condition","trigger"],u=(i,t,e)=>{if(typeof t!=typeof e)return!1;for(const a in t)if(p.includes(a))if("entity_id"!==a||t[a]?.includes(".")===e[a]?.includes(".")){if(!Object.is(t[a],e[a]))return!1}else if(!m(i,t[a],e[a]))return!1;for(const a in e)if(p.includes(a))if("entity_id"!==a||t[a]?.includes(".")===e[a]?.includes(".")){if(!Object.is(t[a],e[a]))return!1}else if(!m(i,t[a],e[a]))return!1;return!0},m=(i,t,e)=>!(!t||!e)&&(t.includes(".")&&(t=(0,o.w1)(i)[t].id),e.includes(".")&&(e=(0,o.w1)(i)[e].id),t===e),g=(i,t,e)=>{if(!e)return"<"+i.localize("ui.panel.config.automation.editor.unknown_entity")+">";if(e.includes(".")){const t=i.states[e];return t?(0,a.C)(t):e}const n=(0,o.Mw)(t)[e];return n?(0,o.vA)(i,n)||e:"<"+i.localize("ui.panel.config.automation.editor.unknown_entity")+">"},y=(i,t,e)=>i.localize(`component.${e.domain}.device_automation.action_type.${e.type}`,{entity_name:g(i,t,e.entity_id),subtype:e.subtype?i.localize(`component.${e.domain}.device_automation.action_subtype.${e.subtype}`)||e.subtype:""})||(e.subtype?`"${e.subtype}" ${e.type}`:e.type),_=(i,t,e)=>i.localize(`component.${e.domain}.device_automation.condition_type.${e.type}`,{entity_name:g(i,t,e.entity_id),subtype:e.subtype?i.localize(`component.${e.domain}.device_automation.condition_subtype.${e.subtype}`)||e.subtype:""})||(e.subtype?`"${e.subtype}" ${e.type}`:e.type),v=(i,t,e)=>i.localize(`component.${e.domain}.device_automation.trigger_type.${e.type}`,{entity_name:g(i,t,e.entity_id),subtype:e.subtype?i.localize(`component.${e.domain}.device_automation.trigger_subtype.${e.subtype}`)||e.subtype:""})||(e.subtype?`"${e.subtype}" ${e.type}`:e.type),$=(i,t)=>e=>i.localize(`component.${t.domain}.device_automation.extra_fields.${e.name}`)||e.name,f=(i,t)=>e=>i.localize(`component.${t.domain}.device_automation.extra_fields_descriptions.${e.name}`),b=(i,t)=>i.metadata?.secondary&&!t.metadata?.secondary?1:!i.metadata?.secondary&&t.metadata?.secondary?-1:0},25842:function(i,t,e){e.r(t),e.d(t,{DialogDeviceAutomation:()=>m});var a=e(44249),n=e(72621),o=(e(2060),e(57243)),s=e(15093),c=e(36522),d=e(87707),l=e(73729),r=(e(13928),e(7285),e(14473)),h=e(5318),p=e(68418),u=e(28008);let m=(0,a.Z)([(0,s.Mo)("dialog-device-automation")],(function(i,t){class e extends t{constructor(...t){super(...t),i(this)}}return{F:e,d:[{kind:"field",decorators:[(0,s.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,s.SB)()],key:"_triggers",value:()=>[]},{kind:"field",decorators:[(0,s.SB)()],key:"_conditions",value:()=>[]},{kind:"field",decorators:[(0,s.SB)()],key:"_actions",value:()=>[]},{kind:"field",decorators:[(0,s.SB)()],key:"_params",value:void 0},{kind:"method",key:"showDialog",value:async function(i){this._params=i,await this.updateComplete}},{kind:"method",key:"closeDialog",value:function(){this._params=void 0,(0,c.B)(this,"dialog-closed",{dialog:this.localName})}},{kind:"method",key:"firstUpdated",value:function(i){(0,n.Z)(e,"firstUpdated",this,3)([i]),this.hass.loadBackendTranslation("device_automation")}},{kind:"method",key:"updated",value:function(i){if((0,n.Z)(e,"updated",this,3)([i]),!i.has("_params"))return;if(this._triggers=[],this._conditions=[],this._actions=[],!this._params)return;const{device:t,script:a}=this._params;(0,h.AG)(this.hass,t.id).then((i=>{this._actions=i.sort(h.h6)})),a||((0,h.r3)(this.hass,t.id).then((i=>{this._triggers=i.sort(h.h6)})),(0,h.Gg)(this.hass,t.id).then((i=>{this._conditions=i.sort(h.h6)})))}},{kind:"field",key:"_handleRowClick",value(){return i=>{if(!(0,d.Q)(i)||!this._params)return;const t=i.currentTarget.type,e=this._params.script;if(this.closeDialog(),e){const i={};"action"===t&&(i.sequence=[this._actions[0]]),(0,p.rg)(i,!0)}else{const i={};"trigger"===t&&(i.triggers=[this._triggers[0]]),"condition"===t&&(i.conditions=[this._conditions[0]]),"action"===t&&(i.actions=[this._actions[0]]),(0,r.Ip)(i,!0)}}}},{kind:"method",key:"render",value:function(){if(!this._params)return o.Ld;const i=this._params.script?"script":"automation",t=this.hass.localize(`ui.panel.config.devices.${i}.create`,{type:this.hass.localize(`ui.panel.config.devices.type.${this._params.device.entry_type||"device"}`)});return o.dy` <ha-dialog open hideActions ="${this.closeDialog}" .heading="${(0,l.i)(this.hass,t)}"> <mwc-list innerRole="listbox" itemRoles="option" innerAriaLabel="Create new automation" rootTabbable dialogInitialFocus> ${this._triggers.length?o.dy` <ha-list-item hasmeta twoline graphic="icon" .type="${"trigger"}" -selected="${this._handleRowClick}"> <ha-svg-icon slot="graphic" .path="${"M10,9A1,1 0 0,1 11,8A1,1 0 0,1 12,9V13.47L13.21,13.6L18.15,15.79C18.68,16.03 19,16.56 19,17.14V21.5C18.97,22.32 18.32,22.97 17.5,23H11C10.62,23 10.26,22.85 10,22.57L5.1,18.37L5.84,17.6C6.03,17.39 6.3,17.28 6.58,17.28H6.8L10,19V9M11,5A4,4 0 0,1 15,9C15,10.5 14.2,11.77 13,12.46V11.24C13.61,10.69 14,9.89 14,9A3,3 0 0,0 11,6A3,3 0 0,0 8,9C8,9.89 8.39,10.69 9,11.24V12.46C7.8,11.77 7,10.5 7,9A4,4 0 0,1 11,5Z"}"></ha-svg-icon> ${this.hass.localize("ui.panel.config.devices.automation.triggers.title")} <span slot="secondary"> ${this.hass.localize("ui.panel.config.devices.automation.triggers.description")} </span> <ha-icon-next slot="meta"></ha-icon-next> </ha-list-item> `:o.Ld} ${this._conditions.length?o.dy` <ha-list-item hasmeta twoline graphic="icon" .type="${"condition"}" -selected="${this._handleRowClick}"> <ha-svg-icon slot="graphic" .path="${"M4 2A2 2 0 0 0 2 4V12H4V8H6V12H8V4A2 2 0 0 0 6 2H4M4 4H6V6H4M22 15.5V14A2 2 0 0 0 20 12H16V22H20A2 2 0 0 0 22 20V18.5A1.54 1.54 0 0 0 20.5 17A1.54 1.54 0 0 0 22 15.5M20 20H18V18H20V20M20 16H18V14H20M5.79 21.61L4.21 20.39L18.21 2.39L19.79 3.61Z"}"></ha-svg-icon> ${this.hass.localize("ui.panel.config.devices.automation.conditions.title")} <span slot="secondary"> ${this.hass.localize("ui.panel.config.devices.automation.conditions.description")} </span> <ha-icon-next slot="meta"></ha-icon-next> </ha-list-item> `:o.Ld} ${this._actions.length?o.dy` <ha-list-item hasmeta twoline graphic="icon" .type="${"action"}" -selected="${this._handleRowClick}"> <ha-svg-icon slot="graphic" .path="${"M12,5A2,2 0 0,1 14,7C14,7.24 13.96,7.47 13.88,7.69C17.95,8.5 21,11.91 21,16H3C3,11.91 6.05,8.5 10.12,7.69C10.04,7.47 10,7.24 10,7A2,2 0 0,1 12,5M22,19H2V17H22V19Z"}"></ha-svg-icon> ${this.hass.localize(`ui.panel.config.devices.${i}.actions.title`)} <span slot="secondary"> ${this.hass.localize(`ui.panel.config.devices.${i}.actions.description`)} </span> <ha-icon-next slot="meta"></ha-icon-next> </ha-list-item> `:o.Ld} ${this._triggers.length||this._conditions.length||this._actions.length?o.dy`<li divider role="separator"></li>`:o.Ld} <ha-list-item hasmeta twoline graphic="icon" -selected="${this._handleRowClick}"> <ha-svg-icon slot="graphic" .path="${"M14.06,9L15,9.94L5.92,19H5V18.08L14.06,9M17.66,3C17.41,3 17.15,3.1 16.96,3.29L15.13,5.12L18.88,8.87L20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18.17,3.09 17.92,3 17.66,3M14.06,6.19L3,17.25V21H6.75L17.81,9.94L14.06,6.19Z"}"></ha-svg-icon> ${this.hass.localize(`ui.panel.config.devices.${i}.new.title`)} <span slot="secondary"> ${this.hass.localize(`ui.panel.config.devices.${i}.new.description`)} </span> <ha-icon-next slot="meta"></ha-icon-next> </ha-list-item> </mwc-list> </ha-dialog> `}},{kind:"get",static:!0,key:"styles",value:function(){return[u.Qx,u.yu,o.iv`ha-dialog{--dialog-content-padding:0;--mdc-dialog-max-height:60vh} all and (min-width:550px){ha-dialog{--mdc-dialog-min-width:500px}}ha-icon-next{width:24px}`]}}]}}),o.oi)}};
//# sourceMappingURL=20353.c5f6b2cdb3439c14.js.map