|
@@ -18,22 +18,22 @@ import custom_components.tuya_local.devices as config_dir
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
-def _typematch(type, value):
|
|
|
|
|
|
|
+def _typematch(vtype, value):
|
|
|
# Workaround annoying legacy of bool being a subclass of int in Python
|
|
# Workaround annoying legacy of bool being a subclass of int in Python
|
|
|
- if type is int and isinstance(value, bool):
|
|
|
|
|
|
|
+ if vtype is int and isinstance(value, bool):
|
|
|
return False
|
|
return False
|
|
|
|
|
|
|
|
# Allow integers to pass as floats.
|
|
# Allow integers to pass as floats.
|
|
|
- if type is float and isinstance(value, Number):
|
|
|
|
|
|
|
+ if vtype is float and isinstance(value, Number):
|
|
|
return True
|
|
return True
|
|
|
|
|
|
|
|
- if isinstance(value, type):
|
|
|
|
|
|
|
+ if isinstance(value, vtype):
|
|
|
return True
|
|
return True
|
|
|
# Allow values embedded in strings if they can be converted
|
|
# Allow values embedded in strings if they can be converted
|
|
|
# But not for bool, as everything can be converted to bool
|
|
# But not for bool, as everything can be converted to bool
|
|
|
- elif isinstance(value, str) and type is not bool:
|
|
|
|
|
|
|
+ elif isinstance(value, str) and vtype is not bool:
|
|
|
try:
|
|
try:
|
|
|
- type(value)
|
|
|
|
|
|
|
+ vtype(value)
|
|
|
return True
|
|
return True
|
|
|
except ValueError:
|
|
except ValueError:
|
|
|
return False
|
|
return False
|
|
@@ -844,7 +844,7 @@ class TuyaDpsConfig:
|
|
|
if cval == value:
|
|
if cval == value:
|
|
|
c_dps = self._entity.find_dps(mapping.get("constraint", self.name))
|
|
c_dps = self._entity.find_dps(mapping.get("constraint", self.name))
|
|
|
cond_dpsval = cond.get("dps_val")
|
|
cond_dpsval = cond.get("dps_val")
|
|
|
- single_match = type(cond_dpsval) == str or (
|
|
|
|
|
|
|
+ single_match = isinstance(cond_dpsval, str) or (
|
|
|
not isinstance(cond_dpsval, Sequence)
|
|
not isinstance(cond_dpsval, Sequence)
|
|
|
)
|
|
)
|
|
|
if c_dps.id != self.id and single_match:
|
|
if c_dps.id != self.id and single_match:
|