Add master automation on/off switch to Settings

A single global toggle that overrides every zone's own auto_mode —
lets staff pause all HVAC automation stack-wide (e.g. during
maintenance) without touching each zone individually. Backed by the
existing config key/value store; pollOnce() short-circuits entirely
when off (no NewBook fetch, no state tracking, no device commands).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-27 15:46:12 +00:00
parent e5c40bbb8c
commit c6e3c73ead
4 changed files with 46 additions and 0 deletions

View file

@ -146,6 +146,7 @@ export async function initDb() {
async function seedDefaults() {
const defaults = {
automation_enabled: true, // master kill switch — overrides every zone's own auto_mode
excluded_site_ids: [],
poll_interval_minutes: 10, // matches the old integration's DEFAULT_SCAN_INTERVAL
default_arrival_time: '15:00:00',

View file

@ -148,6 +148,12 @@ 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
const defaults = {
default_arrival_time: await getConfig('default_arrival_time', '15:00:00'),
default_departure_time: await getConfig('default_departure_time', '10:00:00'),