Skip to content

Commit

Permalink
handle device update
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierZal committed Oct 2, 2024
1 parent a99cd64 commit 4476a97
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions bases/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ export default abstract class<
protected async setCapabilityValues(
data: ListDevice[T]['Device'],
): Promise<void> {
this.homey.api.realtime('deviceUpdate', undefined)
await Promise.all(
this.#opCapabilityTagEntries.map(async ([capability, tag]) => {
if (tag in data) {
Expand Down
13 changes: 7 additions & 6 deletions widgets/ata-group-setting/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,12 @@ const setAtaValues = async (homey: Homey): Promise<void> => {
}
}

const addAtaValuesEventListeners = (homey: Homey): void => {
const addEventListeners = (homey: Homey): void => {
zoneElement.addEventListener('change', () => {
fetchAtaValues(homey).catch(() => {
//
})
})
refreshAtaValues.addEventListener('click', () => {
refreshAtaValuesElement()
})
Expand All @@ -374,15 +379,11 @@ const addAtaValuesEventListeners = (homey: Homey): void => {
//
})
})
}

const addEventListeners = (homey: Homey): void => {
zoneElement.addEventListener('change', () => {
homey.on('deviceUpdate', () => {
fetchAtaValues(homey).catch(() => {
//
})
})
addAtaValuesEventListeners(homey)
}

// eslint-disable-next-line func-style
Expand Down

0 comments on commit 4476a97

Please sign in to comment.