Bump tuyaha to 0.0.10 and fix set temperature issues (#45732)
This commit is contained in:
parent
1bb535aa67
commit
3c26235e78
11 changed files with 318 additions and 52 deletions
|
@ -23,7 +23,6 @@ from homeassistant.const import (
|
|||
from homeassistant.core import callback
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
# pylint:disable=unused-import
|
||||
from .const import (
|
||||
CONF_BRIGHTNESS_RANGE_MODE,
|
||||
CONF_COUNTRYCODE,
|
||||
|
@ -35,17 +34,19 @@ from .const import (
|
|||
CONF_MIN_TEMP,
|
||||
CONF_QUERY_DEVICE,
|
||||
CONF_QUERY_INTERVAL,
|
||||
CONF_SET_TEMP_DIVIDED,
|
||||
CONF_SUPPORT_COLOR,
|
||||
CONF_TEMP_DIVIDER,
|
||||
CONF_TEMP_STEP_OVERRIDE,
|
||||
CONF_TUYA_MAX_COLTEMP,
|
||||
DEFAULT_DISCOVERY_INTERVAL,
|
||||
DEFAULT_QUERY_INTERVAL,
|
||||
DEFAULT_TUYA_MAX_COLTEMP,
|
||||
DOMAIN,
|
||||
TUYA_DATA,
|
||||
TUYA_PLATFORMS,
|
||||
TUYA_TYPE_NOT_QUERY,
|
||||
)
|
||||
from .const import DOMAIN # pylint:disable=unused-import
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -66,6 +67,7 @@ ERROR_DEV_NOT_FOUND = "dev_not_found"
|
|||
|
||||
RESULT_AUTH_FAILED = "invalid_auth"
|
||||
RESULT_CONN_ERROR = "cannot_connect"
|
||||
RESULT_SINGLE_INSTANCE = "single_instance_allowed"
|
||||
RESULT_SUCCESS = "success"
|
||||
|
||||
RESULT_LOG_MESSAGE = {
|
||||
|
@ -123,7 +125,7 @@ class TuyaConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
async def async_step_user(self, user_input=None):
|
||||
"""Handle a flow initialized by the user."""
|
||||
if self._async_current_entries():
|
||||
return self.async_abort(reason="single_instance_allowed")
|
||||
return self.async_abort(reason=RESULT_SINGLE_INSTANCE)
|
||||
|
||||
errors = {}
|
||||
|
||||
|
@ -257,7 +259,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
|||
|
||||
if self.config_entry.state != config_entries.ENTRY_STATE_LOADED:
|
||||
_LOGGER.error("Tuya integration not yet loaded")
|
||||
return self.async_abort(reason="cannot_connect")
|
||||
return self.async_abort(reason=RESULT_CONN_ERROR)
|
||||
|
||||
if user_input is not None:
|
||||
dev_ids = user_input.get(CONF_LIST_DEVICES)
|
||||
|
@ -323,11 +325,14 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
|||
|
||||
def _get_device_schema(self, device_type, curr_conf, device):
|
||||
"""Return option schema for device."""
|
||||
if device_type != device.device_type():
|
||||
return None
|
||||
schema = None
|
||||
if device_type == "light":
|
||||
return self._get_light_schema(curr_conf, device)
|
||||
if device_type == "climate":
|
||||
return self._get_climate_schema(curr_conf, device)
|
||||
return None
|
||||
schema = self._get_light_schema(curr_conf, device)
|
||||
elif device_type == "climate":
|
||||
schema = self._get_climate_schema(curr_conf, device)
|
||||
return schema
|
||||
|
||||
@staticmethod
|
||||
def _get_light_schema(curr_conf, device):
|
||||
|
@ -374,6 +379,8 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
|||
"""Create option schema for climate device."""
|
||||
unit = device.temperature_unit()
|
||||
def_unit = TEMP_FAHRENHEIT if unit == "FAHRENHEIT" else TEMP_CELSIUS
|
||||
supported_steps = device.supported_temperature_steps()
|
||||
default_step = device.target_temperature_step()
|
||||
|
||||
config_schema = vol.Schema(
|
||||
{
|
||||
|
@ -389,6 +396,14 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
|||
CONF_CURR_TEMP_DIVIDER,
|
||||
default=curr_conf.get(CONF_CURR_TEMP_DIVIDER, 0),
|
||||
): vol.All(vol.Coerce(int), vol.Clamp(min=0)),
|
||||
vol.Optional(
|
||||
CONF_SET_TEMP_DIVIDED,
|
||||
default=curr_conf.get(CONF_SET_TEMP_DIVIDED, True),
|
||||
): bool,
|
||||
vol.Optional(
|
||||
CONF_TEMP_STEP_OVERRIDE,
|
||||
default=curr_conf.get(CONF_TEMP_STEP_OVERRIDE, default_step),
|
||||
): vol.In(supported_steps),
|
||||
vol.Optional(
|
||||
CONF_MIN_TEMP,
|
||||
default=curr_conf.get(CONF_MIN_TEMP, 0),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue