mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-30 12:46:35 +00:00
Fix climate control rounding error (#2375)
* Fix climate rounding error * Update ha-climate-control.js
This commit is contained in:
parent
5a90edc893
commit
38a2627227
@ -81,8 +81,15 @@ class HaClimateControl extends EventsMixin(PolymerElement) {
|
|||||||
this.$.target_temperature.classList.toggle("in-flux", inFlux);
|
this.$.target_temperature.classList.toggle("in-flux", inFlux);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_round(val) {
|
||||||
|
// round value to precision derived from step
|
||||||
|
// insired by https://github.com/soundar24/roundSlider/blob/master/src/roundslider.js
|
||||||
|
const s = this.step.toString().split(".");
|
||||||
|
return s[1] ? parseFloat(val.toFixed(s[1].length)) : Math.round(val);
|
||||||
|
}
|
||||||
|
|
||||||
incrementValue() {
|
incrementValue() {
|
||||||
const newval = this.value + this.step;
|
const newval = this._round(this.value + this.step);
|
||||||
if (this.value < this.max) {
|
if (this.value < this.max) {
|
||||||
this.last_changed = Date.now();
|
this.last_changed = Date.now();
|
||||||
this.temperatureStateInFlux(true);
|
this.temperatureStateInFlux(true);
|
||||||
@ -102,7 +109,7 @@ class HaClimateControl extends EventsMixin(PolymerElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
decrementValue() {
|
decrementValue() {
|
||||||
const newval = this.value - this.step;
|
const newval = this._round(this.value - this.step);
|
||||||
if (this.value > this.min) {
|
if (this.value > this.min) {
|
||||||
this.last_changed = Date.now();
|
this.last_changed = Date.now();
|
||||||
this.temperatureStateInFlux(true);
|
this.temperatureStateInFlux(true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user