Fix duplicate unique_ids in emonitor (#107320)

This commit is contained in:
Joost Lekkerkerker 2024-01-06 00:33:04 +01:00 committed by GitHub
parent ad3c78f848
commit 49284fb469
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,7 +15,7 @@ from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.device_registry import DeviceInfo
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 (
CoordinatorEntity,
DataUpdateCoordinator,
@ -83,7 +83,7 @@ class EmonitorPowerSensor(CoordinatorEntity, SensorEntity):
mac_address = self.emonitor_status.network.mac_address
device_name = name_short_mac(mac_address[-6:])
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_unique_id = f"{mac_address}_{channel_number}_{description.key}"
else: