From 147957256913b32d476b41a0a21c4b4edd735e71 Mon Sep 17 00:00:00 2001 From: Dusan Vojacek Date: Sun, 14 Jun 2026 23:20:32 +0200 Subject: [PATCH] =?UTF-8?q?feat(activate):=20home-01=20=E2=80=94=20notify?= =?UTF-8?q?=20(V111)=20+=20pool=20control=20(V112)=20+=20EV=20start=20pena?= =?UTF-8?q?lty=20(V113)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Operační aktivace nasazených featur přes Flyway: - V111: asset_vehicle.presence_nudge_enabled=true (tesla-my) → proaktivní nudge - V112: signal_route POOL_PUMP_ON → Shelly + asset_pool_pump.schedulable=true - V113: asset_ev_charger.planner_ev_start_penalty_czk=0.5 (anti-fragmentace, laditelné) Geofence (env EV_GEOFENCE_ARRIVAL_OBS_ENABLED) si nastaví uživatel na serveru. Co-Authored-By: Claude Opus 4.8 (1M context) --- ...111__activate_ev_presence_nudge_home01.sql | 10 +++++ .../V112__activate_pool_control_home01.sql | 38 +++++++++++++++++++ ...V113__activate_ev_start_penalty_home01.sql | 10 +++++ 3 files changed, 58 insertions(+) create mode 100644 db/migration/V111__activate_ev_presence_nudge_home01.sql create mode 100644 db/migration/V112__activate_pool_control_home01.sql create mode 100644 db/migration/V113__activate_ev_start_penalty_home01.sql diff --git a/db/migration/V111__activate_ev_presence_nudge_home01.sql b/db/migration/V111__activate_ev_presence_nudge_home01.sql new file mode 100644 index 0000000..530e169 --- /dev/null +++ b/db/migration/V111__activate_ev_presence_nudge_home01.sql @@ -0,0 +1,10 @@ +-- Aktivace proaktivní notifikace „píchni auto" pro Teslu na home-01. +-- V110 přidala flag asset_vehicle.presence_nudge_enabled (default false = inertní); +-- tato migrace ho operačně zapíná pro tesla-my. Job ev_presence_notify pak pošle +-- Discord nudge, když je auto doma + odpojené + (SoC < cíl−tolerance) + levné/přebytek. +-- Vypnutí později: nová migrace nebo operační update. + +update ems.asset_vehicle +set presence_nudge_enabled = true +where code = 'tesla-my' + and site_id = (select id from ems.site where code = 'home-01'); diff --git a/db/migration/V112__activate_pool_control_home01.sql b/db/migration/V112__activate_pool_control_home01.sql new file mode 100644 index 0000000..af33a6d --- /dev/null +++ b/db/migration/V112__activate_pool_control_home01.sql @@ -0,0 +1,38 @@ +-- Aktivace řízení bazénového čerpadla na home-01 (Phase 1). +-- Kód: R__101 (fn_pool_schedule_slot / fn_pool_control_tick) + V087 (asset/telemetrie) +-- + R__094 (fn_signal_enqueue_bool) + signal_service. Tato migrace ho operačně zapíná: +-- 1) signal_route POOL_PUMP_ON → Shelly Gen2 RPC Switch.Set (http_rest), map_bool +-- true/false; switch id z asset_pool_pump.shelly_switch_id. verify_readback=false +-- (ověřuje se přes telemetry_pool_pump.is_on; readback verify lze doplnit později). +-- 2) schedulable = true → control tick (á 15 min) řídí relé dle nejlevnějšího okna +-- denního runtime budgetu (fn_pool_daily_runtime_min) + dump-load při sell<=0. +-- Tím se i opraví bazálový odečet (R__003): bazén je nyní řízený + plánovaný. +-- Idempotentní: route se vloží jen pokud ještě neexistuje. + +insert into ems.signal_route + (site_id, signal_code, destination_type, endpoint_id, destination_key, + route_config_json, transform_json, verify_readback, enabled) +select + pp.site_id, + 'POOL_PUMP_ON', + 'http_rest', + pp.endpoint_id, + 'pool-pump', + jsonb_build_object( + 'method', 'GET', + 'path_template', '/rpc/Switch.Set?id=' || pp.shelly_switch_id || '&on={value}' + ), + '{"map_bool": {"true": "true", "false": "false"}}'::jsonb, + false, + true +from ems.asset_pool_pump pp +where pp.site_id = (select id from ems.site where code = 'home-01') + and pp.endpoint_id is not null + and not exists ( + select 1 from ems.signal_route sr + where sr.site_id = pp.site_id and sr.signal_code = 'POOL_PUMP_ON' + ); + +update ems.asset_pool_pump +set schedulable = true +where site_id = (select id from ems.site where code = 'home-01'); diff --git a/db/migration/V113__activate_ev_start_penalty_home01.sql b/db/migration/V113__activate_ev_start_penalty_home01.sql new file mode 100644 index 0000000..eecc0c3 --- /dev/null +++ b/db/migration/V113__activate_ev_start_penalty_home01.sql @@ -0,0 +1,10 @@ +-- Aktivace anti-fragmentační start penalty EV na home-01 (konzervativně 0.5 Kč/start). +-- V108 přidala sloupec asset_ev_charger.planner_ev_start_penalty_czk (default 0 = no-op); +-- tato migrace zapíná malou penaltu → solver slepí EV nabíjení do souvislejší dávky +-- místo rozsekání. 3f floor (Fix B) už 1f trickle vyřešil; tohle je doladění. +-- Hodnota je laditelná — pokud by penalta přebíjela reálný cenový spread, snížit/zrušit +-- novou migrací nebo operačním updatem. + +update ems.asset_ev_charger +set planner_ev_start_penalty_czk = 0.5 +where site_id = (select id from ems.site where code = 'home-01');