Skip to content

Commit

Permalink
FIX ON_DEMAND=False (#1040)
Browse files Browse the repository at this point in the history
* downgrade MTX to v1.1.0 #1036

* parse accessories response #921

* set the flood light switch #921

* run health check on streams #1036 #1037

* Revert "downgrade MTX to v1.1.0 #1036"

This reverts commit d43437c.

* bump ios version

* changelog
  • Loading branch information
mrlt8 authored Nov 13, 2023
1 parent 3e3bf41 commit e6c4955
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 10 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ 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.5.1

* FIX `ON_DEMAND=False` option was broken in v2.5.0 #1036 #1037
* NEW API/MQTT commands Thanks @ralacher! #921:
* GET: `/api/<cam-name>/accessories` | MQTT: `wyzebridge/<cam-name>/accessories/get`
* SET: `/api/<cam-name>/spotlight` | MQTT: `wyzebridge/<cam-name>/spotlight/set`

## What's Changed in v2.5.0

* NEW camera support:
Expand Down
2 changes: 1 addition & 1 deletion app/.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VERSION=2.5.0
MTX_TAG=1.1.1
IOS_VERSION=17.0.3
IOS_VERSION=17.1.1
APP_VERSION=2.44.5.3
MTX_HLSVARIANT=fmp4
MTX_PROTOCOLS=tcp
Expand Down
7 changes: 7 additions & 0 deletions app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## What's Changed in v2.5.1

* FIX `ON_DEMAND=False` option was broken in v2.5.0 #1036 #1037
* NEW API/MQTT commands Thanks @ralacher! #921:
* GET: `/api/<cam-name>/accessories` | MQTT: `wyzebridge/<cam-name>/accessories/get`
* SET: `/api/<cam-name>/spotlight` | MQTT: `wyzebridge/<cam-name>/spotlight/set`

## What's Changed in v2.5.0

* NEW camera support:
Expand Down
19 changes: 10 additions & 9 deletions app/wyzebridge/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def monitor_streams(self, mtx_health: Callable) -> None:
events = WyzeEvents(self.streams) if MOTION else None
while not self.stop_flag:
event.read(timeout=1)
self.snap_all()
self.snap_all(self.active_streams())
if events:
events.check_motion()
if int(time.time()) % 15 == 0:
Expand Down Expand Up @@ -138,22 +138,23 @@ def active_streams(self) -> list[str]:
"""
return [cam for cam, s in self.streams.items() if s.health_check() > 0]

def snap_all(self, force: bool = False):
def snap_all(self, cams: Optional[list[str]] = None, force: bool = False):
"""
Take an rtsp snapshot of active_streams.
Take an rtsp snapshot of the streams in the list.
Args:
- cams (list[str], optional): names of the streams to take a snapshot of.
- force (bool, optional): Ignore interval and force snapshot. Defaults to False.
"""
if force or (
SNAPSHOT_TYPE == "rtsp" and time.time() - self.last_snap >= SNAPSHOT_INT
):
if force or self._should_snap():
self.last_snap = time.time()
for cam in self.active_streams():
for cam in cams or self.active_streams():
stop_subprocess(self.rtsp_snapshots.get(cam))
self.rtsp_snap_popen(cam, True)

def _should_snap(self):
return SNAPSHOT_TYPE == "rtsp" and time.time() - self.last_snap >= SNAPSHOT_INT

def get_sse_status(self) -> dict:
return {
uri: {"status": cam.status(), "motion": cam.motion}
Expand All @@ -177,7 +178,7 @@ def send_cmd(
resp = {"status": "error", "command": cmd, "payload": payload}

if cam_name == "all" and cmd == "update_snapshot":
self.snap_all(True)
self.snap_all(force=True)
return resp | {"status": "success"}

if not (stream := self.get(cam_name)):
Expand Down
1 change: 1 addition & 0 deletions app/wyzebridge/wyze_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"rtsp": "K10600SetRtspSwitch",
"quick_response": "K11635ResponseQuickMessage",
"spotlight": "K10646SetSpotlightStatus",
"floodlight": "K12060SetFloodLightSwitch",
}

CMD_VALUES = {
Expand Down
18 changes: 18 additions & 0 deletions app/wyzecam/tutk/tutk_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,9 @@ class K10720GetAccessoriesInfo(TutkWyzeProtocolMessage):
def __init__(self):
super().__init__(10720)

def parse_response(self, resp_data):
return json.loads(resp_data)


class K10788GetIntegratedFloodlightInfo(TutkWyzeProtocolMessage):
"""
Expand All @@ -1226,6 +1229,21 @@ def __init__(self):
super().__init__(10820)


class K12060SetFloodLightSwitch(TutkWyzeProtocolMessage):
"""
A message used to set the flood light switch.
"""

def __init__(self, value):
super().__init__(12060)

assert 1 <= value <= 2, "value must be 1 or 2"
self.value: int = value

def encode(self) -> bytes:
return encode(self.code, bytes([self.value]))


def encode(code: int, data: Optional[bytes]) -> bytes:
data_len = 0 if data is None else len(data)
encoded_msg = bytearray([0] * (16 + data_len))
Expand Down

0 comments on commit e6c4955

Please sign in to comment.