hass-core/homeassistant/components/refoss/entity.py
ashionky 102c7f1959
Add Refoss integration (#100573)
* refoss

* refoss

* refoss

* refoss

* refoss modify

* ip

* 8.22

* format

* format

* format

* bugfix

* test

* test

* test

* test

* test

* test

* 9.1

* refosss

* refoss

* refoss

* refoss

* refoss

* refoss

* refoss

* refoss

* test

* requirements_test_all.txt

* codeowners

* refoss

* Review feedback repair

* strings

* refoss

* refoss

* refoss

* 1.1.1

* 1.1.2

* refoss

* refoss

* refoss.1.1.7

* refoss-gree

* 1.1.7

* test

* refoss

* test refoss

* test refoss

* refoss-test

* refoss

* refoss

* test

* test

* refoss

* CODEOWNERS

* fix

* Update homeassistant/components/refoss/__init__.py

---------

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2023-12-22 13:18:32 +01:00

31 lines
1 KiB
Python

"""Entity object for shared properties of Refoss entities."""
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC, DeviceInfo
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .bridge import RefossDataUpdateCoordinator
from .const import DOMAIN
class RefossEntity(CoordinatorEntity[RefossDataUpdateCoordinator]):
"""Refoss entity."""
_attr_has_entity_name = True
def __init__(self, coordinator: RefossDataUpdateCoordinator, channel: int) -> None:
"""Initialize the entity."""
super().__init__(coordinator)
mac = coordinator.device.mac
self.channel_id = channel
if channel == 0:
self._attr_name = None
else:
self._attr_name = str(channel)
self._attr_unique_id = f"{mac}_{channel}"
self._attr_device_info = DeviceInfo(
connections={(CONNECTION_NETWORK_MAC, mac)},
identifiers={(DOMAIN, mac)},
manufacturer="Refoss",
name=coordinator.device.dev_name,
)