Skip to content

Fix easyEnergy price period count sensor semantics - #181431

Merged
MartinHjelmare merged 1 commit into
home-assistant:devfrom
klaasnicolaas:fix-easyenergy-price-period-counts
Sep 7, 2026
Merged

Fix easyEnergy price period count sensor semantics#181431
MartinHjelmare merged 1 commit into
home-assistant:devfrom
klaasnicolaas:fix-easyenergy-price-period-counts

Conversation

@klaasnicolaas

@klaasnicolaas klaasnicolaas commented Sep 6, 2026

Copy link
Copy Markdown
Member

Breaking change

The easyEnergy sensors hours_priced_equal_or_lower and hours_priced_equal_or_higher, now named "Periods priced …", no longer expose the h unit of measurement. Their values count price periods, not durations in hours.

Update any templates or dashboard cards that depend on these sensors' unit_of_measurement attribute to handle unitless counts. Numeric values, entity IDs, and unique IDs remain unchanged. Automations that compare only the numeric sensor values require no changes.

Proposed change

The two hours_priced_equal_or_* sensors expose counts from python-easyenergy, but currently label them as hours. Remove UnitOfTime.HOURS and 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.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies a diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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-unused UnitOfTime import) from the two count sensor descriptions.
  • Rename the two sensor display names in strings.json from "Hours priced …" to "Periods priced …" (translation keys kept as hours_priced_*).
  • Update existing sensor tests for the new names/absent unit, and add a parameterized test_price_period_counts covering 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.

@MartinHjelmare MartinHjelmare left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@MartinHjelmare
MartinHjelmare merged commit 31af427 into home-assistant:dev Sep 7, 2026
35 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants