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

Let integers pass as float for auto-detection.

A value of 0 has a type of int, but it can also be a float.

Issue #335
Jason Rumney 3 лет назад
Родитель
Сommit
6aefc8da90
1 измененных файлов с 4 добавлено и 0 удалено
  1. 4 0
      custom_components/tuya_local/helpers/device_config.py

+ 4 - 0
custom_components/tuya_local/helpers/device_config.py

@@ -21,6 +21,10 @@ def _typematch(type, value):
     if type is int and isinstance(value, bool):
         return False
 
+    # Allow integers to pass as floats.
+    if type is float and isinstance(value, int):
+        return True
+
     if isinstance(value, type):
         return True
     # Allow values embedded in strings if they can be converted