From ff256c71bedbda4d640b322be1135a540cd68ea5 Mon Sep 17 00:00:00 2001 From: Mathieu Broillet Date: Mon, 1 Jan 2024 17:09:47 +0100 Subject: [PATCH] fixed bluetooth attr formatting --- custom_components/easy_computer_manager/switch.py | 3 +-- custom_components/easy_computer_manager/utils.py | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/custom_components/easy_computer_manager/switch.py b/custom_components/easy_computer_manager/switch.py index f417d06..7fb5986 100644 --- a/custom_components/easy_computer_manager/switch.py +++ b/custom_components/easy_computer_manager/switch.py @@ -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: diff --git a/custom_components/easy_computer_manager/utils.py b/custom_components/easy_computer_manager/utils.py index 5b128f7..2cb437e 100644 --- a/custom_components/easy_computer_manager/utils.py +++ b/custom_components/easy_computer_manager/utils.py @@ -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