Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: equipment configuration #113

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions aiorobonect/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,14 @@ async def client_close(self):

async def async_cmd(self, command=None, params={}) -> list[dict]:
"""Send command to mower."""
ext = None
if command is None:
return False
if params is None:
params = ""
else:
if command == "ext":
ext = params.pop("ext")
params = urllib.parse.urlencode(params)

if command == "job":
Expand All @@ -93,6 +96,8 @@ async def async_cmd(self, command=None, params={}) -> list[dict]:
def create_url(scheme):
if command == "reset_blades":
return f"{scheme}://{self.host}/?btexe="
if command == "ext":
return f"{scheme}://{self.host}/{ext}?{params}"
return f"{scheme}://{self.host}/json?cmd={command}&{params}"

if self.scheme is None:
Expand Down Expand Up @@ -140,6 +145,12 @@ def create_url(scheme):
await self.client_close()
return {"successful": True}
result_text = response.text
if command == "ext":
await self.client_close()
if "The changes were successfully applied" in result_text:
return {"successful": True}
else:
return {"successful": False}
_LOGGER.debug(f"Rest API call result for {command}: {result_text}")
try:
result_json = json.loads(result_text)
Expand Down
Loading