Quellcode durchsuchen

Add a 3.22 protocol version for enabling "device22" detection

Tinytuya has automatic detection of "device22" devices, which are
3.3 devices that require 3.2 data queries.

This detection seems to falsely detect normal 3.3 devices as device22
if it tries to make a connection when the device is powering up, so
it accepts the network connection but is unable to reply. When this
false detection happens, the tinytuya continues to use device22
commands to communicate with the device, so does not get any data.

With the new 3.22 protocol variant added, we can disable the device22
detection normally, and only enable when the protocol is explicitly 3.22.

Issue #1804
Jason Rumney vor 1 Jahr
Ursprung
Commit
3bd4012880
3 geänderte Dateien mit 10 neuen und 2 gelöschten Zeilen
  1. 1 1
      README.md
  2. 1 1
      custom_components/tuya_local/const.py
  3. 8 0
      custom_components/tuya_local/device.py

+ 1 - 1
README.md

@@ -152,7 +152,7 @@ below](#finding-your-device-id-and-local-key).
 
 #### protocol_version
 
-    _(string or float) (Required)_ Valid options are "auto", 3.1, 3.2, 3.3, 3.4.  If you aren't sure, choose "auto", but some 3.2 and maybe 3.4 devices may be misdetected as 3.3 (or vice-versa), so if your device does not seem to respond to commands reliably, try selecting between those protocol versions.
+    _(string or float) (Required)_ Valid options are "auto", 3.1, 3.2, 3.3, 3.4, 3.5, 3.22.  If you aren't sure, choose "auto", but some 3.2, 3.22 and maybe 3.4 devices may be misdetected as 3.3 (or vice-versa), so if your device does not seem to respond to commands reliably, try selecting between those protocol versions. Protocol 3.22 is a special case, that enables tinytuya's "device22" detection with protocol 3.3. Previously we let tinytuya auto-detect this, but it was found to sometimes misdetect genuine 3.3 devices as device22 which stops them receiving updates, so an explicit version was added to enable the device22 detection.
 
 At the end of this step, an attempt is made to connect to the device and see if
 it returns any data. For tuya protocol version 3.1 devices, the local key is

+ 1 - 1
custom_components/tuya_local/const.py

@@ -7,7 +7,7 @@ CONF_TYPE = "type"
 CONF_POLL_ONLY = "poll_only"
 CONF_DEVICE_CID = "device_cid"
 CONF_PROTOCOL_VERSION = "protocol_version"
-API_PROTOCOL_VERSIONS = [3.3, 3.1, 3.2, 3.4, 3.5]
+API_PROTOCOL_VERSIONS = [3.3, 3.1, 3.2, 3.4, 3.5, 3.22]
 
 CONF_APP_TYPE = "tuya_app_type"
 CONF_ENDPOINT = "endpoint"

+ 8 - 0
custom_components/tuya_local/device.py

@@ -680,10 +680,18 @@ class TuyaLocalDevice(object):
             self.name,
             new_version,
         )
+        # Only enable tinytuya's auto-detect when using 3.22
+        if new_version == 3.22:
+            new_version = 3.3
+            self._api.disabledetect = False
+        else:
+            self._api.disabledetect = True
+
         await self._hass.async_add_executor_job(
             self._api.set_version,
             new_version,
         )
+        self._api.
         if self._api.parent:
             await self._hass.async_add_executor_job(
                 self._api.parent.set_version,