Skip to content

goodwe: add battery charge/discharge current limit number entities#174363

Closed
matifali wants to merge 1 commit into
home-assistant:devfrom
matifali:fix/goodwe-battery-current-limits
Closed

goodwe: add battery charge/discharge current limit number entities#174363
matifali wants to merge 1 commit into
home-assistant:devfrom
matifali:fix/goodwe-battery-current-limits

Conversation

@matifali

@matifali matifali commented Jun 20, 2026

Copy link
Copy Markdown

Proposed change

The GoodWe inverter integration is missing two writable number entities for battery current limits. The underlying goodwe library has exposed battery_charge_current (register 45353) and battery_discharge_current (register 45355) as writable settings since ET inverter support was added, but they were never wired up in the HA integration. Users have no way to see or adjust these limits from Home Assistant.

This PR adds both as EntityCategory.CONFIG number entities with NumberDeviceClass.CURRENT and step 0.1 A.

Dynamic max value from BMS: Rather than hardcoding an upper bound, the entities read battery_charge_limit and battery_discharge_limit from the runtime coordinator data (registers 37004/37005). These are reported directly by the battery BMS and reflect what the hardware actually supports — e.g. 105 A on a standard LV battery. The description's native_max_value (100 A) is used as a fallback when the coordinator has no data yet or no battery is connected.

A filter lambda guards each entity so it is only registered when the inverter firmware actually supports the setting (the library silently drops unsupported registers during read_device_info).

Tested on: GoodWe GW8000M-ES-C10 (ESC platform, single-phase, 8.8 kW). Live readback confirmed 40.0 A charge limit and 60.0 A discharge limit; BMS reports 105 A for both, which becomes the slider ceiling.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally
  • Local tests pass with python -m pytest tests/components/goodwe/ -v (no regressions)
  • I have followed the development checklist
  • The code has been formatted using Ruff (python -m ruff format homeassistant tests)
  • Tests have been added to verify that the new code works

Copilot AI review requested due to automatic review settings June 20, 2026 21:00

@home-assistant home-assistant Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There is a merge conflict.

@home-assistant

Copy link
Copy Markdown
Contributor

Hey there @mletenay, @starkillerOG, mind taking a look at this pull request as it has been labeled with an integration (goodwe) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of goodwe can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant mark-draft Mark the pull request as draft.
  • @home-assistant ready-for-review Remove the draft status from the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign goodwe Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant update-branch Update the pull request branch with the base branch.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) on the pull request.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@matifali
matifali force-pushed the fix/goodwe-battery-current-limits branch 2 times, most recently from bb9c7a1 to 113c4c8 Compare June 20, 2026 21:06
Copilot AI review requested due to automatic review settings June 20, 2026 21:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

battery_charge_current (reg 45353) and battery_discharge_current (reg 45355)
are writable settings already exposed by the goodwe library but were never
wired up as HA number entities. This adds both as EntityCategory.CONFIG
controls with NumberDeviceClass.CURRENT and 0.1 A step.

The slider ceiling is set dynamically from the BMS-reported battery_charge_limit
/ battery_discharge_limit sensors (registers 37004/37005) so it reflects what
the hardware actually supports (e.g. 105 A), with a 100 A fallback when the
coordinator has no data yet.
@matifali
matifali force-pushed the fix/goodwe-battery-current-limits branch from 113c4c8 to d983215 Compare June 20, 2026 22:40

@mletenay mletenay left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I do not agree with this change.
There are many sensors like this which are not exposed intentionally.
The charging current is parameter which is not available to ordinary PV system user, it is installation/configuration parameter meant for installers.
And average user can easily break (burn) things if (s)he does not know what is he doing.

IMHO, this feature does not belong to standard HA.
It is one of the reasons why there is a HACS version of Goodwe integration, meant for advanced users which may contain these kinds of dangerous things.

@matifali

Copy link
Copy Markdown
Author

@mletenay Thanks. I kept this PR in draft to get initial feedback. I will close this one for now. I am adding to my list for the HACS integration instead and would see if it's suitable upstream there.

Thanks again.

@matifali matifali closed this Jun 22, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants