Skip to content

Commit

Permalink
Update pir category to supports "SXSEN003PIR" #97
Browse files Browse the repository at this point in the history
  • Loading branch information
xZetsubou committed Jan 8, 2024
1 parent 62de7f4 commit c5f8bae
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 3 deletions.
7 changes: 7 additions & 0 deletions custom_components/localtuya/core/ha_entities/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,17 @@ class DPCode(StrEnum):
LOCK = "lock" # Lock / Child lock
LOWPROTECTVALUE = "lowprotectvalue"
LOW_POWER_THRESHOLD = "low_power_threshold"
LUX = "lux" # Ikuu SXSEN003PIR IP65 Motion Detector (Wi-Fi)
MACH_OPERATE = "mach_operate"
MANUAL_FEED = "manual_feed"
MASTER_MODE = "master_mode" # alarm mode
MASTER_STATE = "master_state" # alarm mode
MATERIAL = "material" # Material
MIDDLE_CONFIRM = "middle_confirm" # cover reset.
MOD = "mod" # Ikuu SXSEN003PIR IP65 Motion Detector (Wi-Fi)
MODE = "mode" # 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
MOTION_INTERVAL = "motion_interval"
MOTION_RECORD = "motion_record"
Expand Down Expand Up @@ -362,6 +366,7 @@ class DPCode(StrEnum):
SCENE_DATA = "scene_data" # Colored light mode
SCENE_DATA_V2 = "scene_data_v2" # Colored light mode
SEEK = "seek"
SENS = "sens" # Ikuu SXSEN003PIR IP65 Motion Detector (Wi-Fi)
SENSITIVITY = "sensitivity" # Sensitivity
SENSORTYPE = "sensortype"
SENSOR_HUMIDITY = "sensor_humidity"
Expand All @@ -383,6 +388,7 @@ class DPCode(StrEnum):
SPEED = "speed" # Speed level
SPRAY_MODE = "spray_mode" # Spraying mode
SPRAY_VOLUME = "spray_volume" # Dehumidifier
STA = "sta" # Ikuu SXSEN003PIR IP65 Motion Detector (Wi-Fi)
START = "start" # Start
STATUS = "status"
STERILIZATION = "sterilization" # Sterilization
Expand Down Expand Up @@ -447,6 +453,7 @@ class DPCode(StrEnum):
TEMP_UNIT_CONVERT = "temp_unit_convert" # Temperature unit switching
TEMP_VALUE = "temp_value" # Color temperature
TEMP_VALUE_V2 = "temp_value_v2"
TIM = "tim" # Ikuu SXSEN003PIR IP65 Motion Detector (Wi-Fi)
TIME_TOTAL = "time_total"
TOTAL_CLEAN_AREA = "total_clean_area"
TOTAL_CLEAN_COUNT = "total_clean_count"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,11 @@ def localtuya_binarySensor(state_on="1"):
device_class=BinarySensorDeviceClass.MOTION,
custom_configs={CONF_STATE_ON: "pir"},
),
LocalTuyaEntity(
id=DPCode.STA,
device_class=BinarySensorDeviceClass.MOTION,
custom_configs={CONF_STATE_ON: "true"},
),
TAMPER_BINARY_SENSOR,
),
# PM2.5 Sensor
Expand Down
25 changes: 25 additions & 0 deletions custom_components/localtuya/core/ha_entities/numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,31 @@ def localtuya_numbers(_min, _max, _step=1, _scale=1, unit=None) -> dict:
custom_configs=localtuya_numbers(0, 360),
),
),
# PIR Detector
# https://developer.tuya.com/en/docs/iot/categorypir?id=Kaiuz3ss11b80
"pir": (
LocalTuyaEntity(
id=DPCode.SENS,
icon="mdi:signal-distance-variant",
entity_category=EntityCategory.CONFIG,
name="Sensitivity",
custom_configs=localtuya_numbers(0, 4),
),
LocalTuyaEntity(
id=DPCode.TIM,
icon="mdi:signal-distance-variant",
entity_category=EntityCategory.CONFIG,
name="Hold Time",
custom_configs=localtuya_numbers(10, 900, 1, 1, UnitOfTime.SECONDS),
),
LocalTuyaEntity(
id=DPCode.LUX,
icon="mdi:brightness-6",
entity_category=EntityCategory.CONFIG,
name="Light level",
custom_configs=localtuya_numbers(0, 981, 1, 1, "lx"),
),
),
# Robot Vacuum
# https://developer.tuya.com/en/docs/iot/fsd?id=K9gf487ck1tlo
"sd": (
Expand Down
27 changes: 25 additions & 2 deletions custom_components/localtuya/core/ha_entities/selects.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,14 +743,37 @@ def localtuya_selector(options, options_name=None):
),
),
),
# PIR Detector
# https://developer.tuya.com/en/docs/iot/categorypir?id=Kaiuz3ss11b80
"pir": (
LocalTuyaEntity(
id=DPCode.MOD,
icon="mdi:cog",
entity_category=EntityCategory.CONFIG,
name="Mode",
custom_configs=localtuya_selector(
"mode_auto,mode_on,mode_off", "AUTO,ON,OFF"
),
),
),
# Thermostat
# https://developer.tuya.com/en/docs/iot/f?id=K9gf45ld5l0t9
"wk": (
LocalTuyaEntity(
id=DPCode.SENSORTYPE,
entity_category=EntityCategory.CONFIG,
name="Temperature sensor",
custom_configs=localtuya_selector("0,1,2", "Internal,External,Both"),
),
),
# Thermostat
# https://developer.tuya.com/en/docs/iot/f?id=K9gf45ld5l0t9
"wk": (
LocalTuyaEntity(
id=DPCode.SENSORTYPE,
entity_category=EntityCategory.CONFIG,
name="Temperature sensor",
custom_configs=localtuya_selector("0,1,2", "Internal;External;Both"),
custom_configs=localtuya_selector("0,1,2", "Internal,External,Both"),
),
),
}
Expand Down Expand Up @@ -882,4 +905,4 @@ def localtuya_selector(options, options_name=None):
# }

