<html><head></head><body><dom-module id="ha-panel-dev-state"><template><style include="ha-style">:host{-ms-user-select:initial;-webkit-user-select:initial;-moz-user-select:initial;}.content{padding:16px;}ha-entity-picker, .state-input, paper-textarea{display:block;max-width:400px;}.entities th{text-align:left;}.entities tr{vertical-align:top;}.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:nth-child(3){white-space:pre-wrap;word-break:break-word;}.entities a{color:var(--primary-color);}</style><app-header-layout has-scrolling-region=""><app-header slot="header" fixed=""><app-toolbar><ha-menu-button narrow="[[narrow]]" show-menu="[[showMenu]]"></ha-menu-button><div main-title="">States</div></app-toolbar></app-header><div class="content"><div><p>Set the representation of a device within Home Assistant.<br>This will not communicate with the actual device.</p><ha-entity-picker autofocus="" hass="[[hass]]" value="{{_entityId}}" allow-custom-entity=""></ha-entity-picker><paper-input label="State" required="" value="{{_state}}" class="state-input"></paper-input><paper-textarea label="State attributes (JSON, optional)" value="{{_stateAttributes}}"></paper-textarea><paper-button on-tap="handleSetState" raised="">Set State</paper-button></div><h1>Current entities</h1><table class="entities"><tbody><tr><th>Entity</th><th>State</th><th hidden$="[[narrow]]">Attributes<paper-checkbox checked="{{_showAttributes}}"></paper-checkbox></th></tr><tr><th><paper-input label="Filter entities" type="search" value="{{_entityFilter}}"></paper-input></th><th><paper-input label="Filter states" type="search" value="{{_stateFilter}}"></paper-input></th><th hidden$="[[!computeShowAttributes(narrow, _showAttributes)]]"><paper-input label="Filter attributes" type="search" value="{{_attributeFilter}}"></paper-input></th></tr><tr hidden$="[[!computeShowEntitiesPlaceholder(_entities)]]"><td colspan="3">No entities</td></tr><template is="dom-repeat" items="[[_entities]]" as="entity"><tr><td><a href="#" on-tap="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></tbody></table></div></app-header-layout></template></dom-module><script>function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var _createClass=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),HaPanelDevState=function(t){function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return _inherits(e,Polymer.Element),_createClass(e,[{key:"entitySelected",value:function(t){var e=t.model.entity;this._entityId=e.entity_id,this._state=e.state,this._stateAttributes=JSON.stringify(e.attributes,null,"  "),t.preventDefault()}},{key:"handleSetState",value:function(){var t,e=this._stateAttributes.replace(/^\s+|\s+$/g,"");try{t=e?JSON.parse(e):{}}catch(t){return void alert("Error parsing JSON: "+t)}this.hass.callApi("POST","states/"+this._entityId,{state:this._state,attributes:t})}},{key:"computeEntities",value:function(t,e,r,n){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(r.toLowerCase()))return!1;if(""!==n){var i=n.toLowerCase(),a=i.indexOf(":"),s=-1!==a,u=i,o=i;s&&(u=i.substring(0,a).trim(),o=i.substring(a+1).trim());for(var l=Object.keys(t.attributes),c=0;c<l.length;c++){var y=l[c];if(y.includes(u)&&!s)return!0;if(y.includes(u)||!s){var f=t.attributes[y];if(null!==f&&JSON.stringify(f).toLowerCase().includes(o))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})}},{key:"computeShowEntitiesPlaceholder",value:function(t){return 0===t.length}},{key:"computeShowAttributes",value:function(t,e){return!t&&e}},{key:"attributeString",value:function(t){var e,r,n,i,a="";for(e=0,r=Object.keys(t.attributes);e<r.length;e++)n=r[e],i=t.attributes[n],!Array.isArray(i)&&i instanceof Object&&(i=JSON.stringify(i,null,"  ")),a+=n+": "+i+"\n";return a}}],[{key:"is",get:function(){return"ha-panel-dev-state"}},{key:"properties",get:function(){return{hass:{type:Object},narrow:{type:Boolean,value:!1},showMenu:{type:Boolean,value:!1},_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)"}}}}]),e}();customElements.define(HaPanelDevState.is,HaPanelDevState);</script></body></html>