Draft
Investigate configurable week-start-day support for weekly meter cycles#166
Conversation
3 tasks
cabberley
marked this pull request as ready for review
August 5, 2026 21:02
cabberley
marked this pull request as draft
August 5, 2026 21:05
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Copilot
AI
changed the title
[WIP] Add configurable week start day to align with locale settings
Investigate configurable week-start-day support for weekly meter cycles
Aug 5, 2026
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.
Problem
Weekly meter cycles always reset on Sunday, regardless of Home Assistant's configured locale (
hass.config.country/language) or user expectation. Most European/other locales expect Monday as the first day of the week, so weekly meter resets are misaligned with user expectations and with statistics elsewhere in Home Assistant.Status
This session focused on investigation and did not land a code change yet:
PERIOD2CRON[WEEKLY]incustom_components/utility_meter_next_gen/const.pyproduces"{minute} {hour} * * {day}", populated fromCONF_METER_OFFSET["days"]insensor.py(__init__, around line 657) — thedayfield here is currently just a plain integer offset, not tied to any weekday-of-reset concept.hass.config— onlycountryandlanguageare available (homeassistant/core_config.py). Locale-based week start would need to be derived viababel.Locale(...).first_week_day, which is available sincebabelis already a transitive HA dependency.config_flow.py,schemas.py) to identify where an explicit override selector (Sunday/Monday) would need to be added toBASE_PREDEFINED_CONFIG_SCHEMAand the corresponding options schema, alongside the existingCONF_METER_OFFSETduration selector.Next steps
CONF_WEEK_STARTconfig option (e.g.default,sunday,monday) toconst.py/schemas.py, exposed viaselector.SelectSelectorin both the config and options flows.default, derive week start fromhass.config.country/languageviababel.Locale.first_week_day; otherwise use the explicit override.sensor.pyso the{day}cron field reflects the resolved week-start weekday plus the existing offset, rather than treating offset days as an absolute weekday.tests/components/utility_meter_evolved/test_sensor.pycovering weekly reset on both Sunday- and Monday-start configurations.