feat: use newer eufy device api

This commit is contained in:
Luke Bonaccorsi 2024-03-29 00:36:23 +00:00
parent 76aafc32a6
commit f38fa9ca54
2 changed files with 11 additions and 11 deletions

View File

@ -132,29 +132,29 @@ def get_eufy_vacuums(self):
phone_code=self[CONF_COUNTRY_CODE],
)
items = device_response["items"]
items = device_response["devices"]
self[CONF_VACS] = {}
for item in items:
if item["device"]["product"]["appliance"] == "Cleaning":
if item["product"]["appliance"] == "Cleaning":
try:
device = tuya_client.get_device(item["device"]["id"])
device = tuya_client.get_device(item["id"])
_LOGGER.debug("Robovac schema: {}".format(device["schema"]))
vac_details = {
CONF_ID: item["device"]["id"],
CONF_MODEL: item["device"]["product"]["product_code"],
CONF_NAME: item["device"]["alias_name"],
CONF_DESCRIPTION: item["device"]["name"],
CONF_MAC: item["device"]["wifi"]["mac"],
CONF_ID: item["id"],
CONF_MODEL: item["product"]["product_code"],
CONF_NAME: item["alias_name"],
CONF_DESCRIPTION: item["name"],
CONF_MAC: item["wifi"]["mac"],
CONF_IP_ADDRESS: "",
CONF_AUTODISCOVERY: True,
CONF_ACCESS_TOKEN: device["localKey"],
}
self[CONF_VACS][item["device"]["id"]] = vac_details
self[CONF_VACS][item["id"]] = vac_details
except:
_LOGGER.debug(
"Vacuum {} found on Eufy, but not on Tuya. Skipping.".format(
item["device"]["id"]
item["id"]
)
)

View File

@ -39,7 +39,7 @@ class EufyLogon:
return requests.request("GET", setting_url, headers=eufyheaders, timeout=1.5)
def get_device_info(self, url, userid, token):
device_url = url + "/v1/device/list/devices-and-groups"
device_url = url + "/v1/device/v2"
eufyheaders["token"] = token
eufyheaders["id"] = userid
return requests.request("GET", device_url, headers=eufyheaders)