python-swidget 1.4.11__tar.gz → 1.4.13__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.11 → python_swidget-1.4.13}/PKG-INFO +1 -1
- {python_swidget-1.4.11 → python_swidget-1.4.13}/pyproject.toml +1 -1
- {python_swidget-1.4.11 → python_swidget-1.4.13}/swidget/swidgetdevice.py +55 -0
- {python_swidget-1.4.11 → python_swidget-1.4.13}/README.md +0 -0
- {python_swidget-1.4.11 → python_swidget-1.4.13}/swidget/__init__.py +0 -0
- {python_swidget-1.4.11 → python_swidget-1.4.13}/swidget/cli.py +0 -0
- {python_swidget-1.4.11 → python_swidget-1.4.13}/swidget/discovery.py +0 -0
- {python_swidget-1.4.11 → python_swidget-1.4.13}/swidget/exceptions.py +0 -0
- {python_swidget-1.4.11 → python_swidget-1.4.13}/swidget/provision.py +0 -0
- {python_swidget-1.4.11 → python_swidget-1.4.13}/swidget/py.typed +0 -0
- {python_swidget-1.4.11 → python_swidget-1.4.13}/swidget/swidgetdimmer.py +0 -0
- {python_swidget-1.4.11 → python_swidget-1.4.13}/swidget/swidgetoutlet.py +0 -0
- {python_swidget-1.4.11 → python_swidget-1.4.13}/swidget/swidgetswitch.py +0 -0
- {python_swidget-1.4.11 → python_swidget-1.4.13}/swidget/swidgettimerswitch.py +0 -0
- {python_swidget-1.4.11 → python_swidget-1.4.13}/swidget/websocket.py +0 -0
|
@@ -381,6 +381,18 @@ class SwidgetDevice:
|
|
|
381
381
|
self.device_config = DeviceConfiguration(config)
|
|
382
382
|
self._last_update = int(time.time())
|
|
383
383
|
|
|
384
|
+
async def set_device_config(self, updates: Dict[str, Any]) -> None:
|
|
385
|
+
"""POST a partial device_config update.
|
|
386
|
+
|
|
387
|
+
The firmware accepts a sparse dict mirroring the full config tree
|
|
388
|
+
(only the changed leaves), so callers should pass the same nested
|
|
389
|
+
shape ``get_device_config()`` returns. After the POST succeeds the
|
|
390
|
+
local cache is refreshed so reads see the new value immediately.
|
|
391
|
+
"""
|
|
392
|
+
_LOGGER.debug("SwidgetDevice.set_device_config(%s) called", updates)
|
|
393
|
+
await self.make_http_request("POST", "device_config", json_payload=updates)
|
|
394
|
+
await self.get_device_config()
|
|
395
|
+
|
|
384
396
|
async def get_summary(self) -> None:
|
|
385
397
|
"""Get a summary of the device over HTTP."""
|
|
386
398
|
_LOGGER.debug("SwidgetDevice.get_summary() called")
|
|
@@ -889,6 +901,49 @@ class SwidgetDevice:
|
|
|
889
901
|
return True
|
|
890
902
|
return False
|
|
891
903
|
|
|
904
|
+
@property
|
|
905
|
+
def rtsp_enabled(self) -> Optional[bool]:
|
|
906
|
+
"""Return whether the video insert's RTSP server is enabled.
|
|
907
|
+
|
|
908
|
+
Returns None when the config hasn't been fetched yet or the path
|
|
909
|
+
isn't present (non-video insert, or older firmware that omits the
|
|
910
|
+
key). Callers should treat None as "unknown" rather than False.
|
|
911
|
+
"""
|
|
912
|
+
try:
|
|
913
|
+
return bool(
|
|
914
|
+
self.device_config.config["insert"]["components"]["video"]["rtsp"][
|
|
915
|
+
"enable"
|
|
916
|
+
]
|
|
917
|
+
)
|
|
918
|
+
except (KeyError, TypeError):
|
|
919
|
+
return None
|
|
920
|
+
|
|
921
|
+
async def set_rtsp_enabled(self, enabled: bool) -> None:
|
|
922
|
+
"""Enable or disable the video insert's RTSP server."""
|
|
923
|
+
await self.set_device_config(
|
|
924
|
+
{"insert": {"components": {"video": {"rtsp": {"enable": bool(enabled)}}}}}
|
|
925
|
+
)
|
|
926
|
+
|
|
927
|
+
@property
|
|
928
|
+
def rtsp_stream_source(self) -> Optional[str]:
|
|
929
|
+
"""Return the device's RTSP URL, or None when unavailable.
|
|
930
|
+
|
|
931
|
+
Path ``/ph264`` is fixed by firmware; the port comes from device
|
|
932
|
+
config. None if RTSP is disabled, the insert isn't video, or the
|
|
933
|
+
config hasn't been loaded yet.
|
|
934
|
+
"""
|
|
935
|
+
if self.rtsp_enabled is not True:
|
|
936
|
+
return None
|
|
937
|
+
try:
|
|
938
|
+
port = int(
|
|
939
|
+
self.device_config.config["insert"]["components"]["video"]["rtsp"][
|
|
940
|
+
"port"
|
|
941
|
+
]
|
|
942
|
+
)
|
|
943
|
+
except (KeyError, TypeError, ValueError):
|
|
944
|
+
return None
|
|
945
|
+
return f"rtsp://{self.ip_address}:{port}/ph264"
|
|
946
|
+
|
|
892
947
|
async def __aenter__(self) -> "SwidgetDevice":
|
|
893
948
|
"""Initialize and connect the Swidget Websocket client."""
|
|
894
949
|
await self.connect()
|
|
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
|