From cb043200cc4af17dbbc3f5bc4ab84b7939fdd7c4 Mon Sep 17 00:00:00 2001 From: Zack Arnett Date: Wed, 12 Aug 2020 10:58:53 -0500 Subject: [PATCH] do calc once --- src/panels/lovelace/cards/hui-thermostat-card.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/panels/lovelace/cards/hui-thermostat-card.ts b/src/panels/lovelace/cards/hui-thermostat-card.ts index 3509b66016..ade28fa470 100644 --- a/src/panels/lovelace/cards/hui-thermostat-card.ts +++ b/src/panels/lovelace/cards/hui-thermostat-card.ts @@ -433,29 +433,24 @@ export class HuiThermostatCard extends LitElement implements LovelaceCard { private _handleStepAction(e: MouseEvent): void { const stateObj = this.hass!.states[this._config!.entity] as ClimateEntity; + const tempChange = (e.currentTarget as any).tempDiff * this._stepSize; if (!Array.isArray(this._setTemp!)) { this.hass!.callService("climate", "set_temperature", { entity_id: this._config!.entity, - temperature: - (this._setTemp! as number) + - (e.currentTarget as any).tempDiff * this._stepSize, + temperature: (this._setTemp! as number) + tempChange, }); } else if (this._lastSetMode === 0) { this.hass!.callService("climate", "set_temperature", { entity_id: this._config!.entity, - target_temp_low: - this._setTemp![this._lastSetMode] + - (e.currentTarget as any).tempDiff * this._stepSize, + target_temp_low: this._setTemp![this._lastSetMode] + tempChange, target_temp_high: stateObj.attributes.target_temp_high, }); } else if (this._lastSetMode === 1) { this.hass!.callService("climate", "set_temperature", { entity_id: this._config!.entity, target_temp_low: stateObj.attributes.target_temp_low, - target_temp_high: - this._setTemp![this._lastSetMode] + - (e.currentTarget as any).tempDiff * this._stepSize, + target_temp_high: this._setTemp![this._lastSetMode] + tempChange, }); } }