fixed bluetooth attr formatting
This commit is contained in:
parent
fdb0e69f82
commit
ff256c71be
@ -291,8 +291,7 @@ class ComputerSwitch(SwitchEntity):
|
||||
"operating_system_version": utils.get_operating_system_version(self._connection),
|
||||
"mac_address": self._mac_address,
|
||||
"ip_address": self._host,
|
||||
"connected_devices": utils.get_bluetooth_devices(self._connection, only_connected=True,
|
||||
format_for_hass=True),
|
||||
"connected_devices": utils.get_bluetooth_devices(self._connection, only_connected=True, return_as_string=True),
|
||||
}
|
||||
|
||||
def renew_ssh_connection(self) -> None:
|
||||
|
@ -488,7 +488,7 @@ def get_debug_info(connection: Connection):
|
||||
return data
|
||||
|
||||
|
||||
def get_bluetooth_devices(connection: Connection, only_connected: bool = False, format_for_hass: bool = False):
|
||||
def get_bluetooth_devices(connection: Connection, only_connected: bool = False, return_as_string: bool = False):
|
||||
"""Return a list of Bluetooth devices connected to the host system."""
|
||||
|
||||
commands = {
|
||||
@ -525,7 +525,7 @@ def get_bluetooth_devices(connection: Connection, only_connected: bool = False,
|
||||
if only_connected:
|
||||
devices = [device for device in devices if device["connected"] == "yes"]
|
||||
|
||||
if format_for_hass:
|
||||
if return_as_string:
|
||||
devices = "; ".join([f"{device['name']} ({device['address']})" for device in devices])
|
||||
|
||||
return devices
|
||||
|
Loading…
Reference in New Issue
Block a user