Skip to content

Add option to disable GivTCP power data#3359

Merged
springfall2008 merged 1 commit intomainfrom
fixes12
Feb 13, 2026
Merged

Add option to disable GivTCP power data#3359
springfall2008 merged 1 commit intomainfrom
fixes12

Conversation

@springfall2008
Copy link
Owner

Copilot AI review requested due to automatic review settings February 13, 2026 13:42
@springfall2008 springfall2008 merged commit 73aaaf9 into main Feb 13, 2026
5 checks passed
@springfall2008 springfall2008 deleted the fixes12 branch February 13, 2026 13:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds a configuration option to allow users to disable GivTCP REST API power data reading and use configured sensor entities instead. It addresses issue #3353 where predbat.load_power was incorrectly double the actual load power during battery charging when using GivTCP REST API data.

Changes:

  • Adds new givtcp_rest_power configuration option (per-inverter boolean, defaults to False)
  • When True, uses sensor entities (load_power, pv_power, grid_power, battery_power) instead of REST API power values
  • Documents the new option in apps-yaml.md

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
apps/predbat/inverter.py Adds conditional check to skip REST API power data reading when givtcp_rest_power is True, falling back to sensor entity reading instead
docs/apps-yaml.md Documents the new givtcp_rest_power configuration option with usage instructions

self.soc_percent = calc_percent_limit(self.soc_kw, self.soc_max)

if self.rest_data and ("Power" in self.rest_data):
if self.rest_data and ("Power" in self.rest_data) and not self.base.get_arg("givtcp_rest_power", default=False, index=self.id):
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The configuration name givtcp_rest_power is confusing because when set to True, it actually DISABLES reading power from the REST API, rather than enabling it. This is counterintuitive.

Consider renaming to something clearer that indicates what True does, such as:

  • givtcp_rest_power_disable (True disables REST power reading)
  • use_sensor_power (True uses sensor entities instead of REST)
  • disable_rest_power (explicit about disabling)

This would make the intent much clearer in configuration files and reduce user confusion.

Suggested change
if self.rest_data and ("Power" in self.rest_data) and not self.base.get_arg("givtcp_rest_power", default=False, index=self.id):
# Prefer new, clearer config name `disable_rest_power`; fall back to legacy `givtcp_rest_power` for compatibility
disable_rest_power = self.base.get_arg("disable_rest_power", default=None, index=self.id)
if disable_rest_power is None:
# Legacy name: `givtcp_rest_power` historically meant "disable REST power when True"
disable_rest_power = self.base.get_arg("givtcp_rest_power", default=False, index=self.id)
if self.rest_data and ("Power" in self.rest_data) and not disable_rest_power:

Copilot uses AI. Check for mistakes.
self.soc_percent = calc_percent_limit(self.soc_kw, self.soc_max)

if self.rest_data and ("Power" in self.rest_data):
if self.rest_data and ("Power" in self.rest_data) and not self.base.get_arg("givtcp_rest_power", default=False, index=self.id):
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The new configuration option givtcp_rest_power is not defined in the APPS_SCHEMA dictionary in config.py. While this matches the pattern used by other optional flags like battery_power_invert, it means the configuration won't be validated and won't appear in the web interface configuration editor.

If this is intended to be a supported configuration option that users should use (especially given it addresses a bug), it should be added to APPS_SCHEMA with type "boolean_list" and entries "num_inverters" to match the pattern of other per-inverter boolean settings like those at line 2042 in config.py.

Suggested change
if self.rest_data and ("Power" in self.rest_data) and not self.base.get_arg("givtcp_rest_power", default=False, index=self.id):
if self.rest_data and ("Power" in self.rest_data):

Copilot uses AI. Check for mistakes.
Comment on lines +1008 to +1009
- **givtcp_rest_power** - Optional, defaults to False. When set to True for a given inverter, Predbat will use the configured sensor entities (load_power, pv_power, grid_power, battery_power) instead of reading power values from the GivTCP REST API.
This can be useful if you want to use alternative sensors or if the REST API power readings are unreliable. Set this to False (or omit) to use REST API power readings (default behavior).
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The documentation says "When set to True... Predbat will use the configured sensor entities... instead of reading power values from the GivTCP REST API." However, this wording is unclear about the behavior when set to False or omitted.

Consider rewording for clarity:

  • "When True: Uses configured sensor entities (load_power, pv_power, grid_power, battery_power) for power readings instead of GivTCP REST API"
  • "When False or omitted (default): Uses GivTCP REST API for power readings"

Also, the second sentence "Set this to False (or omit) to use REST API power readings (default behavior)" is redundant since that's already stated as the default in the first sentence.

Suggested change
- **givtcp_rest_power** - Optional, defaults to False. When set to True for a given inverter, Predbat will use the configured sensor entities (load_power, pv_power, grid_power, battery_power) instead of reading power values from the GivTCP REST API.
This can be useful if you want to use alternative sensors or if the REST API power readings are unreliable. Set this to False (or omit) to use REST API power readings (default behavior).
- **givtcp_rest_power** - Optional, defaults to False. When True, Predbat uses the configured sensor entities (load_power, pv_power, grid_power, battery_power) for power readings instead of the GivTCP REST API. When False or omitted (default), Predbat uses power readings from the GivTCP REST API.
This can be useful if you want to use alternative sensors or if the REST API power readings are unreliable.

Copilot uses AI. Check for mistakes.
self.soc_percent = calc_percent_limit(self.soc_kw, self.soc_max)

if self.rest_data and ("Power" in self.rest_data):
if self.rest_data and ("Power" in self.rest_data) and not self.base.get_arg("givtcp_rest_power", default=False, index=self.id):
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

There is no test coverage for the new givtcp_rest_power configuration option. Given that this feature addresses a significant bug (issue #3353 where load_power was double the actual value), it should have test coverage to ensure:

  1. When givtcp_rest_power is False (default), power values are read from REST API
  2. When givtcp_rest_power is True, power values are read from sensor entities
  3. The transition between modes works correctly

Existing tests in apps/predbat/tests/test_inverter.py already test REST vs non-REST power reading separately (e.g., around lines 551-570 and 856-882), so you could add a test that validates the new configuration option controls which path is taken.

Copilot uses AI. Check for mistakes.
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