fix ecovacshome cleanlogs
update for lg logs to support viewing cleaning logs in ecovacs home app. Tested with D901.
This commit is contained in:
parent
abaf9ebae2
commit
b604a4d214
1 changed files with 39 additions and 17 deletions
|
|
@ -271,10 +271,34 @@ class ConfServer:
|
||||||
|
|
||||||
except web.HTTPNotFound as notfound:
|
except web.HTTPNotFound as notfound:
|
||||||
confserverlog.debug("Request path {} not found".format(request.raw_path))
|
confserverlog.debug("Request path {} not found".format(request.raw_path))
|
||||||
|
requestlog = {
|
||||||
|
"request": {
|
||||||
|
"route_name": f"{request.match_info.route.name}",
|
||||||
|
"method": f"{request.method}",
|
||||||
|
"path": f"{request.path}",
|
||||||
|
"query_string": f"{request.query_string}",
|
||||||
|
"raw_path": f"{request.raw_path}",
|
||||||
|
"raw_headers": f'{",".join(map("{}".format, request.raw_headers))}',
|
||||||
|
"body": f"{postbody}",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
confserverlog.debug(json.dumps(requestlog))
|
||||||
return notfound
|
return notfound
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
confserverlog.exception("{}".format(e))
|
confserverlog.exception("{}".format(e))
|
||||||
|
requestlog = {
|
||||||
|
"request": {
|
||||||
|
"route_name": f"{request.match_info.route.name}",
|
||||||
|
"method": f"{request.method}",
|
||||||
|
"path": f"{request.path}",
|
||||||
|
"query_string": f"{request.query_string}",
|
||||||
|
"raw_path": f"{request.raw_path}",
|
||||||
|
"raw_headers": f'{",".join(map("{}".format, request.raw_headers))}',
|
||||||
|
"body": f"{postbody}",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
confserverlog.debug(json.dumps(requestlog))
|
||||||
return e
|
return e
|
||||||
|
|
||||||
async def restart_Helper(self):
|
async def restart_Helper(self):
|
||||||
|
|
@ -1058,8 +1082,6 @@ class ConfServer:
|
||||||
bumper.bot_remove(postbody["did"])
|
bumper.bot_remove(postbody["did"])
|
||||||
body = {"result": "ok", "todo": "result"}
|
body = {"result": "ok", "todo": "result"}
|
||||||
|
|
||||||
confserverlog.debug("POST: {} - Response: {}".format(postbody, body))
|
|
||||||
|
|
||||||
return web.json_response(body)
|
return web.json_response(body)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
@ -1101,8 +1123,6 @@ class ConfServer:
|
||||||
"todo": "result",
|
"todo": "result",
|
||||||
}
|
}
|
||||||
|
|
||||||
confserverlog.debug("POST: {} - Response: {}".format(postbody, body))
|
|
||||||
|
|
||||||
return web.json_response(body)
|
return web.json_response(body)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
@ -1171,7 +1191,6 @@ class ConfServer:
|
||||||
if not "cmdName" in json_body:
|
if not "cmdName" in json_body:
|
||||||
if "td" in json_body:
|
if "td" in json_body:
|
||||||
json_body["cmdName"] = json_body["td"]
|
json_body["cmdName"] = json_body["td"]
|
||||||
# json_body["td"] = "q"
|
|
||||||
|
|
||||||
if not "toId" in json_body:
|
if not "toId" in json_body:
|
||||||
json_body["toId"] = did
|
json_body["toId"] = did
|
||||||
|
|
@ -1186,18 +1205,18 @@ class ConfServer:
|
||||||
json_body["payloadType"] = "x"
|
json_body["payloadType"] = "x"
|
||||||
|
|
||||||
if not "payload" in json_body:
|
if not "payload" in json_body:
|
||||||
json_body["payload"] = ""
|
#json_body["payload"] = ""
|
||||||
if json_body["td"] == "GetCleanLogs":
|
if json_body["td"] == "GetCleanLogs":
|
||||||
json_body["td"] = "q"
|
json_body["td"] = "q"
|
||||||
json_body["payload"] = '<ctl count="30"/>' # <ctl />"
|
json_body["payload"] = '<ctl count="30"/>'
|
||||||
|
|
||||||
if did != "":
|
if did != "":
|
||||||
bot = bumper.bot_get(did)
|
bot = bumper.bot_get(did)
|
||||||
if bot["company"] == "eco-ng":
|
if bot["company"] == "eco-ng":
|
||||||
body = ""
|
|
||||||
retcmd = await bumper.mqtt_helperbot.send_command(
|
retcmd = await bumper.mqtt_helperbot.send_command(
|
||||||
json_body, randomid
|
json_body, randomid
|
||||||
)
|
)
|
||||||
|
body = retcmd
|
||||||
confserverlog.debug("Send Bot - {}".format(json_body))
|
confserverlog.debug("Send Bot - {}".format(json_body))
|
||||||
confserverlog.debug("Bot Response - {}".format(body))
|
confserverlog.debug("Bot Response - {}".format(body))
|
||||||
logs = []
|
logs = []
|
||||||
|
|
@ -1205,21 +1224,24 @@ class ConfServer:
|
||||||
if logsroot.attrib["ret"] == "ok":
|
if logsroot.attrib["ret"] == "ok":
|
||||||
cleanlogs = logsroot.getchildren()
|
cleanlogs = logsroot.getchildren()
|
||||||
for l in cleanlogs:
|
for l in cleanlogs:
|
||||||
logs.append(l.attrib)
|
cleanlog = {
|
||||||
|
"ts": l.attrib['s'],
|
||||||
|
"area": l.attrib['a'],
|
||||||
|
"last": l.attrib['l'],
|
||||||
|
"cleanType": l.attrib['t'],
|
||||||
|
#imageUrl allows for providing images of cleanings, something to look into later
|
||||||
|
#"imageUrl": "https://localhost:8007",
|
||||||
|
}
|
||||||
|
logs.append(cleanlog)
|
||||||
body = {
|
body = {
|
||||||
"ret": "ok",
|
"ret": "ok",
|
||||||
# "logs": logs, #TODO: Doesn't parse correctly, new protocol & server side processing
|
"logs": logs,
|
||||||
"logs": [],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else:
|
else:
|
||||||
body = {"ret": "ok", "logs": []}
|
body = {"ret": "ok", "logs": []}
|
||||||
|
|
||||||
confserverlog.debug(
|
confserverlog.debug("lg logs return: {}".format(json.dumps(body)))
|
||||||
"POST: {} - Response: {}".format(json_body, body)
|
|
||||||
)
|
|
||||||
|
|
||||||
return web.json_response(body)
|
return web.json_response(body)
|
||||||
else:
|
else:
|
||||||
# No response, send error back
|
# No response, send error back
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue