Skip to content

Commit

Permalink
Add motion sensor DPCodes and "tdq" category. #231 #232
Browse files Browse the repository at this point in the history
* Motion sensor added "pir_state" possibility.
* Motion sensor add Pir Sensitivity.
* Motion sensor add reset time.
" Dimmer add new category "tdq"
  • Loading branch information
xZetsubou committed May 14, 2024
1 parent 298d561 commit d64fc68
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
2 changes: 2 additions & 0 deletions custom_components/localtuya/core/ha_entities/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,8 @@ class DPCode(StrEnum):
PHOTO_MODE = "photo_mode"
PIR = "pir" # Motion sensor
PIR_SENSITIVITY = "pir_sensitivity"
PIR_STATE = "pir_state"
PIR_TIME = "pir_time"
PLAY_INFO = "play_info"
PLAY_MODE = "play_mode"
PLAY_TIME = "play_time"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def localtuya_binarySensor(state_on="1"):
# https://developer.tuya.com/en/docs/iot/categorypir?id=Kaiuz3ss11b80
"pir": (
LocalTuyaEntity(
id=DPCode.PIR,
id=(DPCode.PIR, DPCode.PIR_STATE),
device_class=BinarySensorDeviceClass.MOTION,
custom_configs={CONF_STATE_ON: "pir"},
),
Expand Down
8 changes: 5 additions & 3 deletions custom_components/localtuya/core/ha_entities/lights.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,23 +261,22 @@ def localtuya_light(
"tgkg": (
LocalTuyaEntity(
id=DPCode.SWITCH_LED_1,
name="light",
brightness=DPCode.BRIGHT_VALUE_1,
brightness_upper=DPCode.BRIGHTNESS_MAX_1,
brightness_lower=DPCode.BRIGHTNESS_MIN_1,
custom_configs=localtuya_light(29, 1000, 2700, 6500, False, False),
),
LocalTuyaEntity(
id=DPCode.SWITCH_LED_2,
name="light_2",
name="Light 2",
brightness=DPCode.BRIGHT_VALUE_2,
brightness_upper=DPCode.BRIGHTNESS_MAX_2,
brightness_lower=DPCode.BRIGHTNESS_MIN_2,
custom_configs=localtuya_light(29, 1000, 2700, 6500, False, False),
),
LocalTuyaEntity(
id=DPCode.SWITCH_LED_3,
name="light_3",
name="Light 3",
brightness=DPCode.BRIGHT_VALUE_3,
brightness_upper=DPCode.BRIGHTNESS_MAX_3,
brightness_lower=DPCode.BRIGHTNESS_MIN_3,
Expand Down Expand Up @@ -399,6 +398,9 @@ def localtuya_light(
*LIGHTS["dj"],
)

# Dimmer
LIGHTS["tdq"] = LIGHTS["tgkg"]

# Scene Switch
# https://developer.tuya.com/en/docs/iot/f?id=K9gf7nx6jelo8
LIGHTS["cjkg"] = LIGHTS["tgkg"]
Expand Down
21 changes: 20 additions & 1 deletion custom_components/localtuya/core/ha_entities/selects.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,9 @@ def localtuya_selector(options):
),
LocalTuyaEntity(
id=DPCode.PIR_SENSITIVITY,
icon="mdi:ray-start-arrow",
entity_category=EntityCategory.CONFIG,
name="PIR sensitivity",
name="PIR Sensitivity",
custom_configs=localtuya_selector({"0": "Low", "1": "Medium", "2": "High"}),
),
),
Expand Down Expand Up @@ -966,6 +967,24 @@ def localtuya_selector(options):
{"mode_auto": "AUTO", "mode_on": "ON", "mode_off": "OFF"}
),
),
LocalTuyaEntity(
id=DPCode.PIR_SENSITIVITY,
icon="mdi:ray-start-arrow",
entity_category=EntityCategory.CONFIG,
name="PIR Sensitivity",
custom_configs=localtuya_selector(
{"low": "Low", "middle": "Middle", "high": "High"}
),
),
LocalTuyaEntity(
id=DPCode.PIR_TIME,
icon="mdi:timer-sand",
entity_category=EntityCategory.CONFIG,
name="Reset Time",
custom_configs=localtuya_selector(
{"30s": "30 Seconds", "60s": "60 Seconds", "120s": "120 Seconds"}
),
),
),
# Thermostat
# https://developer.tuya.com/en/docs/iot/f?id=K9gf45ld5l0t9
Expand Down

0 comments on commit d64fc68

Please sign in to comment.