Fix easyEnergy price period count sensor semantics - #181431
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
It changes user-facing sensor metadata/semantics (removing a unit of measurement) that normally warrants code-owner review, and the test outcomes depend on python-easyenergy behavior that could not be executed in this environment.
Pull request overview
This PR corrects the semantics of the two easyEnergy "priced equal or lower/higher" count sensors. These sensors return a count of matching price periods from python-easyenergy, but were incorrectly labeled with UnitOfTime.HOURS and displayed as "Hours priced …". The fix removes the misleading unit and renames the display strings to "Periods priced …", while intentionally preserving the existing entity IDs, unique IDs, and translation keys to avoid breaking users. It fits into the broader effort to raise this integration to Platinum quality (related PR #181378).
Changes:
- Remove
native_unit_of_measurement=UnitOfTime.HOURS(and the now-unusedUnitOfTimeimport) from the two count sensor descriptions. - Rename the two sensor display names in
strings.jsonfrom "Hours priced …" to "Periods priced …" (translation keys kept ashours_priced_*). - Update existing sensor tests for the new names/absent unit, and add a parameterized
test_price_period_countscovering inclusive counting for distinct usage/return prices at hourly and quarter-hourly granularity.
File summaries
| File | Description |
|---|---|
| homeassistant/components/easyenergy/sensor.py | Drops the incorrect UnitOfTime.HOURS unit and its import from the two period-count sensors. |
| homeassistant/components/easyenergy/strings.json | Renames the two sensor display names from "Hours priced …" to "Periods priced …". |
| tests/components/easyenergy/test_sensor.py | Updates existing assertions (unit absent, new names) and adds a parameterized test verifying inclusive period counts across interval sizes. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Proposed change
The two
hours_priced_equal_or_*sensors expose counts from python-easyenergy, but currently label them as hours. RemoveUnitOfTime.HOURSand rename their translated display names to “Periods priced …”. No device class applies: these values count today's periods whose usage price is at or below the current usage price, or whose return price is at or above the current return price. The library counts matching intervals without weighting their duration.Keep the existing entity IDs, unique IDs and translation keys. The current hourly request granularity and numeric values are unchanged. The incorrect
unit_of_measurement: hattribute is removed. Tests cover state, unit, device class, names and identity, plus inclusive comparisons with distinct usage/return prices for hourly and quarter-hourly data.Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: