Shelly - use common coordinator base class (#86262)
* Shelly - use common coordinator base class * rename entry to device_entry Co-authored-by: J. Nick Koston <nick@koston.org> Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
3c4455c696
commit
585c4acfee
2 changed files with 108 additions and 164 deletions
|
@ -44,15 +44,23 @@ def async_remove_shelly_entity(
|
|||
|
||||
|
||||
def get_block_device_name(device: BlockDevice) -> str:
|
||||
"""Naming for device."""
|
||||
"""Get Block device name."""
|
||||
return cast(str, device.settings["name"] or device.settings["device"]["hostname"])
|
||||
|
||||
|
||||
def get_rpc_device_name(device: RpcDevice) -> str:
|
||||
"""Naming for device."""
|
||||
"""Get RPC device name."""
|
||||
return cast(str, device.config["sys"]["device"].get("name") or device.hostname)
|
||||
|
||||
|
||||
def get_device_name(device: BlockDevice | RpcDevice) -> str:
|
||||
"""Get device name."""
|
||||
if isinstance(device, BlockDevice):
|
||||
return get_block_device_name(device)
|
||||
|
||||
return get_rpc_device_name(device)
|
||||
|
||||
|
||||
def get_number_of_channels(device: BlockDevice, block: Block) -> int:
|
||||
"""Get number of channels for block type."""
|
||||
assert isinstance(device.shelly, dict)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue