From 7bc58c45df86d06a87d946281d9d9da3c71214d6 Mon Sep 17 00:00:00 2001 From: Raymond Julin Date: Fri, 16 Apr 2021 08:52:31 +0200 Subject: [PATCH] fix: Update temperature on multiple clicks Fixes #245 --- src/main.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main.ts b/src/main.ts index b99ba13..8943e0a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -92,7 +92,7 @@ function getModeList( }) } -type Values = { +interface Values { [key: string]: number | string } @@ -109,7 +109,6 @@ export default class SimpleThermostat extends LitElement { service: Service @property() modes: Array = [] - @property() _hass: HASS = {} @property() entity: LooseObject @@ -120,8 +119,10 @@ export default class SimpleThermostat extends LitElement { @property() name: string | false = '' stepSize = STEP_SIZE - @property() - _values: Values + @property({ + type: Object, + }) + _values: Values = {} @property() _updatingValues: boolean = false @property() @@ -459,11 +460,14 @@ export default class SimpleThermostat extends LitElement { setTemperature(change: number, field: string) { this._updatingValues = true - const previousValue = this._values[field] as number - const newValue = previousValue + change + const previousValue = this._values[field] + const newValue = Number(previousValue) + change const { decimals } = this.config - this._values[field] = +formatNumber(newValue, { decimals }) + this._values = { + ...this._values, + [field]: +formatNumber(newValue, { decimals }), + } this._debouncedSetTemperature(this._values) }