Skip to content

Commit

Permalink
update battery commands #864 (#981)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlt8 authored Sep 2, 2023
1 parent 0cc6e8b commit e1ce8db
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/wyzebridge/wyze_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"motion_tracking": "K11020GetMotionTracking",
"motion_tagging": "K10290GetMotionTagging",
"camera_info": "K10020CheckCameraInfo",
"battery": "K10448GetBatteryUsage",
"battery": "K10050GetPowerLevel",
"battery_usage": "K10448GetBatteryUsage",
"rtsp": "K10604GetRtspParam",
"param_info": "K10020CheckCameraParams", # Requires a Payload
}
Expand Down
22 changes: 21 additions & 1 deletion app/wyzecam/tutk/tutk_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,18 @@ def encode(self) -> bytes:
return encode(self.code, bytes([self.status]))


class K10050GetPowerLevel(TutkWyzeProtocolMessage):
def __init__(self):
super().__init__(10050)

def parse_response(self, resp_data):
data = json.loads(resp_data)
try:
return data["camerainfo"]["powerlevel"]
except KeyError:
return 0


class K10056SetResolvingBit(TutkWyzeProtocolMessage):
"""
A message used to set the resolution and bitrate of the camera.
Expand Down Expand Up @@ -846,7 +858,15 @@ def __init__(self):
super().__init__(10448)

def parse_response(self, resp_data):
return json.loads(resp_data)
data = json.loads(resp_data)
return {
"last_charge": data["0"],
"live_streaming": data["1"],
"events_uploaded": data["2"],
"events_filtered": data["3"],
"sd_recordings": data["4"],
"5": data["5"],
}


class K10600SetRtspSwitch(TutkWyzeProtocolMessage):
Expand Down

0 comments on commit e1ce8db

Please sign in to comment.