Clean up Balboa entity (#99203)

This commit is contained in:
Joost Lekkerkerker 2023-08-28 17:59:53 +02:00 committed by GitHub
parent 00cc57c4ed
commit 1c0d5f8637
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,18 +9,18 @@ from homeassistant.helpers.entity import Entity
from .const import DOMAIN
class BalboaBaseEntity(Entity):
class BalboaEntity(Entity):
"""Balboa base entity."""
_attr_should_poll = False
_attr_has_entity_name = True
def __init__(self, client: SpaClient, name: str | None = None) -> None:
"""Initialize the control."""
mac = client.mac_address
model = client.model
self._attr_should_poll = False
self._attr_unique_id = f'{model}-{name}-{mac.replace(":","")[-6:]}'
self._attr_name = name
self._attr_has_entity_name = True
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, mac)},
name=model,
@ -36,10 +36,6 @@ class BalboaBaseEntity(Entity):
"""Return whether the state is based on actual reading from device."""
return not self._client.available
class BalboaEntity(BalboaBaseEntity):
"""Balboa entity."""
async def async_added_to_hass(self) -> None:
"""Run when entity about to be added to hass."""
self.async_on_remove(self._client.on(EVENT_UPDATE, self.async_write_ha_state))