Revert "Allow setting an entity's name by its device class" (#93539)

This commit is contained in:
Erik Montnemery 2023-05-25 17:20:54 +02:00 committed by GitHub
parent f7404e2ee0
commit a71c097aeb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 35 additions and 141 deletions

View file

@ -19,7 +19,6 @@ from homeassistant.helpers.device_registry import (
async_get as dr_async_get,
format_mac,
)
from homeassistant.helpers.entity import DEVICE_CLASS_NAME, DeviceClassName
from homeassistant.helpers.entity_registry import async_get as er_async_get
from homeassistant.helpers.typing import EventType
from homeassistant.util.dt import utcnow
@ -73,16 +72,12 @@ def get_number_of_channels(device: BlockDevice, block: Block) -> int:
def get_block_entity_name(
device: BlockDevice,
block: Block | None,
description: str | DeviceClassName | None = None,
description: str | None = None,
) -> str:
"""Naming for block based switch and sensors."""
channel_name = get_block_channel_name(device, block)
if description:
# It's not possible to do string manipulations on DEVICE_CLASS_NAME
# the assert satisfies the type checker and will catch attempts
# to use DEVICE_CLASS_NAME as description.
assert description is not DEVICE_CLASS_NAME
return f"{channel_name} {description.lower()}"
return channel_name
@ -306,16 +301,12 @@ def get_rpc_channel_name(device: RpcDevice, key: str) -> str:
def get_rpc_entity_name(
device: RpcDevice, key: str, description: str | DeviceClassName | None = None
device: RpcDevice, key: str, description: str | None = None
) -> str:
"""Naming for RPC based switch and sensors."""
channel_name = get_rpc_channel_name(device, key)
if description:
# It's not possible to do string manipulations on DEVICE_CLASS_NAME
# the assert satisfies the type checker and will catch attempts
# to use DEVICE_CLASS_NAME as description.
assert description is not DEVICE_CLASS_NAME
return f"{channel_name} {description.lower()}"
return channel_name