mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Fix duplicate unique_ids in emonitor (#107320)
This commit is contained in:
parent
ad3c78f848
commit
49284fb469
@ -15,7 +15,7 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.helpers import device_registry as dr
|
from homeassistant.helpers import device_registry as dr
|
||||||
from homeassistant.helpers.device_registry import DeviceInfo
|
from homeassistant.helpers.device_registry import DeviceInfo
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import UNDEFINED, StateType
|
from homeassistant.helpers.typing import StateType
|
||||||
from homeassistant.helpers.update_coordinator import (
|
from homeassistant.helpers.update_coordinator import (
|
||||||
CoordinatorEntity,
|
CoordinatorEntity,
|
||||||
DataUpdateCoordinator,
|
DataUpdateCoordinator,
|
||||||
@ -83,7 +83,7 @@ class EmonitorPowerSensor(CoordinatorEntity, SensorEntity):
|
|||||||
mac_address = self.emonitor_status.network.mac_address
|
mac_address = self.emonitor_status.network.mac_address
|
||||||
device_name = name_short_mac(mac_address[-6:])
|
device_name = name_short_mac(mac_address[-6:])
|
||||||
label = self.channel_data.label or str(channel_number)
|
label = self.channel_data.label or str(channel_number)
|
||||||
if description.name is not UNDEFINED:
|
if description.translation_key is not None:
|
||||||
self._attr_translation_placeholders = {"label": label}
|
self._attr_translation_placeholders = {"label": label}
|
||||||
self._attr_unique_id = f"{mac_address}_{channel_number}_{description.key}"
|
self._attr_unique_id = f"{mac_address}_{channel_number}_{description.key}"
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user