Skip to content

Commit 7e0e786

Browse files
committed
Add discovery to example
1 parent 4c8a705 commit 7e0e786

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

example.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
11
"""Sample code to use the wrapper for interacting with the dingz device."""
22
import asyncio
3+
import logging
34

45
from dingz.dingz import Dingz
6+
from dingz.discovery import discover_dingz_devices
7+
58

69
IP_ADDRESS = "192.168.0.103"
710

811

912
async def main():
1013
"""Sample code to work with a dingz unit."""
14+
# Discover dingz devices
15+
devices = await discover_dingz_devices()
16+
17+
print(f"Found {len(devices)} devices")
18+
for device in devices:
19+
print(
20+
f" MAC address: {device.mac}, IP address: {device.host}, HW: {device.hardware}"
21+
)
22+
23+
# Work with one dingz unit
1124
async with Dingz(IP_ADDRESS) as dingz:
1225

1326
# Collect the data of the current state
@@ -39,7 +52,6 @@ async def main():
3952
await dingz.get_button_action()
4053
print("Button actions:", dingz.button_action)
4154

42-
4355
# # Turn on the front LED
4456
print("Turning Front LED on...")
4557
await dingz.turn_on()
@@ -50,5 +62,6 @@ async def main():
5062

5163

5264
if __name__ == "__main__":
65+
logging.basicConfig(level=logging.DEBUG)
5366
loop = asyncio.get_event_loop()
5467
loop.run_until_complete(main())

0 commit comments

Comments
 (0)