Skip to content

Commit

Permalink
Rename hub info
Browse files Browse the repository at this point in the history
  • Loading branch information
JohNan committed Sep 19, 2023
1 parent bf338d8 commit 65be026
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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():
Expand Down
8 changes: 4 additions & 4 deletions pyflichub/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand All @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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}")
Expand Down
2 changes: 1 addition & 1 deletion pyflichub/network.py → pyflichub/flichub.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 65be026

Please sign in to comment.