8000 Changes to be committed: by cabberley · Pull Request #8 · cabberley/utility_meter_evolved · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Changes to be committed: #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 20, 2025
Merged

Changes to be committed: #8

merged 1 commit into from
Jun 20, 2025

Conversation

cabberley
Copy link
Owner
@cabberley cabberley commented Jun 20, 2025

modified: .devcontainer.json
modified: .github/ISSUE_TEMPLATE/bug.yml
modified: .github/ISSUE_TEMPLATE/feature_request.yml
modified: CONTRIBUTING.md
modified: config/configuration.yaml
renamed: custom_components/utility_meter_evolved/init.py -> custom_components/utility_meter_next_gen/init.py
renamed: custom_components/utility_meter_evolved/config_flow.py -> custom_components/utility_meter_next_gen/config_flow.py
renamed: custom_components/utility_meter_evolved/const.py -> custom_components/utility_meter_next_gen/const.py
renamed: custom_components/utility_meter_evolved/diagnostics.py -> custom_components/utility_meter_next_gen/diagnostics.py
renamed: custom_components/utility_meter_evolved/icons.json -> custom_components/utility_meter_next_gen/icons.json
renamed: custom_components/utility_meter_evolved/manifest.json -> custom_components/utility_meter_next_gen/manifest.json
renamed: custom_components/utility_meter_evolved/readme.md -> custom_components/utility_meter_next_gen/readme.md
renamed: custom_components/utility_meter_evolved/select.py -> custom_components/utility_meter_next_gen/select.py
renamed: custom_components/utility_meter_evolved/sensor.py -> custom_components/utility_meter_next_gen/sensor.py
renamed: custom_components/utility_meter_evolved/services.yaml -> custom_components/utility_meter_next_gen/services.yaml
renamed: custom_components/utility_meter_evolved/strings.json -> custom_components/utility_meter_next_gen/strings.json
renamed: custom_components/utility_meter_evolved/translations/en.json -> custom_components/utility_meter_next_gen/translations/en.json
modified: hacs.json
modified: scripts/develop
modified: tests/components/utility_meter_evolved/test_sensor.py

Summary by Sourcery

Rebrand the utility meter component to utility_meter_next_gen, introduce a source calculation multiplier with config flow support and migration, and refine tariff selection behavior.

New Features:

  • Add a source calculation multiplier option to adjust computed sensor values

Enhancements:

  • Rebrand the integration from utility_meter_evolved to utility_meter_next_gen across code, metadata, documentation, and tests
  • Bump config flow version to 3 and migrate existing entries to include the new multiplier option
  • Make removal of 'total' tariff option in select entity case-insensitive

Documentation:

  • Update issue templates, contributing guide, configuration examples, and manifest to reflect the new integration name

Tests:

  • Update tests to reference the utility_meter_next_gen integration

Chores:

  • Update development container config, HACS settings, and helper scripts for the rebranded integration

	modified:   .devcontainer.json
	modified:   .github/ISSUE_TEMPLATE/bug.yml
	modified:   .github/ISSUE_TEMPLATE/feature_request.yml
	modified:   CONTRIBUTING.md
	modified:   config/configuration.yaml
	renamed:    custom_components/utility_meter_evolved/__init__.py -> custom_components/utility_meter_next_gen/__init__.py
	renamed:    custom_components/utility_meter_evolved/config_flow.py -> custom_components/utility_meter_next_gen/config_flow.py
	renamed:    custom_components/utility_meter_evolved/const.py -> custom_components/utility_meter_next_gen/const.py
	renamed:    custom_components/utility_meter_evolved/diagnostics.py -> custom_components/utility_meter_next_gen/diagnostics.py
	renamed:    custom_components/utility_meter_evolved/icons.json -> custom_components/utility_meter_next_gen/icons.json
	renamed:    custom_components/utility_meter_evolved/manifest.json -> custom_components/utility_meter_next_gen/manifest.json
	renamed:    custom_components/utility_meter_evolved/readme.md -> custom_components/utility_meter_next_gen/readme.md
	renamed:    custom_components/utility_meter_evolved/select.py -> custom_components/utility_meter_next_gen/select.py
	renamed:    custom_components/utility_meter_evolved/sensor.py -> custom_components/utility_meter_next_gen/sensor.py
	renamed:    custom_components/utility_meter_evolved/services.yaml -> custom_components/utility_meter_next_gen/services.yaml
	renamed:    custom_components/utility_meter_evolved/strings.json -> custom_components/utility_meter_next_gen/strings.json
	renamed:    custom_components/utility_meter_evolved/translations/en.json -> custom_components/utility_meter_next_gen/translations/en.json
	modified:   hacs.json
	modified:   scripts/develop
	modified:   tests/components/utility_meter_evolved/test_sensor.py
Copy link
sourcery-ai bot commented Jun 20, 2025

Reviewer's Guide

This PR renames the custom component from utility_meter_evolved to utility_meter_next_gen, introduces a new “source_calc_multiplier” configuration option throughout the config flow, schemas, sensor logic, migration routines and documentation, refines tariff handling to remove “total” case-insensitively, and bumps the integration version to support the new option.

