Skip to content

Commit

Permalink
Default to - for cruise_point #921
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlt8 committed Jul 23, 2023
1 parent fb88530 commit 8639eb5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
3 changes: 2 additions & 1 deletion app/wyzebridge/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,8 @@ def get_entities(base_topic: str, pan_cam: bool = False, rtsp: bool = False) ->
"payload": {
"state_topic": f"{base_topic}cruise_point",
"command_topic": f"{base_topic}cruise_point/set",
"options": ["1", "2", "3", "4"],
"optimistic": False,
"options": ["-", "1", "2", "3", "4"],
"icon": "mdi:map-marker-multiple",
},
},
Expand Down
7 changes: 3 additions & 4 deletions app/wyzebridge/wyze_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def pan_to_cruise_point(sess: WyzeIOTCSession, cmd):
"""
Pan to cruise point/waypoint.
"""
resp = {"command": "cruise_point", "status": "error", "value": None}
resp = {"command": "cruise_point", "status": "error", "value": "-"}
if not isinstance(cmd, tuple) or not str(cmd[1]).isdigit():
return resp | {"response": f"Invalid cruise point: {cmd=}"}

Expand All @@ -194,17 +194,16 @@ def pan_to_cruise_point(sess: WyzeIOTCSession, cmd):
try:
waypoints = (points[i]["vertical"], points[i]["horizontal"])
except IndexError:
return resp | {"response": f"Cruise point NOT found. {points=}"}
return resp | {"response": f"Cruise point {i} NOT found. {points=}"}

logger.info(f"Pan to cruise_point={i} ({waypoints})")
logger.info(f"Pan to cruise_point={i} {waypoints}")
res = mux.send_ioctl(tutk_protocol.K11018SetPTZPosition(*waypoints)).result(
timeout=5
)

return resp | {
"status": "success",
"response": ",".join(map(str, res)) if isinstance(res, bytes) else res,
"value": int(cmd[1]),
}


Expand Down
13 changes: 8 additions & 5 deletions app/wyzebridge/wyze_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,24 +298,27 @@ def send_cmd(self, cmd: str, payload: str | list | dict = "") -> dict:
if cmd == "power":
return self.power_control(str(payload).lower())

if cmd == "time_zone" and payload and isinstance(payload, str):
return self.tz_control(payload)

if self.state < StreamStatus.STOPPED:
return {"response": self.status()}

if env_bool("disable_control"):
return {"response": "control disabled"}

if cmd not in GET_CMDS | SET_CMDS | PARAMS and cmd not in {"caminfo"}:
return {"response": "invalid command"}
if cmd == "time_zone" and payload and isinstance(payload, str):
return self.tz_control(payload)

if cmd == "bitrate" and isinstance(payload, (str, int)) and payload.isdigit():
self.options.bitrate = int(payload)

if cmd == "update_snapshot":
return {"update_snapshot": True}

if cmd == "cruise_point" and payload == "-":
return {"status": "success", "value": "-"}

if cmd not in GET_CMDS | SET_CMDS | PARAMS and cmd not in {"caminfo"}:
return {"response": "invalid command"}

if on_demand := not self.connected:
logger.info(f"[CONTROL] Connecting to {self.uri}")
self.start()
Expand Down

0 comments on commit 8639eb5

Please sign in to comment.