iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
2 lines • 14.3 kB
JavaScript
export const __webpack_ids__=["72974"];export const __webpack_modules__={85746:function(t,e,s){s.d(e,{V:()=>n});var i=s(87733);const n=(t,e)=>(t=>{switch(t){case"de":case"lb":return!0;default:return!1}})(e)?(0,i.f)(t):t.toLocaleLowerCase(e)},29095:function(t,e,s){s.a(t,(async function(t,e){try{var i=s(44249),n=s(57243),o=s(15093),a=(s(59826),s(17170)),r=(s(37583),t([a]));a=(r.then?(await r)():r)[0];const c="M2.2,16.06L3.88,12L2.2,7.94L6.26,6.26L7.94,2.2L12,3.88L16.06,2.2L17.74,6.26L21.8,7.94L20.12,12L21.8,16.06L17.74,17.74L16.06,21.8L12,20.12L7.94,21.8L6.26,17.74L2.2,16.06M13,17V15H11V17H13M13,13V7H11V13H13Z",u="M9,20.42L2.79,14.21L5.62,11.38L9,14.77L18.88,4.88L21.71,7.71L9,20.42Z";(0,i.Z)([(0,o.Mo)("ha-progress-button")],(function(t,e){return{F:class extends e{constructor(...e){super(...e),t(this)}},d:[{kind:"field",decorators:[(0,o.Cb)()],key:"label",value:void 0},{kind:"field",decorators:[(0,o.Cb)({type:Boolean})],key:"disabled",value:()=>!1},{kind:"field",decorators:[(0,o.Cb)({type:Boolean})],key:"progress",value:()=>!1},{kind:"field",decorators:[(0,o.Cb)({type:Boolean})],key:"raised",value:()=>!1},{kind:"field",decorators:[(0,o.Cb)({type:Boolean})],key:"unelevated",value:()=>!1},{kind:"field",decorators:[(0,o.SB)()],key:"_result",value:void 0},{kind:"method",key:"render",value:function(){const t=this._result||this.progress;return n.dy` <ha-button .raised="${this.raised}" .label="${this.label}" .unelevated="${this.unelevated}" .disabled="${this.disabled||this.progress}" class="${this._result||""}"> <slot name="icon" slot="icon"></slot> <slot></slot> </ha-button> ${t?n.dy` <div class="progress"> ${"success"===this._result?n.dy`<ha-svg-icon .path="${u}"></ha-svg-icon>`:"error"===this._result?n.dy`<ha-svg-icon .path="${c}"></ha-svg-icon>`:this.progress?n.dy`<ha-spinner size="small"></ha-spinner>`:n.Ld} </div> `:n.Ld} `}},{kind:"method",key:"actionSuccess",value:function(){this._setResult("success")}},{kind:"method",key:"actionError",value:function(){this._setResult("error")}},{kind:"method",key:"_setResult",value:function(t){this._result=t,setTimeout((()=>{this._result=void 0}),2e3)}},{kind:"field",static:!0,key:"styles",value:()=>n.iv`:host{outline:0;display:inline-block;position:relative;pointer-events:none}ha-button{transition:all 1s;pointer-events:initial}ha-button.success{--mdc-theme-primary:white;background-color:var(--success-color);transition:none;border-radius:4px;pointer-events:none}ha-button[raised].success,ha-button[unelevated].success{--mdc-theme-primary:var(--success-color);--mdc-theme-on-primary:white}ha-button.error{--mdc-theme-primary:white;background-color:var(--error-color);transition:none;border-radius:4px;pointer-events:none}ha-button[raised].error,ha-button[unelevated].error{--mdc-theme-primary:var(--error-color);--mdc-theme-on-primary:white}.progress{bottom:4px;position:absolute;text-align:center;top:4px;width:100%}ha-svg-icon{color:#fff}ha-button.error slot,ha-button.success slot{visibility:hidden}:host([destructive]){--mdc-theme-primary:var(--error-color)}`}]}}),n.oi);e()}catch(t){e(t)}}))},6280:function(t,e,s){s.a(t,(async function(t,i){try{s.d(e,{Nu:()=>L,V3:()=>S,Vk:()=>h,YA:()=>$,xS:()=>m,zP:()=>H});s(92745),s(84283),s(9359),s(56475),s(1331),s(31526),s(70104),s(52924),s(92519),s(42179),s(89256),s(24931),s(88463),s(57449),s(19814);var n=s(73850),o=s(97547),a=s(47194),r=t([o]);o=(r.then?(await r)():r)[0];const c=["climate","humidifier","water_heater"],u=["climate","humidifier","input_datetime","water_heater","person","device_tracker"],l=["temperature","current_temperature","target_temp_low","target_temp_high","hvac_action","humidity","mode","action","current_humidity"],d=(t,e)=>!t.states[e]||u.includes((0,n.M)(e)),h=(t,e,s,i,n)=>{const o={type:"history/stream",entity_ids:n,start_time:s.toISOString(),end_time:i.toISOString(),minimal_response:!0,no_attributes:!n.some((e=>d(t,e)))},a=new _(t);return t.connection.subscribeMessage((t=>e(a.processMessage(t))),o)};class _{constructor(t,e){this.hass=void 0,this.hoursToShow=void 0,this.combinedHistory=void 0,this.hass=t,this.hoursToShow=e,this.combinedHistory={}}processMessage(t){if(!this.combinedHistory||!Object.keys(this.combinedHistory).length)return this.combinedHistory=t.states,this.combinedHistory;if(!Object.keys(t.states).length)return this.combinedHistory;const e=this.hoursToShow?((new Date).getTime()-3600*this.hoursToShow*1e3)/1e3:void 0,s={};for(const t of Object.keys(this.combinedHistory))s[t]=[];for(const e of Object.keys(t.states))s[e]=[];for(const i of Object.keys(s)){if(i in this.combinedHistory&&i in t.states){const e=this.combinedHistory[i],n=e[e.length-1];s[i]=e.concat(t.states[i]),t.states[i][0].lu<n.lu&&(s[i]=s[i].sort(((t,e)=>t.lu-e.lu)))}else i in this.combinedHistory?s[i]=this.combinedHistory[i]:s[i]=t.states[i];if(e&&i in this.combinedHistory){const t=s[i].filter((t=>t.lu<e));if(!t.length)continue;if(s[i]=s[i].filter((t=>t.lu>=e)),s[i].length&&s[i][0].lu===e)continue;const n=t[t.length-1];n.lu=e,s[i].unshift(n)}}return this.combinedHistory=s,this.combinedHistory}}const m=(t,e,s,i,n,o=!0,a=!0)=>{const r={type:"history/stream",entity_ids:i,start_time:new Date((new Date).getTime()-3600*s*1e3).toISOString(),minimal_response:o,significant_changes_only:a,no_attributes:n??!i.some((e=>d(t,e)))},c=new _(t,s);return t.connection.subscribeMessage((t=>e(c.processMessage(t))),r)},p=(t,e)=>t.state===e.state&&(!t.attributes||!e.attributes||l.every((s=>t.attributes[s]===e.attributes[s]))),b=(t,e,s,i,n,r,c)=>{const u=[],l=r[0];for(const a of r){if(u.length>0&&a.s===u[u.length-1].state)continue;const r={};c?.attributes.device_class&&(r.device_class=c?.attributes.device_class),u.push({state_localize:(0,o.c)(t,e,[],s,i[n],n,{...a.a||l.a,...r},a.s),state:a.s,last_changed:1e3*(a.lc?a.lc:a.lu)})}return{name:(0,a.a)(n,c?.attributes||l.a),entity_id:n,data:u}},g=(t,e,s,i)=>{const o=[];return Object.keys(s).forEach((t=>{const e=s[t],r=e[0],u=(0,n.M)(t),d=[];for(const t of e){let e;if(c.includes(u)){e={state:t.s,last_changed:1e3*t.lu,attributes:{}};for(const s of l)s in t.a&&(e.attributes[s]=t.a[s])}else e={state:t.s,last_changed:1e3*(t.lc?t.lc:t.lu),attributes:{}};d.length>1&&p(e,d[d.length-1])&&p(e,d[d.length-2])||d.push(e)}const h=t in i?i[t].attributes:"friendly_name"in r.a?r.a:void 0;o.push({domain:u,name:(0,a.a)(t,h||{}),entity_id:t,states:d})})),{unit:t,device_class:e,identifier:Object.keys(s).join(""),data:o}},f=["counter","input_number","number"],y=t=>f.includes(t),v=t=>"unit_of_measurement"in t||"state_class"in t,k=(t,e)=>null!=t.attributes.device_class&&e.includes(t.attributes.device_class),w=" ",$=(t,e,s,i,n=!1)=>{const o={};s.forEach((t=>{t in e&&(o[t]=e[t])}));const a={};Object.entries(o).forEach((([t,e])=>{const s=e.map((t=>({s:null!=t.mean?t.mean.toString():t.state.toString(),lc:t.start/1e3,a:{},lu:t.start/1e3})));a[t]=s}));const r=L(t,a,[],t.localize,i,n,!0);return(r?.line||[]).forEach((t=>{t.data.forEach((t=>{t.statistics=t.states,t.states=[]}))})),r},L=(t,e,s,i,o,a=!1,r=!1)=>{const c={},u=[],l={};if(new Set([...s,...Object.keys(e)]).forEach((s=>{s in e?l[s]=e[s]:t.states[s]&&(l[s]=[{s:t.states[s].state,a:t.states[s].attributes,lu:new Date(t.states[s].last_updated).getTime()/1e3}])})),!l)return{line:[],timeline:[]};Object.keys(l).forEach((e=>{const s=l[e];if(0===s.length)return;const d=(0,n.M)(e),h=e in t.states?t.states[e]:void 0,_=h||y(d)?void 0:s.find((t=>t.a&&v(t.a)));let m;m=H(d,h,_,o,r)?h?.attributes.unit_of_measurement||_?.a.unit_of_measurement||w:{zone:i("ui.dialogs.more_info_control.zone.graph_unit"),climate:t.config.unit_system.temperature,humidifier:"%",water_heater:t.config.unit_system.temperature}[d];const p=M(m,{climate:"temperature",humidifier:"humidity",water_heater:"temperature"}[d]||(h?.attributes||_?.a)?.device_class,a);m?p&&p in c&&e in c[p]?c[p][e].push(...s):p&&(p in c||(c[p]={}),c[p][e]=s):u.push(b(i,t.locale,t.config,t.entities,e,s,h))}));return{line:Object.keys(c).map((e=>{const s=e.split("_"),i=s[0],n=s[1]||void 0;return g(i,n,c[e],t.states)})),timeline:u}},M=(t,e,s)=>s?`${t}_${e||""}`:t,H=(t,e,s,i,n=!1)=>n||y(t)||null!=e&&v(e.attributes)||null!=e&&"sensor"===t&&k(e,i)||null!=s,S=(t,e,s=!0)=>{if(!e)return t;const i={...t,line:[]},n={};for(const e of t.line){const t=M(e.unit,e.device_class,s);t&&(n[t]={historyItem:e})}for(const t of e.line){const e=M(t.unit,t.device_class,s);e&&(e in n?n[e].ltsItem=t:n[e]={ltsItem:t})}for(const{historyItem:t,ltsItem:e}of Object.values(n)){if(!t||!e){i.line.push(t||e);continue}const s={...t,data:[]},n=new Set([...t.data.map((t=>t.entity_id)),...e.data.map((t=>t.entity_id))]);for(const i of n){const n=t.data.find((t=>t.entity_id===i)),o=e.data.find((t=>t.entity_id===i));if(!n||!o){s.data.push(n||o);continue}const a=n.states[0]?.last_changed||o.statistics[o.statistics.length-1].last_changed+1,r=[];for(const t of o.statistics){if(t.last_changed>=a)break;r.push(t)}s.data.push(0===r.length?n:{...n,statistics:r})}i.line.push(s)}return i};i()}catch(t){i(t)}}))},25433:function(t,e,s){s.d(e,{MY:()=>g,Yc:()=>_,hb:()=>p,jV:()=>u,o1:()=>m,ri:()=>b,sS:()=>d});var i=s(73358),n=s(73850),o=s(59847),a=s(85746),r=s(96194);const c="ui.components.logbook.messages",u=["counter","proximity","sensor","zone"],l={triggered_by_numeric_state_of:"numeric state of",triggered_by_state_of:"state of",triggered_by_event:"event",triggered_by_time_pattern:"time pattern",triggered_by_time:"time",triggered_by_homeassistant_stopping:"ioBroker stopping",triggered_by_homeassistant_starting:"ioBroker starting"},d=async(t,e,s)=>h(t,e,void 0,void 0,s),h=(t,e,s,i,n,o)=>{if((i||o)&&(!i||0===i.length)&&(!o||0===o.length))return Promise.resolve([]);const a={type:"logbook/get_events",start_time:e};return s&&(a.end_time=s),i?.length&&(a.entity_ids=i),o?.length&&(a.device_ids=o),n&&(a.context_id=n),t.callWS(a)},_=(t,e,s,i,n,o)=>{if((n||o)&&(!n||0===n.length)&&(!o||0===o.length))return Promise.reject("No entities or devices");const a={type:"logbook/event_stream",start_time:s,end_time:i};return n?.length&&(a.entity_ids=n),o?.length&&(a.device_ids=o),t.connection.subscribeMessage((t=>e(t)),a)},m=(t,e)=>({entity_id:t.entity_id,state:e,attributes:{device_class:t?.attributes.device_class,source_type:t?.attributes.source_type,has_date:t?.attributes.has_date,has_time:t?.attributes.has_time,entity_picture_local:i.iY.has((0,n.M)(t.entity_id))?void 0:t?.attributes.entity_picture_local,entity_picture:i.iY.has((0,n.M)(t.entity_id))?void 0:t?.attributes.entity_picture}}),p=(t,e)=>{for(const s of Object.keys(l)){const i=l[s];if(e.startsWith(i))return e.replace(i,`${t(`ui.components.logbook.${s}`)}`)}return e},b=(t,e,s,n,o)=>{switch(o){case"device_tracker":case"person":return"not_home"===s?e(`${c}.was_away`):"home"===s?e(`${c}.was_at_home`):e(`${c}.was_at_state`,{state:s});case"sun":return e("above_horizon"===s?`${c}.rose`:`${c}.set`);case"binary_sensor":{const o=s===i.uo,r=s===i.lC,u=n.attributes.device_class;if(u&&(o||r))return e(`${c}.${o?"detected_device_classes":"cleared_device_classes"}.${u}`,{device_class:(0,a.V)(e(`component.binary_sensor.entity_component.${u}.name`)||u,t.language)})||e(`${c}.${o?"detected_device_class":"cleared_device_class"}`,{device_class:(0,a.V)(e(`component.binary_sensor.entity_component.${u}.name`)||u,t.language)});break}case"cover":switch(s){case"open":return e(`${c}.was_opened`);case"opening":return e(`${c}.is_opening`);case"closing":return e(`${c}.is_closing`);case"closed":return e(`${c}.was_closed`)}break;case"event":return e(`${c}.detected_event_no_type`);case"lock":switch(s){case"unlocked":return e(`${c}.was_unlocked`);case"locking":return e(`${c}.is_locking`);case"unlocking":return e(`${c}.is_unlocking`);case"opening":return e(`${c}.is_opening`);case"open":return e(`${c}.is_opened`);case"locked":return e(`${c}.was_locked`);case"jammed":return e(`${c}.is_jammed`)}}return s===i.uo?e(`${c}.turned_on`):s===i.lC?e(`${c}.turned_off`):s===r.lz?e(`${c}.became_unknown`):s===r.nZ?e(`${c}.became_unavailable`):t.localize(`${c}.changed_to_state`,{state:n?t.formatEntityState(n,s):s})},g=t=>"sensor"!==(0,o.N)(t)||void 0===t.attributes.unit_of_measurement&&void 0===t.attributes.state_class},81530:function(t,e,s){s.a(t,(async function(t,i){try{s.d(e,{Fb:()=>v,Gt:()=>k,Og:()=>_,PG:()=>y,kh:()=>d,l:()=>b,oA:()=>h,tm:()=>g,uq:()=>p});var n=s(72344),o=s(73850),a=s(3582),r=s(25433),c=s(6280),u=s(49319),l=t([c]);c=(l.then?(await l)():l)[0];const d=["camera","configurator","weather"],h=["scene","automation"],_=["script"],m=["alarm_control_panel","cover","climate","conversation","fan","humidifier","input_boolean","light","lock","siren","script","switch","valve","water_heater","weather"],p=["update"],b=["alarm_control_panel","automation","camera","climate","configurator","conversation","counter","cover","date","datetime","fan","group","humidifier","image","input_boolean","input_datetime","lawn_mower","light","lock","media_player","person","remote","script","scene","siren","sun","switch","time","timer","update","vacuum","valve","water_heater","weather"],g=["input_number","input_select","input_text","number","scene","select","text","update","event"],f=["camera","configurator"],y=(t,e)=>{if("weather"===(0,o.M)(e)){const s=t.states[e];if(s&&(0,u.M0)(s.state))return!1}return(0,n.p)(t,"history")&&!f.includes((0,o.M)(e))},v=(t,e,s=[])=>{if(!(0,n.p)(t,"logbook"))return!1;const i=t.states[e];if(!i)return!1;const a=(0,o.M)(e);return!(r.jV.includes(a)&&(0,c.zP)(a,i,void 0,s)||f.includes(a))&&("weather"!==a||!i||!(0,u.M0)(i.state))},k=t=>{const e=(0,o.M)(t.entity_id);if("group"===e){const e=(0,a.W)(t);return null!=e&&"group"!==e&&m.includes(e)}return m.includes(e)};i()}catch(t){i(t)}}))},12660:function(t,e,s){s.a(t,(async function(t,i){try{if(s.r(e),s.d(e,{createBadgeElement:()=>r.JE,createCardElement:()=>c.Z6,createHeaderFooterElement:()=>u.t,createHuiElement:()=>l.w,createRowElement:()=>d.m,importMoreInfoControl:()=>a.ST,showAlertDialog:()=>o.showAlertDialog,showConfirmationDialog:()=>o.showConfirmationDialog,showEnterCodeDialog:()=>n.t,showPromptDialog:()=>o.showPromptDialog}),99387==s.j)var n=s(17808);var o=s(76131),a=s(88991),r=s(27934),c=s(62037),u=s(64830),l=s(52032),d=s(46542),h=t([a,r,c,l,d]);[a,r,c,l,d]=h.then?(await h)():h,i()}catch(t){i(t)}}))}};
//# sourceMappingURL=72974.f00352c821c5ddf6.js.map