-- Bazén: sezóna, délka filtrace dle teploty vody, čtení čidel z Loxone. -- -- Sezóna: přepínač = existující asset_pool_pump.schedulable (true = plánovač -- řídí; konec sezóny -> false: telemetrie běží dál, signály/solver ne). -- Viz docs/04-modules/pool-shelly.md § Sezóna. -- -- Teplotní funkce (slaná voda, chlorinátor potřebuje průtok; teplejší voda = -- delší filtrace): runtime_min(t) = clamp(base + per_c × (t − ref), min, max). -- Defaulty pro 30 m³ / 8 m³/h (obrátka 3.75 h): 20 °C → 4.5 h, 26 °C → 7.5 h, -- 28 °C → 8.5 h, strop 10 h. Bez čidla / starého měření → fallback -- daily_runtime_min. Vše per čerpadlo v DB (pravidlo 16). create table ems.loxone_sensor ( id serial primary key, site_id int not null references ems.site (id), code text not null, loxone_name text not null, unit text, enabled boolean not null default true, notes text, constraint uq_loxone_sensor_site_code unique (site_id, code) ); comment on table ems.loxone_sensor is 'Čidla čtená z Loxone Miniserveru (GET /jdev/sps/io//state přes loxone_http endpoint site). Telemetrie 60 s do telemetry_loxone_sensor.'; create table ems.telemetry_loxone_sensor ( sensor_id int not null references ems.loxone_sensor (id), measured_at timestamptz not null, value numeric(10, 2), primary key (sensor_id, measured_at) ); select create_hypertable( 'ems.telemetry_loxone_sensor', 'measured_at', chunk_time_interval => interval '1 week', if_not_exists => true ); comment on table ems.telemetry_loxone_sensor is '1min hodnoty Loxone čidel (teplota bazénu, akumulační nádrže, ...).'; alter table ems.asset_pool_pump add column if not exists water_temp_sensor_id int references ems.loxone_sensor (id), add column if not exists runtime_ref_temp_c numeric(4, 1) not null default 20.0, add column if not exists runtime_base_min int not null default 270, add column if not exists runtime_min_per_c int not null default 30, add column if not exists runtime_min_min int not null default 180, add column if not exists runtime_max_min int not null default 600; comment on column ems.asset_pool_pump.water_temp_sensor_id is 'Loxone čidlo teploty vody; NULL = teplotní funkce vypnutá (fallback daily_runtime_min).'; comment on column ems.asset_pool_pump.runtime_base_min is 'Minuty filtrace/den při runtime_ref_temp_c; nad ní +runtime_min_per_c za °C, clamp [runtime_min_min, runtime_max_min].';