<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;}.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><paper-input label="Entity ID" autofocus="" required="" value="{{_entityId}}"></paper-input><paper-input label="State" required="" value="{{_state}}"></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><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>Polymer({is:"ha-panel-dev-state",properties:{hass:{type:Object},narrow:{type:Boolean,value:!1},showMenu:{type:Boolean,value:!1},_entityId:{type:String,value:""},_state:{type:String,value:""},_stateAttributes:{type:String,value:""},_showAttributes:{type:Boolean,value:!0},_entities:{type:Array,computed:"computeEntities(hass)"}},entitySelected: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()},handleSetState: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})},computeEntities:function(t){return Object.keys(t.states).map(function(e){return t.states[e]}).sort(function(t,e){return t.entity_id<e.entity_id?-1:t.entity_id>e.entity_id?1:0})},computeShowAttributes:function(t,e){return!t&&e},attributeString:function(t){var e,i,s,n,r="";for(e=0,i=Object.keys(t.attributes);e<i.length;e++)s=i[e],n=t.attributes[s],!Array.isArray(n)&&n instanceof Object&&(n=JSON.stringify(n,null,"  ")),r+=s+": "+n+"\n";return r}});</script></body></html>