mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-12-01 13:48:15 +00:00
Add discovery port 20004 (#1595)
Some checks failed
CI / Perform linting checks (3.13) (push) Has been cancelled
CodeQL checks / Analyze (python) (push) Has been cancelled
CI / Python 3.11 on macos-latest (push) Has been cancelled
CI / Python 3.12 on macos-latest (push) Has been cancelled
CI / Python 3.13 on macos-latest (push) Has been cancelled
CI / Python 3.11 on ubuntu-latest (push) Has been cancelled
CI / Python 3.12 on ubuntu-latest (push) Has been cancelled
CI / Python 3.13 on ubuntu-latest (push) Has been cancelled
CI / Python 3.11 on windows-latest (push) Has been cancelled
CI / Python 3.12 on windows-latest (push) Has been cancelled
CI / Python 3.13 on windows-latest (push) Has been cancelled
Stale / stale (push) Has been cancelled
Some checks failed
CI / Perform linting checks (3.13) (push) Has been cancelled
CodeQL checks / Analyze (python) (push) Has been cancelled
CI / Python 3.11 on macos-latest (push) Has been cancelled
CI / Python 3.12 on macos-latest (push) Has been cancelled
CI / Python 3.13 on macos-latest (push) Has been cancelled
CI / Python 3.11 on ubuntu-latest (push) Has been cancelled
CI / Python 3.12 on ubuntu-latest (push) Has been cancelled
CI / Python 3.13 on ubuntu-latest (push) Has been cancelled
CI / Python 3.11 on windows-latest (push) Has been cancelled
CI / Python 3.12 on windows-latest (push) Has been cancelled
CI / Python 3.13 on windows-latest (push) Has been cancelled
Stale / stale (push) Has been cancelled
Adds additional discovery port for Tapo Doorbells (D210 and D225) --------- Co-authored-by: Sameer Alam <alams154@users.noreply.github.com>
This commit is contained in:
@@ -264,6 +264,7 @@ class _DiscoverProtocol(asyncio.DatagramProtocol):
|
||||
self.target = target
|
||||
self.target_1 = (target, self.discovery_port)
|
||||
self.target_2 = (target, Discover.DISCOVERY_PORT_2)
|
||||
self.target_3 = (target, Discover.DISCOVERY_PORT_3)
|
||||
|
||||
self.discovered_devices = {}
|
||||
self.unsupported_device_exceptions: dict = {}
|
||||
@@ -333,6 +334,7 @@ class _DiscoverProtocol(asyncio.DatagramProtocol):
|
||||
break
|
||||
self.transport.sendto(encrypted_req[4:], self.target_1) # type: ignore
|
||||
self.transport.sendto(aes_discovery_query, self.target_2) # type: ignore
|
||||
self.transport.sendto(aes_discovery_query, self.target_3) # type: ignore
|
||||
await asyncio.sleep(sleep_between_packets)
|
||||
|
||||
def datagram_received(
|
||||
@@ -361,7 +363,7 @@ class _DiscoverProtocol(asyncio.DatagramProtocol):
|
||||
if port == self.discovery_port:
|
||||
json_func = Discover._get_discovery_json_legacy
|
||||
device_func = Discover._get_device_instance_legacy
|
||||
elif port == Discover.DISCOVERY_PORT_2:
|
||||
elif port in (Discover.DISCOVERY_PORT_2, Discover.DISCOVERY_PORT_3):
|
||||
json_func = Discover._get_discovery_json
|
||||
device_func = Discover._get_device_instance
|
||||
else:
|
||||
@@ -422,6 +424,7 @@ class Discover:
|
||||
}
|
||||
|
||||
DISCOVERY_PORT_2 = 20002
|
||||
DISCOVERY_PORT_3 = 20004
|
||||
DISCOVERY_QUERY_2 = binascii.unhexlify("020000010000000000000000463cb5d3")
|
||||
|
||||
_redact_data = True
|
||||
|
||||
@@ -301,12 +301,13 @@ async def test_discover_invalid_info(msg, data, mocker):
|
||||
async def test_discover_send(mocker):
|
||||
"""Test discovery parameters."""
|
||||
discovery_timeout = 0
|
||||
discovery_ports = 3
|
||||
proto = _DiscoverProtocol(discovery_timeout=discovery_timeout)
|
||||
assert proto.discovery_packets == 3
|
||||
assert proto.target_1 == ("255.255.255.255", 9999)
|
||||
transport = mocker.patch.object(proto, "transport")
|
||||
await proto.do_discover()
|
||||
assert transport.sendto.call_count == proto.discovery_packets * 2
|
||||
assert transport.sendto.call_count == proto.discovery_packets * discovery_ports
|
||||
|
||||
|
||||
async def test_discover_datagram_received(mocker, discovery_data):
|
||||
|
||||
Reference in New Issue
Block a user