Skip to content

Commit

Permalink
Auto configre: Add wxkg category #113
Browse files Browse the repository at this point in the history
  • Loading branch information
xZetsubou committed Jan 30, 2024
1 parent 626be63 commit 656f6db
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 5 deletions.
6 changes: 6 additions & 0 deletions custom_components/localtuya/core/ha_entities/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,12 @@ class DPCode(StrEnum):
MIDDLE_CONFIRM = "middle_confirm" # cover reset.
MOD = "mod" # Ikuu SXSEN003PIR IP65 Motion Detector (Wi-Fi)
MODE = "mode" # Working mode / Mode
MODE_1 = "mode_1" # Working mode / Mode
MODE_2 = "mode_2" # Working mode / Mode
MODE_3 = "mode_3" # Working mode / Mode
MODE_4 = "mode_4" # Working mode / Mode
MODE_5 = "mode_5" # Working mode / Mode
MODE_6 = "mode_6" # Working mode / Mode
MOD_ON_TMR = "mod_on_tmr" # Ikuu SXSEN003PIR IP65 Motion Detector (Wi-Fi)
MOD_ON_TMR_CD = "mod_on_tmr_cd" # Ikuu SXSEN003PIR IP65 Motion Detector (Wi-Fi)
MOODLIGHTING = "moodlighting" # Mood light
Expand Down
4 changes: 4 additions & 0 deletions custom_components/localtuya/core/ha_entities/buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,7 @@
),
),
}

