UNPKG

iobroker.lovelace

Version:

With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI

1 lines 12.5 kB
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[52808],{58139:function(e,t,s){s.d(t,{d:function(){return i},t:function(){return a}});s(3362);const i=async(e,t)=>new Promise(s=>{const i=t(e,e=>{i(),s(e)})}),a=async e=>new Promise(t=>{const s=e.subscribe(e=>{s(),t(e)})})},64138:function(e,t,s){s.a(e,async function(e,i){try{s.r(t),s.d(t,{HaIconPicker:function(){return w}});s(74423),s(44114),s(26910),s(18111),s(22489),s(7588),s(61701),s(13579),s(3362),s(27495),s(25440),s(62953);var a=s(40445),o=s(5124),r=s(67576),n=s(22786),l=s(1087),c=s(700),u=(s(75064),s(38508)),h=(s(47680),e([u]));u=(h.then?(await h)():h)[0];let d,g,p,f=e=>e,b=[],m=!1;const v=(e,t)=>{var s;const i=`${t}:${e.name}`,a=e.name,o=a.split("-"),r=null!==(s=e.keywords)&&void 0!==s?s:[],n={iconName:a};return o.forEach((e,t)=>{n[`part${t}`]=e}),r.forEach((e,t)=>{n[`keyword${t}`]=e}),{id:i,primary:i,icon:i,search_labels:n,sorting_label:i}},_=async()=>{m=!0;const e=await s.e(81340).then(s.t.bind(s,25143,19));b=e.default.map(e=>v(e,"mdi"));const t=[];Object.keys(c.y).forEach(e=>{t.push(y(e))}),(await Promise.all(t)).forEach(e=>{b.push(...e)})},y=async e=>{try{const t=c.y[e].getIconList;if("function"!=typeof t)return[];return(await t()).map(t=>v(t,e))}catch(t){return console.warn(`Unable to load icon list for ${e} iconset`),[]}},$=e=>(0,o.qy)(d||(d=f` <ha-combo-box-item type="button"> <ha-icon .icon="${0}" slot="start"></ha-icon> ${0} </ha-combo-box-item> `),e.id,e.id);class w extends o.WF{render(){return(0,o.qy)(g||(g=f` <ha-generic-picker allow-custom-value .getItems="${0}" .helper="${0}" .disabled="${0}" .required="${0}" .errorMessage="${0}" .invalid="${0}" .rowRenderer="${0}" .icon="${0}" .label="${0}" .value="${0}" .searchFn="${0}" @value-changed="${0}"> <slot name="start"></slot> </ha-generic-picker> `),this._getIconPickerItems,this.helper,this.disabled,this.required,this.errorMessage,this.invalid,$,this._icon,this.label,this._value,this._filterIcons,this._valueChanged)}firstUpdated(){m||_().then(()=>{this._getIconPickerItems=()=>b,this.requestUpdate()})}_valueChanged(e){e.stopPropagation(),this._setValue(e.detail.value)}_setValue(e){this.value=e,(0,l.r)(this,"value-changed",{value:this._value},{bubbles:!1,composed:!1})}get _icon(){var e;return null!==(e=this.value)&&void 0!==e&&e.length?this.value:this.placeholder}get _value(){return this.value||""}constructor(...e){super(...e),this.disabled=!1,this.required=!1,this.invalid=!1,this._getIconPickerItems=()=>b,this._filterIcons=(0,n.A)((e,t,s)=>{const i=e.toLowerCase().replace(/\s+/g,"-"),a=null!=s&&s.length?s:t;if(!i.length)return a;const o=[];for(const r of a){const e=(r.id.split(":")[1]||r.id).toLowerCase().split("-"),t=r.search_labels?Object.values(r.search_labels).filter(e=>null!==e).map(e=>e.toLowerCase()):[],s=r.id.toLowerCase();e.includes(i)?o.push({item:r,rank:1}):t.includes(i)?o.push({item:r,rank:2}):s.includes(i)?o.push({item:r,rank:3}):t.some(e=>e.includes(i))&&o.push({item:r,rank:4})}return o.sort((e,t)=>e.rank-t.rank).map(e=>e.item)})}}w.styles=(0,o.AH)(p||(p=f`ha-generic-picker{width:100%;display:block}`)),(0,a.Cg)([(0,r.MZ)()],w.prototype,"value",void 0),(0,a.Cg)([(0,r.MZ)()],w.prototype,"label",void 0),(0,a.Cg)([(0,r.MZ)()],w.prototype,"helper",void 0),(0,a.Cg)([(0,r.MZ)()],w.prototype,"placeholder",void 0),(0,a.Cg)([(0,r.MZ)({attribute:"error-message"})],w.prototype,"errorMessage",void 0),(0,a.Cg)([(0,r.MZ)({type:Boolean})],w.prototype,"disabled",void 0),(0,a.Cg)([(0,r.MZ)({type:Boolean})],w.prototype,"required",void 0),(0,a.Cg)([(0,r.MZ)({type:Boolean})],w.prototype,"invalid",void 0),w=(0,a.Cg)([(0,r.EM)("ha-icon-picker")],w),i()}catch(d){i(d)}})},63891:function(e,t,s){s(16280),s(3362),s(62953);var i=s(40445),a=s(5124),o=s(67576),r=s(36312),n=s(1087),l=s(49142);s(34296),s(67094);let c,u,h=e=>e;class d extends a.WF{firstUpdated(e){super.firstUpdated(e),this.hass&&(0,r.x)(this.hass.config,"ai_task")&&(0,l.sG)(this.hass).then(e=>{this._aiPrefs=e})}render(){if(!this._aiPrefs||!this._aiPrefs.gen_data_entity_id)return a.s6;let e;switch(this._state.status){case"error":e=this.hass.localize("ui.components.suggest_with_ai.error");break;case"done":e=this.hass.localize("ui.components.suggest_with_ai.done");break;case"suggesting":e=this.hass.localize(`ui.components.suggest_with_ai.suggesting_${this._state.suggestionIndex}`);break;default:e=this.hass.localize("ui.components.suggest_with_ai.label")}return(0,a.qy)(c||(c=h` <ha-assist-chip @click="${0}" .label="${0}" ?active="${0}" class="${0}" style="${0}"> <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> </ha-assist-chip> `),this._suggest,e,"suggesting"===this._state.status,"error"===this._state.status?"error":"done"===this._state.status?"done":"",this._minWidth?`min-width: ${this._minWidth}`:"","M12,1L9,9L1,12L9,15L12,23L15,15L23,12L15,9L12,1Z")}async _suggest(){if(this.generateTask&&"suggesting"!==this._state.status){this._chip&&(this._minWidth=`${this._chip.offsetWidth}px`),this._state={status:"suggesting",suggestionIndex:1};try{this._intervalId=window.setInterval(()=>{this._state=Object.assign(Object.assign({},this._state),{},{suggestionIndex:this._state.suggestionIndex%3+1})},3e3);const e=await this.generateTask();let t;if("data"!==e.type)throw new Error("Unsupported task type");t=await(0,l.Pj)(this.hass,e.task),(0,n.r)(this,"suggestion",t),this._state=Object.assign(Object.assign({},this._state),{},{status:"done"})}catch(e){console.error("Error generating AI suggestion:",e),this._state=Object.assign(Object.assign({},this._state),{},{status:"error"})}finally{this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),setTimeout(()=>{this._state=Object.assign(Object.assign({},this._state),{},{status:"idle"}),this._minWidth=void 0},3e3)}}}constructor(...e){super(...e),this._state={status:"idle",suggestionIndex:1}}}d.styles=(0,a.AH)(u||(u=h`ha-assist-chip[active]{animation:pulse-glow 1.5s ease-in-out infinite}ha-assist-chip.error{box-shadow:0 0 12px 4px rgba(var(--rgb-error-color),.8)}ha-assist-chip.done{box-shadow:0 0 12px 4px rgba(var(--rgb-primary-color),.8)}@keyframes pulse-glow{0%{box-shadow:0 0 0 0 rgba(var(--rgb-primary-color),0)}50%{box-shadow:0 0 8px 2px rgba(var(--rgb-primary-color),.6)}100%{box-shadow:0 0 0 0 rgba(var(--rgb-primary-color),0)}}`)),(0,i.Cg)([(0,o.MZ)({attribute:!1})],d.prototype,"hass",void 0),(0,i.Cg)([(0,o.MZ)({attribute:"task-type"})],d.prototype,"taskType",void 0),(0,i.Cg)([(0,o.MZ)({attribute:!1})],d.prototype,"generateTask",void 0),(0,i.Cg)([(0,o.wk)()],d.prototype,"_aiPrefs",void 0),(0,i.Cg)([(0,o.wk)()],d.prototype,"_state",void 0),(0,i.Cg)([(0,o.wk)()],d.prototype,"_minWidth",void 0),(0,i.Cg)([(0,o.P)("ha-assist-chip")],d.prototype,"_chip",void 0),d=(0,i.Cg)([(0,o.EM)("ha-suggest-with-ai-button")],d)},49142:function(e,t,s){s.d(t,{HU:function(){return o},Pj:function(){return r},sG:function(){return a},xW:function(){return i}});s(3362);var i=66649!=s.j?function(e){return e[e.GENERATE_DATA=1]="GENERATE_DATA",e[e.SUPPORT_ATTACHMENTS=2]="SUPPORT_ATTACHMENTS",e[e.GENERATE_IMAGE=4]="GENERATE_IMAGE",e}({}):null;const a=e=>e.callWS({type:"ai_task/preferences/get"}),o=(e,t)=>e.callWS(Object.assign({type:"ai_task/preferences/set"},t)),r=async(e,t)=>(await e.callService("ai_task","generate_data",t,void 0,!0,!0)).response},36215:function(e,t,s){s.a(e,async function(e,i){try{s.d(t,{Fn:function(){return d},q3:function(){return h}});s(89463),s(18111),s(22489),s(20116),s(61701),s(53921),s(3362),s(62953);var a=s(74487),o=s(53289),r=s(91536),n=e([a]);a=(n.then?(await n)():n)[0];const c={name:!0,description:!0,categories:!0,labels:!0},u=new Intl.ListFormat("en",{style:"long",type:"conjunction"});async function h(e,t,s,i,a=[],n=c){const[l,h]=await Promise.all([n.categories?(0,r.jE)(e,s):Promise.resolve(void 0),n.floor?(0,r.q6)(e):Promise.resolve(void 0)]),d=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},n.name&&{name:{description:`The name of the ${s}`,required:!0,selector:{text:{}}}}),n.description&&{description:{description:`A short description of the ${s}`,required:!1,selector:{text:{}}}}),n.labels&&{labels:{description:`Labels for the ${s}`,required:!1,selector:{text:{multiple:!0}}}}),n.categories&&l&&{category:{description:`The category of the ${s}`,required:!1,selector:{select:{options:Object.entries(l).map(([e,t])=>({value:e,label:t}))}}}}),n.floor&&h&&{floor:{description:`The floor of the ${s}`,required:!1,selector:{select:{options:Object.values(h).map(e=>({value:e.floor_id,label:e.name}))}}}}),g=[n.name?"a name":null,n.description?"a description":null,n.categories?"a category":null,n.labels?"labels":null,n.floor?"a floor":null].filter(e=>null!==e),p=[n.categories?"category":null,n.labels?"labels":null,n.floor?"floor":null].filter(e=>null!==e),f=u.format(p);return{type:"data",task:{task_name:`frontend__${s}__save`,instructions:[`Suggest in language "${t}" ${g.length?u.format(g):"suggestions"} for the following ioBroker ${s}.`,"",n.name?`The name should be relevant to the ${s}'s purpose.`:`The suggestions should be relevant to the ${s}'s purpose.`,...a.length?[...n.name?[`The name should be in same style and sentence capitalization as existing ${s}s.`]:[],...n.categories||n.labels||n.floor?[`Suggest ${f} if relevant to the ${s}'s purpose.`,`Only suggest ${f} that are already used by existing ${s}s.`]:[]]:n.name?[`The name should be short, descriptive, sentence case, and written in the language ${t}.`]:[],...n.description?[`If the ${s} contains 5+ steps, include a short description.`]:[],"",`For inspiration, here are existing ${s}s:`,a.join("\n"),"",`The ${s} configuration is as follows:`,"",`${(0,o.dump)(i)}`].join("\n"),structure:d}}}async function d(e,t,s,i=c){var a;const[o,n,l]=await Promise.all([i.categories?(0,r.jE)(e,t):Promise.resolve(void 0),i.labels?(0,r.wR)(e):Promise.resolve(void 0),i.floor?(0,r.q6)(e):Promise.resolve(void 0)]),u={name:i.name?s.data.name:void 0,description:i.description?s.data.description:void 0};if(i.categories&&o&&s.data.category){var h;const e=null===(h=Object.entries(o).find(([,e])=>e===s.data.category))||void 0===h?void 0:h[0];e&&(u.category=e)}if(i.labels&&n&&null!==(a=s.data.labels)&&void 0!==a&&a.length){const e=Object.fromEntries(s.data.labels.map(e=>[e,void 0]));let t=s.data.labels.length;for(const[s,a]of Object.entries(n))if(a in e&&void 0===e[a]&&(e[a]=s,t--,0===t))break;const i=Object.values(e).filter(e=>void 0!==e);i.length&&(u.labels=i)}if(i.floor&&l&&s.data.floor){var d;const e=s.data.floor in l?s.data.floor:null===(d=Object.entries(l).find(([,e])=>e.name===s.data.floor))||void 0===d?void 0:d[0];e&&(u.floor=e)}return u}i()}catch(l){i(l)}})},91536:function(e,t,s){s.d(t,{RF:function(){return g},U3:function(){return p},jE:function(){return u},q6:function(){return d},wR:function(){return h}});s(18111),s(61701),s(53921);var i=s(58139),a=s(53641),o=s(76570),r=s(59241),n=s(42961),l=s(92557);const c=e=>e.catch(e=>(console.error("Error fetching data for suggestion: ",e),{})),u=(e,t)=>c((0,o.AH)(e,t).then(e=>Object.fromEntries(e.map(e=>[e.category_id,e.name])))),h=e=>c((0,i.d)(e,l.o5).then(e=>Object.fromEntries(e.map(e=>[e.label_id,e.name])))),d=e=>c((0,i.d)(e,n.e).then(e=>Object.fromEntries(e.map(e=>[e.floor_id,e])))),g=e=>c((0,i.d)(e,a.ft).then(e=>Object.fromEntries(e.map(e=>[e.area_id,e])))),p=e=>c((0,i.d)(e,r.Bz).then(e=>Object.fromEntries(e.map(e=>[e.entity_id,e]))))},97268:function(e,t,s){s.d(t,{U:function(){return r},m:function(){return o}});s(44114),s(72712),s(18111),s(22489),s(61701),s(18237),s(3362),s(62953);if(66649!=s.j)var i=s(71727);var a=s(91536);const o=async(e,t,s)=>{const[o,r,n]=await Promise.all([(0,a.jE)(e,s),(0,a.U3)(e),(0,a.wR)(e)]);return Object.values(r).reduce((e,a)=>{if(!a||(0,i.m)(a.entity_id)!==s)return e;const r=t[a.entity_id];if(!r||r.attributes.restored||!r.attributes.friendly_name)return e;let l=`- ${r.attributes.friendly_name}`;const c=a.categories[s];if(c&&o[c]&&(l+=` (category: ${o[c]})`),a.labels.length){const e=a.labels.map(e=>n[e]).filter(Boolean);e.length&&(l+=` (labels: ${e.join(", ")})`)}return e.push(l),e},[])},r=async e=>{const[t,s,i]=await Promise.all([(0,a.wR)(e),(0,a.q6)(e),(0,a.RF)(e)]);return Object.values(i).reduce((e,i)=>{var a;if(!i.floor_id)return e;const o=null===(a=s[i.floor_id])||void 0===a?void 0:a.name,r=i.labels.map(e=>t[e]).filter(Boolean);return e.push(`- ${i.name} (${o?`floor: ${o}`:"no floor"}${r.length?`, labels: ${r.join(", ")}`:""})`),e},[])}}}]);