Scope automation switch to setpoints only, not the whole poll cycle

Master switch should behave like each zone's own auto_mode — NewBook
polling, room-state tracking, and activity logging keep running as
normal; only the actual device setpoint commands are held back.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-27 15:48:13 +00:00
parent c6e3c73ead
commit ab14d4dfe1
2 changed files with 9 additions and 9 deletions

View file

@ -148,11 +148,10 @@ async function saveZoneState(zoneId, roomState, bookingStatus) {
// One poll cycle: fetch bookings once, walk every active room zone, apply heating // One poll cycle: fetch bookings once, walk every active room zone, apply heating
// logic only where the room's state has actually changed since the last cycle. // logic only where the room's state has actually changed since the last cycle.
export async function pollOnce() { export async function pollOnce() {
// Master kill switch — overrides every zone's own auto_mode. Off means a full // Master switch — same effect as every zone's own auto_mode, just applied stack-wide:
// pause: no NewBook fetch, no state tracking, no device commands. Deliberately // NewBook fetch, room-state tracking and activity logging all keep running as normal,
// silent (no activity_log entry) since "paused" is a normal standing state, not // only the actual device setpoint commands are skipped.
// an event — the Settings toggle itself is the record of when it changed. const automationEnabled = await getConfig('automation_enabled', true)
if (!(await getConfig('automation_enabled', true))) return
const defaults = { const defaults = {
default_arrival_time: await getConfig('default_arrival_time', '15:00:00'), default_arrival_time: await getConfig('default_arrival_time', '15:00:00'),
@ -212,7 +211,7 @@ export async function pollOnce() {
await saveZoneState(zone.id, newState, booking?.booking_status || null) await saveZoneState(zone.id, newState, booking?.booking_status || null)
if (!zone.auto_mode) continue // manual override in effect — don't touch setpoints if (!zone.auto_mode || !automationEnabled) continue // manual override or master switch off — don't touch setpoints
if (newState === oldState) continue // no transition — never poll-and-reassert if (newState === oldState) continue // no transition — never poll-and-reassert
await applyStateTransition(zone, oldState, newState) await applyStateTransition(zone, oldState, newState)

View file

@ -95,7 +95,7 @@ export default function Settings() {
try { try {
await updateConfig('automation_enabled', next) await updateConfig('automation_enabled', next)
setAutomationEnabled(next) setAutomationEnabled(next)
setMsg(next ? 'Automation resumed' : 'Automation paused — no setpoints will be sent to any device until resumed') setMsg(next ? 'Automation resumed' : 'Automation paused — device setpoints will no longer change until resumed')
setTimeout(() => setMsg(''), 4000) setTimeout(() => setMsg(''), 4000)
} catch (e) { } catch (e) {
setError(e instanceof Error ? e.message : 'Failed to update automation state') setError(e instanceof Error ? e.message : 'Failed to update automation state')
@ -155,8 +155,9 @@ export default function Settings() {
{automationEnabled ? 'Automation is ON' : 'Automation is PAUSED'} {automationEnabled ? 'Automation is ON' : 'Automation is PAUSED'}
</div> </div>
<div className="muted" style={{ fontSize: 13, marginTop: 2 }}> <div className="muted" style={{ fontSize: 13, marginTop: 2 }}>
Master switch for every zone overrides each zone's own auto mode. While paused, the scheduler Master switch for every zone overrides each zone's own auto mode. While paused, NewBook polling,
skips its poll entirely: no NewBook fetch, no state tracking, no setpoints sent to any device. room-state tracking and activity logging all keep running as normal only setpoint changes to
TRVs/aircon devices are skipped.
</div> </div>
</div> </div>
<button <button