Skip to content

Add switch platform to Vistapool#172540

Open
fdebrus wants to merge 4 commits into
home-assistant:devfrom
fdebrus:vistapool-switch
Open

Add switch platform to Vistapool#172540
fdebrus wants to merge 4 commits into
home-assistant:devfrom
fdebrus:vistapool-switch

Conversation

@fdebrus
Copy link
Copy Markdown
Contributor

@fdebrus fdebrus commented May 29, 2026

Proposed change

Adds the switch platform to the Vistapool integration. This is the first PR that lets users actually control their pool from Home Assistant instead of just observing it. Follow-up to the sensor PR (#168051) and the binary_sensor PR (#172234), per joostlek's "one platform per PR" guidance.

Switches exposed (per pool):

  • Filtrationfiltration.status toggle.
  • Relay 1–4relays.relay{1-4}.info.onoff toggles for the four generic relay outputs. is_on ORs the writable onoff with the read-only status next to it, so the entity correctly reads "on" when the device is currently driving the relay regardless of how the toggle was last set.
  • Electrolysis cover / Electrolysis boosthidro.cover_enabled / hidro.cloration_enabled, gated on hasHidro.
  • Heating climate — dynamic, gated on filtration.hasHeat (the "Climat" toggle under the HEAT slider in the Hayward app).
  • Smart mode freeze — dynamic, gated on filtration.hasSmart (Smart-mode freeze protection).

Implementation notes

Same patterns as sensor.py and binary_sensor.py:

  • VistapoolSwitchEntityDescription extends SwitchEntityDescription.
  • Conditional entities use exists_path (single path or tuple) instead of inline if blocks.
  • Iterates entry.runtime_data.coordinators.values() for multi-pool support.
  • AddConfigEntryEntitiesCallback, PARALLEL_UPDATES = 1, translation_key-only naming, unique IDs via build_unique_id(description.key).

Writes go through aioaquarite's AquariteClient.set_value(pool_id, path, value). AquariteError is caught and re-raised as HomeAssistantError with a translated set_failed message, which moves the quality_scale.yaml action-exceptions rule from exempt to done.

Tests

tests/components/vistapool/test_switch.py covers:

  • Default fixture: test_all_entities with snapshot_platform (pins every entity's registry entry + state).
  • Relay status fallback (read-only status field is OR'd into is_on).
  • Dynamic entity creation: heating_climate only when filtration.hasHeat is set; smart_mode_freeze only when filtration.hasSmart is set.
  • Parametrized turn_on / turn_off round-trip through set_value with the correct (pool_id, path, value) 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:

Adds the switch platform that turns Vistapool from a read-only
monitoring integration into one that can actually control the pool.
Exposes:

- filtration toggle (filtration.status)
- 4 generic relay outputs (relays.relay{1-4}.info.onoff), with the
  read-only status field OR'd into is_on so the entity shows the
  effective state when the device is currently driving the relay
- electrolysis cover / electrolysis boost toggles (gated on hasHidro)
- heating climate toggle (dynamic, gated on filtration.hasHeat)
- smart-mode freeze protection toggle (dynamic, gated on
  filtration.hasSmart)

Writes go through aioaquarite's AquariteClient.set_value(); AquariteError
is translated to HomeAssistantError with a translated message. The
quality_scale.yaml action-exceptions rule moves from exempt to done
now that the integration has user actions.
claude added 3 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.
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.
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.

2 participants