Add Luminance Sensor (ldcg) device support to Tuya (#57797)
This commit is contained in:
parent
6e5d49144a
commit
a7c7e58a5b
3 changed files with 66 additions and 3 deletions
|
@ -45,7 +45,16 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = {
|
|||
TuyaBinarySensorEntityDescription(
|
||||
key=DPCode.TEMPER_ALARM,
|
||||
name="Tamper",
|
||||
entity_registry_enabled_default=False,
|
||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
),
|
||||
),
|
||||
# Luminance Sensor
|
||||
# https://developer.tuya.com/en/docs/iot/categoryldcg?id=Kaiuz3n7u69l8
|
||||
"ldcg": (
|
||||
TuyaBinarySensorEntityDescription(
|
||||
key=DPCode.TEMPER_ALARM,
|
||||
name="Tamper",
|
||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
),
|
||||
),
|
||||
# PIR Detector
|
||||
|
|
|
@ -41,6 +41,7 @@ TUYA_SUPPORTED_PRODUCT_CATEGORIES = (
|
|||
"kg", # Switch
|
||||
"kj", # Air Purifier
|
||||
"kt", # Air conditioner
|
||||
"ldcg", # Luminance Sensor
|
||||
"mcs", # Door Window Sensor
|
||||
"pc", # Power Strip
|
||||
"pir", # PIR Detector
|
||||
|
@ -81,10 +82,11 @@ class DPCode(str, Enum):
|
|||
ANION = "anion" # Ionizer unit
|
||||
BATTERY_PERCENTAGE = "battery_percentage" # Battery percentage
|
||||
BATTERY_STATE = "battery_state" # Battery state
|
||||
BRIGHT_STATE = "Brightness" # Brightness
|
||||
BRIGHT_STATE = "bright_state" # Brightness status
|
||||
BRIGHT_VALUE = "bright_value" # Brightness
|
||||
C_F = "c_f" # Temperature unit switching
|
||||
CHILD_LOCK = "child_lock" # Child lock
|
||||
CO2_VALUE = "co2_value" # CO2 concentration
|
||||
COLOUR_DATA = "colour_data" # Colored light mode
|
||||
COLOUR_DATA_V2 = "colour_data_v2" # Colored light mode
|
||||
CONCENTRATION_SET = "concentration_set" # Concentration setting
|
||||
|
@ -99,12 +101,13 @@ class DPCode(str, Enum):
|
|||
FILTER_RESET = "filter_reset" # Filter (cartridge) reset
|
||||
HUMIDITY_CURRENT = "humidity_current" # Current humidity
|
||||
HUMIDITY_SET = "humidity_set" # Humidity setting
|
||||
HUMIDITY_VALUE = "humidity_value" # Humidity
|
||||
LIGHT = "light" # Light
|
||||
LOCK = "lock" # Lock / Child lock
|
||||
MATERIAL = "material" # Material
|
||||
MODE = "mode" # Working mode / Mode
|
||||
PIR = "pir" # Motion sensor
|
||||
MUFFLING = "muffling" # Muffling
|
||||
PIR = "pir" # Motion sensor
|
||||
POWDER_SET = "powder_set" # Powder
|
||||
PUMP_RESET = "pump_reset" # Water pump reset
|
||||
SHAKE = "shake" # Oscillating
|
||||
|
|
|
@ -14,8 +14,12 @@ from homeassistant.components.sensor import (
|
|||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
DEVICE_CLASS_CO2,
|
||||
DEVICE_CLASS_CURRENT,
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
DEVICE_CLASS_ILLUMINANCE,
|
||||
DEVICE_CLASS_POWER,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
DEVICE_CLASS_VOLTAGE,
|
||||
ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
PERCENTAGE,
|
||||
|
@ -75,6 +79,53 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = {
|
|||
entity_registry_enabled_default=False,
|
||||
),
|
||||
),
|
||||
# Luminance Sensor
|
||||
# https://developer.tuya.com/en/docs/iot/categoryldcg?id=Kaiuz3n7u69l8
|
||||
"ldcg": (
|
||||
SensorEntityDescription(
|
||||
key=DPCode.BRIGHT_STATE,
|
||||
name="Luminosity",
|
||||
icon="mdi:brightness-6",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key=DPCode.BRIGHT_VALUE,
|
||||
name="Luminosity",
|
||||
device_class=DEVICE_CLASS_ILLUMINANCE,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key=DPCode.TEMP_CURRENT,
|
||||
name="Temperature",
|
||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key=DPCode.HUMIDITY_VALUE,
|
||||
name="Humidity",
|
||||
device_class=DEVICE_CLASS_HUMIDITY,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key=DPCode.CO2_VALUE,
|
||||
name="Carbon Dioxide (CO2)",
|
||||
device_class=DEVICE_CLASS_CO2,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key=DPCode.BATTERY_PERCENTAGE,
|
||||
name="Battery",
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
device_class=DEVICE_CLASS_BATTERY,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key=DPCode.BATTERY_STATE,
|
||||
name="Battery State",
|
||||
icon="mdi:battery",
|
||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
),
|
||||
),
|
||||
# PIR Detector
|
||||
# https://developer.tuya.com/en/docs/iot/categorypir?id=Kaiuz3ss11b80
|
||||
"pir": (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue