Add date-parameterized sync with production and consumption tables

- Accept ?date= param on POST /eloverblik/sync (defaults to today)
- Populate production table from D06 meter (571313113163368491)
- Populate consumption table from D07 meter (571313113163368507)
- ON CONFLICT DO NOTHING to skip existing data

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-14 18:09:36 +01:00
co-authored by Claude Opus 4.6
parent ca473c62bb
commit d756c98810
3 changed files with 46 additions and 9 deletions
+12
View File
@@ -47,3 +47,15 @@ INSERT INTO charges (metering_point_id, charge_type, name, description, owner,
VALUES (:metering-point-id, :charge-type, :name, :description, :owner,
:valid-from-date, :valid-to-date, :period-type, :price, :quantity, :position)
ON CONFLICT (metering_point_id, charge_type, name, owner, valid_from_date, position) DO NOTHING;
-- :name insert-production! :! :n
-- :doc Insert a production record, skip if already exists
INSERT INTO production (time_start, hour, kwh)
VALUES (:time-start, :hour, :kwh)
ON CONFLICT (time_start, hour) DO NOTHING;
-- :name insert-consumption! :! :n
-- :doc Insert a consumption record, skip if already exists
INSERT INTO consumption (time_start, hour, kwh)
VALUES (:time-start, :hour, :kwh)
ON CONFLICT (time_start, hour) DO NOTHING;