Skip to content

Commit

Permalink
v2.9.1 (#1192)
Browse files Browse the repository at this point in the history
* unpack k10050 response #1185

* add back bitrate check for HL_CFL2 #1112

* Ignore api request value and add api header #1189

* changelog
  • Loading branch information
mrlt8 committed May 13, 2024
1 parent 99ac5ba commit ae31b2d
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 12 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ 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.9.1

- FIX: Setting bitrate higher than 255 would not report correctly (#1185) Thanks @Anc0dia!
- FIX: Wrong bitrate for HL_CFL2 (#1112) Thanks @dreondre!
- FIX: Could not set values with the REST API when `WB_AUTH` is enabled.(#1189) Thanks @kiwi-cam!
- NEW: `api` header authentication option for the RES API when `WB_AUTH` is enabled:
- `-H "api: MyWbApiKey"`

## What's Changed in v2.9.0

> [!IMPORTANT]
Expand Down
9 changes: 5 additions & 4 deletions app/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,16 @@ def api_cam(cam_name: str):
@auth_required
def api_cam_control(cam_name: str, cam_cmd: str, payload: str | dict = ""):
"""API Endpoint to send tutk commands to the camera."""
if args := request.values:
payload = args.to_dict() if len(args) > 1 else next(args.values())
elif request.is_json:
if not payload and (args := request.values.to_dict()):
args.pop("api", None)
payload = next(iter(args.values())) if len(args) == 1 else args
if not payload and request.is_json:
json = request.get_json()
if isinstance(json, dict):
payload = json if len(json) > 1 else list(json.values())[0]
else:
payload = json
elif request.data:
elif not payload and request.data:
payload = request.data.decode()

return wb.streams.send_cmd(cam_name, cam_cmd.lower(), payload)
Expand Down
2 changes: 1 addition & 1 deletion app/wyzebridge/web_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
def verify_password(username, password):
if config.HASS_TOKEN and request.remote_addr == "172.30.32.2":
return True
if request.args.get("api") == config.WB_API:
if config.WB_API in (request.args.get("api"), request.headers.get("api")):
return request.path.startswith(API_ENDPOINTS)
if username == config.WB_USERNAME:
return check_password_hash(HASHED_PASS, password)
Expand Down
3 changes: 1 addition & 2 deletions app/wyzebridge/wyze_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,7 @@ def bitrate_check(sess: WyzeIOTCSession, res: dict, topic: str):
key = "bitrate" if topic in res else "3"
if (bitrate := res.get(key)) and int(bitrate) != sess.preferred_bitrate:
logger.info(f"{bitrate=} does not match {sess.preferred_bitrate}")
if sess.preferred_frame_size != 4:
sess.update_frame_size_rate()
sess.update_frame_size_rate()

if key == "bitrate":
return res.get(topic, res)
Expand Down
11 changes: 6 additions & 5 deletions app/wyzecam/tutk/tutk_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,12 +463,13 @@ def __init__(self):
super().__init__(10050)

def parse_response(self, resp_data):
data = unpack("<HBBBB", resp_data)
return {
"bitrate": resp_data[0],
"res": resp_data[2],
"fps": resp_data[3],
"hor_flip": resp_data[4],
"ver_flip": resp_data[5],
"bitrate": data[0],
"res": data[1],
"fps": data[2],
"hor_flip": data[3],
"ver_flip": data[4],
}


Expand Down
8 changes: 8 additions & 0 deletions home_assistant/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## What's Changed in v2.9.1

- FIX: Setting bitrate higher than 255 would not report correctly (#1185) Thanks @Anc0dia!
- FIX: Wrong bitrate for HL_CFL2 (#1112) Thanks @dreondre!
- FIX: Could not set values with the REST API when `WB_AUTH` is enabled.(#1189) Thanks @kiwi-cam!
- NEW: `api` header authentication option for the RES API when `WB_AUTH` is enabled:
- `-H "api: MyWbApiKey"`

## What's Changed in v2.9.0

> [!IMPORTANT]
Expand Down

0 comments on commit ae31b2d

Please sign in to comment.