# # Dehumidifier
# DEHUMIDITY_SET_ENUM = {OPS_VALS: "10,20,30,40,50", OPS_NAME: "10,20,30,40,50"}
# DEHUMIDITY_SET_ENUM = {OPS_VALS: "10,20,30,40,50", OPS_NAME: "10,20,30,40,50"}
17 changes: 16 additions & 1 deletion custom_components/localtuya/core/ha_entities/sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,22 @@ def localtuya_sensor(unit_of_measurement=None, scale_factor: float = None) -> di
),
# PIR Detector
# https://developer.tuya.com/en/docs/iot/categorypir?id=Kaiuz3ss11b80
"pir": BATTERY_SENSORS,
"pir": (
LocalTuyaEntity(
id=DPCode.PM25_VALUE,
# translation_id="pm25",
device_class=SensorDeviceClass.PM25,
state_class=SensorStateClass.MEASUREMENT,
),
LocalTuyaEntity(
id=DPCode.MOD_ON_TMR_CD,
icon="mdi:timer-edit-outline",
name="Timer left",
entity_category=EntityCategory.DIAGNOSTIC,
custom_configs=localtuya_sensor("s"),
),
*BATTERY_SENSORS,
),
# PM2.5 Sensor
# https://developer.tuya.com/en/docs/iot/categorypm25?id=Kaiuz3qof3yfu
"pm2.5": (
Expand Down
10 changes: 10 additions & 0 deletions custom_components/localtuya/core/ha_entities/switches.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,16 @@
entity_category=EntityCategory.CONFIG,
),
),
# PIR Detector
# https://developer.tuya.com/en/docs/iot/categorypir?id=Kaiuz3ss11b80
"pir": (
LocalTuyaEntity(
id=DPCode.MOD_ON_TMR,
icon="mdi:timer-play",
entity_category=EntityCategory.CONFIG,
name="Timer",
),
),
# Thermostatic Radiator Valve
# Not documented
"wkf": (
Expand Down

0 comments on commit c5f8bae

Please sign in to comment.