Skip to content

feat(devices): let ElectricalUtilityMeter.addElectricalMeter() combine a tariff onto the same endpoint - #615

Open
lboue wants to merge 3 commits into
Luligu:devfrom
lboue:fix/electrical-meter-combined-tariff-604
Open

feat(devices): let ElectricalUtilityMeter.addElectricalMeter() combine a tariff onto the same endpoint#615
lboue wants to merge 3 commits into
Luligu:devfrom
lboue:fix/electrical-meter-combined-tariff-604

Conversation

@lboue

@lboue lboue commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

What

Adds a tariff sub-option to ElectricalMeterOptions so addElectricalMeter() can fold the Electrical Energy Tariff device type and its clusters (CommodityPrice, CommodityTariff, ElectricalGridConditions) onto the same endpoint as the electrical meter, instead of always requiring a separate one:

meter.addElectricalMeter('electricalMeterCurrent', {
  voltage, current, power, energyImported,
  tariff: { tariffLabel: 'Standard', providerName: 'Matterbridge Example', currentPrice },
});

addElectricalEnergyTariff() remains available for a standalone tariff endpoint. Together they let callers build the exact EP1/EP2/EP3 "Basic Utility Meter" topology example (Device Library Specification § 14.9.6) from the class's own public convenience methods, without bypassing both and hand-rolling addChildDeviceType()/behaviors.require() calls.

Both methods now share a private configureElectricalEnergyTariffClusters() helper (and a getDefaultElectricalEnergyTariffTagList() helper for the § 14.7.4 semantic tags) so the CommodityPrice/CommodityTariff/ElectricalGridConditions setup — including the § 9.12.6.2 rule that CommodityTariff.tariffUnit stays null while tariffInfo is null — isn't duplicated between them.

Why

Closes #604 — this is the design you agreed to in that issue's thread ("We could add the Energy Tariff options to Electrical Meter options to add also Tariff").

Testing

  • Extended packages/core/vitest/devices/electricalUtilityMeter.test.ts with tests covering the new tariff sub-option (combined device types/clusters on one endpoint, and the tariffUnit-stays-null-while-tariffInfo-is-null case).
  • Build, typecheck, lint, and the full vitest/devices/ suite (302 tests) pass on a clean worktree based on dev.

…e a tariff onto the same endpoint

Adds a `tariff` sub-option to `ElectricalMeterOptions` so callers can fold
the Electrical Energy Tariff device type and its clusters (CommodityPrice,
CommodityTariff, ElectricalGridConditions) onto the *same* endpoint as the
electrical meter, instead of always requiring a separate one:

  meter.addElectricalMeter('electricalMeterCurrent', {
    voltage, current, power, energyImported,
    tariff: { tariffLabel: 'Standard', providerName: 'Matterbridge Example', currentPrice },
  });

`addElectricalEnergyTariff()` remains available for a standalone tariff
endpoint. Together they let callers build the exact EP1/EP2/EP3 "Basic
Utility Meter" topology example (Device Library Specification § 14.9.6)
from the class's own public convenience methods, without bypassing both
and hand-rolling `addChildDeviceType()`/`behaviors.require()` calls.

Both methods now share a private `configureElectricalEnergyTariffClusters()`
helper (and a `getDefaultElectricalEnergyTariffTagList()` helper for the
§ 14.7.4 semantic tags) so the CommodityPrice/CommodityTariff/
ElectricalGridConditions setup — including the § 9.12.6.2 rule that
CommodityTariff.tariffUnit stays null while tariffInfo is null — isn't
duplicated between them.

Closes Luligu#604.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Luligu Luligu self-assigned this Aug 24, 2026
@Luligu Luligu added the enhancement New feature or request label Aug 24, 2026
lboue added 2 commits August 24, 2026 11:10
…evice changelog tag convention

Rebases our CHANGELOG.md entry onto dev's reorganized [3.10.7] section (renamed
category tags to per-device-type tags such as [Closure]/[WaterValve]/[Pump],
added the Pump entries and chip line, and moved the Fixed section after
Changed). Our new entry now uses the [ElectricalUtilityMeter] tag and is
appended at the end of the Added list, matching dev's content everywhere else
so the PR is no longer conflicting with dev.
@lboue
lboue requested a review from Luligu August 24, 2026 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants