diff --git a/homeassistant/components/shelly/sensor.py b/homeassistant/components/shelly/sensor.py index 694c467b5662..10655b695351 100644 --- a/homeassistant/components/shelly/sensor.py +++ b/homeassistant/components/shelly/sensor.py @@ -63,6 +63,7 @@ from .utils import ( get_blu_trv_device_info, get_device_entry_gen, get_device_uptime, + get_entity_translation_attributes, get_rpc_channel_name, get_shelly_air_lamp_life, get_virtual_component_unit, @@ -73,25 +74,6 @@ from .utils import ( PARALLEL_UPDATES = 0 -def get_entity_translation_attributes( - channel_name: str | None, - translation_key: str | None, - device_class: str | None, - default_to_device_class_name: bool, -) -> tuple[dict[str, str] | None, str | None]: - """Translation attributes for entity with channel name.""" - if channel_name is None: - return None, None - - key = translation_key - if key is None and default_to_device_class_name: - key = device_class - - final_translation_key = f"{key}_with_channel_name" if key else None - - return {"channel_name": channel_name}, final_translation_key - - @dataclass(frozen=True, kw_only=True) class BlockSensorDescription(BlockEntityDescription, SensorEntityDescription): """Class to describe a BLOCK sensor.""" diff --git a/homeassistant/components/shelly/utils.py b/homeassistant/components/shelly/utils.py index e40e5d91f6dc..24814dcea147 100644 --- a/homeassistant/components/shelly/utils.py +++ b/homeassistant/components/shelly/utils.py @@ -459,6 +459,23 @@ def get_rpc_entity_name( return channel_name +def get_entity_translation_attributes( + channel_name: str | None, + translation_key: str | None, + device_class: str | None, + default_to_device_class_name: bool, +) -> tuple[dict[str, str] | None, str | None]: + """Translation attributes for entity with channel name.""" + if channel_name is None: + return None, None + + key = translation_key + if key is None and default_to_device_class_name: + key = device_class + + return {"channel_name": channel_name}, f"{key}_with_channel_name" if key else None + + def get_device_entry_gen(entry: ConfigEntry) -> int: """Return the device generation from config entry.""" return entry.data.get(CONF_GEN, 1) # type: ignore[no-any-return]