Class diagram for UtilityMeterSensor with source_calc_multiplier

classDiagram
    class UtilityMeterSensor {
        - _attr_multiplier
        - _attr_calculated_value
        + __init__(..., source_calc_multiplier, ...)
        + async_reset_meter(entity_id)
        + extra_state_attributes()
    }
    UtilityMeterSensor : +source_calc_multiplier
    UtilityMeterSensor : +_attr_multiplier
    UtilityMeterSensor : +extra_state_attributes includes source_calc_multiplier
Loading

Class diagram for config flow schemas with source_calc_multiplier

classDiagram
    class ConfigFlowSchema {
        +create_option_schema_cron(data)
        +create_option_schema_predefined(data)
        +PREDEFINED_CYCLES_SCHEMA
        +CRON_CYCLES_SCHEMA
    }
    ConfigFlowSchema : +CONF_SOURCE_CALC_MULTIPLIER in schemas
    ConfigFlowSchema : +create_option_schema_cron includes source_calc_multiplier
    ConfigFlowSchema : +create_option_schema_predefined includes source_calc_multiplier
    ConfigFlowSchema : +PREDEFINED_CYCLES_SCHEMA includes source_calc_multiplier
    ConfigFlowSchema : +CRON_CYCLES_SCHEMA includes source_calc_multiplier
Loading

Class diagram for migration routine with source_calc_multiplier

classDiagram
    class MigrationRoutine {
        +async_migrate_entry(hass, config_entry)
    }
    MigrationRoutine : +adds CONF_SOURCE_CALC_MULTIPLIER with default 1 on version 2->3
Loading

File-Level Changes

Change Details Files
Component and domain rename to utility_meter_next_gen
  • Updated DOMAIN and data keys (DATA_UTILITY, DATA_TARIFF_SENSORS)
  • Renamed files and directories under custom_components
  • Adjusted manifest.json name/domain and services.yaml integration targets
  • Updated issue templates, CONTRIBUTING.md, configuration.yaml, hacs.json, scripts/develop references
  • Modified tests comments to refer to utility_meter_next_gen
custom_components/utility_meter_next_gen/__init__.py
custom_components/utility_meter_next_gen/const.py
custom_components/utility_meter_next_gen/manifest.json
custom_components/utility_meter_next_gen/services.yaml
.github/ISSUE_TEMPLATE/bug.yml
.github/ISSUE_TEMPLATE/feature_request.yml
CONTRIBUTING.md
config/configuration.yaml
hacs.json
scripts/develop
tests/components/utility_meter_evolved/test_sensor.py
custom_components/utility_meter_next_gen/icons.json
custom_components/utility_meter_next_gen/strings.json
custom_components/utility_meter_next_gen/translations/en.json
Add source_calc_multiplier option across schemas and config flow
  • Defined new CONF_SOURCE_CALC_MULTIPLIER constant
  • Extended create_option_schema_* and CYCLES_SCHEMA to require multiplier with default
  • Inserted multiplier field in config_flow option schemas
  • Added extraction of multiplier from config_entry.options in async_setup_entry and async_setup_platform
custom_components/utility_meter_next_gen/config_flow.py
Integrate multiplier into sensor logic
  • Added source_calc_multiplier parameter to UtilityMeterSensor init
  • Stored multiplier in _attr_multiplier and included it in state attributes
  • Applied multiplier in calculation of _attr_calculated_value
  • Updated _unrecorded_attributes to include multiplier
custom_components/utility_meter_next_gen/sensor.py
Config entry migration and version bump
  • Bumped config flow VERSION to 3
  • Enhanced async_migrate_entry to add default multiplier for version 2→3
  • Maintained existing migration to version 2 for periodically_resetting option
  • Logged migration success after each step
custom_components/utility_meter_next_gen/__init__.py
Refine tariff ‘total’ removal logic
  • Replaced literal removal of "total" with case-insensitive match
  • Used regex fullmatch to filter variants like "Total", "TOTAL"
  • Retained warning message
custom_components/utility_meter_next_gen/select.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@cabberley cabberley merged commit 5aacb1f into main Jun 20, 2025
1 of 3 checks passed
Copy link
@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @cabberley - I've reviewed your changes - here's some feedback:

  • The migration logic logs success twice and may re‐migrate version 2 entries—consider updating the entry version immediately after each migration step and consolidating the log to avoid duplicate runs.
  • The same vol.Required(CONF_SOURCE_CALC_MULTIPLIER) selector is repeated across multiple schemas—extract it into a shared helper to reduce duplication.
  • Avoid checking for “total” in multiple cases; normalize tariff strings to lower‐case once and compare against a single value for more maintainable logic.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The migration logic logs success twice and may re‐migrate version 2 entries—consider updating the entry version immediately after each migration step and consolidating the log to avoid duplicate runs.
- The same vol.Required(CONF_SOURCE_CALC_MULTIPLIER) selector is repeated across multiple schemas—extract it into a shared helper to reduce duplication.
- Avoid checking for “total” in multiple cases; normalize tariff strings to lower‐case once and compare against a single value for more maintainable logic.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0