Skip to content

Commit

Permalink
v2.3.16 (#972)
Browse files Browse the repository at this point in the history
* fix typing

* catch and raise TutkError in TutkIOCtrlMux thread

* fix typo

* changelog
  • Loading branch information
mrlt8 authored Aug 26, 2023
1 parent 5d0ac33 commit 07be86d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ You can then use the web interface at `http://localhost:5000` where localhost is

See [basic usage](#basic-usage) for additional information or visit the [wiki page](https://github.com/mrlt8/docker-wyze-bridge/wiki/Home-Assistant) for additional information on using the bridge as a Home Assistant Add-on.

## What's Changed in v2.3.15
## What's Changed in v2.3.16

* FIX: `caminfo` not found error.
* Update MediaMTX version from v0.23.8 to v1.0.0 (#956)
* FIX: Catch exception in thread errors
* FIX: Other minor typos and typing errors.
* UPDATE: Wyze App version to v2.44.1.1 (#946)


[View previous changes](https://github.com/mrlt8/docker-wyze-bridge/releases)
Expand Down
6 changes: 6 additions & 0 deletions app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## What's Changed in v2.3.16

* FIX: Catch exception in thread errors
* FIX: Other minor typos and typing errors.
* UPDATE: Wyze App version to v2.44.1.1 (#946)

## What's Changed in v2.3.15

* FIX: `caminfo` not found error.
Expand Down
7 changes: 4 additions & 3 deletions app/wyze_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from wyzebridge.stream import StreamManager
from wyzebridge.wyze_api import WyzeApi
from wyzebridge.wyze_stream import WyzeStream, WyzeStreamOptions
from wyzecam.api_models import WyzeCamera


class WyzeBridge(Thread):
Expand Down Expand Up @@ -55,7 +56,7 @@ def setup_streams(self):
self.rtsp.add_path(stream.uri, not options.reconnect)
self.streams.add(stream)

def rtsp_fw_proxy(self, cam, stream) -> bool:
def rtsp_fw_proxy(self, cam: WyzeCamera, stream: WyzeStream) -> bool:
if rtsp_fw := env_bool("rtsp_fw").lower():
if rtsp_path := stream.check_rtsp_fw(rtsp_fw == "force"):
rtsp_uri = f"{cam.name_uri}-fw"
Expand All @@ -64,7 +65,7 @@ def rtsp_fw_proxy(self, cam, stream) -> bool:
return True
return False

def add_substream(self, cam, options):
def add_substream(self, cam: WyzeCamera, options: WyzeStreamOptions):
"""Setup and add substream if enabled for camera."""
if env_bool(f"SUBSTREAM_{cam.name_uri}") or (
env_bool("SUBSTREAM") and cam.can_substream
Expand All @@ -76,7 +77,7 @@ def add_substream(self, cam, options):
self.rtsp.add_path(sub.uri, not options.reconnect)
self.streams.add(sub)

def clean_up(self, *args):
def clean_up(self, *_):
"""Stop all streams and clean up before shutdown."""
if self.streams.stop_flag:
sys.exit(0)
Expand Down
6 changes: 3 additions & 3 deletions app/wyzebridge/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def get_info(self, item: Optional[str] = None) -> dict:
def status(self) -> str:
...

def send_cmd(self, cmd: str, value: str | list | dict = "") -> dict:
def send_cmd(self, cmd: str, payload: str | list | dict = "") -> dict:
...


Expand Down Expand Up @@ -94,7 +94,7 @@ def stop_all(self) -> None:
def monitor_streams(self, mtx_health: Callable) -> None:
self.stop_flag = False
if MQTT_DISCOVERY:
self.thread = Thread(target=self.monior_snapshots)
self.thread = Thread(target=self.monitor_snapshots)
self.thread.start()
mqtt = cam_control(self.streams, self.send_cmd)
logger.info(f"🎬 {self.total} stream{'s'[:self.total^1]} enabled")
Expand All @@ -110,7 +110,7 @@ def monitor_streams(self, mtx_health: Callable) -> None:
mqtt.loop_stop()
logger.info("Stream monitoring stopped")

def monior_snapshots(self) -> None:
def monitor_snapshots(self) -> None:
for cam in self.streams:
update_preview(cam)
while not self.stop_flag:
Expand Down
15 changes: 10 additions & 5 deletions app/wyzecam/tutk/tutk_ioctl_mux.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import contextlib
import logging
import threading
import time
Expand Down Expand Up @@ -259,20 +260,23 @@ def __init__(
self.tutk_platform_lib = tutk_platform_lib
self.av_chan_id = av_chan_id
self.queues = queues
self.exception: Optional[tutk.TutkError] = None

def join(self, timeout=None):
super(TutkIOCtrlMuxListener, self).join(timeout)
if self.exception:
raise self.exception

def run(self) -> None:
timeout_ms = 1000
logger.debug(f"Now listening on channel id {self.av_chan_id}")

while True:
try:
with contextlib.suppress(Empty):
control_channel_command = self.queues[CONTROL_CHANNEL].get_nowait()
if control_channel_command == STOP_SENTINEL:
logger.debug(f"No longer listening on channel id {self.av_chan_id}")
return
except Empty:
pass

actual_len, io_ctl_type, data = tutk.av_recv_io_ctrl(
self.tutk_platform_lib, self.av_chan_id, timeout_ms
)
Expand All @@ -285,7 +289,8 @@ def run(self) -> None:
logger.warning("Connection closed because of no response from remote.")
break
elif actual_len < 0:
raise tutk.TutkError(actual_len)
self.exception = tutk.TutkError(actual_len)
break

header, payload = tutk_protocol.decode(data)
logger.debug(f"RECV {header}: {repr(payload)}")
Expand Down

0 comments on commit 07be86d

Please sign in to comment.