Merge pull request #89 from bmartin5692/update-ecovacshome

Update ecovacshome
This commit is contained in:
Brian Martin 2020-01-05 09:49:10 -05:00 committed by GitHub
commit 8709a39876
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 3644 additions and 689 deletions

View file

@ -76,11 +76,13 @@ class ConfServer:
api_v1 = {"prefix": "/v1/", "app": web.Application()} # for /v1/
api_v2 = {"prefix": "/v2/", "app": web.Application()} # for /v2/
portal_api = {"prefix": "/api/", "app": web.Application()} # for /api/
upload_api = {"prefix": "/upload/", "app": web.Application()} # for /upload/
apis = {
"api_v1": api_v1,
"api_v2": api_v2,
"portal_api": portal_api,
"upload_api": upload_api,
}
@ -102,8 +104,8 @@ class ConfServer:
for api in apis:
self.app.add_subapp(apis[api]["prefix"], apis[api]["app"])
for resource in self.app.router.resources():
print(resource)
#for resource in self.app.router.resources():
# print(resource)
@ -839,6 +841,34 @@ class ConfServer:
"msg": "操作成功",
"time": self.get_milli_time(datetime.utcnow().timestamp()),
}
# Example body
# {
# "code": "0000",
# "data": {
# "email": "user@gmail.com",
# "hasMobile": "N",
# "hasPassword": "Y",
# "headIco": "",
# "loginName": "user@gmail.com",
# "mobile": null,
# "mobileAreaNo": null,
# "nickname": "",
# "obfuscatedMobile": null,
# "thirdLoginInfoList": [
# {
# "accountType": "WeChat",
# "hasBind": "N"
# }
# ],
# "uid": "20180719212155_*****",
# "userName": "EAY*****"
# },
# "msg": "操作成功",
# "success": true,
# "time": 1578203898343
# }
return web.json_response(body)
except Exception as e:

View file

@ -83,7 +83,7 @@ class EcoVacsHome_Login(EcoVacs_Login):
ucUid = ""
# EcoVacs Home Product IOT Map - 2019-09-16
# EcoVacs Home Product IOT Map - 2020-01-05
# https://portal-ww.ecouser.net/api/pim/product/getProductIotMap
EcoVacsHomeProducts = [
{
@ -720,7 +720,7 @@ EcoVacsHomeProducts = [
"classid": "4f0c4e",
"product": {
"_id": "5d2c5fcd4d60de0001eaf2a5",
"materialNo": "134564",
"materialNo": "70200000227",
"name": "AT01",
"icon": "5d2d996c4d60de0001eaf2b5",
"UILogicId": "AT_01G",
@ -738,9 +738,9 @@ EcoVacsHomeProducts = [
"classid": "q1v5dn",
"product": {
"_id": "5d312ae18d8d430001817002",
"materialNo": "134564",
"materialNo": "70200000228",
"name": "AT01",
"icon": "5d67af719305ff0001df1a5c",
"icon": "5d83375f6b6a570001569e26",
"UILogicId": "AT_01G",
"ota": True,
"supportType": {
@ -749,7 +749,7 @@ EcoVacsHomeProducts = [
"assistant": False,
"alexa": False
},
"iconUrl": "https://portal-ww.ecouser.net/api/pim/file/get/5d67af719305ff0001df1a5c"
"iconUrl": "https://portal-ww.ecouser.net/api/pim/file/get/5d83375f6b6a570001569e26"
}
},
{
@ -769,6 +769,24 @@ EcoVacsHomeProducts = [
},
"iconUrl": "https://portal-ww.ecouser.net/api/pim/file/get/5d280ce3350e7a0001e84c95"
}
},
{
"classid": "zi1uwd",
"product": {
"_id": "5d78f4e878d8b60001e23edc",
"materialNo": "3",
"name": "DEEBOT U3 LINE FRIENDS",
"icon": "5da834a8d66cd10001f58265",
"UILogicId": "DK_4GLINE",
"ota": True,
"supportType": {
"share": True,
"tmjl": False,
"assistant": True,
"alexa": True
},
"iconUrl": "https://portal-ww.ecouser.net/api/pim/file/get/5da834a8d66cd10001f58265"
}
}
]

View file

@ -58,6 +58,98 @@ class portal_api_appsvr(plugins.ConfServerApp):
return web.json_response(body)
#elif todo == "GetShareDeviceList":
# example response
# {
# "code": 0,
# "devices": [
# {
# "deviceName": "DEEBOT 900 Series (Cleaner Cleaner)",
# "did": "did",
# "icon": "https://portal-ww.ecouser.net/api/pim/file/get/5ba4a2cb6c2f120001c32839",
# "mid": "ls1ok3",
# "ownUsers": {
# "isMe": true,
# "nickname": "user@gmail.com",
# "user": "cg****"
# },
# "resource": "wC3g",
# "share": true,
# "shareUsers": []
# }
# ],
# "ret": "ok",
# "todo": "result"
# }
# if shared shareUsers
# "shareUsers": [
# {
# "isMe": false,
# "nickname": "user@gmail.com",
# "status": "sharing",
# "user": "eafg****"
# }
# ]
#elif todo == "ShareDevice":
# example post
# {
# "todo": "ShareDevice",
# "accountType": "EMAIL",
# "auth": {
# "realm": "ecouser.net",
# "resource": "res",
# "token": "token***",
# "userid": "cg***",
# "with": "users"
# },
# "country": "US",
# "did": "did",
# "resource": "wC3g",
# "username": "email to share to"
# }
#fail response (no user)
# {
# "todo": "result",
# "code": -3,
# "errno": -3,
# "ret": "fail"
# }
#success response
#{"ret":"ok","code":0,"todo":"result"}
#elif todo == "ShareUnRegisterDevice":
# example post
# {
# "todo": "ShareUnRegisterDevice",
# "account": "email to share to",
# "auth": {
# "realm": "ecouser.net",
# "resource": "res",
# "token": "toke",
# "userid": "userid",
# "with": "users"
# },
# "country": "US",
# "did": "did",
# "lang": "EN",
# "mid": "ls1ok3"
# }
# example response
# {
# "todo": "result",
# "code": 0,
# "data": {
# "mailContent": "<!-- 邮件代码 --><div style=\"position: relative;\"><div style=\"font-size: 14px;font-family: Helvetica;padding: 65px 0;line-height: 150%;\"><p style=\"margin-bottom: 15px;\">Hey there,</p><p style=\"margin-bottom: 15px;\">\n\t\t\tCheck out my new awesome robot vacuum: <a href=\"#\" style=\"color: #1c95ea;text-decoration: none;\">DEEBOT 900 Series</a>!<br/>\n\t\t\tDownload the <strong>ECOVACS HOME</strong> App and sign up with your email: <a href=\"#\" style=\"color: #1c95ea;text-decoration: none;\">brian@bmartin.net</a>, so you and I can control this kick-ass robot together.</p><p style=\"margin-bottom: 15px;\">\n\t\t\tIOS: <span style=\"font-size:15px\"><a href=\"https://itunes.apple.com/us/app/ecovacs-home/id1329458504?l=zh&ls=1&mt=8\">https://itunes.apple.com/us/app/ecovacs-home/id1329458504?l=zh&amp;ls=1&amp;mt=8</a></span><br/>\n\t\t\tAndroid: <span style=\"font-size:15px\"><a href=\"https://play.google.com/store/apps/details?id=com.eco.global.app\">https://play.google.com/store/apps/details?id=com.eco.global.app</a></span></p><p style=\"margin-bottom: 15px;\">\n\t\t\tThis invitation is valid within 7 days.<br/>\n\t\t\tIf I&#39;m sending to the wrong person, please ignore this email.</p><p style=\"margin-bottom: 15px;\">Thank you.</p></div></div><!-- 邮件代码 -->",
# "mailTitle": "I'm sharing my DEEBOT and you're invited!"
# },
# "ret": "ok"
# }
except Exception as e:
logging.exception("{}".format(e))

View file

@ -65,6 +65,10 @@ class portal_api_dim(plugins.ConfServerApp):
body = {"ret": "ok", "unRead": False}
return web.json_response(body)
if json_body["td"] == "ReceiveShareDevice": # EcoVacs Home
body = {"ret":"ok"}
return web.json_response(body)
except Exception as e:
logging.exception("{}".format(e))

View file

@ -69,6 +69,11 @@ class portal_api_iot(plugins.ConfServerApp):
body = {"ret": "ok", "unRead": False}
return web.json_response(body)
if json_body["td"] == "PreWifiConfig": # EcoVacs Home
body = {"ret":"ok"}
return web.json_response(body)
except Exception as e:
logging.exception("{}".format(e))

View file

@ -19,6 +19,8 @@ class portal_api_neng(plugins.ConfServerApp):
self.routes = [
web.route("*", "/neng/message/hasUnreadMsg", self.handle_neng_hasUnreadMessage, name="portal_api_neng_hasUnreadMessage"),
web.route("*", "/neng/message/getShareMsgs", self.handle_neng_getShareMsgs, name="portal_api_neng_getShareMsgs"),
web.route("*", "/neng/message/getlist", self.handle_neng_getlist, name="portal_api_neng_getlist"),
]
@ -33,5 +35,63 @@ class portal_api_neng(plugins.ConfServerApp):
except Exception as e:
logging.exception("{}".format(e))
async def handle_neng_getShareMsgs(self, request): # EcoVacs Home
try:
body = {"code":0,"data":{"hasNext":False,"msgs":[]}}
# share msg response
# {
# "code": 0,
# "data": {
# "hasNext": False,
# "msgs": [
# {
# "action": "shareDevice",
# "deviceName": "DEEBOT 900 Series",
# "did": "DID",
# "icon": "https://portal-ww.ecouser.net/api/pim/file/get/5ba4a2cb6c2f120001c32839",
# "id": "0154d03a-294e-4b99-a6df-fc2dbf4146d5",
# "isRead": False,
# "message": "User user@gmail.com sent you the sharing invitation of DEEBOT 900 Series.",
# "mid": "ls1ok3",
# "resource": "grU0",
# "shareStatus": "sharing",
# "ts": 1578206187412
# }
# ]
# }
# }
return web.json_response(body)
except Exception as e:
logging.exception("{}".format(e))
async def handle_neng_getlist(self, request): # EcoVacs Home
try:
body = {"code":0,"data":{"hasNext":False,"msgs":[]}}
#Sample Message
# {
# "id": "5da0ac9d636aec5107627ac4",
# "ts": 1570811036877,
# "did": "bot did",
# "cid": "ls1ok3",
# "name": "DEEBOT 900 Series",
# "icon": "https://portal-ww.ecouser.net/api/pim/file/get/5ba4a2cb6c2f120001c32839",
# "eventTypeId": "5aab824bb62ce30001f9a702",
# "title": "DEEBOT is off the floor.",
# "body": "DEEBOT is off the floor. Please put it back.",
# "read": false,
# "UILogicId": "D_900",
# "type": "web",
# "url": "https://portal-ww.ecouser.net/api/pim/eventdetail.html?id=5ba21e44aed83800015b9ca8" # Off the floor instructions
# }
return web.json_response(body)
except Exception as e:
logging.exception("{}".format(e))
plugin = portal_api_neng()

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,40 @@
#!/usr/bin/env python3
import asyncio
from aiohttp import web
from bumper import plugins
import logging
import bumper
from bumper.models import *
from bumper import plugins
from datetime import datetime, timedelta
import os
class upload_global(plugins.ConfServerApp):
def __init__(self):
self.name = "upload_global"
self.plugin_type = "sub_api"
self.sub_api = "upload_api"
self.routes = [
web.route("*", "/global/{year}/{month}/{day}/{fileid}", self.handle_upload_global_file, name="upload_global_getFile"),
]
self.get_milli_time = bumper.ConfServer.ConfServer_GeneralFunctions().get_milli_time
async def handle_upload_global_file(self, request):
try:
fileID = request.match_info.get("id", "")
return web.FileResponse(os.path.join(bumper.data_dir,"web","robotvac_image.jpg"))
except Exception as e:
logging.exception("{}".format(e))
plugin = upload_global()

View file

@ -26,8 +26,11 @@ class v1_private_user(plugins.ConfServerApp):
web.route("*", "/private/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/user/checkAgreement", self.handle_checkAgreement,name="v1_user_checkAgreement"),
web.route("*", "/private/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/user/checkAgreementBatch", self.handle_checkAgreement,name="v1_user_checkAgreementBatch"),
web.route("*", "/private/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/user/getUserAccountInfo", authhandler.getUserAccountInfo,name="v1_user_getUserAccountInfo"),
web.route("*", "/private/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/user/getUserMenuInfo", self.handle_getUserMenuInfo,name="v1_user_getUserMenuInfo"),
# Direct register from app:
# /{apiversion}/private/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/user/directRegister
#Register by email
# /registerByEmail
]
@ -72,5 +75,74 @@ class v1_private_user(plugins.ConfServerApp):
except Exception as e:
logging.exception("{}".format(e))
async def handle_getUserMenuInfo(self, request):
try:
apptype = request.match_info.get("apptype", "")
body = {
"code": "0000",
"data": [
{
"menuItems": [
{
"clickAction": 1,
"clickUri": "https://ecovacs.zendesk.com/hc/en-us",
"menuIconUrl": "https://gl-us-pub.ecovacs.com/upload/global/2019/12/16/2019121603180741b73907046e742b80e8fe4a90fe2498.png",
"menuId": "20191216031849_4d744630f7ad2f5208a4b8051be61d10",
"menuName": "Help & Feedback",
"paramsJson": ""
}
],
"menuPositionKey": "A_FIRST"
},
{
"menuItems": [
{
"clickAction": 3,
"clickUri": "robotShare",
"menuIconUrl": "https://gl-us-pub.ecovacs.com/upload/global/2019/12/16/2019121603284185e632ec6c5da10bd82119d7047a1f9e.png",
"menuId": "20191216032853_5fac4cc9cbd0e166dfa951485d1d8cc4",
"menuName": "Share Robot",
"paramsJson": ""
}
],
"menuPositionKey": "B_SECOND"
},
{
"menuItems": [
{
"clickAction": 3,
"clickUri": "config",
"menuIconUrl": "https://gl-us-pub.ecovacs.com/upload/global/2019/12/16/201912160325324068da4e4a09b8c3973db162e84784d5.png",
"menuId": "20191216032545_ebea0fbb4cb02d9c2fec5bdf3371bc2d",
"menuName": "Settings",
"paramsJson": ""
}
],
"menuPositionKey": "C_THIRD"
},
{
"menuItems": [
{
"clickAction": 1,
"clickUri": "https://bumper.ecovacs.com/",
"menuIconUrl": "https://gl-us-pub.ecovacs.com/upload/global/2019/12/16/201912160325324068da4e4a09b8c3973db162e84784d5.png",
"menuId": "20191216032545_ebea0fbb4cb02d9c2fec5bdf3371bc2c",
"menuName": "Bumper Status",
"paramsJson": ""
}
],
"menuPositionKey": "D_FOURTH"
}
],
"msg": "操作成功",
"success": True,
"time": self.get_milli_time(datetime.utcnow().timestamp())
}
return web.json_response(body)
except Exception as e:
logging.exception("{}".format(e))
plugin = v1_private_user()