-
-
- Set the representation of a device within Home Assistant.
- This will not communicate with the actual device.
-
-
-
-
+
+
+
+
+ States
+
+
+
-
-
+ Set the representation of a device within Home Assistant.
+ This will not communicate with the actual device.
+
+
+
+
+
Set State
+
+
Current entities
+
+
+ Entity |
+ State |
+
+ Attributes
+
+ |
+
+
+
+ [[entity.entityId]] |
+ [[entity.state]] |
+
+ [[attributeString(entity)]] |
+
+
+
+
-
+
@@ -63,6 +90,8 @@
Polymer({
is: 'ha-panel-dev-state',
+ behaviors: [window.hassBehavior],
+
properties: {
hass: {
type: Object,
@@ -78,43 +107,51 @@ Polymer({
value: false,
},
- entityId: {
+ _entityId: {
type: String,
value: '',
},
- state: {
+ _state: {
type: String,
value: '',
},
- stateAttributes: {
+ _stateAttributes: {
type: String,
value: '',
},
- },
- setStateData: function (stateData) {
- var value = stateData ? JSON.stringify(stateData, null, ' ') : '';
+ _showAttributes: {
+ type: Boolean,
+ value: true,
+ },
- this.$.inputData.value = value;
-
- // not according to the spec but it works...
- this.$.inputDataWrapper.update(this.$.inputData);
+ _entities: {
+ type: Array,
+ bindNuclear: function (hass) {
+ return [
+ hass.entityGetters.entityMap,
+ function (map) {
+ return map.valueSeq().sortBy(function (entity) { return entity.entityId; }).toArray();
+ },
+ ];
+ },
+ },
},
entitySelected: function (ev) {
- var state = this.hass.reactor.evaluate(this.hass.entityGetters.byId(ev.detail.entityId));
-
- this.entityId = state.entityId;
- this.state = state.state;
- this.stateAttributes = JSON.stringify(state.attributes, null, ' ');
+ var state = ev.model.entity;
+ this._entityId = state.entityId;
+ this._state = state.state;
+ this._stateAttributes = JSON.stringify(state.attributes, null, ' ');
+ ev.preventDefault();
},
handleSetState: function () {
var attr;
try {
- attr = this.stateAttributes ? JSON.parse(this.stateAttributes) : {};
+ attr = this.stateAttributes ? JSON.parse(this._stateAttributes) : {};
} catch (err) {
/* eslint-disable no-alert */
alert('Error parsing JSON: ' + err);
@@ -123,15 +160,28 @@ Polymer({
}
this.hass.entityActions.save({
- entityId: this.entityId,
- state: this.state,
+ entityId: this._entityId,
+ state: this._state,
attributes: attr,
});
},
- computeFormClasses: function (narrow) {
- return narrow ?
- 'content fit' : 'content fit layout horizontal';
+ computeShowAttributes: function (narrow, _showAttributes) {
+ return !narrow && _showAttributes;
+ },
+
+ attributeString: function (entity) {
+ var output = '';
+ var i;
+ var keys;
+ var key;
+
+ for (i = 0, keys = Object.keys(entity.attributes); i < keys.length; i++) {
+ key = keys[i];
+ output += key + ': ' + entity.attributes[key] + '\n';
+ }
+
+ return output;
},
});
diff --git a/panels/dev-template/ha-panel-dev-template.html b/panels/dev-template/ha-panel-dev-template.html
index 1132ab8b6a..8f5f421ef1 100644
--- a/panels/dev-template/ha-panel-dev-template.html
+++ b/panels/dev-template/ha-panel-dev-template.html
@@ -4,23 +4,29 @@
-
+
+
+
+
+
+
-
+
-
- Template Editor
+
+
+
+
+ Templates
+
+
@@ -75,7 +86,7 @@
[[processed]]
-
+
diff --git a/panels/history/ha-panel-history.html b/panels/history/ha-panel-history.html
index 60e800dccd..4ba7480395 100644
--- a/panels/history/ha-panel-history.html
+++ b/panels/history/ha-panel-history.html
@@ -2,15 +2,19 @@
-
+
+
+
+
+
+
-
-
-
- History
-
-
+
+
+
+
+ History
+
+
+
-
+
diff --git a/panels/iframe/ha-panel-iframe.html b/panels/iframe/ha-panel-iframe.html
index a243ade784..c0fd889fee 100644
--- a/panels/iframe/ha-panel-iframe.html
+++ b/panels/iframe/ha-panel-iframe.html
@@ -1,19 +1,23 @@
-
+
+
+
+
-
-
-
- [[panel.title]]
+
+
+ [[panel.title]]
+