mirror of
https://github.com/home-assistant/core.git
synced 2026-06-06 23:46:56 +01:00
d766aae436
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: frenck <195327+frenck@users.noreply.github.com>
47 lines
1.5 KiB
Python
47 lines
1.5 KiB
Python
"""Support for Balboa switches."""
|
|
|
|
from typing import Any
|
|
|
|
from pybalboa import SpaClient
|
|
|
|
from homeassistant.components.switch import SwitchEntity
|
|
from homeassistant.const import EntityCategory
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
|
|
|
from . import BalboaConfigEntry
|
|
from .entity import BalboaEntity
|
|
|
|
|
|
async def async_setup_entry(
|
|
hass: HomeAssistant,
|
|
entry: BalboaConfigEntry,
|
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
|
) -> None:
|
|
"""Set up the spa's switches."""
|
|
spa = entry.runtime_data
|
|
async_add_entities([BalboaSwitchEntity(spa)])
|
|
|
|
|
|
class BalboaSwitchEntity(BalboaEntity, SwitchEntity):
|
|
"""Representation of a Balboa switch entity."""
|
|
|
|
def __init__(self, spa: SpaClient) -> None:
|
|
"""Initialize a Balboa switch entity."""
|
|
super().__init__(spa, "filter_cycle_2_enabled")
|
|
self._attr_entity_category = EntityCategory.CONFIG
|
|
self._attr_translation_key = "filter_cycle_2_enabled"
|
|
|
|
@property
|
|
def is_on(self) -> bool:
|
|
"""Return True if entity is on."""
|
|
return self._client.filter_cycle_2_enabled
|
|
|
|
async def async_turn_on(self, **kwargs: Any) -> None:
|
|
"""Turn the entity on."""
|
|
await self._client.configure_filter_cycle(2, enabled=True)
|
|
|
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
|
"""Turn the entity off."""
|
|
await self._client.configure_filter_cycle(2, enabled=False)
|