Add weather compensation tiers for occupied aircon defaults
Warm/hot/heatwave tiers (ascending peak_above_c thresholds) override the global ac_occupied template when today's forecast peak clears one, picked once at the occupied-state transition so a guest's later manual adjustment is never stomped. New lib/weather.js fetches the peak via Met Office DataHub (if configured in settings) or Open-Meteo (no key needed) as a fallback, TTL-cached with a stale-fallback window on fetch failure. Zone-level per-field overrides still apply on top of a picked tier. Thresholds/templates live in hvac_defaults.ac_occupied_tiers (existing JSONB config blob, no migration) and are editable on the Settings page's new Weather Compensation table. Hotel lat/lon and the optional Met Office API key live centrally in the settings app (hotel_location/met_office integrations), not hvac-local, for reuse by other apps later. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
48ffebc08d
commit
915fc0039c
7 changed files with 236 additions and 14 deletions
|
|
@ -210,6 +210,16 @@ export const DEFAULT_HVAC_TEMPLATE = {
|
|||
trv_vacant_temp: 16.0,
|
||||
ac_occupied: { power: 'on', mode: 'cool', setpoint: 22.0, fan_speed: 'medium' },
|
||||
ac_vacant: { power: 'off', mode: 'cool', setpoint: 18.0, fan_speed: 'low' },
|
||||
// Weather compensation — ordered ascending by peak_above_c. At an occupied-state
|
||||
// transition, the scheduler picks the HIGHEST tier whose threshold today's forecast
|
||||
// peak clears and uses its template instead of ac_occupied above; below every
|
||||
// threshold (or if no forecast is available), ac_occupied is used unchanged. See
|
||||
// lib/weather.js and resolveAcTemplate() in lib/scheduler.js.
|
||||
ac_occupied_tiers: [
|
||||
{ name: 'warm', peak_above_c: 24, power: 'off', mode: 'cool', setpoint: 20.0, fan_speed: 'medium' },
|
||||
{ name: 'hot', peak_above_c: 28, power: 'on', mode: 'cool', setpoint: 20.0, fan_speed: 'high' },
|
||||
{ name: 'heatwave', peak_above_c: 32, power: 'on', mode: 'cool', setpoint: 20.0, fan_speed: 'powerful' },
|
||||
],
|
||||
}
|
||||
|
||||
async function seedDefaults() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue