diff --git a/homeassistant/components/shelly/utils.py b/homeassistant/components/shelly/utils.py index bf242d47e6c..e13395999b1 100644 --- a/homeassistant/components/shelly/utils.py +++ b/homeassistant/components/shelly/utils.py @@ -298,7 +298,7 @@ def get_rpc_channel_name(device: RpcDevice, key: str) -> str: entity_name = device.config[key].get("name", device_name) if entity_name is None: - if [k for k in key if k.startswith(("input", "switch"))]: + if key.startswith(("input:", "switch:")): return f"{device_name} {key.replace(':', '_')}" return device_name diff --git a/tests/components/shelly/test_utils.py b/tests/components/shelly/test_utils.py index c78adf4c37c..c817b7d620c 100644 --- a/tests/components/shelly/test_utils.py +++ b/tests/components/shelly/test_utils.py @@ -208,6 +208,7 @@ async def test_get_block_input_triggers(mock_block_device, monkeypatch): async def test_get_rpc_channel_name(mock_rpc_device): """Test get RPC channel name.""" assert get_rpc_channel_name(mock_rpc_device, "input:0") == "test switch_0" + assert get_rpc_channel_name(mock_rpc_device, "input:3") == "Test name switch_3" async def test_get_rpc_input_triggers(mock_rpc_device, monkeypatch):