mirror of
https://github.com/home-assistant/core.git
synced 2025-05-17 04:19:16 +00:00

* First checkin for myUplink * Refactored coordinator and sensor state classe * Updated .coveragerc * Update test_config_flow * Fix test_config_flow for myuplink * Only set state class for temperature sensor * PR comment updates * Type strong dict * use asyncio.timeouts * PR updates (part 1) * Updated to myuplink 0.0.9 * Add strict typing * Fix typing * Inherit CoordinatorEntity * Clean up coordinator and sensors * Use common base entity * Improve device point sensor * Exclude entity from coverage * Set device point entity name if there's no entity description * Update homeassistant/components/myuplink/sensor.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Update homeassistant/components/myuplink/entity.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Update homeassistant/components/myuplink/entity.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Remvoed firmware + connstate sensors * Always add device point parameter name * Removed MyUplinkDeviceSensor * Removed unused class * key="celsius", --------- Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
29 lines
877 B
Python
29 lines
877 B
Python
"""Provide a common entity class for myUplink entities."""
|
|
from homeassistant.helpers.device_registry import DeviceInfo
|
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
|
|
|
from .const import DOMAIN
|
|
from .coordinator import MyUplinkDataCoordinator
|
|
|
|
|
|
class MyUplinkEntity(CoordinatorEntity[MyUplinkDataCoordinator]):
|
|
"""Representation of a sensor."""
|
|
|
|
_attr_has_entity_name = True
|
|
|
|
def __init__(
|
|
self,
|
|
coordinator: MyUplinkDataCoordinator,
|
|
device_id: str,
|
|
unique_id_suffix: str,
|
|
) -> None:
|
|
"""Initialize the sensor."""
|
|
super().__init__(coordinator=coordinator)
|
|
|
|
# Internal properties
|
|
self.device_id = device_id
|
|
|
|
# Basic values
|
|
self._attr_unique_id = f"{device_id}-{unique_id_suffix}"
|
|
self._attr_device_info = DeviceInfo(identifiers={(DOMAIN, device_id)})
|