Skip to content

Commit cb0bbf4

Browse files
committed
Remove main()
1 parent 2c987d1 commit cb0bbf4

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

dingz/discovery.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
class DiscoveredDevice(object):
1010
"""Representation of discovered device."""
11+
1112
mac: str
1213
type: int
1314
is_child: bool
@@ -26,15 +27,15 @@ def create_from_announce_msg(raw_addr, announce_msg):
2627
device.type = announce_msg[6]
2728
status = announce_msg[7]
2829

29-
# parse status field
30+
# Parse status field
3031
device.is_child = status & 1 != 0
3132
device.mystrom_registered = status & 2 != 0
3233
device.mystrom_online = status & 4 != 0
3334
device.restarted = status & 8 != 0
3435
return device
3536

3637
def __init__(self, host, mac):
37-
"""Initialize the """
38+
"""Initialize the discovery."""
3839
self.host = host
3940
self.mac = mac
4041

@@ -57,6 +58,7 @@ def devices(self):
5758

5859
class DiscoveryProtocol(asyncio.DatagramProtocol):
5960
"""Representation of the discovery protocol."""
61+
6062
def __init__(self, registry: DeviceRegistry):
6163
""""Initialize the discovery protocol."""
6264
super().__init__()
@@ -103,13 +105,3 @@ async def discover_dingz_devices(timeout: int = 7) -> List[DiscoveredDevice]:
103105
"Discovered dingz %s (%s) with mac %s", device.host, device.type, device.mac
104106
)
105107
return devices
106-
107-
108-
if __name__ == "__main__":
109-
logging.basicConfig(level=logging.DEBUG)
110-
loop = asyncio.get_event_loop()
111-
devices = asyncio.run(discover_dingz_devices())
112-
113-
print("found %s devices" % len(devices))
114-
for device in devices:
115-
print(f"{device.mac} {device.host}")

0 commit comments

Comments
 (0)