Add Dimmer Switch (tgkg) device support to Tuya (#58134)
This commit is contained in:
parent
c204196a7a
commit
7353ea5416
5 changed files with 77 additions and 1 deletions
|
@ -75,8 +75,9 @@ CONF_PASSWORD = "password"
|
||||||
CONF_COUNTRY_CODE = "country_code"
|
CONF_COUNTRY_CODE = "country_code"
|
||||||
CONF_APP_TYPE = "tuya_app_type"
|
CONF_APP_TYPE = "tuya_app_type"
|
||||||
|
|
||||||
DEVICE_CLASS_TUYA_RELAY_STATUS = "tuya__relay_status"
|
DEVICE_CLASS_TUYA_LED_TYPE = "tuya__led_type"
|
||||||
DEVICE_CLASS_TUYA_LIGHT_MODE = "tuya__light_mode"
|
DEVICE_CLASS_TUYA_LIGHT_MODE = "tuya__light_mode"
|
||||||
|
DEVICE_CLASS_TUYA_RELAY_STATUS = "tuya__relay_status"
|
||||||
|
|
||||||
TUYA_DISCOVERY_NEW = "tuya_discovery_new"
|
TUYA_DISCOVERY_NEW = "tuya_discovery_new"
|
||||||
TUYA_HA_SIGNAL_UPDATE_ENTITY = "tuya_entry_update"
|
TUYA_HA_SIGNAL_UPDATE_ENTITY = "tuya_entry_update"
|
||||||
|
@ -136,6 +137,7 @@ class DPCode(str, Enum):
|
||||||
BRIGHT_VALUE = "bright_value" # Brightness
|
BRIGHT_VALUE = "bright_value" # Brightness
|
||||||
BRIGHT_VALUE_1 = "bright_value_1"
|
BRIGHT_VALUE_1 = "bright_value_1"
|
||||||
BRIGHT_VALUE_2 = "bright_value_2"
|
BRIGHT_VALUE_2 = "bright_value_2"
|
||||||
|
BRIGHT_VALUE_3 = "bright_value_3"
|
||||||
BRIGHT_VALUE_V2 = "bright_value_v2"
|
BRIGHT_VALUE_V2 = "bright_value_v2"
|
||||||
C_F = "c_f" # Temperature unit switching
|
C_F = "c_f" # Temperature unit switching
|
||||||
CH2O_STATE = "ch2o_state"
|
CH2O_STATE = "ch2o_state"
|
||||||
|
@ -168,6 +170,9 @@ class DPCode(str, Enum):
|
||||||
HUMIDITY_CURRENT = "humidity_current" # Current humidity
|
HUMIDITY_CURRENT = "humidity_current" # Current humidity
|
||||||
HUMIDITY_SET = "humidity_set" # Humidity setting
|
HUMIDITY_SET = "humidity_set" # Humidity setting
|
||||||
HUMIDITY_VALUE = "humidity_value" # Humidity
|
HUMIDITY_VALUE = "humidity_value" # Humidity
|
||||||
|
LED_TYPE_1 = "led_type_1"
|
||||||
|
LED_TYPE_2 = "led_type_2"
|
||||||
|
LED_TYPE_3 = "led_type_3"
|
||||||
LIGHT = "light" # Light
|
LIGHT = "light" # Light
|
||||||
LIGHT_MODE = "light_mode"
|
LIGHT_MODE = "light_mode"
|
||||||
LOCK = "lock" # Lock / Child lock
|
LOCK = "lock" # Lock / Child lock
|
||||||
|
@ -217,6 +222,7 @@ class DPCode(str, Enum):
|
||||||
SWITCH_LED = "switch_led" # Switch
|
SWITCH_LED = "switch_led" # Switch
|
||||||
SWITCH_LED_1 = "switch_led_1"
|
SWITCH_LED_1 = "switch_led_1"
|
||||||
SWITCH_LED_2 = "switch_led_2"
|
SWITCH_LED_2 = "switch_led_2"
|
||||||
|
SWITCH_LED_3 = "switch_led_3"
|
||||||
SWITCH_NIGHT_LIGHT = "switch_night_light"
|
SWITCH_NIGHT_LIGHT = "switch_night_light"
|
||||||
SWITCH_SPRAY = "switch_spray" # Spraying switch
|
SWITCH_SPRAY = "switch_spray" # Spraying switch
|
||||||
SWITCH_USB1 = "switch_usb1" # USB 1
|
SWITCH_USB1 = "switch_usb1" # USB 1
|
||||||
|
|
|
@ -113,6 +113,25 @@ LIGHTS: dict[str, tuple[TuyaLightEntityDescription, ...]] = {
|
||||||
name="Backlight",
|
name="Backlight",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
# Dimmer Switch
|
||||||
|
# https://developer.tuya.com/en/docs/iot/categorytgkg?id=Kaiuz0ktx7m0o
|
||||||
|
"tgkg": (
|
||||||
|
TuyaLightEntityDescription(
|
||||||
|
key=DPCode.SWITCH_LED_1,
|
||||||
|
name="Light",
|
||||||
|
brightness=DPCode.BRIGHT_VALUE_1,
|
||||||
|
),
|
||||||
|
TuyaLightEntityDescription(
|
||||||
|
key=DPCode.SWITCH_LED_2,
|
||||||
|
name="Light 2",
|
||||||
|
brightness=DPCode.BRIGHT_VALUE_2,
|
||||||
|
),
|
||||||
|
TuyaLightEntityDescription(
|
||||||
|
key=DPCode.SWITCH_LED_3,
|
||||||
|
name="Light 3",
|
||||||
|
brightness=DPCode.BRIGHT_VALUE_3,
|
||||||
|
),
|
||||||
|
),
|
||||||
# Dimmer
|
# Dimmer
|
||||||
# https://developer.tuya.com/en/docs/iot/tgq?id=Kaof8ke9il4k4
|
# https://developer.tuya.com/en/docs/iot/tgq?id=Kaof8ke9il4k4
|
||||||
"tgq": (
|
"tgq": (
|
||||||
|
|
|
@ -16,6 +16,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from . import HomeAssistantTuyaData
|
from . import HomeAssistantTuyaData
|
||||||
from .base import EnumTypeData, TuyaEntity
|
from .base import EnumTypeData, TuyaEntity
|
||||||
from .const import (
|
from .const import (
|
||||||
|
DEVICE_CLASS_TUYA_LED_TYPE,
|
||||||
DEVICE_CLASS_TUYA_LIGHT_MODE,
|
DEVICE_CLASS_TUYA_LIGHT_MODE,
|
||||||
DEVICE_CLASS_TUYA_RELAY_STATUS,
|
DEVICE_CLASS_TUYA_RELAY_STATUS,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
|
@ -82,6 +83,40 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = {
|
||||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
# Dimmer Switch
|
||||||
|
# https://developer.tuya.com/en/docs/iot/categorytgkg?id=Kaiuz0ktx7m0o
|
||||||
|
"tgkg": (
|
||||||
|
SelectEntityDescription(
|
||||||
|
key=DPCode.RELAY_STATUS,
|
||||||
|
name="Power on Behavior",
|
||||||
|
device_class=DEVICE_CLASS_TUYA_RELAY_STATUS,
|
||||||
|
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||||
|
),
|
||||||
|
SelectEntityDescription(
|
||||||
|
key=DPCode.LIGHT_MODE,
|
||||||
|
name="Indicator Light Mode",
|
||||||
|
device_class=DEVICE_CLASS_TUYA_LIGHT_MODE,
|
||||||
|
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||||
|
),
|
||||||
|
SelectEntityDescription(
|
||||||
|
key=DPCode.LED_TYPE_1,
|
||||||
|
name="Light Source Type",
|
||||||
|
device_class=DEVICE_CLASS_TUYA_LED_TYPE,
|
||||||
|
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||||
|
),
|
||||||
|
SelectEntityDescription(
|
||||||
|
key=DPCode.LED_TYPE_2,
|
||||||
|
name="Light 2 Source Type",
|
||||||
|
device_class=DEVICE_CLASS_TUYA_LED_TYPE,
|
||||||
|
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||||
|
),
|
||||||
|
SelectEntityDescription(
|
||||||
|
key=DPCode.LED_TYPE_3,
|
||||||
|
name="Light 3 Source Type",
|
||||||
|
device_class=DEVICE_CLASS_TUYA_LED_TYPE,
|
||||||
|
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||||
|
),
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
{
|
{
|
||||||
"state": {
|
"state": {
|
||||||
|
"tuya__led_type": {
|
||||||
|
"halogen": "Halogen",
|
||||||
|
"incandescent": "Incandescent",
|
||||||
|
"led": "LED"
|
||||||
|
},
|
||||||
"tuya__light_mode": {
|
"tuya__light_mode": {
|
||||||
"none": "[%key:common::state::off%]",
|
"none": "[%key:common::state::off%]",
|
||||||
"pos": "Indicate switch location",
|
"pos": "Indicate switch location",
|
||||||
|
@ -7,6 +12,9 @@
|
||||||
},
|
},
|
||||||
"tuya__relay_status": {
|
"tuya__relay_status": {
|
||||||
"last": "Remember last state",
|
"last": "Remember last state",
|
||||||
|
"memory": "Remember last state",
|
||||||
|
"off": "[%key:common::state::off%]",
|
||||||
|
"on": "[%key:common::state::on%]",
|
||||||
"power_off": "[%key:common::state::off%]",
|
"power_off": "[%key:common::state::off%]",
|
||||||
"power_on": "[%key:common::state::on%]"
|
"power_on": "[%key:common::state::on%]"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
{
|
{
|
||||||
"state": {
|
"state": {
|
||||||
|
"tuya__led_type": {
|
||||||
|
"halogen": "Halogen",
|
||||||
|
"incandescent": "Incandescent",
|
||||||
|
"led": "LED"
|
||||||
|
},
|
||||||
"tuya__light_mode": {
|
"tuya__light_mode": {
|
||||||
"none": "Off",
|
"none": "Off",
|
||||||
"pos": "Indicate switch location",
|
"pos": "Indicate switch location",
|
||||||
|
@ -7,6 +12,9 @@
|
||||||
},
|
},
|
||||||
"tuya__relay_status": {
|
"tuya__relay_status": {
|
||||||
"last": "Remember last state",
|
"last": "Remember last state",
|
||||||
|
"memory": "Remember last state",
|
||||||
|
"off": "Off",
|
||||||
|
"on": "On",
|
||||||
"power_off": "Off",
|
"power_off": "Off",
|
||||||
"power_on": "On"
|
"power_on": "On"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue