iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
158 lines (147 loc) • 9.49 kB
JavaScript
(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([[7257],{22311:(t,e,i)=>{"use strict";i.d(e,{N:()=>a});var s=i(58831);const a=t=>(0,s.M)(t.entity_id)},26765:(t,e,i)=>{"use strict";i.d(e,{Ys:()=>n,g7:()=>o,D9:()=>l});var s=i(47181);const a=()=>Promise.all([i.e(8941),i.e(879),i.e(6372),i.e(6547),i.e(6509),i.e(7230)]).then(i.bind(i,1281)),r=(t,e,i)=>new Promise((r=>{const n=e.cancel,o=e.confirm;(0,s.B)(t,"show-dialog",{dialogTag:"dialog-box",dialogImport:a,dialogParams:{...e,...i,cancel:()=>{r(!!(null==i?void 0:i.prompt)&&null),n&&n()},confirm:t=>{r(!(null==i?void 0:i.prompt)||t),o&&o(t)}}})})),n=(t,e)=>r(t,e),o=(t,e)=>r(t,e,{confirmation:!0}),l=(t,e)=>r(t,e,{prompt:!0})},11052:(t,e,i)=>{"use strict";i.d(e,{I:()=>r});var s=i(76389),a=i(47181);const r=(0,s.o)((t=>class extends t{fire(t,e,i){return i=i||{},(0,a.B)(i.node||this,t,e,i)}}))},1265:(t,e,i)=>{"use strict";i.d(e,{Z:()=>s});const s=(0,i(76389).o)((t=>class extends t{static get properties(){return{hass:Object,localize:{type:Function,computed:"__computeLocalize(hass.localize)"}}}__computeLocalize(t){return t}}))},89875:(t,e,i)=>{"use strict";i.r(e);i(53918),i(32296),i(30879);var s=i(50856),a=i(28426),r=i(50947),n=(i(74535),i(52039),i(53822),i(26765)),o=i(11052),l=i(1265),u=(i(3426),i(55317)),c=i(87744);const p={};class d extends((0,o.I)((0,l.Z)(a.H3))){static get template(){return s.d`
<style include="ha-style">
:host {
-ms-user-select: initial;
-webkit-user-select: initial;
-moz-user-select: initial;
display: block;
padding: 16px;
}
.inputs {
max-width: 400px;
}
mwc-button {
margin-top: 8px;
}
.entities th {
text-align: left;
}
:host([rtl]) .entities th {
text-align: right;
}
.entities tr {
vertical-align: top;
direction: ltr;
}
.entities tr:nth-child(odd) {
background-color: var(--table-row-background-color, #fff);
}
.entities tr:nth-child(even) {
background-color: var(--table-row-alternative-background-color, #eee);
}
.entities td {
padding: 4px;
min-width: 200px;
word-break: break-word;
}
.entities ha-svg-icon {
--mdc-icon-size: 20px;
padding: 4px;
cursor: pointer;
}
.entities td:nth-child(3) {
white-space: pre-wrap;
word-break: break-word;
}
.entities a {
color: var(--primary-color);
}
</style>
<div class="inputs">
<p>
[[localize('ui.panel.developer-tools.tabs.states.description1')]]<br />
[[localize('ui.panel.developer-tools.tabs.states.description2')]]
</p>
<ha-entity-picker
autofocus
hass="[[hass]]"
value="{{_entityId}}"
on-change="entityIdChanged"
allow-custom-entity
></ha-entity-picker>
<paper-input
label="[[localize('ui.panel.developer-tools.tabs.states.state')]]"
required
autocapitalize="none"
autocomplete="off"
autocorrect="off"
spellcheck="false"
value="{{_state}}"
class="state-input"
></paper-input>
<p>
[[localize('ui.panel.developer-tools.tabs.states.state_attributes')]]
</p>
<ha-code-editor
mode="yaml"
value="[[_stateAttributes]]"
error="[[!validJSON]]"
on-value-changed="_yamlChanged"
></ha-code-editor>
<mwc-button on-click="handleSetState" disabled="[[!validJSON]]" raised
>[[localize('ui.panel.developer-tools.tabs.states.set_state')]]</mwc-button
>
</div>
<h1>
[[localize('ui.panel.developer-tools.tabs.states.current_entities')]]
</h1>
<table class="entities">
<tr>
<th>[[localize('ui.panel.developer-tools.tabs.states.entity')]]</th>
<th>[[localize('ui.panel.developer-tools.tabs.states.state')]]</th>
<th hidden$="[[narrow]]">
[[localize('ui.panel.developer-tools.tabs.states.attributes')]]
<paper-checkbox checked="{{_showAttributes}}"></paper-checkbox>
</th>
</tr>
<tr>
<th>
<paper-input
label="[[localize('ui.panel.developer-tools.tabs.states.filter_entities')]]"
type="search"
value="{{_entityFilter}}"
></paper-input>
</th>
<th>
<paper-input
label="[[localize('ui.panel.developer-tools.tabs.states.filter_states')]]"
type="search"
value="{{_stateFilter}}"
></paper-input>
</th>
<th hidden$="[[!computeShowAttributes(narrow, _showAttributes)]]">
<paper-input
label="[[localize('ui.panel.developer-tools.tabs.states.filter_attributes')]]"
type="search"
value="{{_attributeFilter}}"
></paper-input>
</th>
</tr>
<tr hidden$="[[!computeShowEntitiesPlaceholder(_entities)]]">
<td colspan="3">
[[localize('ui.panel.developer-tools.tabs.states.no_entities')]]
</td>
</tr>
<template is="dom-repeat" items="[[_entities]]" as="entity">
<tr>
<td>
<ha-svg-icon
on-click="entityMoreInfo"
alt="[[localize('ui.panel.developer-tools.tabs.states.more_info')]]"
title="[[localize('ui.panel.developer-tools.tabs.states.more_info')]]"
path="[[informationOutlineIcon()]]"
></ha-svg-icon>
<a href="#" on-click="entitySelected">[[entity.entity_id]]</a>
</td>
<td>[[entity.state]]</td>
<template
is="dom-if"
if="[[computeShowAttributes(narrow, _showAttributes)]]"
>
<td>[[attributeString(entity)]]</td>
</template>
</tr>
</template>
</table>
`}static get properties(){return{hass:{type:Object},parsedJSON:{type:Object,computed:"_computeParsedStateAttributes(_stateAttributes)"},validJSON:{type:Boolean,computed:"_computeValidJSON(parsedJSON)"},_entityId:{type:String,value:""},_entityFilter:{type:String,value:""},_stateFilter:{type:String,value:""},_attributeFilter:{type:String,value:""},_state:{type:String,value:""},_stateAttributes:{type:String,value:""},_showAttributes:{type:Boolean,value:!0},_entities:{type:Array,computed:"computeEntities(hass, _entityFilter, _stateFilter, _attributeFilter)"},rtl:{reflectToAttribute:!0,computed:"_computeRTL(hass)"}}}entitySelected(t){const e=t.model.entity;this._entityId=e.entity_id,this._state=e.state,this._stateAttributes=(0,r.safeDump)(e.attributes),t.preventDefault()}entityIdChanged(){if(""===this._entityId)return this._state="",void(this._stateAttributes="");const t=this.hass.states[this._entityId];t&&(this._state=t.state,this._stateAttributes=(0,r.safeDump)(t.attributes))}entityMoreInfo(t){t.preventDefault(),this.fire("hass-more-info",{entityId:t.model.entity.entity_id})}handleSetState(){this._entityId?this.hass.callApi("POST","states/"+this._entityId,{state:this._state,attributes:this.parsedJSON}):(0,n.Ys)(this,{text:this.hass.localize("ui.panel.developer-tools.tabs.states.alert_entity_field")})}informationOutlineIcon(){return u.EaN}computeEntities(t,e,i,s){return Object.keys(t.states).map((function(e){return t.states[e]})).filter((function(t){if(!t.entity_id.includes(e.toLowerCase()))return!1;if(!t.state.includes(i.toLowerCase()))return!1;if(""!==s){const e=s.toLowerCase(),i=e.indexOf(":"),a=-1!==i;let r=e,n=e;a&&(r=e.substring(0,i).trim(),n=e.substring(i+1).trim());const o=Object.keys(t.attributes);for(let s=0;s<o.length;s++){const e=o[s];if(e.includes(r)&&!a)return!0;if(!e.includes(r)&&a)continue;const i=t.attributes[e];if(null!==i&&JSON.stringify(i).toLowerCase().includes(n))return!0}return!1}return!0})).sort((function(t,e){return t.entity_id<e.entity_id?-1:t.entity_id>e.entity_id?1:0}))}computeShowEntitiesPlaceholder(t){return 0===t.length}computeShowAttributes(t,e){return!t&&e}attributeString(t){let e,i,s,a,r="";for(e=0,i=Object.keys(t.attributes);e<i.length;e++)s=i[e],a=this.formatAttributeValue(t.attributes[s]),r+=`${s}: ${a}\n`;return r}formatAttributeValue(t){return Array.isArray(t)&&t.some((t=>t instanceof Object))||!Array.isArray(t)&&t instanceof Object?"\n"+(0,r.safeDump)(t):Array.isArray(t)?t.join(", "):t}_computeParsedStateAttributes(t){try{return t.trim()?(0,r.safeLoad)(t):{}}catch(e){return p}}_computeValidJSON(t){return t!==p}_yamlChanged(t){this._stateAttributes=t.detail.value}_computeRTL(t){return(0,c.HE)(t)}}customElements.define("developer-tools-state",d)},3426:(t,e,i)=>{"use strict";i(21384);var s=i(11654);const a=document.createElement("template");a.setAttribute("style","display: none;"),a.innerHTML=`<dom-module id="ha-style">\n <template>\n <style>\n ${s.Qx.cssText}\n </style>\n </template>\n</dom-module>`,document.head.appendChild(a.content)}}]);
//# sourceMappingURL=chunk.5f0b02a2c58702413c17.js.map