UNPKG

iobroker.lovelace

Version:

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

2 lines 15 kB
"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["72974"],{85746:function(t,e,s){s.d(e,{V:()=>i});var n=s(87733);const i=(t,e)=>(t=>{switch(t){case"de":case"lb":return!0;default:return!1}})(e)?(0,n.f)(t):t.toLocaleLowerCase(e)},29095:function(t,e,s){s.a(t,(async function(t,e){try{var n=s(61701),i=(s(71695),s(47021),s(57243)),o=s(50778),a=(s(59826),s(17170)),r=(s(37583),t([a]));a=(r.then?(await r)():r)[0];let c,l,u,d,h,_,m=t=>t;const b="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",g="M9,20.42L2.79,14.21L5.62,11.38L9,14.77L18.88,4.88L21.71,7.71L9,20.42Z";(0,n.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(){return!1}},{kind:"field",decorators:[(0,o.Cb)({type:Boolean})],key:"progress",value(){return!1}},{kind:"field",decorators:[(0,o.Cb)({type:Boolean})],key:"raised",value(){return!1}},{kind:"field",decorators:[(0,o.Cb)({type:Boolean})],key:"unelevated",value(){return!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(0,i.dy)(c||(c=m` <ha-button .raised="${0}" .label="${0}" .unelevated="${0}" .disabled="${0}" class="${0}"> <slot name="icon" slot="icon"></slot> <slot></slot> </ha-button> ${0} `),this.raised,this.label,this.unelevated,this.disabled||this.progress,this._result||"",t?(0,i.dy)(l||(l=m` <div class="progress"> ${0} </div> `),"success"===this._result?(0,i.dy)(u||(u=m`<ha-svg-icon .path="${0}"></ha-svg-icon>`),g):"error"===this._result?(0,i.dy)(d||(d=m`<ha-svg-icon .path="${0}"></ha-svg-icon>`),b):this.progress?(0,i.dy)(h||(h=m`<ha-spinner size="small"></ha-spinner>`)):i.Ld):i.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(){return(0,i.iv)(_||(_=m`: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)}`))}}]}}),i.oi);e()}catch(c){e(c)}}))},6280:function(t,e,s){s.a(t,(async function(t,n){try{s.d(e,{Nu:()=>j,V3:()=>M,Vk:()=>h,YA:()=>$,xS:()=>m,zP:()=>O});s(19083),s(71695),s(92745),s(61893),s(84283),s(9359),s(56475),s(1331),s(31526),s(70104),s(52924),s(19423),s(11740),s(92519),s(42179),s(89256),s(24931),s(88463),s(57449),s(19814),s(61006),s(47021);var i=s(73850),o=s(97547),a=s(47194),r=t([o]);o=(r.then?(await r)():r)[0];const c=["climate","humidifier","water_heater"],l=["climate","humidifier","input_datetime","water_heater","person","device_tracker"],u=["temperature","current_temperature","target_temp_low","target_temp_high","hvac_action","humidity","mode","action","current_humidity"],d=(t,e)=>!t.states[e]||l.includes((0,i.M)(e)),h=(t,e,s,n,i)=>{const o={type:"history/stream",entity_ids:i,start_time:s.toISOString(),end_time:n.toISOString(),minimal_response:!0,no_attributes:!i.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 n of Object.keys(this.combinedHistory))s[n]=[];for(const n of Object.keys(t.states))s[n]=[];for(const n of Object.keys(s)){if(n in this.combinedHistory&&n in t.states){const e=this.combinedHistory[n],i=e[e.length-1];s[n]=e.concat(t.states[n]),t.states[n][0].lu<i.lu&&(s[n]=s[n].sort(((t,e)=>t.lu-e.lu)))}else n in this.combinedHistory?s[n]=this.combinedHistory[n]:s[n]=t.states[n];if(e&&n in this.combinedHistory){const t=s[n].filter((t=>t.lu<e));if(!t.length)continue;if(s[n]=s[n].filter((t=>t.lu>=e)),s[n].length&&s[n][0].lu===e)continue;const i=t[t.length-1];i.lu=e,s[n].unshift(i)}}return this.combinedHistory=s,this.combinedHistory}}const m=(t,e,s,n,i,o=!0,a=!0)=>{const r={type:"history/stream",entity_ids:n,start_time:new Date((new Date).getTime()-3600*s*1e3).toISOString(),minimal_response:o,significant_changes_only:a,no_attributes:null!=i?i:!n.some((e=>d(t,e)))},c=new _(t,s);return t.connection.subscribeMessage((t=>e(c.processMessage(t))),r)},b=(t,e)=>t.state===e.state&&(!t.attributes||!e.attributes||u.every((s=>t.attributes[s]===e.attributes[s]))),g=(t,e,s,n,i,r,c)=>{const l=[],u=r[0];for(const a of r){if(l.length>0&&a.s===l[l.length-1].state)continue;const r={};null!=c&&c.attributes.device_class&&(r.device_class=null==c?void 0:c.attributes.device_class),l.push({state_localize:(0,o.c)(t,e,[],s,n[i],i,Object.assign(Object.assign({},a.a||u.a),r),a.s),state:a.s,last_changed:1e3*(a.lc?a.lc:a.lu)})}return{name:(0,a.a)(i,(null==c?void 0:c.attributes)||u.a),entity_id:i,data:l}},p=(t,e,s,n)=>{const o=[];return Object.keys(s).forEach((t=>{const e=s[t],r=e[0],l=(0,i.M)(t),d=[];for(const s of e){let t;if(c.includes(l)){t={state:s.s,last_changed:1e3*s.lu,attributes:{}};for(const e of u)e in s.a&&(t.attributes[e]=s.a[e])}else t={state:s.s,last_changed:1e3*(s.lc?s.lc:s.lu),attributes:{}};d.length>1&&b(t,d[d.length-1])&&b(t,d[d.length-2])||d.push(t)}const h=t in n?n[t].attributes:"friendly_name"in r.a?r.a:void 0;o.push({domain:l,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"],v=t=>f.includes(t),y=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,n,i=!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=j(t,a,[],t.localize,n,i,!0);return((null==r?void 0:r.line)||[]).forEach((t=>{t.data.forEach((t=>{t.statistics=t.states,t.states=[]}))})),r},j=(t,e,s,n,o,a=!1,r=!1)=>{const c={},l=[],u={};if(new Set([...s,...Object.keys(e)]).forEach((s=>{s in e?u[s]=e[s]:t.states[s]&&(u[s]=[{s:t.states[s].state,a:t.states[s].attributes,lu:new Date(t.states[s].last_updated).getTime()/1e3}])})),!u)return{line:[],timeline:[]};Object.keys(u).forEach((e=>{var s;const d=u[e];if(0===d.length)return;const h=(0,i.M)(e),_=e in t.states?t.states[e]:void 0,m=_||v(h)?void 0:d.find((t=>t.a&&y(t.a)));let b;b=O(h,_,m,o,r)?(null==_?void 0:_.attributes.unit_of_measurement)||(null==m?void 0:m.a.unit_of_measurement)||w:{zone:n("ui.dialogs.more_info_control.zone.graph_unit"),climate:t.config.unit_system.temperature,humidifier:"%",water_heater:t.config.unit_system.temperature}[h];const p={climate:"temperature",humidifier:"humidity",water_heater:"temperature"}[h]||(null===(s=(null==_?void 0:_.attributes)||(null==m?void 0:m.a))||void 0===s?void 0:s.device_class),f=L(b,p,a);b?f&&f in c&&e in c[f]?c[f][e].push(...d):f&&(f in c||(c[f]={}),c[f][e]=d):l.push(g(n,t.locale,t.config,t.entities,e,d,_))}));return{line:Object.keys(c).map((e=>{const s=e.split("_"),n=s[0],i=s[1]||void 0;return p(n,i,c[e],t.states)})),timeline:l}},L=(t,e,s)=>s?`${t}_${e||""}`:t,O=(t,e,s,n,i=!1)=>i||v(t)||null!=e&&y(e.attributes)||null!=e&&"sensor"===t&&k(e,n)||null!=s,M=(t,e,s=!0)=>{if(!e)return t;const n=Object.assign(Object.assign({},t),{},{line:[]}),i={};for(const a of t.line){const t=L(a.unit,a.device_class,s);t&&(i[t]={historyItem:a})}for(const a of e.line){const t=L(a.unit,a.device_class,s);t&&(t in i?i[t].ltsItem=a:i[t]={ltsItem:a})}for(const{historyItem:a,ltsItem:r}of Object.values(i)){if(!a||!r){n.line.push(a||r);continue}const t=Object.assign(Object.assign({},a),{},{data:[]}),e=new Set([...a.data.map((t=>t.entity_id)),...r.data.map((t=>t.entity_id))]);for(const s of e){var o;const e=a.data.find((t=>t.entity_id===s)),n=r.data.find((t=>t.entity_id===s));if(!e||!n){t.data.push(e||n);continue}const i=(null===(o=e.states[0])||void 0===o?void 0:o.last_changed)||n.statistics[n.statistics.length-1].last_changed+1,c=[];for(const t of n.statistics){if(t.last_changed>=i)break;c.push(t)}t.data.push(0===c.length?e:Object.assign(Object.assign({},e),{},{statistics:c}))}n.line.push(t)}return n};n()}catch(c){n(c)}}))},25433:function(t,e,s){s.d(e,{MY:()=>p,Yc:()=>_,hb:()=>b,jV:()=>l,o1:()=>m,ri:()=>g,sS:()=>d});s(71695),s(40251),s(19134),s(11740),s(97003),s(88044),s(47021);var n=s(73358),i=s(73850),o=s(59847),a=s(85746),r=s(96194);const c="ui.components.logbook.messages",l=["counter","proximity","sensor","zone"],u={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,n,i,o)=>{if((n||o)&&(!n||0===n.length)&&(!o||0===o.length))return Promise.resolve([]);const a={type:"logbook/get_events",start_time:e};return s&&(a.end_time=s),null!=n&&n.length&&(a.entity_ids=n),null!=o&&o.length&&(a.device_ids=o),i&&(a.context_id=i),t.callWS(a)},_=(t,e,s,n,i,o)=>{if((i||o)&&(!i||0===i.length)&&(!o||0===o.length))return Promise.reject("No entities or devices");const a={type:"logbook/event_stream",start_time:s,end_time:n};return null!=i&&i.length&&(a.entity_ids=i),null!=o&&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:null==t?void 0:t.attributes.device_class,source_type:null==t?void 0:t.attributes.source_type,has_date:null==t?void 0:t.attributes.has_date,has_time:null==t?void 0:t.attributes.has_time,entity_picture_local:n.iY.has((0,i.M)(t.entity_id))||null==t?void 0:t.attributes.entity_picture_local,entity_picture:n.iY.has((0,i.M)(t.entity_id))||null==t?void 0:t.attributes.entity_picture}}),b=(t,e)=>{for(const s of Object.keys(u)){const n=u[s];if(e.startsWith(n))return e.replace(n,`${t(`ui.components.logbook.${s}`)}`)}return e},g=(t,e,s,i,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===n.uo,r=s===n.lC,l=i.attributes.device_class;if(l&&(o||r))return e(`${c}.${o?"detected_device_classes":"cleared_device_classes"}.${l}`,{device_class:(0,a.V)(e(`component.binary_sensor.entity_component.${l}.name`)||l,t.language)})||e(`${c}.${o?"detected_device_class":"cleared_device_class"}`,{device_class:(0,a.V)(e(`component.binary_sensor.entity_component.${l}.name`)||l,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===n.uo?e(`${c}.turned_on`):s===n.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:i?t.formatEntityState(i,s):s})},p=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,n){try{s.d(e,{Fb:()=>y,Gt:()=>k,Og:()=>_,PG:()=>v,kh:()=>d,l:()=>g,oA:()=>h,tm:()=>p,uq:()=>b});s(19083),s(61006);var i=s(72344),o=s(73850),a=s(3582),r=s(25433),c=s(6280),l=s(49319),u=t([c]);c=(u.then?(await u)():u)[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"],b=["update"],g=["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"],p=["input_number","input_select","input_text","number","scene","select","text","update","event"],f=["camera","configurator"],v=(t,e)=>{if("weather"===(0,o.M)(e)){const s=t.states[e];if(s&&(0,l.M0)(s.state))return!1}return(0,i.p)(t,"history")&&!f.includes((0,o.M)(e))},y=(t,e,s=[])=>{if(!(0,i.p)(t,"logbook"))return!1;const n=t.states[e];if(!n)return!1;const a=(0,o.M)(e);return!(r.jV.includes(a)&&(0,c.zP)(a,n,void 0,s)||f.includes(a))&&("weather"!==a||!n||!(0,l.M0)(n.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)};n()}catch(d){n(d)}}))},12660:function(t,e,s){s.a(t,(async function(t,n){try{s.r(e),s.d(e,{createBadgeElement:()=>r.JE,createCardElement:()=>c.Z6,createHeaderFooterElement:()=>l.t,createHuiElement:()=>u.w,createRowElement:()=>d.m,importMoreInfoControl:()=>a.ST,showAlertDialog:()=>o.showAlertDialog,showConfirmationDialog:()=>o.showConfirmationDialog,showEnterCodeDialog:()=>i.t,showPromptDialog:()=>o.showPromptDialog});var i=s(17808),o=s(76131),a=s(88991),r=s(27934),c=s(62037),l=s(64830),u=s(52032),d=s(46542),h=t([a,r,c,u,d]);[a,r,c,u,d]=h.then?(await h)():h,n()}catch(_){n(_)}}))}}]); //# sourceMappingURL=72974.eef220b9dc1982f7.js.map