Skip to content

Add light platform to Vistapool#172549

Open
fdebrus wants to merge 5 commits into
home-assistant:devfrom
fdebrus:vistapool-light
Open

Add light platform to Vistapool#172549
fdebrus wants to merge 5 commits into
home-assistant:devfrom
fdebrus:vistapool-light

Conversation

@fdebrus
Copy link
Copy Markdown
Contributor

@fdebrus fdebrus commented May 29, 2026

Proposed change

Adds the light platform to the Vistapool integration. Exposes the pool light as a single on/off entity, mirroring what the Hayward app shows.

  • Pool lightlight.status, ColorMode.ONOFF, _attr_supported_color_modes={ColorMode.ONOFF}.

Implementation notes

Same patterns as the open switch / number / select PRs:

  • Single entity (no EntityDescription tuple needed for a single static entity; the description scaffold would be overkill here).
  • Iterates entry.runtime_data.coordinators.values() for multi-pool support.
  • is_on uses the same value in (True, "1") coercion the switch platform settled on.
  • Writes go through aioaquarite.AquariteClient.set_value. AquariteError becomes a translated HomeAssistantError using the existing set_failed translation key.
  • No optimistic update or async_request_refresh() — the coordinator's Firestore push (subscribe_pool_resilient) delivers the state update typically within sub-second latency, same "trust the push" pattern as the other write-capable platforms.
  • quality_scale.yaml action-exceptions moves from exempt to done.

Tests

tests/components/vistapool/test_light.py covers:

  • Default fixture: test_all_entities with snapshot_platform (pins the registry entry + state).
  • Default-fixture state assertion (light.status=0STATE_OFF).
  • Numeric-as-string state coercion ("1"STATE_ON).
  • Parametrized turn_on / turn_off round-trip through set_value with the correct args.
  • Error path: AquariteError from the library is re-raised as HomeAssistantError.

Type of change

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

Additional information

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies a diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

Exposes the pool light (light.status) as a single ColorMode.ONOFF
light entity. Writes go through AquariteClient.set_value; AquariteError
becomes a translated HomeAssistantError using the existing set_failed
key. State is delivered by the existing Firestore push subscription, so
no optimistic updates or explicit refresh on the write path.
Copy link
Copy Markdown
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

Note

Copilot was unable to run its full agentic suite in this review.

Adds a Light platform to the Vistapool integration to expose pool light control as a Home Assistant light entity.

Changes:

  • New light.py platform with VistapoolLight entity supporting on/off via the Aquarite API, with error translation.
  • Registered Platform.LIGHT in the integration setup, added translations for the new entity and set_failed error, and updated quality scale rules.
  • Added unit tests and snapshots covering setup, state coercion, turn on/off service calls, and API error handling.

Reviewed changes

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

Show a summary per file
File Description
homeassistant/components/vistapool/init.py Adds Platform.LIGHT to the platforms list.
homeassistant/components/vistapool/light.py New light entity implementation with on/off control.
homeassistant/components/vistapool/strings.json Adds translations for the pool light entity and set_failed error.
homeassistant/components/vistapool/quality_scale.yaml Updates rule statuses now that actions exist.
tests/components/vistapool/test_light.py New tests covering the light platform.
tests/components/vistapool/snapshots/test_light.ambr Snapshot of the new light entity.

Comment thread homeassistant/components/vistapool/light.py
Comment thread homeassistant/components/vistapool/strings.json
@fdebrus fdebrus marked this pull request as ready for review May 29, 2026 08:49
Comment on lines +28 to +32
"light": {
"pool_light": {
"name": "Pool light"
}
},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The device name is already prepended, so how much does Pool add to the entity name?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch ! Dropping to "Light" so the friendly name renders as "My Pool Light" instead of "My Pool Pool light". There's only ever one light fixture per controller, so the unqualified name is unambiguous

claude added 2 commits May 30, 2026 15:48
Confirms the HomeAssistantError raised by the turn_on/off handler is
the expected set_failed one rather than an unrelated HomeAssistantError.
The device name ("My Pool") is already prepended for entities with
has_entity_name=True, so the friendly name was rendering as "My Pool
Pool light". Drops the redundant prefix so it reads "My Pool Light".
The auto-derived entity_id cascades to light.my_pool_light.
Copilot AI review requested due to automatic review settings May 30, 2026 16:03
Copy link
Copy Markdown
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

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread homeassistant/components/vistapool/light.py
claude added 2 commits June 1, 2026 12:47
0.5.1 wraps aiohttp.ClientError and asyncio.TimeoutError from both the
REST send_command path and the upstream auth client refresh in
ConnectionError (an AquariteError subclass), so transport failures
surface as the translated set_failed HomeAssistantError via the
existing except AquariteError clause.
Copilot AI review requested due to automatic review settings June 1, 2026 15:13
Copy link
Copy Markdown
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

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Comment on lines +47 to +52
def is_on(self) -> bool | None:
"""Return true if the light is on."""
value = self.coordinator.get_value(_VALUE_PATH)
if value is None:
return None
return value in (True, "1")
Comment on lines +62 to +67
async def _async_set_value(self, value: int) -> None:
"""Send a value update via the Vistapool cloud API."""
try:
await self.coordinator.api.set_value(
self.coordinator.pool_id, _VALUE_PATH, value
)
Comment on lines +69 to +73
raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="set_failed",
translation_placeholders={"entity": self.entity_id},
) from err
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants