1
mirror of https://github.com/home-assistant/core synced 2024-08-28 03:36:46 +02:00
ha-core/homeassistant/components/flipr/entity.py
Jan-Philipp Benecke 16cc87bf45
Move flipr base entity to its own file (#100481)
* Move flipr base entity to its own file

* Add forgotten __init__.py
2023-09-16 11:55:49 +02:00

33 lines
1.1 KiB
Python

"""Base entity for the flipr entity."""
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.entity import EntityDescription
from homeassistant.helpers.update_coordinator import (
CoordinatorEntity,
DataUpdateCoordinator,
)
from .const import ATTRIBUTION, CONF_FLIPR_ID, DOMAIN, MANUFACTURER
class FliprEntity(CoordinatorEntity):
"""Implements a common class elements representing the Flipr component."""
_attr_attribution = ATTRIBUTION
_attr_has_entity_name = True
def __init__(
self, coordinator: DataUpdateCoordinator, description: EntityDescription
) -> None:
"""Initialize Flipr sensor."""
super().__init__(coordinator)
self.entity_description = description
if coordinator.config_entry:
flipr_id = coordinator.config_entry.data[CONF_FLIPR_ID]
self._attr_unique_id = f"{flipr_id}-{description.key}"
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, flipr_id)},
manufacturer=MANUFACTURER,
name=f"Flipr {flipr_id}",
)