Skip to content

Commit 25f8df9

Browse files
committed
Add example for discovery
1 parent 6b1e29b commit 25f8df9

File tree

6 files changed

+21
-0
lines changed

6 files changed

+21
-0
lines changed

examples/example-bulb-hsv.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Example code for communicating with a myStrom bulb and HSV values."""
2+
23
import time
34

45
from pymystrom import bulb

examples/example-bulb.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Example code for communicating with a myStrom bulb."""
2+
23
import asyncio
34
import logging
45

@@ -8,6 +9,7 @@
89
IP_ADDRESS = "192.168.1.25"
910
MAC_ADDRESS = "5CCF7FA0C27C"
1011

12+
1113
async def main():
1214
"""Sample code to work with a myStrom bulb."""
1315
# Discover myStrom bulbs devices

examples/example-discovery.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import asyncio
2+
3+
from pymystrom import discovery
4+
5+
6+
async def main():
7+
"""Sample code to work with discovery."""
8+
# Discover all bulbs in the network via broadcast datagram (UDP)
9+
bulbs = await discovery.discover_devices()
10+
print(f"Number of detected bulbs: {len(bulbs)}")
11+
12+
13+
if __name__ == "__main__":
14+
loop = asyncio.get_event_loop()
15+
loop.run_until_complete(main())

examples/example-get-data-bulb.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Example code for getting the data from a myStrom bulb."""
2+
23
from pymystrom import bulb
34

45
bulb = bulb.MyStromBulb("192.168.0.51", "5CCF7FA0AFB0")

examples/example-pir.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Example code for communicating with a myStrom PIR unit."""
2+
23
import asyncio
34

45
from pymystrom.pir import MyStromPir

examples/example-switch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Example code for communicating with a myStrom plug/switch."""
2+
23
import asyncio
34

45
from pymystrom.switch import MyStromSwitch

0 commit comments

Comments
 (0)