Skip to content

Adopt has_entity_name, fix frozen monthly statistics and stale completion readings#47

Open
codezorz wants to merge 5 commits into
mainfrom
feature/entity-naming-has-entity-name
Open

Adopt has_entity_name, fix frozen monthly statistics and stale completion readings#47
codezorz wants to merge 5 commits into
mainfrom
feature/entity-naming-has-entity-name

Conversation

@codezorz

@codezorz codezorz commented Apr 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • Entity naming: Adopt has_entity_name pattern and add configurable device name via options flow, aligning with Home Assistant best practices for entity/device naming
  • Fix frozen dashboard statistics: Allow statistics re-injection for the current calendar month so charts update throughout the month instead of freezing at the first injected value
  • Fix stale completion readings: Always fetch the authoritative date anchor when a month transitions to COMPLETE_READINGS, instead of relying on cached live-poll readings that can be off by 1 unit; correct the previous month's cache and cascade corrected start values into the current month
  • Anonymize docs: Replace real residential unit ID in ENDPOINTS.md example

Fixes #46

Test plan

  • All 231 existing tests pass after changes
  • New test: current month always bypasses the statistics injection guard
  • New tests: anchor is always fetched at completion (5 scenarios: always fetched, cache corrected when anchor differs, current month starts cascade, no-op when anchor matches, fallback on API failure)
  • Verify dashboard chart updates throughout the current month after HA restart
  • Verify that at month boundary, the previous month's total_usage matches the API's totalEnergyUsage value

@codezorz codezorz added bug Something isn't working enhancement New feature or request labels Apr 7, 2026
codezorz added 5 commits April 10, 2026 21:41
Enable modern HA entity naming (has_entity_name=True) so entity
friendly names are composed as "<device> <entity>" by Home Assistant
instead of carrying a hardcoded prefix. The device name is now
user-configurable (default "MijnTed") via the config and options flows,
which also prevents entity-id collisions when multiple config entries
exist.

Key changes:
- Add CONF_NAME / DEFAULT_NAME constants and wire them through the
  config flow, options flow, and translations.
- Set has_entity_name=True on all sensor and button entities; strip the
  "MijnTed" prefix from entity names so they become short descriptors.
- Pass the configured name into device_info and all entity constructors.

Made-with: Cursor
…letion readings

Allow statistics re-injection for the current calendar month so the
dashboard chart updates throughout the month. Always fetch the
authoritative date anchor at COMPLETE_READINGS transition instead of
relying on potentially stale cached device readings, and correct the
previous month's cache entry when anchor readings differ.

Fixes #46

Made-with: Cursor
…tion

Cover the current-month bypass in _has_already_injected_period and the
anchor correction behavior in _lock_current_month_starts_when_previous_complete
(always fetches anchor, corrects cache when readings differ, cascades
corrected starts, no-ops when anchor matches, falls back on API failure).

Made-with: Cursor
@codezorz codezorz force-pushed the feature/entity-naming-has-entity-name branch from 6aa742a to c8cbf1d Compare April 10, 2026 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Monthly usage statistics frozen and completion uses stale device readings

1 participant