From 65be026e9c7596f505491ff6d196af067b505690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Nenz=C3=A9n?= Date: Tue, 19 Sep 2023 23:50:51 +0200 Subject: [PATCH] Rename hub info --- main.py | 4 ++-- pyflichub/client.py | 8 ++++---- pyflichub/{network.py => flichub.py} | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) rename pyflichub/{network.py => flichub.py} (98%) diff --git a/main.py b/main.py index 394d739..df3d4b1 100644 --- a/main.py +++ b/main.py @@ -8,7 +8,7 @@ from pyflichub.client import FlicHubTcpClient from pyflichub.command import Command from pyflichub.event import Event -from pyflichub.network import Network +from pyflichub.flichub import FlicHubInfo logging.basicConfig(level=logging.DEBUG) @@ -50,7 +50,7 @@ def client_disconnected(): for button in buttons: print(f"Button name: {button.name} - Connected: {button.connected}") - network: Network = await client.get_network() + network: FlicHubInfo = await client.get_hubinfo() if network.has_wifi(): print(f"Wifi State: {network.wifi.state} - Connected: {network.wifi.connected}") if network.has_ethernet(): diff --git a/pyflichub/client.py b/pyflichub/client.py index cad6969..7479dd9 100644 --- a/pyflichub/client.py +++ b/pyflichub/client.py @@ -12,7 +12,7 @@ from pyflichub.command import Command from pyflichub.event import Event from pyflichub.button import FlicButton -from pyflichub.network import Network +from pyflichub.flichub import FlicHubInfo _LOGGER = logging.getLogger(__name__) @@ -32,7 +32,7 @@ async def run(*args, loop=None, executor=None, **kwargs): class FlicHubTcpClient(asyncio.Protocol): buttons: [FlicButton] = [] - network: Network + network: FlicHubInfo def __init__(self, ip, port, loop, timeout=1.0, reconnect_timeout=10.0, event_callback=None, command_callback=None): self._data_ready: Union[asyncio.Event, None] = None @@ -92,7 +92,7 @@ async def connect(self): async def get_buttons(self): return await self._async_send_command('buttons') - async def get_network(self): + async def get_hubinfo(self): return await self._async_send_command('network') async def get_battery_status(self, bdaddr: str): @@ -147,7 +147,7 @@ def _handle_command(self, cmd: Command): for button in self.buttons: _LOGGER.debug(f"Button name: {button.name} - Connected: {button.connected}") if cmd.command == 'network': - self.network = Network(**humps.decamelize(cmd.data)) + self.network = FlicHubInfo(**humps.decamelize(cmd.data)) command_data = cmd.data = self.network if self.network.has_wifi(): _LOGGER.debug(f"Wifi State: {self.network.wifi.state} - Connected: {self.network.wifi.connected}") diff --git a/pyflichub/network.py b/pyflichub/flichub.py similarity index 98% rename from pyflichub/network.py rename to pyflichub/flichub.py index 2c5d61c..072ab6f 100644 --- a/pyflichub/network.py +++ b/pyflichub/flichub.py @@ -34,7 +34,7 @@ def _decode_ssid(ssid_list): return ''.join(chr(byte) for byte in ssid_list) -class Network: +class FlicHubInfo: def __init__(self, dhcp, wifi_state=None): self._dhcp = DhcpInfo(**dhcp) self._dhcp.wifi.state = wifi_state.get('state', None) if wifi_state else None