Просмотр исходного кода

Config flow: log cloud info where available.

Log product id and QueryThingsDataModel result if cloud is available.

Issue #2419
Jason Rumney 1 год назад
Родитель
Сommit
40af89040d
1 измененных файлов с 15 добавлено и 1 удалено
  1. 15 1
      custom_components/tuya_local/config_flow.py

+ 15 - 1
custom_components/tuya_local/config_flow.py

@@ -363,6 +363,20 @@ class ConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
 
         best_match = int(best_match)
         dps = self.device._get_cached_state()
+        if self.__cloud_device:
+            _LOGGER.warning(
+                "Adding %s device with product id %s",
+                self.__cloud_device["product_name"],
+                self.__cloud_device["product_id"],
+            )
+            response = self.cloud.async_get_datamodel(self.__cloud_device["device_id"])
+            if response and response["result"] and response["result"]["model"]:
+                model = json.loads(response["result"]["model"])
+
+                _LOGGER.warning(
+                    "QueryThingsDataModel result:\n%s",
+                    json.dumps(model, indent=4),
+                )
         _LOGGER.warning(
             "Device matches %s with quality of %d%%. DPS: %s",
             best_matching_type,
@@ -370,7 +384,7 @@ class ConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
             log_json(dps),
         )
         _LOGGER.warning(
-            "Include the previous log message with any new device request to https://github.com/make-all/tuya-local/issues/",
+            "Include the previous log messages with any new device request to https://github.com/make-all/tuya-local/issues/",
         )
         if types:
             return self.async_show_form(