Kaynağa Gözat

Migrate config.

- "auto" no longer allowed as a device type, a concrete type must be selected.
    This opens the door to having different devices with the same DPS but
    different presets for example.  Such devices cannot be distinguished
    automatically so we need the user to explicitly set each one.
- "child_lock" renamed to "lock"
- "display_light" renamed to "light"
     This opens the door to adding other light and lock devices that are not
     display lights or child locks.
- No longer import yaml config.
     As the config format has changed, no longer import yaml config.
     Although it was marked deprecated only for a short time, the yaml was
     always imported, so existing configurations will work from the device
     registry import after migration.
- Update the config flow.
     - Break config into three stages.
         Information gathered based on earlier config can be used to improve
         the flow by filtering only available options.
     - Filter devices to just those that are possible matches.
     - Filter entities to those available on the selected device.
Jason Rumney 4 yıl önce
ebeveyn
işleme
ae418c840a

+ 37 - 33
custom_components/tuya_local/__init__.py

@@ -8,46 +8,56 @@ https://github.com/codetheweb/tuyapi/issues/31.
 """
 import logging
 
-import homeassistant.helpers.config_validation as cv
-import voluptuous as vol
 from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
+from homeassistant.const import CONF_HOST
 from homeassistant.core import HomeAssistant
 
-from .configuration import individual_config_schema
 from .const import (
-    CONF_CHILD_LOCK,
     CONF_CLIMATE,
     CONF_DEVICE_ID,
-    CONF_DISPLAY_LIGHT,
     CONF_FAN,
     CONF_HUMIDIFIER,
+    CONF_LIGHT,
+    CONF_LOCAL_KEY,
+    CONF_LOCK,
     CONF_SWITCH,
     CONF_TYPE,
-    CONF_TYPE_AUTO,
     DOMAIN,
 )
 from .device import setup_device, delete_device
 
 _LOGGER = logging.getLogger(__name__)
 
-CONFIG_SCHEMA = vol.Schema(
-    vol.All(
-        cv.deprecated(DOMAIN),
-        {DOMAIN: vol.All(cv.ensure_list, [vol.Schema(individual_config_schema())])},
-    ),
-    extra=vol.ALLOW_EXTRA,
-)
 
-
-async def async_setup(hass: HomeAssistant, config: dict):
-    for device_config in config.get(DOMAIN, []):
-        hass.async_create_task(
-            hass.config_entries.flow.async_init(
-                DOMAIN, context={"source": SOURCE_IMPORT}, data=device_config
-            )
-        )
-
-    return True
+async def async_migrate_entry(hass, entry: ConfigEntry):
+    """Migrate to latest config format."""
+
+    CONF_TYPE_AUTO = "auto"
+    CONF_DISPLAY_LIGHT = "display_light"
+    CONF_CHILD_LOCK = "child_lock"
+
+    if entry.version == 1:
+        # Removal of Auto detection.
+        config = {**entry.data, **entry.options, "name": entry.title}
+        if config[CONF_TYPE] == CONF_TYPE_AUTO:
+            device = setup_device(hass, config)
+            config[CONF_TYPE] = await device.async_inferred_type()
+            entry.data = {
+                CONF_DEVICE_ID: config[CONF_DEVICE_ID],
+                CONF_LOCAL_KEY: config[CONF_LOCAL_KEY],
+                CONF_HOST: config[CONF_HOST],
+            }
+            opts = {**entry.options}
+            opts[CONF_TYPE] = config[CONF_TYPE]
+            if CONF_CHILD_LOCK in config:
+                opts.pop(CONF_CHILD_LOCK)
+                opts[CONF_LOCK] = config[CONF_CHILD_LOCK]
+            if CONF_DISPLAY_LIGHT in config:
+                opts.pop(CONF_DISPLAY_LIGHT)
+                opts[CONF_LIGHT] = config[CONF_DISPLAY_LIGHT]
+
+            entry.options = {**opts}
+            entry.version = 2
 
 
 async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
@@ -55,21 +65,15 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
     config = {**entry.data, **entry.options, "name": entry.title}
     device = setup_device(hass, config)
 
-    if config[CONF_TYPE] == CONF_TYPE_AUTO:
-        config[CONF_TYPE] = await device.async_inferred_type()
-        if config[CONF_TYPE] is None:
-            raise ValueError(f"Unable to detect type for device {device.name}")
-        entry.data = {**config}
-
     if config.get(CONF_CLIMATE, False) is True:
         hass.async_create_task(
             hass.config_entries.async_forward_entry_setup(entry, "climate")
         )
-    if config.get(CONF_DISPLAY_LIGHT, False) is True:
+    if config.get(CONF_LIGHT, False) is True:
         hass.async_create_task(
             hass.config_entries.async_forward_entry_setup(entry, "light")
         )
-    if config.get(CONF_CHILD_LOCK, False) is True:
+    if config.get(CONF_LOCK, False) is True:
         hass.async_create_task(
             hass.config_entries.async_forward_entry_setup(entry, "lock")
         )
@@ -100,9 +104,9 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
 
     if CONF_CLIMATE in data:
         await hass.config_entries.async_forward_entry_unload(entry, "climate")
-    if CONF_DISPLAY_LIGHT in data:
+    if CONF_LIGHT in data:
         await hass.config_entries.async_forward_entry_unload(entry, "light")
-    if CONF_CHILD_LOCK in data:
+    if CONF_LOCK in data:
         await hass.config_entries.async_forward_entry_unload(entry, "lock")
     if CONF_SWITCH in data:
         await hass.config_entries.async_forward_entry_unload(entry, "switch")

+ 0 - 6
custom_components/tuya_local/climate.py

@@ -8,7 +8,6 @@ from .const import (
     CONF_CLIMATE,
     CONF_DEVICE_ID,
     CONF_TYPE,
-    CONF_TYPE_AUTO,
 )
 from .generic.climate import TuyaLocalClimate
 from .helpers.device_config import config_for_legacy_use
@@ -21,11 +20,6 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
     data = hass.data[DOMAIN][discovery_info[CONF_DEVICE_ID]]
     device = data["device"]
 
-    if discovery_info[CONF_TYPE] == CONF_TYPE_AUTO:
-        raise ValueError(
-            f"Device type for {device.name} not resolved before climate init"
-        )
-
     cfg = config_for_legacy_use(discovery_info[CONF_TYPE])
     ecfg = cfg.primary_entity
     if ecfg.entity != "climate":

+ 42 - 26
custom_components/tuya_local/config_flow.py

@@ -5,15 +5,17 @@ from homeassistant import config_entries, data_entry_flow
 from homeassistant.const import CONF_HOST, CONF_NAME
 from homeassistant.core import HomeAssistant, callback
 
-from . import DOMAIN, individual_config_schema
+from . import DOMAIN
+from .configuration import individual_config_schema
 from .device import TuyaLocalDevice
-from .const import CONF_DEVICE_ID, CONF_LOCAL_KEY
+from .const import CONF_DEVICE_ID, CONF_LOCAL_KEY, CONF_TYPE
+from .helpers.device_config import config_for_legacy_use
 
 _LOGGER = logging.getLogger(__name__)
 
 
 class ConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
-    VERSION = 1
+    VERSION = 2
     CONNECTION_CLASS = config_entries.CONN_CLASS_LOCAL_POLL
 
     async def async_step_user(self, user_input=None):
@@ -23,11 +25,10 @@ class ConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
             await self.async_set_unique_id(user_input[CONF_DEVICE_ID])
             self._abort_if_unique_id_configured()
 
-            device = await async_test_connection(user_input, self.hass)
-            if device:
-                title = user_input[CONF_NAME]
-                del user_input[CONF_NAME]
-                return self.async_create_entry(title=title, data=user_input)
+            self.device = await async_test_connection(user_input, self.hass)
+            if self.device:
+                self.data = user_input
+                return self.async_step_select_type()
             else:
                 errors["base"] = "connection"
 
@@ -37,25 +38,40 @@ class ConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
             errors=errors,
         )
 
-    async def async_step_import(self, user_input):
-        title = user_input[CONF_NAME]
-        del user_input[CONF_NAME]
-        user_input[config_entries.SOURCE_IMPORT] = True
-
-        current_entries = self.hass.config_entries.async_entries(DOMAIN)
-        existing_entry = next(
-            (
-                entry
-                for entry in current_entries
-                if entry.data[CONF_DEVICE_ID] == user_input[CONF_DEVICE_ID]
-            ),
-            None,
-        )
-        if existing_entry is not None:
-            return self.async_abort(reason="imported")
+    async def async_step_select_type(self, user_input=None):
+        if user_input is not None:
+            self.data[CONF_TYPE] = user_input[CONF_TYPE]
+
+        types = []
+        async for type in self.device.async_possible_types():
+            types.append(type)
+        if types:
+            return self.async_show_form(
+                step_id="type",
+                data_schema=vol.Schema({vol.Required(CONF_TYPE): vol.In(types)}),
+            )
         else:
-            await self.async_set_unique_id(user_input[CONF_DEVICE_ID])
-            return self.async_create_entry(title=title, data=user_input)
+            return self.async_abort(reason="not_supported")
+
+    async def async_step_choose_entities(self, user_input=None):
+        if user_input is not None:
+            title = user_input[CONF_NAME]
+            del user_input[CONF_NAME]
+
+            return self.async_create_entry(
+                title=title, data={**self.data, **user_input}
+            )
+        config = config_for_legacy_use(self.data[CONF_TYPE])
+        schema = {vol.Required(CONF_NAME, default=config.name): str}
+        e = config.primary_entity
+        schema[vol.Optional(e.entity, default=True)] = bool
+        for e in config.secondary_entities():
+            schema[vol.Optional(e.entity, default=not e.deprecated)] = bool
+
+        return self.async_show_form(
+            step_id="entities",
+            data_schema=vol.Schema(schema),
+        )
 
     @staticmethod
     @callback

+ 18 - 11
custom_components/tuya_local/configuration.py

@@ -2,22 +2,21 @@ import voluptuous as vol
 from homeassistant.const import CONF_HOST, CONF_NAME
 
 from .const import (
-    CONF_CHILD_LOCK,
     CONF_CLIMATE,
     CONF_DEVICE_ID,
-    CONF_DISPLAY_LIGHT,
     CONF_FAN,
     CONF_HUMIDIFIER,
+    CONF_LIGHT,
     CONF_LOCAL_KEY,
+    CONF_LOCK,
     CONF_SWITCH,
     CONF_TYPE,
-    CONF_TYPE_AUTO,
 )
 from .helpers.device_config import available_configs, TuyaDeviceConfig
 
 
 def conf_types():
-    types = [CONF_TYPE_AUTO]
+    types = []
     for cfg in available_configs():
         parsed = TuyaDeviceConfig(cfg)
         types.append(parsed.legacy_type)
@@ -25,15 +24,17 @@ def conf_types():
 
 
 INDIVIDUAL_CONFIG_SCHEMA_TEMPLATE = [
-    {"key": CONF_NAME, "type": str, "required": True, "option": False},
     {"key": CONF_HOST, "type": str, "required": True, "option": True},
     {"key": CONF_DEVICE_ID, "type": str, "required": True, "option": False},
     {"key": CONF_LOCAL_KEY, "type": str, "required": True, "option": True},
+]
+
+STAGE2_CONFIG_SCHEMA_TEMPLATE = [
+    {"key": CONF_NAME, "type": str, "required": True, "option": False},
     {
         "key": CONF_TYPE,
         "type": vol.In(conf_types()),
-        "required": False,
-        "default": CONF_TYPE_AUTO,
+        "required": True,
         "option": True,
     },
     {
@@ -44,14 +45,14 @@ INDIVIDUAL_CONFIG_SCHEMA_TEMPLATE = [
         "option": True,
     },
     {
-        "key": CONF_DISPLAY_LIGHT,
+        "key": CONF_LIGHT,
         "type": bool,
         "required": False,
         "default": False,
         "option": True,
     },
     {
-        "key": CONF_CHILD_LOCK,
+        "key": CONF_LOCK,
         "type": bool,
         "required": False,
         "default": False,
@@ -81,10 +82,16 @@ INDIVIDUAL_CONFIG_SCHEMA_TEMPLATE = [
 ]
 
 
-def individual_config_schema(defaults={}, options_only=False):
+def individual_config_schema(defaults={}, options_only=False, stage=1):
     output = {}
+    if options_only:
+        schema = [*INDIVIDUAL_CONFIG_SCHEMA_TEMPLATE, *STAGE2_CONFIG_SCHEMA_TEMPLATE]
+    elif stage == 1:
+        schema = INDIVIDUAL_CONFIG_SCHEMA_TEMPLATE
+    else:
+        schema = STAGE2_CONFIG_SCHEMA_TEMPLATE
 
-    for prop in INDIVIDUAL_CONFIG_SCHEMA_TEMPLATE:
+    for prop in schema:
         if options_only and not prop.get("option"):
             continue
 

+ 2 - 3
custom_components/tuya_local/const.py

@@ -5,11 +5,10 @@ DOMAIN = "tuya_local"
 CONF_DEVICE_ID = "device_id"
 CONF_LOCAL_KEY = "local_key"
 CONF_TYPE = "type"
-CONF_TYPE_AUTO = "auto"
 CONF_CLIMATE = "climate"
-CONF_DISPLAY_LIGHT = "display_light"
-CONF_CHILD_LOCK = "child_lock"
 CONF_FAN = "fan"
+CONF_LIGHT = "light"
+CONF_LOCK = "lock"
 CONF_SWITCH = "switch"
 CONF_HUMIDIFIER = "humidifier"
 API_PROTOCOL_VERSIONS = [3.3, 3.1]

+ 8 - 9
custom_components/tuya_local/device.py

@@ -85,21 +85,20 @@ class TuyaLocalDevice(object):
     def temperature_unit(self):
         return self._TEMPERATURE_UNIT
 
-    async def async_inferred_type(self):
-
+    async def async_possible_types(self):
         cached_state = self._get_cached_state()
-        # cached state should have "updated_at" timestamp if it has anything,
-        # so use 1 as the threshold for judging if dps have been fetched.
         if len(cached_state) <= 1:
             await self.async_refresh()
             cached_state = self._get_cached_state()
 
-        _LOGGER.info(
-            f"{self.name} inferring device type from cached state: {cached_state}"
-        )
+        for match in possible_matches(cached_state):
+            yield match
+
+    async def async_inferred_type(self):
         best_match = None
         best_quality = 0
-        for config in possible_matches(cached_state):
+        cached_state = self._get_cached_state()
+        async for config in self.async_possible_types():
             quality = config.match_quality(cached_state)
             _LOGGER.info(
                 f"{self.name} considering {config.name} with quality {quality}"
@@ -109,7 +108,7 @@ class TuyaLocalDevice(object):
                 best_match = config
 
         if best_match is None:
-            _LOGGER.warning(f"Detection for {self.name} failed")
+            _LOGGER.warning(f"Detection for {self.name} with dps {cached_state} failed")
             return None
 
         return best_match.legacy_type

+ 0 - 4
custom_components/tuya_local/fan.py

@@ -8,7 +8,6 @@ from .const import (
     CONF_FAN,
     CONF_DEVICE_ID,
     CONF_TYPE,
-    CONF_TYPE_AUTO,
 )
 from .generic.fan import TuyaLocalFan
 from .helpers.device_config import config_for_legacy_use
@@ -21,9 +20,6 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
     data = hass.data[DOMAIN][discovery_info[CONF_DEVICE_ID]]
     device = data["device"]
 
-    if discovery_info[CONF_TYPE] == CONF_TYPE_AUTO:
-        raise ValueError(f"Device type for {device.name} not resolved before fan init")
-
     cfg = config_for_legacy_use(discovery_info[CONF_TYPE])
     ecfg = cfg.primary_entity
     if ecfg.entity != "fan":

+ 0 - 6
custom_components/tuya_local/humidifier.py

@@ -8,7 +8,6 @@ from .const import (
     CONF_HUMIDIFIER,
     CONF_DEVICE_ID,
     CONF_TYPE,
-    CONF_TYPE_AUTO,
 )
 from .generic.humidifier import TuyaLocalHumidifier
 from .helpers.device_config import config_for_legacy_use
@@ -21,11 +20,6 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
     data = hass.data[DOMAIN][discovery_info[CONF_DEVICE_ID]]
     device = data["device"]
 
-    if discovery_info[CONF_TYPE] == CONF_TYPE_AUTO:
-        raise ValueError(
-            f"Device type for {device.name} not resolved before humidifier init"
-        )
-
     cfg = config_for_legacy_use(discovery_info[CONF_TYPE])
     ecfg = cfg.primary_entity
     if ecfg.entity != "humidifier":

+ 3 - 9
custom_components/tuya_local/light.py

@@ -6,9 +6,8 @@ import logging
 from . import DOMAIN
 from .const import (
     CONF_DEVICE_ID,
-    CONF_DISPLAY_LIGHT,
+    CONF_LIGHT,
     CONF_TYPE,
-    CONF_TYPE_AUTO,
 )
 from .generic.light import TuyaLocalLight
 from .helpers.device_config import config_for_legacy_use
@@ -21,11 +20,6 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
     data = hass.data[DOMAIN][discovery_info[CONF_DEVICE_ID]]
     device = data["device"]
 
-    if discovery_info[CONF_TYPE] == CONF_TYPE_AUTO:
-        raise ValueError(
-            f"Device type for {device.name} not resolved before light init"
-        )
-
     cfg = config_for_legacy_use(discovery_info[CONF_TYPE])
     ecfg = cfg.primary_entity
     if ecfg.entity != "light":
@@ -37,8 +31,8 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
     if ecfg.deprecated:
         _LOGGER.warning(ecfg.deprecation_message)
 
-    data[CONF_DISPLAY_LIGHT] = TuyaLocalLight(device, ecfg)
-    async_add_entities([data[CONF_DISPLAY_LIGHT]])
+    data[CONF_LIGHT] = TuyaLocalLight(device, ecfg)
+    async_add_entities([data[CONF_LIGHT]])
     _LOGGER.debug(f"Adding light for {discovery_info[CONF_TYPE]}")
 
 

+ 3 - 7
custom_components/tuya_local/lock.py

@@ -5,10 +5,9 @@ import logging
 
 from . import DOMAIN
 from .const import (
-    CONF_CHILD_LOCK,
     CONF_DEVICE_ID,
+    CONF_LOCK,
     CONF_TYPE,
-    CONF_TYPE_AUTO,
 )
 from .generic.lock import TuyaLocalLock
 from .helpers.device_config import config_for_legacy_use
@@ -22,9 +21,6 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
     data = hass.data[DOMAIN][discovery_info[CONF_DEVICE_ID]]
     device = data["device"]
 
-    if discovery_info[CONF_TYPE] == CONF_TYPE_AUTO:
-        raise ValueError(f"Device type for {device.name} not resolved before lock init")
-
     cfg = config_for_legacy_use(discovery_info[CONF_TYPE])
     ecfg = cfg.primary_entity
     if ecfg.entity != "lock":
@@ -36,8 +32,8 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
     if ecfg.deprecated:
         _LOGGER.warning(ecfg.deprecation_message)
 
-    data[CONF_CHILD_LOCK] = TuyaLocalLock(device, ecfg)
-    async_add_entities([data[CONF_CHILD_LOCK]])
+    data[CONF_LOCK] = TuyaLocalLock(device, ecfg)
+    async_add_entities([data[CONF_LOCK]])
     _LOGGER.debug(f"Adding lock for {discovery_info[CONF_TYPE]}")
 
 

+ 0 - 6
custom_components/tuya_local/switch.py

@@ -8,7 +8,6 @@ from .const import (
     CONF_DEVICE_ID,
     CONF_SWITCH,
     CONF_TYPE,
-    CONF_TYPE_AUTO,
 )
 from .generic.switch import TuyaLocalSwitch
 from .helpers.device_config import config_for_legacy_use
@@ -21,11 +20,6 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
     data = hass.data[DOMAIN][discovery_info[CONF_DEVICE_ID]]
     device = data["device"]
 
-    if discovery_info[CONF_TYPE] == CONF_TYPE_AUTO:
-        raise ValueError(
-            f"Device type for {device.name} not resolved before switch init"
-        )
-
     cfg = config_for_legacy_use(discovery_info[CONF_TYPE])
     ecfg = cfg.primary_entity
     if ecfg.entity != "switch":

+ 54 - 45
custom_components/tuya_local/translations/en.json

@@ -1,59 +1,68 @@
 {
-  "title": "Tuya Local",
-  "config": {
-    "step": {
-      "user": {
-        "title": "Configure your Tuya Local device",
-        "description": "[Follow these instructions to find your device id and local key.](https://github.com/codetheweb/tuyapi/blob/master/docs/SETUP.md)",
-        "data": {
-          "name": "Name",
-          "host": "IP address or hostname",
-          "device_id": "Device ID (uuid)",
-          "local_key": "Local key",
-          "type": "Device type",
-          "climate": "Include a climate entity (unsupported on switches)",
-          "display_light": "Include LED display as a light entity (Goldair only)",
-          "child_lock": "Include child lock as a lock entity (unsupported on fans and switches)",
-          "switch": "Include a switch entity (switches only)",
-          "humidifier": "Include a humidifier entity (humidifiers and dehumidifiers only)",
-	  "fan": "Include a fan entitiy (fans, humidifiers and dehumidifiers)"
-        }
-      }
+    "title": "Tuya Local",
+    "config": {
+	"step": {
+	    "user": {
+		"title": "Configure your Tuya Local device",
+		"description": "[Follow these instructions to find your device id and local key.](https://github.com/codetheweb/tuyapi/blob/master/docs/SETUP.md)",
+		"data": {
+		    "host": "IP address or hostname",
+		    "device_id": "Device ID (uuid)",
+		    "local_key": "Local key",
+		}
+            }
+	    "type": {
+		"title": "Choose the type of device",
+		"description": "Choose the type that matches your device",
+		"data": {
+		    "type": "Device type",
+		}
+	    }
+	    "entities": {
+		"title": "Device details",
+		"description": "Choose a name for this device, and which entities will be enabled"
+		"data": {
+		    "name": "Name",
+		    "humidifier": "Include a humidifier entity",
+		    "fan": "Include a fan entitiy"
+		    "climate": "Include a climate entity",
+		    "light": "Include a light entity",
+		    "lock": "Include a lock entity",
+		    "switch": "Include a switch entity",
+		}
+	}
     },
     "abort": {
-      "already_configured": "A device with that ID has already been added.",
-      "imported_connection": "Unable to connect to your device with the configured details."
+	"already_configured": "A device with that ID has already been added.",
+	"imported_connection": "Unable to connect to your device with the configured details."
     },
     "error": {
-      "connection": "Unable to connect to your device with those details. It could be an intermittent issue, or they may be incorrect."
+	"connection": "Unable to connect to your device with those details. It could be an intermittent issue, or they may be incorrect."
     }
-  },
-  "options": {
+},
+"options": {
     "step": {
-      "user": {
-        "title": "Configure your Tuya Local device",
-        "description": "[Follow these instructions to find your local key.](https://github.com/codetheweb/tuyapi/blob/master/docs/SETUP.md)",
-        "data": {
-          "host": "IP address or hostname",
-          "local_key": "Local key",
-          "type": "Device type",
-          "climate": "Include device as a climate entity (unsupported for switches)",
-          "display_light": "Include LED display as light entity (Goldair only)",
-          "child_lock": "Include child lock as lock entity (unsupported on fans and switches)",
-	    "switch": "Include device as a switch entity (switches only)",
-          "humidifier": "Include a humidifier entity (humidifiers and dehumidifiers only)",
-	  "fan": "Include a fan entitiy (fans, humidifiers and dehumidifiers)"
-        }
-      },
-      "imported": {
-        "title": "Configured via yaml"
-      }
+	"user": {
+            "title": "Configure your Tuya Local device",
+            "description": "[Follow these instructions to find your local key.](https://github.com/codetheweb/tuyapi/blob/master/docs/SETUP.md)",
+            "data": {
+		"host": "IP address or hostname",
+		"local_key": "Local key",
+		"type": "Device type",
+		"climate": "Include device as a climate entity (unsupported for switches)",
+		"display_light": "Include LED display as light entity (Goldair only)",
+		"child_lock": "Include child lock as lock entity (unsupported on fans and switches)",
+		"switch": "Include device as a switch entity (switches only)",
+		"humidifier": "Include a humidifier entity (humidifiers and dehumidifiers only)",
+		"fan": "Include a fan entitiy (fans, humidifiers and dehumidifiers)"
+            }
+	},
     },
     "error": {
-      "connection": "Unable to connect to your device with those details. It could be an intermittent issue, or they may be incorrect."
+	"connection": "Unable to connect to your device with those details. It could be an intermittent issue, or they may be incorrect."
     },
     "abort": {
-      "imported": "This device is configured via your `configuration.yaml` file. To configure it via the UI, remove it from `configuration.yaml` first then add it here."
+	"not_supported": "No configuration matching this device was found"
     }
   }
 }

+ 2 - 2
tests/test_light.py

@@ -3,7 +3,7 @@ from pytest_homeassistant_custom_component.common import MockConfigEntry
 from unittest.mock import AsyncMock, Mock
 
 from custom_components.tuya_local.const import (
-    CONF_DISPLAY_LIGHT,
+    CONF_LIGHT,
     CONF_DEVICE_ID,
     CONF_TYPE,
     DOMAIN,
@@ -29,5 +29,5 @@ async def test_init_entry(hass):
     hass.data[DOMAIN]["dummy"]["device"] = m_device
 
     await async_setup_entry(hass, entry, m_add_entities)
-    assert type(hass.data[DOMAIN]["dummy"][CONF_DISPLAY_LIGHT]) == TuyaLocalLight
+    assert type(hass.data[DOMAIN]["dummy"][CONF_LIGHT]) == TuyaLocalLight
     m_add_entities.assert_called_once()

+ 2 - 2
tests/test_lock.py

@@ -3,7 +3,7 @@ from pytest_homeassistant_custom_component.common import MockConfigEntry
 from unittest.mock import AsyncMock, Mock
 
 from custom_components.tuya_local.const import (
-    CONF_CHILD_LOCK,
+    CONF_LOCK,
     CONF_DEVICE_ID,
     CONF_TYPE,
     DOMAIN,
@@ -29,5 +29,5 @@ async def test_init_entry(hass):
     hass.data[DOMAIN]["dummy"]["device"] = m_device
 
     await async_setup_entry(hass, entry, m_add_entities)
-    assert type(hass.data[DOMAIN]["dummy"][CONF_CHILD_LOCK]) == TuyaLocalLock
+    assert type(hass.data[DOMAIN]["dummy"][CONF_LOCK]) == TuyaLocalLock
     m_add_entities.assert_called_once()