- [[statusString(stateObj)]]
+ const style = Polymer.html`
+
+
+
+
+ `;
+
+ const input = Polymer.html`
+
+
+
+
+
+
+ [[statusString(stateObj)]]
+
+
+
+
+
-
-
-
- ${slider}
-
-
- `
- }
+ `;
- static get properties() {
- return {
- _hass: Object,
- _config: Object,
- hideToggle: { type: Boolean, value: false },
- breakSlider: { type: Boolean, value: false },
- hideWhenOff: { type: Boolean, value: false },
- showValue: { type: Boolean, value: false },
- stateObj: { type: Object, value: null },
- value: Number,
- };
+ return Polymer.html`
+ ${style}
+
+
+
+ ${input}
+
+
+
+ ${input}
+
+ `;
}
setConfig(config)
@@ -136,14 +137,15 @@ class SliderEntityRow extends Polymer.Element {
this._config = config;
+ this.stateObj = null;
const domain = config.entity.split('.')[0];
this.controller = CONTROLLERS[domain];
if(!this.controller) throw new Error('Unsupported entity domain: ' + domain);
- this.hideToggle = config.hide_control || config.hide_toggle || false;
- this.breakSlider = config.break_slider || false;
- this.hideWhenOff = config.hide_when_off || false;
- this.showValue = config.show_value || false;
+ this.displayRow = !config.full_row;
+ this.displayToggle = config.toggle && domain === 'light';
+ this.displayValue = !this.displayToggle;
+ this.displaySlider = false;
}
statusString(stateObj) {
@@ -152,42 +154,12 @@ class SliderEntityRow extends Polymer.Element {
return this.controller.string(stateObj, l18n);
}
- updateSliders()
- {
- this.displayTop = false;
- this.displayBottom = false;
- this.displayToggle = true;
- this.displayStatus = false;
-
- if(this.hideToggle) this.displayToggle = false;
-
- if(this.showValue) {
- this.displayToggle = false;
- this.displayStatus = true;
- }
-
- if(!(this.stateObj.state === 'on' || this.stateObj.state === 'off')) {
- this.displayToggle = false;
- this.displayStatus = true;
- }
-
- if(this.stateObj.state === 'on' || !this.hideWhenOff) {
- this.displayBottom = this.breakSlider;
- this.displayTop = !this.breakSlider;
- }
-
- if(!this.controller.supported(this.stateObj)) {
- this.displayTop = this.displayBottom = false;
- }
-
- }
-
set hass(hass) {
this._hass = hass;
this.stateObj = this._config.entity in hass.states ? hass.states[this._config.entity] : null;
if(this.stateObj) {
this.value = this.controller.get(this.stateObj);
- this.updateSliders();
+ this.displaySlider = this.controller.supported(this.stateObj);
}
}