# Wireless Switch # also can come as knob switch.
# https://developer.tuya.com/en/docs/iot/wxkg?id=Kbeo9t3ryuqm5
BUTTONS["wxkg"] = BUTTONS["cjkg"]
5 changes: 5 additions & 0 deletions custom_components/localtuya/core/ha_entities/lights.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,11 @@ def localtuya_light(
# https://developer.tuya.com/en/docs/iot/f?id=K9gf7nx6jelo8
LIGHTS["cjkg"] = LIGHTS["tgkg"]

# Wireless Switch # also can come as knob switch.
# https://developer.tuya.com/en/docs/iot/wxkg?id=Kbeo9t3ryuqm5
LIGHTS["wxkg"] = LIGHTS["tgkg"]


# Socket (duplicate of `kg`)
# https://developer.tuya.com/en/docs/iot/s?id=K9gf7o5prgf7s
LIGHTS["cz"] = LIGHTS["kg"]
Expand Down
14 changes: 14 additions & 0 deletions custom_components/localtuya/core/ha_entities/numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Credits: official HA Tuya integration.
Modified by: xZetsubou
"""

from homeassistant.components.number import NumberDeviceClass
from homeassistant.const import PERCENTAGE, UnitOfTime, CONF_UNIT_OF_MEASUREMENT

Expand Down Expand Up @@ -593,6 +594,19 @@ def localtuya_numbers(_min, _max, _step=1, _scale=1, unit=None) -> dict:
),
),
}

# Wireless Switch # also can come as knob switch.
# https://developer.tuya.com/en/docs/iot/wxkg?id=Kbeo9t3ryuqm5
NUMBERS["wxkg"] = (
LocalTuyaEntity(
id=DPCode.TEMP_VALUE,
name="Temperature",
icon="mdi:thermometer",
custom_configs=localtuya_numbers(0, 1000),
),
*NUMBERS["kg"],
)

# Scene Switch
# https://developer.tuya.com/en/docs/iot/f?id=K9gf7nx6jelo8
NUMBERS["cjkg"] = NUMBERS["kg"]
Expand Down
64 changes: 59 additions & 5 deletions custom_components/localtuya/core/ha_entities/selects.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,47 @@ def localtuya_selector(options):
name="Source",
icon="mdi:volume-source",
entity_category=EntityCategory.CONFIG,
custom_configs=localtuya_selector("cloud,local,aux,bluetooth"),
custom_configs=localtuya_selector(
{
"cloud": "Cloud",
"local": "Local",
"aux": "Aux",
"bluetooth": "Bluetooth",
}
),
),
LocalTuyaEntity(
id=DPCode.PLAY_MODE,
name="Mode",
icon="mdi:cog-outline",
entity_category=EntityCategory.CONFIG,
custom_configs=localtuya_selector("order,repeat_all,repeat_one,random"),
custom_configs=localtuya_selector(
{
"order": "Order",
"repeat_all": "Repeat ALL",
"repeat_one": "Repeat one",
"random": "Random",
}
),
),
LocalTuyaEntity(
id=DPCode.SOUND_EFFECTS,
name="Sound Effects",
icon="mdi:sine-wave",
entity_category=EntityCategory.CONFIG,
custom_configs=localtuya_selector(
"normal,pop,opera,classical,jazz,rock,folk,heavy_metal,hip_hop,wave"
{
"normal": "Normal",
"pop": "Pop",
"opera": "Opera",
"classical": "Classical",
"jazz": "Jazz",
"rock": "Rock",
"folk": "Folk",
"heavy_metal": "Metal",
"hip_hop": "HipHop",
"wave": "Wave",
}
),
),
),
Expand All @@ -79,13 +104,28 @@ def localtuya_selector(options):
id=DPCode.ALARM_VOLUME,
name="volume",
entity_category=EntityCategory.CONFIG,
custom_configs=localtuya_selector("low,middle,high,mute"),
custom_configs=localtuya_selector(
{
"low": "Low",
"middle": "Middle",
"high": "High",
"mute": "Mute",
}
),
),
LocalTuyaEntity(
id=DPCode.ALARM_RINGTONE,
name="Ringtone",
entity_category=EntityCategory.CONFIG,
custom_configs=localtuya_selector("1,2,3,4,5"),
custom_configs=localtuya_selector(
{
"1": "1",
"2": "2",
"3": "3",
"4": "4",
"5": "5",
}
),
),
),
# Heater
Expand Down Expand Up @@ -791,6 +831,20 @@ def localtuya_selector(options):
),
),
}
# Wireless Switch # also can come as knob switch.
# https://developer.tuya.com/en/docs/iot/wxkg?id=Kbeo9t3ryuqm5
SELECTS["wxkg"] = (
LocalTuyaEntity(
id=DPCode.WORK_MODE,
name="Display mode",
icon="mdi:square-outline",
entity_category=EntityCategory.CONFIG,
custom_configs=localtuya_selector(
{"brightness": "Brightness", "temperature": "Temperature"}
),
),
*SELECTS["kg"],
)

# Scene Switch
# https://developer.tuya.com/en/docs/iot/f?id=K9gf7nx6jelo8
Expand Down
15 changes: 15 additions & 0 deletions custom_components/localtuya/core/ha_entities/sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Credits: official HA Tuya integration.
Modified by: xZetsubou
"""

from homeassistant.components.sensor import SensorStateClass, SensorDeviceClass
from homeassistant.const import (
PERCENTAGE,
Expand Down Expand Up @@ -81,6 +82,20 @@ def localtuya_sensor(unit_of_measurement=None, scale_factor: float = None) -> di
# end up being a sensor.
# https://developer.tuya.com/en/docs/iot/standarddescription?id=K9i5ql6waswzq
SENSORS: dict[str, tuple[LocalTuyaEntity, ...]] = {
# Wireless Switch # also can come as knob switch.
# https://developer.tuya.com/en/docs/iot/wxkg?id=Kbeo9t3ryuqm5
"wxkg": (
LocalTuyaEntity(
id=DPCode.MODE_1,
name="Switch 1 Mode",
icon="mdi:information-slab-circle-outline",
),
LocalTuyaEntity(
id=DPCode.MODE_2,
name="Switch 2 Mode",
icon="mdi:information-slab-circle-outline",
),
),
# Smart panel with switches and zigbee hub ?
# Not documented
"dgnzk": (
Expand Down
4 changes: 4 additions & 0 deletions custom_components/localtuya/core/ha_entities/switches.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,10 @@
# https://developer.tuya.com/en/docs/iot/f?id=K9gf7nx6jelo8
SWITCHES["cjkg"] = SWITCHES["kg"]

# Wireless Switch # also can come as knob switch.
# https://developer.tuya.com/en/docs/iot/wxkg?id=Kbeo9t3ryuqm5
SWITCHES["wxkg"] = SWITCHES["kg"]

# Socket (duplicate of `pc`)
# https://developer.tuya.com/en/docs/iot/s?id=K9gf7o5prgf7s
SWITCHES["cz"] = SWITCHES["pc"]
Expand Down

0 comments on commit 656f6db

Please sign in to comment.