add typing hints to make it easier for 3rd party developers to use the library (#90)

* add typing hints to make it easier for 3rd party developers to use the library

* remove unused devicetype enum to support python3.3

* add python 3.3 to travis and tox, install typing module in setup.py
This commit is contained in:
Teemu R
2017-09-18 18:13:06 +02:00
committed by GitHub
parent 3ddd31f3c1
commit af90a36153
11 changed files with 163 additions and 135 deletions

View File

@@ -1,20 +1,24 @@
import socket
import logging
import json
from typing import Dict
from pyHS100 import TPLinkSmartHomeProtocol, SmartPlug, SmartBulb
from pyHS100 import TPLinkSmartHomeProtocol, SmartDevice, SmartPlug, SmartBulb
_LOGGER = logging.getLogger(__name__)
class Discover:
@staticmethod
def discover(protocol=None, port=9999, timeout=3):
def discover(protocol: TPLinkSmartHomeProtocol = None,
port: int = 9999,
timeout: int = 3) -> Dict[str, SmartDevice]:
"""
Sends discovery message to 255.255.255.255:9999 in order
to detect available supported devices in the local network,
and waits for given timeout for answers from devices.
:param protocol: Protocol implementation to use
:param timeout: How long to wait for responses, defaults to 5
:param port: port to send broadcast messages, defaults to 9999.
:rtype: dict