Skip to content

Commit

Permalink
fix: Update temperature on multiple clicks
Browse files Browse the repository at this point in the history
Fixes #245
  • Loading branch information
nervetattoo committed Apr 16, 2021
1 parent a97a0a1 commit 7bc58c4
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/main.ts
Expand Up @@ -92,7 +92,7 @@ function getModeList(
})
}

type Values = {
interface Values {
[key: string]: number | string
}

Expand All @@ -109,7 +109,6 @@ export default class SimpleThermostat extends LitElement {
service: Service
@property()
modes: Array<ControlMode> = []
@property()
_hass: HASS = {}
@property()
entity: LooseObject
Expand All @@ -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()
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit 7bc58c4

Please sign in to comment.