Skip to content

Register OHPCF event handler in constructor#228

Open
andig wants to merge 4 commits into
enbility:implement-cem-ohpcffrom
andig:fix/ohpcf-register-event-handler
Open

Register OHPCF event handler in constructor#228
andig wants to merge 4 commits into
enbility:implement-cem-ohpcffrom
andig:fix/ohpcf-register-event-handler

Conversation

@andig

@andig andig commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

NewOHPCF is the only use-case constructor in this repo that does not subscribe the concrete use case to the device event bus. NewUseCaseBase only subscribes the embedded *UseCaseBase, whose HandleEvent handles use-case-data updates (firing UseCaseSupportUpdate). OHPCF.HandleEvent — which on entity-add calls connected() to Subscribe()/Bind() the remote SmartEnergyManagementPs feature, and on data change runs loadSmartEnergyManagementPsDataType to emit the DataUpdate* events — is therefore never registered and never runs.

Add the same _ = localEntity.Device().Events().Subscribe(uc) call to NewOHPCF.

Also added requesting initial data same als LPC does.

🤖 Generated with Claude Code

NewOHPCF never subscribed the concrete *OHPCF to the device event bus, so
only the embedded UseCaseBase.HandleEvent ran (firing UseCaseSupportUpdate).
OHPCF.HandleEvent — which subscribes/binds SmartEnergyManagementPs on entity
add and processes the data updates — was never invoked, so a CEM received no
process-state data and could not schedule the compressor.

Add the localEntity.Device().Events().Subscribe(uc) call that every other
use case constructor already performs.
@andig

andig commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

@sthelen-enqs this is an actual bug with #223

andig added a commit to evcc-io/evcc that referenced this pull request Jun 25, 2026
Point eebus-go at andig/eebus-go fix branch (enbility/eebus-go#228) which
registers the OHPCF use case event handler, so the compressor's
SmartEnergyManagementPs feature is actually subscribed and process-state
updates arrive. Revert to an upstream pseudo-version once #228 lands.
A subscription only delivers future updates, so without an initial read the
CEM never learns the current optional power consumption until the heat pump
pushes a change. Request the data on connect, as the other use cases do.
andig added a commit to evcc-io/evcc that referenced this pull request Jun 25, 2026
Pick up enbility/eebus-go#228 follow-up that reads the OHPCF data on connect
so the compressor's process state is populated instead of staying empty.
Comment thread usecases/cem/ohpcf/events.go
volschin added a commit to volschin/eebus-ha-bridge that referenced this pull request Jun 30, 2026
…SCF)

Adds the read-only CEM-client side of the OHPCF/OSCF use case
(optimizationOfSelfConsumptionByHeatPumpCompressorFlexibility) so a SHIP
trace can confirm whether the VR940 binds and serves its
SmartEnergyManagementPs feature before building the schedule/pause control
path. Gated by experimental.ohpcf_client (EEBUS_EXP_OHPCF_CLIENT), off by
default.

cem/ohpcf only exists in eebus-go's dev API (PR enbility/eebus-go#223), so
this migrates the bridge off v0.7.0 to that commit:

- service.go: NewConfiguration gains deviceCategories + pairingConfig +
  ringBuffer; RegisterRemoteSKI -> RegisterRemoteService(NewServiceIdentity);
  AllowWaitingForTrust behaviour preserved via
  UserIsAbleToApproveOrCancelPairingRequests(true).
- callbacks.go: rewritten for the redesigned ServiceReaderInterface
  (ServiceIdentity / RemoteMdnsService, auto-trust callbacks).
- mgcp/vabd/vapd: Measurement.UpdateDataForId -> UpdateDataForIds.

OHPCFWrapper.Setup works around enbility/eebus-go#228 (NewOHPCF, unlike
NewMPC/NewLPC, does not subscribe its concrete HandleEvent) by registering
the use case on the device event bus explicitly. Setup is idempotent so the
subscription is installed exactly once. Lifecycle is process-scoped, matching
the LPC/monitoring wrappers (no teardown).

Read-only observer: no proto or HA changes. Tests cover event routing and
Setup idempotency. docs/eebus-vaillant-improvements.md updated to supersede
the outdated "OSCF = fully custom SPINE" note.
volschin added a commit to volschin/eebus-ha-bridge that referenced this pull request Jun 30, 2026
…SCF)

Adds the read-only CEM-client side of the OHPCF/OSCF use case
(optimizationOfSelfConsumptionByHeatPumpCompressorFlexibility) so a SHIP
trace can confirm whether the VR940 binds and serves its
SmartEnergyManagementPs feature before building the schedule/pause control
path. Gated by experimental.ohpcf_client (EEBUS_EXP_OHPCF_CLIENT), off by
default.

cem/ohpcf only exists in eebus-go's dev API (PR enbility/eebus-go#223), so
this migrates the bridge off v0.7.0 to that commit:

- service.go: NewConfiguration gains deviceCategories + pairingConfig +
  ringBuffer; RegisterRemoteSKI -> RegisterRemoteService(NewServiceIdentity);
  AllowWaitingForTrust behaviour preserved via
  UserIsAbleToApproveOrCancelPairingRequests(true).
- callbacks.go: rewritten for the redesigned ServiceReaderInterface
  (ServiceIdentity / RemoteMdnsService, auto-trust callbacks).
- mgcp/vabd/vapd: Measurement.UpdateDataForId -> UpdateDataForIds.

OHPCFWrapper.Setup works around enbility/eebus-go#228 (NewOHPCF, unlike
NewMPC/NewLPC, does not subscribe its concrete HandleEvent) by registering
the use case on the device event bus explicitly. Setup is idempotent so the
subscription is installed exactly once. Lifecycle is process-scoped, matching
the LPC/monitoring wrappers (no teardown).

Read-only observer: no proto or HA changes. Tests cover event routing and
Setup idempotency. docs/eebus-vaillant-improvements.md updated to supersede
the outdated "OSCF = fully custom SPINE" note.
volschin added a commit to volschin/eebus-ha-bridge that referenced this pull request Jun 30, 2026
…nt + HA control (#70)

* feat(ohpcf): spike CEM-client for heat-pump compressor flexibility (OSCF)

Adds the read-only CEM-client side of the OHPCF/OSCF use case
(optimizationOfSelfConsumptionByHeatPumpCompressorFlexibility) so a SHIP
trace can confirm whether the VR940 binds and serves its
SmartEnergyManagementPs feature before building the schedule/pause control
path. Gated by experimental.ohpcf_client (EEBUS_EXP_OHPCF_CLIENT), off by
default.

cem/ohpcf only exists in eebus-go's dev API (PR enbility/eebus-go#223), so
this migrates the bridge off v0.7.0 to that commit:

- service.go: NewConfiguration gains deviceCategories + pairingConfig +
  ringBuffer; RegisterRemoteSKI -> RegisterRemoteService(NewServiceIdentity);
  AllowWaitingForTrust behaviour preserved via
  UserIsAbleToApproveOrCancelPairingRequests(true).
- callbacks.go: rewritten for the redesigned ServiceReaderInterface
  (ServiceIdentity / RemoteMdnsService, auto-trust callbacks).
- mgcp/vabd/vapd: Measurement.UpdateDataForId -> UpdateDataForIds.

OHPCFWrapper.Setup works around enbility/eebus-go#228 (NewOHPCF, unlike
NewMPC/NewLPC, does not subscribe its concrete HandleEvent) by registering
the use case on the device event bus explicitly. Setup is idempotent so the
subscription is installed exactly once. Lifecycle is process-scoped, matching
the LPC/monitoring wrappers (no teardown).

Read-only observer: no proto or HA changes. Tests cover event routing and
Setup idempotency. docs/eebus-vaillant-improvements.md updated to supersede
the outdated "OSCF = fully custom SPINE" note.

* feat(ohpcf): Path B — proto RPC + HA control for compressor flexibility

Builds the control path on top of the OHPCF CEM-client spike: Home Assistant
can now read the heat pump compressor's optional-consumption offer and
schedule / pause / resume / abort it to soak up PV surplus (§1.3.1).

Proto contract (regenerated both sides per CLAUDE.md):
- ohpcf_service.proto: OHPCFService with GetCompressorFlexibility,
  ControlCompressorFlexibility (schedule/pause/resume/abort) and
  SubscribeOHPCFEvents; CompressorFlexibility + OHPCFAction +
  CompressorPowerConsumptionState. Added to generate_proto.sh.

Go bridge:
- usecases/ohpcf.go: CompatibleEntity resolver (picks the Compressor entity,
  issue #47), read passthroughs, and Schedule/Pause/Resume/Abort with async
  result-callback logging.
- grpc/ohpcf_service.go: gRPC impl mirroring lpc_service; best-effort
  buildFlexibility (omits fields the compressor has not populated yet) and
  state mapping. Registered in main.go.

HA integration:
- coordinator: poll reads compressor_flexibility + ohpcf_supported;
  async_control_compressor(action). UNAVAILABLE (bridge OHPCF off) keeps the
  entities unavailable.
- switch: EebusCompressorFlexibilitySwitch (on=schedule/resume,
  off=pause/abort), added only when ohpcf_supported.
- proto_stubs re-exports, en/de/strings translations, test_ohpcf.py (5 tests).

Go build/vet/test green; 47 Python tests pass; ruff + gofmt clean.

* test(ohpcf): fix integration test for eebus-go v0.7.1 callback API

RemoteSKIConnected was renamed to RemoteServiceConnected(svc, identity)
in the v0.7.1 rebase. Update the integration test call site accordingly.
@andig andig mentioned this pull request Jul 1, 2026
PowerConsumptionProcessState only matched PowerSequenceStateTypeScheduledPaused
("scheduledPaused"), but [OHPCF-012] specifies the state string "paused" — which
is exactly what this use case's own PausePowerConsumptionProcess writes. So a
paused process was written as "paused" and read back as ErrNotSupported.

Match PowerSequenceStateTypePaused, keeping ScheduledPaused for devices that
report it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant