Skip to content

Expose POWER_OFFSET and POWER_MULTIPLIER as Home Assistant addon config#308

Merged
tomquist merged 2 commits into
developfrom
claude/add-config-offset-multiplier-NmwKE
Apr 6, 2026
Merged

Expose POWER_OFFSET and POWER_MULTIPLIER as Home Assistant addon config#308
tomquist merged 2 commits into
developfrom
claude/add-config-offset-multiplier-NmwKE

Conversation

@tomquist
Copy link
Copy Markdown
Owner

@tomquist tomquist commented Apr 6, 2026

Summary

This PR exposes the POWER_OFFSET and POWER_MULTIPLIER configuration options as optional advanced fields in the Home Assistant addon UI, allowing users to calibrate and transform power meter readings directly through the addon configuration without manual environment variable setup.

Key Changes

  • run.sh: Added configuration parsing for power_offset and power_multiplier options, which are now exported as environment variables if provided
  • config.yaml: Added schema definitions for both new optional string configuration fields
  • translations/en.yaml: Added user-friendly labels and descriptions for the new configuration options, explaining their purpose (calibration, sign flipping, phase nulling) and format (single value or comma-separated per-phase values)
  • CHANGELOG.md: Updated the existing feature entry to clarify that these transforms are now exposed in the Home Assistant app as optional advanced fields

Implementation Details

  • Both configuration options are optional (marked with ? in schema)
  • The implementation follows the existing pattern for optional configuration parsing with bashio::config.has_value checks
  • Carriage returns and newlines are stripped from the values to ensure clean environment variable export
  • The descriptions clearly document the formula (value * POWER_MULTIPLIER + POWER_OFFSET) and support for both single values and comma-separated per-phase lists

https://claude.ai/code/session_018GRnGWjaCTp4QdaCUcVoo4

Summary by CodeRabbit

  • New Features
    • Added optional Power Offset and Power Multiplier configuration options to the add-on. These enable flexible power value adjustments using the formula: value × POWER_MULTIPLIER + POWER_OFFSET. Both options support single or per-phase comma-separated values and can be disabled by leaving them empty. Negative multiplier values enable polarity inversion of power readings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 6, 2026

Walkthrough

Two new configuration options (power_offset and power_multiplier) are being added to the Home Assistant addon. The feature is declared in the changelog, added to the addon schema with optional string fields, implemented in the startup script to read and write these values to the configuration file, and localized with English descriptions.

Changes

Cohort / File(s) Summary
Documentation & Changelog
CHANGELOG.md
Updated changelog entry to note that Home Assistant app exposes both power offset and multiplier as optional advanced fields.
Configuration Schema
ha_addon/config.yaml
Added two new optional string configuration fields: power_offset and power_multiplier.
Runtime Implementation
ha_addon/run.sh
Added conditional logic to read power_offset and power_multiplier from addon config, strip CR/LF characters, and write them to the [HOMEASSISTANT] section of the generated config.ini file.
Localization
ha_addon/translations/en.yaml
Added English translations for the two new configuration options with descriptions: power offset (additive adjustment, supports comma-separated per-phase values) and power multiplier (scaling factor using formula value * POWER_MULTIPLIER + POWER_OFFSET, supports -1 for polarity inversion).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: exposing two configuration fields (POWER_OFFSET and POWER_MULTIPLIER) as Home Assistant addon configuration, which is reflected across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/add-config-offset-multiplier-NmwKE

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
ha_addon/translations/en.yaml (1)

40-43: Consider clarifying mismatched per-phase list behavior.

These descriptions are good, but they currently imply strict “one per phase.” Runtime behavior in src/astrameter/powermeter/transform.py cycles provided values when counts differ and warns once. A short note about cycling/warning would reduce ambiguity.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ha_addon/translations/en.yaml` around lines 40 - 43, Update the user-facing
descriptions for the "power_multiplier" and "power_offset" translation entries
to state that if a comma-separated list length doesn't match the number of
phases the runtime will cycle the provided values and emit a single warning; see
the runtime behavior implemented in src/astrameter/powermeter/transform.py for
exact semantics. Mention both the cycling and the single-warning behavior
succinctly (e.g., "if counts differ, values are cycled and a single warning is
logged") so users understand mismatched-list handling.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@ha_addon/translations/en.yaml`:
- Around line 40-43: Update the user-facing descriptions for the
"power_multiplier" and "power_offset" translation entries to state that if a
comma-separated list length doesn't match the number of phases the runtime will
cycle the provided values and emit a single warning; see the runtime behavior
implemented in src/astrameter/powermeter/transform.py for exact semantics.
Mention both the cycling and the single-warning behavior succinctly (e.g., "if
counts differ, values are cycled and a single warning is logged") so users
understand mismatched-list handling.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4cc3d299-7d08-42b9-a38d-101b1c3e3050

📥 Commits

Reviewing files that changed from the base of the PR and between bf0503d and 250eb6b.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • ha_addon/config.yaml
  • ha_addon/run.sh
  • ha_addon/translations/en.yaml

@tomquist tomquist merged commit 72743ea into develop Apr 6, 2026
13 checks passed
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.

2 participants