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
// logic only where the room's state has actually changed since the last cycle.
export async function pollOnce() {
// Master kill switch — overrides every zone's own auto_mode. Off means a full
// pause: no NewBook fetch, no state tracking, no device commands. Deliberately
// silent (no activity_log entry) since "paused" is a normal standing state, not
// an event — the Settings toggle itself is the record of when it changed.
if (!(await getConfig('automation_enabled', true))) return
// Master switch — same effect as every zone's own auto_mode, just applied stack-wide:
// NewBook fetch, room-state tracking and activity logging all keep running as normal,
// only the actual device setpoint commands are skipped.
const automationEnabled = await getConfig('automation_enabled', true)
const defaults = {
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)
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
await applyStateTransition(zone, oldState, newState)

View file

@ -95,7 +95,7 @@ export default function Settings() {
try {
await updateConfig('automation_enabled', 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)
} catch (e) {
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'}
</div>
<div className="muted" style={{ fontSize: 13, marginTop: 2 }}>
Master switch for every zone overrides each zone's own auto mode. While paused, the scheduler
skips its poll entirely: no NewBook fetch, no state tracking, no setpoints sent to any device.
Master switch for every zone overrides each zone's own auto mode. While paused, NewBook polling,
room-state tracking and activity logging all keep running as normal only setpoint changes to
TRVs/aircon devices are skipped.
</div>
</div>
<button