Make the element more well behaved
This commit is contained in:
parent
ba8f5049de
commit
cde2a9bc93
@ -1,6 +1,8 @@
|
||||
class SliderEntityRow extends Polymer.Element {
|
||||
|
||||
static get template() {
|
||||
if(!this._hass || !this._config)
|
||||
return Polymer.html``;
|
||||
const style = Polymer.html`
|
||||
<style>
|
||||
.flex {
|
||||
@ -157,6 +159,14 @@ class SliderEntityRow extends Polymer.Element {
|
||||
this.min = config.min || 0;
|
||||
this.max = config.max || 100;
|
||||
this.step = config.step || 5;
|
||||
|
||||
if(this._hass && this._config) {
|
||||
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.displaySlider = this.controller.supported(this.stateObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
statusString(stateObj) {
|
||||
@ -167,10 +177,13 @@ class SliderEntityRow extends Polymer.Element {
|
||||
|
||||
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.displaySlider = this.controller.supported(this.stateObj);
|
||||
|
||||
if(hass && this._config) {
|
||||
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.displaySlider = this.controller.supported(this.stateObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user