python-swidget 1.4.10__tar.gz → 1.4.11__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_swidget-1.4.10 → python_swidget-1.4.11}/PKG-INFO +1 -1
- {python_swidget-1.4.10 → python_swidget-1.4.11}/pyproject.toml +1 -1
- {python_swidget-1.4.10 → python_swidget-1.4.11}/swidget/discovery.py +15 -13
- {python_swidget-1.4.10 → python_swidget-1.4.11}/README.md +0 -0
- {python_swidget-1.4.10 → python_swidget-1.4.11}/swidget/__init__.py +0 -0
- {python_swidget-1.4.10 → python_swidget-1.4.11}/swidget/cli.py +0 -0
- {python_swidget-1.4.10 → python_swidget-1.4.11}/swidget/exceptions.py +0 -0
- {python_swidget-1.4.10 → python_swidget-1.4.11}/swidget/provision.py +0 -0
- {python_swidget-1.4.10 → python_swidget-1.4.11}/swidget/py.typed +0 -0
- {python_swidget-1.4.10 → python_swidget-1.4.11}/swidget/swidgetdevice.py +0 -0
- {python_swidget-1.4.10 → python_swidget-1.4.11}/swidget/swidgetdimmer.py +0 -0
- {python_swidget-1.4.10 → python_swidget-1.4.11}/swidget/swidgetoutlet.py +0 -0
- {python_swidget-1.4.10 → python_swidget-1.4.11}/swidget/swidgetswitch.py +0 -0
- {python_swidget-1.4.10 → python_swidget-1.4.11}/swidget/swidgettimerswitch.py +0 -0
- {python_swidget-1.4.10 → python_swidget-1.4.11}/swidget/websocket.py +0 -0
|
@@ -17,7 +17,7 @@ from .swidgetswitch import SwidgetSwitch
|
|
|
17
17
|
from .swidgettimerswitch import SwidgetTimerSwitch
|
|
18
18
|
|
|
19
19
|
RESPONSE_SEC = 5
|
|
20
|
-
|
|
20
|
+
SWIDGET_STS = ("urn:swidget:pico:1", "urn:swidget:video:1")
|
|
21
21
|
# Generous timeout: TLS handshakes on the device's MCU can take several
|
|
22
22
|
# seconds on first connection.
|
|
23
23
|
DETECT_TIMEOUT_SEC = 10
|
|
@@ -91,7 +91,7 @@ class SwidgetProtocol(ssdp.SimpleServiceDiscoveryProtocol):
|
|
|
91
91
|
headers = {h[0]: h[1] for h in response.headers}
|
|
92
92
|
mac_address = headers["USN"].split("-")[-1]
|
|
93
93
|
ip_address = urlparse(headers["LOCATION"]).hostname
|
|
94
|
-
if headers["ST"]
|
|
94
|
+
if headers["ST"] in SWIDGET_STS:
|
|
95
95
|
device_type = headers["SERVER"].split(" ")[1].split("+")[0]
|
|
96
96
|
insert_type = headers["SERVER"].split(" ")[1].split("+")[1].split("/")[0]
|
|
97
97
|
friendly_name = headers["SERVER"].split("/")[2].strip('"')
|
|
@@ -116,17 +116,19 @@ async def discover_devices(timeout=RESPONSE_SEC):
|
|
|
116
116
|
SwidgetProtocol, family=socket.AF_INET
|
|
117
117
|
)
|
|
118
118
|
|
|
119
|
-
#
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
"
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
119
|
+
# SSDP M-SEARCH matches one ST per request, so emit one packet per
|
|
120
|
+
# supported service type. Devices reply only to their matching ST.
|
|
121
|
+
for st in SWIDGET_STS:
|
|
122
|
+
search_request = ssdp.SSDPRequest(
|
|
123
|
+
"M-SEARCH",
|
|
124
|
+
headers={
|
|
125
|
+
"HOST": "239.255.255.250:1900",
|
|
126
|
+
"MAN": '"ssdp:discover"',
|
|
127
|
+
"MX": timeout,
|
|
128
|
+
"ST": st,
|
|
129
|
+
},
|
|
130
|
+
)
|
|
131
|
+
search_request.sendto(transport, (SwidgetProtocol.MULTICAST_ADDRESS, 1900))
|
|
130
132
|
await asyncio.sleep(timeout)
|
|
131
133
|
return devices
|
|
132
134
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|