Skip to content

feat(sigenergy): publish onboard_status sensor#4079

Open
mgazza wants to merge 1 commit into
mainfrom
feat/sigenergy-onboard-status
Open

feat(sigenergy): publish onboard_status sensor#4079
mgazza wants to merge 1 commit into
mainfrom
feat/sigenergy-onboard-status

Conversation

@mgazza

@mgazza mgazza commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Publishes a per-system sensor.<prefix>_sigenergy_<slug>_onboard_status so a managing UI can show a live VPP-onboarding/approval stepper.

Changes

  • onboard_systems records pending_approval / in_other_vpp / firmware_no_vpp / no_permission from the API result codes.
  • run() derives active / offboarded / pending_approval for visible systems and defaults not-yet-visible expected systems to not_onboarded.
  • Publishes the sensor for every expected system_id (so a pending system still gets a sensor).
  • Test: status transitions for the pending-review and in-other-VPP codes.

Read-only addition; no change to existing SigEnergy control behaviour.

🤖 Generated with Claude Code

Tracks a per-system onboarding status string and publishes it as
sensor.<prefix>_sigenergy_<slug>_onboard_status so the SaaS connect UI can show a
live approval stepper:
- onboard_systems records pending_approval / in_other_vpp / firmware_no_vpp /
  no_permission from the API result codes
- run() derives active / offboarded / pending_approval for visible systems and
  defaults not-yet-visible expected systems to not_onboarded
- publishes the sensor for every expected system_id (covers pending systems)
- test: onboard_status transitions for pending-review and in-other-VPP codes

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

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.

Pull request overview

Adds a new per-SigEnergy-system onboarding status sensor intended for an external/UI stepper, by tracking onboarding result states and publishing them as Home Assistant entities.

Changes:

  • Introduces onboard_status tracking on the SigenergyAPI instance and updates it based on onboarding result codes.
  • Derives and publishes sensor.<prefix>_sigenergy_<slug>_onboard_status for expected systems (including ones not yet visible).
  • Adds a unit test covering status mapping for pending-review and in-other-VPP result codes.

Reviewed changes

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

File Description
apps/predbat/sigenergy.py Adds onboard status tracking and publishes the new onboarding-status sensor in the main run loop.
apps/predbat/tests/test_sigenergy.py Adds a unit test validating onboard status mapping for specific API result codes.

Comment on lines +1671 to +1674
api._request = AsyncMock(return_value=None)
api._last_api_code = SIGENERGY_CODE_SYSTEM_PENDING_REVIEW
result = asyncio.run(api.onboard_systems(["sys-1"]))
assert result is None, "pending review returns None"
Comment on lines +1678 to +1683
api2 = MockSigenergyAPI()
api2._request = AsyncMock(return_value=None)
api2._last_api_code = SIGENERGY_CODE_IN_OTHER_VPP
result2 = asyncio.run(api2.onboard_systems("sys-2"))
assert result2 is False, "in-other-vpp returns False"
assert api2.onboard_status["sys-2"] == "in_other_vpp", "in_other_vpp status set"
Comment thread apps/predbat/sigenergy.py
Comment on lines 837 to 841
if code == SIGENERGY_CODE_SOFTWARE_NO_VPP:
for sid in system_ids:
self.onboard_status[str(sid)] = "firmware_no_vpp"
self.log("Warn: SigenergyAPI: Onboard failed — system {} firmware does not support VPP (code=1105)".format(system_ids))
return False
Comment thread apps/predbat/sigenergy.py
Comment on lines 2103 to 2107
for sid in missing_ids:
self.onboard_status.setdefault(str(sid), "not_onboarded")
slug = self._system_slug(sid)
is_offboard_at_start = self.get_state_wrapper("switch.{}_sigenergy_{}_offboard".format(self.prefix, slug), default="off") == "on"
if is_offboard_at_start:
Comment thread apps/predbat/sigenergy.py
Comment on lines +2152 to +2156
# Derive the user-facing onboarding status for the visible system.
if is_offboard:
self.onboard_status[str(sid)] = "offboarded"
elif self.current_mode.get(sid) == SIGENERGY_MODE_VPP:
self.onboard_status[str(sid)] = "active"
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