From f38fa9ca54dd3c058e2d806b1091dd8503e00e06 Mon Sep 17 00:00:00 2001 From: Luke Bonaccorsi Date: Fri, 29 Mar 2024 00:36:23 +0000 Subject: [PATCH] feat: use newer eufy device api --- custom_components/robovac/config_flow.py | 20 ++++++++++---------- custom_components/robovac/eufywebapi.py | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/custom_components/robovac/config_flow.py b/custom_components/robovac/config_flow.py index 0693b53..d0e7c86 100644 --- a/custom_components/robovac/config_flow.py +++ b/custom_components/robovac/config_flow.py @@ -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"] ) ) diff --git a/custom_components/robovac/eufywebapi.py b/custom_components/robovac/eufywebapi.py index 1cbbfab..683c280 100644 --- a/custom_components/robovac/eufywebapi.py +++ b/custom_components/robovac/eufywebapi.py @@ -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)