Procházet zdrojové kódy

Sort device properties when making API calls

Jonathan Peters před 2 roky
rodič
revize
2a84d30f8f
1 změnil soubory, kde provedl 3 přidání a 1 odebrání
  1. 3 1
      custom_components/tuya_local/device.py

+ 3 - 1
custom_components/tuya_local/device.py

@@ -443,7 +443,9 @@ class TuyaLocalDevice(object):
         now = time()
 
         pending_updates = self._get_pending_updates()
-        for key, value in properties.items():
+        # format properties in numeric order
+        sorted_properties = sorted(properties.items(), key=lambda x:int(x[0]))
+        for key, value in sorted_properties:
             pending_updates[key] = {
                 "value": value,
                 "updated_at": now,