From 07c09ab268c9fa630ca849c5b3850755c320b553 Mon Sep 17 00:00:00 2001 From: Simone Chemelli Date: Mon, 29 Nov 2021 16:16:49 +0100 Subject: [PATCH] Add new name handling for Shelly RPC devices (#60539) --- homeassistant/components/shelly/utils.py | 4 +--- tests/components/shelly/conftest.py | 6 +++--- tests/components/shelly/test_config_flow.py | 4 +++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/shelly/utils.py b/homeassistant/components/shelly/utils.py index d61140f56b9..d5fcf154e28 100644 --- a/homeassistant/components/shelly/utils.py +++ b/homeassistant/components/shelly/utils.py @@ -57,9 +57,7 @@ def get_block_device_name(device: BlockDevice) -> str: def get_rpc_device_name(device: RpcDevice) -> str: """Naming for device.""" - # Gen2 does not support setting device name - # AP SSID name is used as a nicely formatted device name - return cast(str, device.config["wifi"]["ap"]["ssid"] or device.hostname) + return cast(str, device.config["sys"]["device"]["name"] or device.hostname) def get_number_of_channels(device: BlockDevice, block: Block) -> int: diff --git a/tests/components/shelly/conftest.py b/tests/components/shelly/conftest.py index 16dc8fdae9e..7fc8fba0e33 100644 --- a/tests/components/shelly/conftest.py +++ b/tests/components/shelly/conftest.py @@ -58,9 +58,9 @@ MOCK_BLOCKS = [ MOCK_CONFIG = { "input:0": {"id": 0, "type": "button"}, "switch:0": {"name": "test switch_0"}, - "sys": {"ui_data": {}}, - "wifi": { - "ap": {"ssid": "Test name"}, + "sys": { + "ui_data": {}, + "device": {"name": "Test name"}, }, } diff --git a/tests/components/shelly/test_config_flow.py b/tests/components/shelly/test_config_flow.py index 2d9cb20342f..12690a35faa 100644 --- a/tests/components/shelly/test_config_flow.py +++ b/tests/components/shelly/test_config_flow.py @@ -26,7 +26,9 @@ DISCOVERY_INFO = zeroconf.ZeroconfServiceInfo( type="mock_type", ) MOCK_CONFIG = { - "wifi": {"ap": {"ssid": "Test name"}}, + "sys": { + "device": {"name": "Test name"}, + }, }