Make device port configurable (#471)

This commit is contained in:
Viktar Karpach
2023-07-09 18:55:27 -05:00
committed by GitHub
parent 6199521269
commit 9b039d8374
11 changed files with 67 additions and 26 deletions

View File

@@ -191,14 +191,15 @@ class SmartDevice:
emeter_type = "emeter"
def __init__(self, host: str) -> None:
def __init__(self, host: str, *, port: Optional[int] = None) -> None:
"""Create a new SmartDevice instance.
:param str host: host name or ip address on which the device listens
"""
self.host = host
self.port = port
self.protocol = TPLinkSmartHomeProtocol(host)
self.protocol = TPLinkSmartHomeProtocol(host, port=port)
_LOGGER.debug("Initializing %s of type %s", self.host, type(self))
self._device_type = DeviceType.Unknown
# TODO: typing Any is just as using Optional[Dict] would require separate checks in