fixed bluetooth attr formatting
Some checks failed
Validate with hassfest / validate (push) Failing after 2s
HACS Action / HACS Action (push) Failing after 4s

This commit is contained in:
Mathieu Broillet 2024-01-01 17:09:47 +01:00
parent fdb0e69f82
commit ff256c71be
Signed by: mathieu
GPG Key ID: C0E9E0E95AF03319
2 changed files with 3 additions and 4 deletions

View File

@ -291,8 +291,7 @@ class ComputerSwitch(SwitchEntity):
"operating_system_version": utils.get_operating_system_version(self._connection), "operating_system_version": utils.get_operating_system_version(self._connection),
"mac_address": self._mac_address, "mac_address": self._mac_address,
"ip_address": self._host, "ip_address": self._host,
"connected_devices": utils.get_bluetooth_devices(self._connection, only_connected=True, "connected_devices": utils.get_bluetooth_devices(self._connection, only_connected=True, return_as_string=True),
format_for_hass=True),
} }
def renew_ssh_connection(self) -> None: def renew_ssh_connection(self) -> None:

View File

@ -488,7 +488,7 @@ def get_debug_info(connection: Connection):
return data 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.""" """Return a list of Bluetooth devices connected to the host system."""
commands = { commands = {
@ -525,7 +525,7 @@ def get_bluetooth_devices(connection: Connection, only_connected: bool = False,
if only_connected: if only_connected:
devices = [device for device in devices if device["connected"] == "yes"] 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]) devices = "; ".join([f"{device['name']} ({device['address']})" for device in devices])
return devices return devices