"""Support for Tuya select."""
from __future__ import annotations

from typing import cast

from tuya_iot import TuyaDevice, TuyaDeviceManager
from tuya_iot.device import TuyaDeviceStatusRange

from homeassistant.components.select import SelectEntity, SelectEntityDescription
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ENTITY_CATEGORY_CONFIG
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import HomeAssistantTuyaData
from .base import EnumTypeData, TuyaEntity
from .const import (
    DEVICE_CLASS_TUYA_BASIC_ANTI_FLICKR,
    DEVICE_CLASS_TUYA_BASIC_NIGHTVISION,
    DEVICE_CLASS_TUYA_DECIBEL_SENSITIVITY,
    DEVICE_CLASS_TUYA_IPC_WORK_MODE,
    DEVICE_CLASS_TUYA_LED_TYPE,
    DEVICE_CLASS_TUYA_LIGHT_MODE,
    DEVICE_CLASS_TUYA_MOTION_SENSITIVITY,
    DEVICE_CLASS_TUYA_RECORD_MODE,
    DEVICE_CLASS_TUYA_RELAY_STATUS,
    DOMAIN,
    TUYA_DISCOVERY_NEW,
    DPCode,
)

# All descriptions can be found here. Mostly the Enum data types in the
# default instructions set of each category end up being a select.
# https://developer.tuya.com/en/docs/iot/standarddescription?id=K9i5ql6waswzq
SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = {
    # Coffee maker
    # https://developer.tuya.com/en/docs/iot/categorykfj?id=Kaiuz2p12pc7f
    "kfj": (
        SelectEntityDescription(
            key=DPCode.CUP_NUMBER,
            name="Cups",
            icon="mdi:numeric",
        ),
        SelectEntityDescription(
            key=DPCode.CONCENTRATION_SET,
            name="Concentration",
            icon="mdi:altimeter",
            entity_category=ENTITY_CATEGORY_CONFIG,
        ),
        SelectEntityDescription(
            key=DPCode.MATERIAL,
            name="Material",
            entity_category=ENTITY_CATEGORY_CONFIG,
        ),
        SelectEntityDescription(
            key=DPCode.MODE,
            name="Mode",
            icon="mdi:coffee",