feat: Capture ctx.updateStatus to correctly reflect timer completion status.
This commit is contained in:
@@ -185,8 +185,11 @@ export default {
|
||||
// Normal mode - schedule light to turn on after stored duration
|
||||
ctx.log(`Light off. Will turn on in ${state.storedDuration}ms`);
|
||||
|
||||
// Capture updateStatus for use in timer callback
|
||||
const updateStatus = ctx.updateStatus;
|
||||
|
||||
// Push status update to dashboard
|
||||
ctx.updateStatus({
|
||||
updateStatus({
|
||||
storedDuration: state.storedDuration,
|
||||
countMode: false,
|
||||
timerActive: true,
|
||||
@@ -198,8 +201,13 @@ export default {
|
||||
await setLight(ctx, mac, true, 20);
|
||||
state.timer = null;
|
||||
|
||||
// Can't use ctx.updateStatus here since ctx is out of scope
|
||||
// The timer completing will be reflected in next getStatus() call
|
||||
// Push timer completed status
|
||||
updateStatus({
|
||||
storedDuration: state.storedDuration,
|
||||
countMode: false,
|
||||
timerActive: false,
|
||||
lastAction: 'Timer completed'
|
||||
});
|
||||
}, state.storedDuration);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user