Procházet zdrojové kódy

Convert masked values to int as we set them.

With a scale, the value can be a float, but we need it converted
to int so the mask can be applied.

Issue #947
Jason Rumney před 2 roky
rodič
revize
b7333bd043

+ 1 - 1
custom_components/tuya_local/helpers/device_config.py

@@ -908,7 +908,7 @@ class TuyaDpsConfig:
             mask = int(mask, 16)
             mask_scale = mask & (1 + ~mask)
             current_value = int.from_bytes(self.decoded_value(device), endianness)
-            result = (current_value & ~mask) | (mask & (result * mask_scale))
+            result = (current_value & ~mask) | (mask & int(result * mask_scale))
             result = self.encode_value(result.to_bytes(length, endianness))
 
         dps_map[self.id] = self._correct_type(result)