Explorar o código

Sort device properties when making API calls

Jonathan Peters %!s(int64=2) %!d(string=hai) anos
pai
achega
2a84d30f8f
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  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,