Add device discovery (#25)

* add (untested) discover mode

* Keep discovery and normal communication separate, uppercase magic consts

This sepearates the earlier test code for discovering devices,
and adds 5 sec timeout for gathering responses from potential devices.

This commit also uppercases magic constants.

Discovery & communication tested with HS110.

* update readme with example how to discover devices, pep8ify
This commit is contained in:
Teemu R
2017-01-08 00:44:57 +02:00
committed by GadgetReactor
parent 1e01530447
commit 71ac1f043a
4 changed files with 64 additions and 5 deletions

9
examples/discover.py Normal file
View File

@@ -0,0 +1,9 @@
import logging
from pprint import pprint as pp
from pyHS100 import TPLinkSmartHomeProtocol
logging.basicConfig(level=logging.DEBUG)
for dev in TPLinkSmartHomeProtocol.discover():
print("Found device!")
pp(dev)