From bd550442d472e39552d236b07989de116e93968d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B8=D0=BA=D1=82=D0=BE=D1=80=D0=BE=D0=B2=20=D0=90?= =?UTF-8?q?=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=93=D0=B5=D1=80=D0=BC=D0=B0?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=B8=D1=87?= Date: Thu, 3 Aug 2023 16:12:35 +0300 Subject: [PATCH] fix #151 --- custom_components/mega/entities.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/custom_components/mega/entities.py b/custom_components/mega/entities.py index 361f24b..9f9f6a4 100644 --- a/custom_components/mega/entities.py +++ b/custom_components/mega/entities.py @@ -8,6 +8,7 @@ from functools import partial from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_NAME from homeassistant.core import State +from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.update_coordinator import CoordinatorEntity from homeassistant.helpers.restore_state import RestoreEntity from . import hub as h @@ -142,7 +143,7 @@ class BaseMegaEntity(CoordinatorEntity, RestoreEntity): return self._customize @property - def device_info(self): + def device_info(self) -> DeviceInfo: if isinstance(self.port, list): pt_idx = self.id_suffix else: @@ -151,19 +152,16 @@ class BaseMegaEntity(CoordinatorEntity, RestoreEntity): pt_idx, _ = _pt.split('e') else: pt_idx = _pt - return { - "identifiers": { + return DeviceInfo( + identifiers={ # Serial numbers are unique identifiers within a specific domain - (DOMAIN, f'{self._mega_id}', pt_idx), + (DOMAIN, f'{self._mega_id}'), #pt_idx }, - "config_entries": [ - self.config_entry, - ], - "name": f'{self._mega_id} port {pt_idx}' if not isinstance(self.port, list) else f'{self._mega_id} {pt_idx}', - "manufacturer": 'ab-log.ru', - "sw_version": self.mega.fw, - "via_device": (DOMAIN, self._mega_id), - } + name=self.name, + manufacturer='ab-log.ru', + sw_version=self.mega.fw, + via_device=(DOMAIN, self._mega_id), + ) @property def lg(self) -> logging.Logger: