diff --git a/rules/waterButtonLearnAndCall.js b/rules/waterButtonLearnAndCall.js index 24eae54..d6516c0 100644 --- a/rules/waterButtonLearnAndCall.js +++ b/rules/waterButtonLearnAndCall.js @@ -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); } }