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

Sort device properties when making API calls

Jonathan Peters 2 лет назад
Родитель
Сommit
2a84d30f8f
1 измененных файлов с 3 добавлено и 1 удалено
  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()
         now = time()
 
 
         pending_updates = self._get_pending_updates()
         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] = {
             pending_updates[key] = {
                 "value": value,
                 "value": value,
                 "updated_at": now,
                 "updated_at": now,