Commit Graph

5 Commits (67836b72348418ba4662d7d0b1652a6725438018)

Author SHA1 Message Date
Patrick Schurig 67836b7234 feat: Installer Setup — LoadAdapterRegistry + adapter layer (v12)
Adds a thin adapter layer that maps installer-visible roles (EVCharger,
DHW, HeatPump, Battery, SolarMeter, GridMeter) to nymea Things and
applies Scheduler slot decisions to real hardware.

New files:
- energyplugin/types/loadrole.h — LoadRole enum + compat interface map
- energyplugin/adapters/iloadapter.h — abstract ILoadAdapter interface
- energyplugin/adapters/relayadapter.h/.cpp — binary on/off relay (DHW/HP)
- energyplugin/adapters/sgreadyadapter.h/.cpp — SG-Ready 2-relay HP (SG1–SG4)
- energyplugin/adapters/evchargeradapter.h/.cpp — EV charger W→A adapter
- energyplugin/adapters/batteryadapter.h/.cpp — battery charge/discharge/standby
- energyplugin/adapters/loadadapterregistry.h/.cpp — role→Thing→adapter registry
- energyplugin/adapters/adaptersettings.h/.cpp — persists to adapters.conf (INI)

Modified:
- SchedulerManager: optional LoadAdapterRegistry param; applyCurrentSlot()
  now calls adapter->applyPower() for DHW/HP/Battery roles
- NymeaEnergyJsonHandler: 6 new v12 methods (GetSetupStatus,
  GetCompatibleThings, AssignThingToRole, UnassignRole, SetRoleEnabled,
  TestRoleConnection) + 3 push notifications
- energypluginnymea.cpp: wires AdapterSettings + LoadAdapterRegistry,
  bumps JSON-RPC version to 12
- energyplugin.pri: adds 7 headers + 6 sources
- testscheduler: 4 new tests (detectAdapterType, AdapterSettings round-trip,
  null-registry no-crash, LoadRole serialization) — 15/15 pass
- doc.md: section 12 Installer Setup

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-24 09:15:06 +01:00
Patrick Schurig 69246618ee fix: test forecast uses UTC hour for solar/price lookup
buildWinterForecast was indexing solarW[] and winterPrices[] by slot
position h instead of actual UTC hour. When a forecast starts at 18:00,
h=8 (02:00 AM) was getting solarW[8]=1200W, giving midnight slots a
false solar bonus in RuleBasedStrategy::slotScore(). The strategy
correctly chose those slots, but countSlotsInCheapestN (price-only)
reported them as outside the 6 cheapest hours → test 1 failed.

Fix: index both arrays by slot.start.toUTC().time().hour() so solar
peaks at noon and prices reflect the real time-of-day. All 11 tests pass.

Also includes the INCLUDEPATH += \$\$PWD fix in energyplugin.pri that
makes relative includes work for test builds consuming the .pri.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-24 06:53:20 +01:00
Patrick Schurig 0797f37c78 feat: ManualStrategy — community tier scheduling with full manual control
- Add ManualSlotConfig type with weekly repeating support and auto-expiry
- Add ManualStrategy (strategyId="manual"): applies user-defined allocations
  exactly; expired slots logged and skipped; inflexible/critical loads always
  applied as safety fallback; decisionReason never empty
- Extend SchedulerSettings with manualSlots persistence section (INI array)
- Extend SchedulerManager with setManualSlot/removeManualSlot/clearManualSlots
  methods; hydrates ManualStrategy from settings on registerStrategy()
- Add JSON-RPC v11 methods: GetManualSlots, SetManualSlot, RemoveManualSlot,
  ClearManualSlots + ManualSlotActivated push notification
- Register ManualStrategy in energypluginnymea.cpp::init() (no feature flag)
- Add 5 unit tests: basicSlot, noConfig_fallback, expiredSlot, repeatingSlot,
  persistence (JSON round-trip)
- Update doc.md section 11

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-24 06:34:31 +01:00
Patrick Schurig 253c5f487a feat: SchedulerManager v1 — build clean
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-23 22:02:01 +01:00
Patrick Schurig b343650f9b initial commit 2026-01-11 11:09:23 +01:00