Revert "Add device info to edl21" (#89217)

This commit is contained in:
Franck Nijhof 2023-03-06 08:51:33 +01:00 committed by GitHub
parent fc673139cd
commit c7b30b61de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -32,7 +32,6 @@ from homeassistant.helpers.dispatcher import (
async_dispatcher_connect, async_dispatcher_connect,
async_dispatcher_send, async_dispatcher_send,
) )
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
@ -284,7 +283,7 @@ async def async_setup_platform(
hass, hass,
DOMAIN, DOMAIN,
"deprecated_yaml", "deprecated_yaml",
breaks_in_ha_version="2023.5.0", breaks_in_ha_version="2023.2.0",
is_fixable=False, is_fixable=False,
severity=IssueSeverity.WARNING, severity=IssueSeverity.WARNING,
translation_key="deprecated_yaml", translation_key="deprecated_yaml",
@ -398,7 +397,7 @@ class EDL21:
old_entity_id = registry.async_get_entity_id( old_entity_id = registry.async_get_entity_id(
"sensor", DOMAIN, entity.old_unique_id "sensor", DOMAIN, entity.old_unique_id
) )
if old_entity_id is not None and entity.unique_id is not None: if old_entity_id is not None:
LOGGER.debug( LOGGER.debug(
"Migrating unique_id from [%s] to [%s]", "Migrating unique_id from [%s] to [%s]",
entity.old_unique_id, entity.old_unique_id,
@ -423,6 +422,8 @@ class EDL21Entity(SensorEntity):
"""Initialize an EDL21Entity.""" """Initialize an EDL21Entity."""
self._electricity_id = electricity_id self._electricity_id = electricity_id
self._obis = obis self._obis = obis
self._name = name
self._unique_id = f"{electricity_id}_{obis}"
self._telegram = telegram self._telegram = telegram
self._min_time = MIN_TIME_BETWEEN_UPDATES self._min_time = MIN_TIME_BETWEEN_UPDATES
self._last_update = utcnow() self._last_update = utcnow()
@ -434,12 +435,6 @@ class EDL21Entity(SensorEntity):
} }
self._async_remove_dispatcher = None self._async_remove_dispatcher = None
self.entity_description = entity_description self.entity_description = entity_description
self._attr_name = name
self._attr_unique_id = f"{electricity_id}_{obis}"
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, self._electricity_id)},
name=self._electricity_id,
)
async def async_added_to_hass(self) -> None: async def async_added_to_hass(self) -> None:
"""Run when entity about to be added to hass.""" """Run when entity about to be added to hass."""
@ -471,11 +466,21 @@ class EDL21Entity(SensorEntity):
if self._async_remove_dispatcher: if self._async_remove_dispatcher:
self._async_remove_dispatcher() self._async_remove_dispatcher()
@property
def unique_id(self) -> str:
"""Return a unique ID."""
return self._unique_id
@property @property
def old_unique_id(self) -> str: def old_unique_id(self) -> str:
"""Return a less unique ID as used in the first version of edl21.""" """Return a less unique ID as used in the first version of edl21."""
return self._obis return self._obis
@property
def name(self) -> str | None:
"""Return a name."""
return self._name
@property @property
def native_value(self) -> str: def native_value(self) -> str:
"""Return the value of the last received telegram.""" """Return the value of the last received telegram."""