Skip to content

fix(features): event payload checks for key values, characteristics and value states - #266

Open
nils-prommersberger wants to merge 1 commit into
devfrom
fix/event-payload-checks
Open

nils-prommersberger wants to merge 1 commit into
devfrom
fix/event-payload-checks

Conversation

@nils-prommersberger

Copy link
Copy Markdown
Contributor

Summary

Three small fixes in the CheckEventPayloadData… helpers in features/internal. These
helpers decide whether an incoming notify concerns a given data point and therefore
whether a use case raises an event. The getters were not affected; only the events were
wrong.

Helper Problem Fix
DeviceConfigurationCommon.CheckEventPayloadDataForFilter (deviceconfiguration.go:54) KeyId == desc.KeyId || Value != nil: every key value carrying a value matched, so an update of any key raised the events of all keys || → &&
ElectricalConnectionCommon.CheckEventPayloadDataForFilterDescriptionList (electricalconnection.go:85–89) Only the parameterId was compared, so characteristics sharing a parameter id raised events for each other. Use case specs require this sharing, e.g. MOI uses the MPC parameter id for several entity characteristics additionally compare characteristicId if set on both sides
MeasurementCommon.CheckEventPayloadDataForFilter (measurement.go:56) Entries without value were ignored. A notify that only sets valueState to error raised no event, so the application kept showing a value it has to ignore entries with value or valueState count as a change

Impact on existing use cases

These are intentional behaviour changes in events (fewer wrong events or an additional
correct event). No API changes.

  • DeviceConfiguration key values: cem/evcc, cem/vapd, cs/lpc, cs/lpp, eg/lpc, eg/lpp, ma/mgcp
  • ElectricalConnection characteristics: eg/lpc, eg/lpp
  • Measurement value state: cem/evcem, cem/evsoc, cem/vabd, cem/vapd, ma/mdt, ma/mgcp, ma/mpc

All existing tests pass unchanged.

Relation to MA-MOI / MA-MOB / MA-MPS

The new use cases are based on this commit. Without it their event tests fail:

  • MOI: up to 6 key value events or 8 characteristic events for a single change
  • MOB: the same effect for its key values and characteristics
  • MPS: the same effect for its key values
  • all three: no event for a value that becomes invalid

If this PR is merged first, the commit drops out of the use case PRs on rebase.

Tests

  • Test_CheckEventPayloadDataForFilter (DeviceConfiguration): a key value with a different key id no longer matches
  • Test_CheckEventPayloadDataForFilterDescriptionList (ElectricalConnection): same parameter id with a different characteristic id no longer matches
  • Test_CheckEventPayloadDataForFilter_ValueStateWithoutValue (Measurement): an entry with only valueState matches, an entry with neither value nor value state does not

…nd value states

- DeviceConfiguration: the payload check matched every key value that
  carried a value, because `||` was used instead of `&&`, so events
  were triggered for unrelated keys
- ElectricalConnection: the characteristic payload check only compared
  the parameter id, characteristics sharing a parameter id (e.g. all
  characteristics of an entity) triggered events for each other, now
  the characteristic id is compared as well if set
- Measurement: a notify that only carries a value state (e.g. "error"
  without a value) marks the value as invalid and is now reported as a
  data change, too

These change the events of existing use cases: cem/vapd (DeviceConfiguration),
eg/lpc and eg/lpp (ElectricalConnection characteristics) and ma/mpc,
ma/mgcp, ma/mdt, cem/vabd and cem/vapd (Measurement).

Co-authored-by: Robin Bendel <robin.bendel@enqs.de>
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