Skip to content

Commit

Permalink
fix: setState when received update from Sisyfos
Browse files Browse the repository at this point in the history
  • Loading branch information
olzzon committed Apr 2, 2024
1 parent b06a79b commit f04970c
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,14 @@ export class SisyfosMessageDevice extends DeviceWithState<SisyfosState, DeviceOp
}

private async _resyncOneChannel(channel: number): Promise<void> {
this._resyncing = true
this._sisyfos.reSyncOneChannel(channel)
// Wait for state will be emitted from Sisyfos
// And set TSR state on current time
setTimeout(() => {
this.setState(this.getDeviceState(false), this.getCurrentTime())
this._resyncing = false
}, 500)
return Promise.resolve()
}
async executeAction<A extends SisyfosActions>(
Expand All @@ -231,7 +238,7 @@ export class SisyfosMessageDevice extends DeviceWithState<SisyfosState, DeviceOp
result: ActionExecutionResultCode.Error,
}
}
return this._resyncOneChannel(payload.channel)
return this._resyncOneChannel(payload.channel + 1)
.then(() => ({
result: ActionExecutionResultCode.Ok,
}))
Expand All @@ -244,7 +251,7 @@ export class SisyfosMessageDevice extends DeviceWithState<SisyfosState, DeviceOp
result: ActionExecutionResultCode.Error,
}
}
this._sisyfos.setSisyfosChannel(payload.channel, { ...this.getDeviceState().channels[payload.channel] })
this._sisyfos.setSisyfosChannel(payload.channel + 1, { ...this.getDeviceState().channels[payload.channel] })
return {
result: ActionExecutionResultCode.Ok,
}
Expand Down

0 comments on commit f04970c

Please sign in to comment.