feat(devices): let ElectricalUtilityMeter.addElectricalMeter() combine a tariff onto the same endpoint - #615
Open
lboue wants to merge 3 commits into
Open
Conversation
…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>
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a
tariffsub-option toElectricalMeterOptionssoaddElectricalMeter()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: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-rollingaddChildDeviceType()/behaviors.require()calls.Both methods now share a private
configureElectricalEnergyTariffClusters()helper (and agetDefaultElectricalEnergyTariffTagList()helper for the § 14.7.4 semantic tags) so the CommodityPrice/CommodityTariff/ElectricalGridConditions setup — including the § 9.12.6.2 rule thatCommodityTariff.tariffUnitstaysnullwhiletariffInfoisnull— 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
packages/core/vitest/devices/electricalUtilityMeter.test.tswith tests covering the newtariffsub-option (combined device types/clusters on one endpoint, and the tariffUnit-stays-null-while-tariffInfo-is-null case).vitest/devices/suite (302 tests) pass on a clean worktree based ondev.