Fixing up style issues

This commit is contained in:
sibowler
2021-12-13 06:08:53 +11:00
committed by rospogrigio
parent fad7e0b1ac
commit 61896605b8
3 changed files with 13 additions and 11 deletions

View File

@@ -46,6 +46,7 @@ DATA_DISCOVERY = "discovery"
DOMAIN = "localtuya" DOMAIN = "localtuya"
# Platforms in this list must support config flows # Platforms in this list must support config flows
PLATFORMS = ["binary_sensor", "cover", "fan", "light", "number", "select", "sensor", "switch"] PLATFORMS = ["binary_sensor", "cover", "fan", "light", "number",
"select", "sensor", "switch"]
TUYA_DEVICE = "tuya_device" TUYA_DEVICE = "tuya_device"

View File

@@ -19,8 +19,9 @@ CONF_MAX_VALUE = "max_value"
DEFAULT_MIN = 0 DEFAULT_MIN = 0
DEFAULT_MAX = 100000 DEFAULT_MAX = 100000
def flow_schema(dps): def flow_schema(dps):
# """Return schema used in config flow.""" """Return schema used in config flow."""
return { return {
vol.Optional(CONF_MIN_VALUE, default=DEFAULT_MIN): vol.All( vol.Optional(CONF_MIN_VALUE, default=DEFAULT_MIN): vol.All(
vol.Coerce(float), vol.Range(min=-1000000.0, max=1000000.0), vol.Coerce(float), vol.Range(min=-1000000.0, max=1000000.0),
@@ -59,7 +60,6 @@ class LocaltuyaNumber(LocalTuyaEntity, NumberEntity):
@property @property
def min_value(self) -> float: def min_value(self) -> float:
"""Return the minimum value.""" """Return the minimum value."""
return self._minValue return self._minValue
@property @property
@@ -76,7 +76,6 @@ class LocaltuyaNumber(LocalTuyaEntity, NumberEntity):
"""Update the current value.""" """Update the current value."""
await self._device.set_dp(value, self._dp_id) await self._device.set_dp(value, self._dp_id)
def status_updated(self): def status_updated(self):
"""Device status was updated.""" """Device status was updated."""
state = self.dps(self._dp_id) state = self.dps(self._dp_id)

View File

@@ -18,7 +18,7 @@ CONF_OPTIONS_FRIENDLY = "select_options_friendly"
def flow_schema(dps): def flow_schema(dps):
# """Return schema used in config flow.""" """Return schema used in config flow."""
return { return {
vol.Required(CONF_OPTIONS): str, vol.Required(CONF_OPTIONS): str,
vol.Optional(CONF_OPTIONS_FRIENDLY): str, vol.Optional(CONF_OPTIONS_FRIENDLY): str,
@@ -40,7 +40,7 @@ class LocaltuyaSelect(LocalTuyaEntity, SelectEntity):
self._state = STATE_UNKNOWN self._state = STATE_UNKNOWN
self._validOptions = self._config.get(CONF_OPTIONS).split(';') self._validOptions = self._config.get(CONF_OPTIONS).split(';')
#Set Display options # Set Display options
self._displayOptions = [] self._displayOptions = []
displayOptionsStr = "" displayOptionsStr = ""
if (CONF_OPTIONS_FRIENDLY in self._config): if (CONF_OPTIONS_FRIENDLY in self._config):
@@ -52,14 +52,17 @@ class LocaltuyaSelect(LocalTuyaEntity, SelectEntity):
elif (len(displayOptionsStr.strip()) > 0): elif (len(displayOptionsStr.strip()) > 0):
self._displayOptions.append(displayOptionsStr) self._displayOptions.append(displayOptionsStr)
else: else:
#Default display string to raw string # Default display string to raw string
_LOGGER.debug("No Display options configured - defaulting to raw values") _LOGGER.debug("No Display options configured - defaulting to raw values")
self._displayOptions = self._validOptions self._displayOptions = self._validOptions
_LOGGER.debug("Total Raw Options: " + str(len(self._validOptions)) + " - Total Display Options: " + str(len(self._displayOptions))) _LOGGER.debug("Total Raw Options: " + str(len(self._validOptions)) +
" - Total Display Options: " + str(len(self._displayOptions)))
if (len(self._validOptions) > len(self._displayOptions)): if (len(self._validOptions) > len(self._displayOptions)):
#If list of display items smaller than list of valid items, then default remaining items to be the raw value # If list of display items smaller than list of valid items,
_LOGGER.debug("Valid options is larger than display options - filling up with raw values") # then default remaining items to be the raw value
_LOGGER.debug("Valid options is larger than display options - \
filling up with raw values")
for i in range(len(self._displayOptions), len(self._validOptions)): for i in range(len(self._displayOptions), len(self._validOptions)):
self._displayOptions.append(self._validOptions[i]) self._displayOptions.append(self._validOptions[i])
@@ -84,7 +87,6 @@ class LocaltuyaSelect(LocalTuyaEntity, SelectEntity):
_LOGGER.debug("Sending Option: " + option + " -> " + optionValue) _LOGGER.debug("Sending Option: " + option + " -> " + optionValue)
await self._device.set_dp(optionValue, self._dp_id) await self._device.set_dp(optionValue, self._dp_id)
def status_updated(self): def status_updated(self):
"""Device status was updated.""" """Device status was updated."""
state = self.dps(self._dp_id) state = self.dps(self._dp_id)