* Initial commit * Support changed API Change sensor entity descriptions * Fix sensor not handling coordinator update * Implement re-authentication flow and handle token expiry * Bump aioaquacell * Bump aioaquacell * Cleanup and initial tests * Fixes for config flow tests * Cleanup * Fixes * Formatted * Use config entry runtime Use icon translations Removed reauth Removed last updated sensor Changed lid in place to binary sensor Cleanup * Remove reauth strings * Removed binary_sensor platform Fixed sensors not updating properly * Remove reauth tests Bump aioaquacell * Moved softener property to entity class Inlined validate_input method Renaming of entities Do a single async_add_entities call to add all entities Reduced code in try blocks * Made tests parameterized and use test fixture for api Cleaned up unused code Removed traces of reauth * Add check if refresh token is expired Add tests * Add missing unique_id to config entry mock Inlined _update_config_entry_refresh_token method Fix incorrect test method name and comment * Add snapshot test Changed WiFi level to WiFi strength * Bump aioaquacell to 0.1.7 * Move test_coordinator tests to test_init Add test for duplicate config entry
41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
"""Aquacell entity."""
|
|
|
|
from aioaquacell import Softener
|
|
|
|
from homeassistant.helpers.device_registry import DeviceInfo
|
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
|
|
|
from .const import DOMAIN
|
|
from .coordinator import AquacellCoordinator
|
|
|
|
|
|
class AquacellEntity(CoordinatorEntity[AquacellCoordinator]):
|
|
"""Representation of an aquacell entity."""
|
|
|
|
_attr_has_entity_name = True
|
|
|
|
def __init__(
|
|
self,
|
|
coordinator: AquacellCoordinator,
|
|
softener_key: str,
|
|
entity_key: str,
|
|
) -> None:
|
|
"""Initialize the aquacell entity."""
|
|
super().__init__(coordinator)
|
|
|
|
self.softener_key = softener_key
|
|
|
|
self._attr_unique_id = f"{softener_key}-{entity_key}"
|
|
self._attr_device_info = DeviceInfo(
|
|
name=self.softener.name,
|
|
hw_version=self.softener.fwVersion,
|
|
identifiers={(DOMAIN, str(softener_key))},
|
|
manufacturer=self.softener.brand,
|
|
model=self.softener.ssn,
|
|
serial_number=softener_key,
|
|
)
|
|
|
|
@property
|
|
def softener(self) -> Softener:
|
|
"""Handle updated data from the coordinator."""
|
|
return self.coordinator.data[self.softener_key]
|