Add new name handling for Shelly RPC devices (#60539)

This commit is contained in:
Simone Chemelli 2021-11-29 16:16:49 +01:00 committed by GitHub
parent 0f2e39adee
commit 07c09ab268
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 7 deletions

View file

@ -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:

View file

@ -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"},
},
}

View file

@ -26,7 +26,9 @@ DISCOVERY_INFO = zeroconf.ZeroconfServiceInfo(
type="mock_type",
)
MOCK_CONFIG = {
"wifi": {"ap": {"ssid": "Test name"}},
"sys": {
"device": {"name": "Test name"},
},
}