For int environment variables (ex: TUYA_BRIGHTNESS), the existing code below doesn't work as intended, which then simply sets the environment variable to the default value.
# In env.pyself.tuyaBrightness=128
...
brightness_try_parse=util.ignore_exception(ValueError, self.tuyaBrightness)(int)
self.tuyaBrightness=brightness_try_parse(os.environ.get('TUYA_BRIGHTNESS', self.tuyaBrightness))We should switch to a less-complex method to parse the integer from a string, i.e.
# In util.pydeftry_parse_int(value, base=10, default=None):
try:
returnint(value, base)
exceptValueError:
returnvalue# In env.pyself.tuyaBrightness=util.try_parse_int(os.environ.get('TUYA_BRIGHTNESS'), default=self.tuyaBrightness)
For
intenvironment variables (ex:TUYA_BRIGHTNESS), the existing code below doesn't work as intended, which then simply sets the environment variable to the default value.We should switch to a less-complex method to parse the integer from a string, i.e.