Display value as text if asked to. Fixes #2, fixes #3.

This commit is contained in:
Thomas Lovén 2018-09-07 13:27:46 +02:00
parent a1f3dbf1cd
commit 506a9dfdf4

View File

@ -39,6 +39,11 @@ class SliderEntityRow extends Polymer.Element {
hass="[[_hass]]"
></ha-entity-toggle>
</template>
<template is='dom-if' if='{{displayStatus}}'>
<div>
[[statusString(stateObj)]]
</div>
</template>
</div>
</hui-generic-entity-row>
<template is='dom-if' if='{{displayBottom}}'>
@ -76,6 +81,17 @@ class SliderEntityRow extends Polymer.Element {
this.showValue = config.show_value || false;
}
statusString(stateObj) {
let l18n = this._hass.resources[this._hass.language];
if(stateObj.state === 'on') {
return Math.ceil(stateObj.attributes[this.attribute]/2.55).toString(10);
} else if (stateObj.state === 'off') {
return l18n['state.default.off'];
} else {
return l18n['state.default.unavailable'];
}
}
updateSliders()
{
this.displayTop = false;