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 May 2, 2021
1 parent b52b0e1 commit 8f36a1d
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/main.ts
Original file line number Diff line number Diff line change
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 8f36a1d

Please sign in to comment.