Skip to content

Commit

Permalink
Fixes for interval en timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisTerBeke committed Nov 27, 2024
1 parent 7403865 commit 71dd305
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions drivers/uponor/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ class UponorThermostatDevice extends Device {
this._uninit()
}

onDeleted(): void {
this.homey.clearInterval(this._syncInterval)
}

onDiscoveryResult(discoveryResult: DiscoveryResultMAC): boolean {
return this.getData().id.includes(discoveryResult.id)
}
Expand Down Expand Up @@ -75,12 +79,12 @@ class UponorThermostatDevice extends Device {
const address = this._getAddress()
if (!address) return this.setUnavailable('No IP address configured')
this._client = new UponorHTTPClient(address)
this._syncInterval = setInterval(this._sync.bind(this), POLL_INTERVAL_MS)
setTimeout(this._sync.bind(this), 2000)
this._syncInterval = this.homey.setInterval(this._sync.bind(this), POLL_INTERVAL_MS)
this.homey.setTimeout(this._sync.bind(this), 2000)
}

async _uninit(): Promise<void> {
clearInterval(this._syncInterval as NodeJS.Timeout)
this.homey.clearInterval(this._syncInterval)
this._syncInterval = undefined
this._client = undefined
}
Expand Down

0 comments on commit 71dd305

Please sign in to comment.