diff --git a/drivers/SmartThings/zigbee-switch/fingerprints.yml b/drivers/SmartThings/zigbee-switch/fingerprints.yml index 8765be8aeb..051d5276a0 100644 --- a/drivers/SmartThings/zigbee-switch/fingerprints.yml +++ b/drivers/SmartThings/zigbee-switch/fingerprints.yml @@ -1075,6 +1075,11 @@ zigbeeManufacturer: manufacturer: model: TERNCY-LS01 deviceProfileName: basic-switch + - id: Third Reality/3RPL01084Z + deviceLabel: ThirdReality Multi-Function Smart Presence Sensor R3 + manufacturer: Third Reality, Inc + model: 3RPL01084Z + deviceProfileName: thirdreality-presence-color-night-light - id: Third Reality/3RSS009Z deviceLabel: ThirdReality Switch manufacturer: Third Reality, Inc diff --git a/drivers/SmartThings/zigbee-switch/profiles/thirdreality-presence-color-night-light.yml b/drivers/SmartThings/zigbee-switch/profiles/thirdreality-presence-color-night-light.yml new file mode 100644 index 0000000000..504472fbf6 --- /dev/null +++ b/drivers/SmartThings/zigbee-switch/profiles/thirdreality-presence-color-night-light.yml @@ -0,0 +1,28 @@ +name: thirdreality-presence-color-night-light +components: +- id: main + capabilities: + - id: switch + version: 1 + - id: switchLevel + version: 1 + config: + values: + - key: "level.value" + range: [1, 100] + - id: colorTemperature + version: 1 + - id: colorControl + version: 1 + - id: motionSensor + version: 1 + - id: illuminanceMeasurement + version: 1 + - id: tvocMeasurement + version: 1 + - id: firmwareUpdate + version: 1 + - id: refresh + version: 1 + categories: + - name: Light \ No newline at end of file diff --git a/drivers/SmartThings/zigbee-switch/src/init.lua b/drivers/SmartThings/zigbee-switch/src/init.lua index 062ac68782..5639918292 100644 --- a/drivers/SmartThings/zigbee-switch/src/init.lua +++ b/drivers/SmartThings/zigbee-switch/src/init.lua @@ -66,6 +66,7 @@ local zigbee_switch_driver_template = { capabilities.illuminanceMeasurement, capabilities.relativeHumidityMeasurement, capabilities.temperatureMeasurement, + capabilities.tvocMeasurement }, sub_drivers = require("sub_drivers"), zigbee_handlers = { diff --git a/drivers/SmartThings/zigbee-switch/src/sub_drivers.lua b/drivers/SmartThings/zigbee-switch/src/sub_drivers.lua index 5dcf24ca74..f9768d36ca 100644 --- a/drivers/SmartThings/zigbee-switch/src/sub_drivers.lua +++ b/drivers/SmartThings/zigbee-switch/src/sub_drivers.lua @@ -35,5 +35,6 @@ return { lazy_load_if_possible("tuya-multi"), lazy_load_if_possible("frient"), lazy_load_if_possible("frient-IO"), - lazy_load_if_possible("color_temp_range_handlers") + lazy_load_if_possible("color_temp_range_handlers"), + lazy_load_if_possible("thirdreality-presence-sensor-r3") } diff --git a/drivers/SmartThings/zigbee-switch/src/thirdreality-presence-sensor-r3/init.lua b/drivers/SmartThings/zigbee-switch/src/thirdreality-presence-sensor-r3/init.lua new file mode 100644 index 0000000000..380db0b9ee --- /dev/null +++ b/drivers/SmartThings/zigbee-switch/src/thirdreality-presence-sensor-r3/init.lua @@ -0,0 +1,52 @@ +local zcl_clusters = require "st.zigbee.zcl.clusters" +local capabilities = require "st.capabilities" +local OccupancySensing = zcl_clusters.OccupancySensing +local log = require "log" + +local THIRDREALITY_TVOC_CLUSTER = 0x042E +local THIRDREALITY_TVOC_VALUE = 0x0000 + +local function occupancy_attr_handler(driver, device, occupancy, zb_rx) + device:emit_event(occupancy.value == 1 and capabilities.motionSensor.motion.active() or capabilities.motionSensor.motion.inactive()) +end + +local function tvoc_attr_handler(driver, device, value, zb_rx) + local voc_value + if type(value) == "number" then + voc_value = value + elseif type(value) == "table" and value.mantissa and value.exponent then + voc_value = (1 + value.mantissa) * (2 ^ value.exponent) + else + log.error("Unsupported VOC value: " .. tostring(value)) + return + end + voc_value = math.floor(voc_value + 0.5) + device:emit_event(capabilities.tvocMeasurement.tvocLevel({value = voc_value, unit = "ppb"})) +end + +local added_handler = function(self, device) + device:send(OccupancySensing.attributes.Occupancy:read(device)) + device:emit_event(capabilities.tvocMeasurement.tvocLevel({value = 0, unit = "ppb"})) +end + +local thirdreality_device_handler = { + NAME = "ThirdReality Multi-Function Smart Presence Sensor R3", + lifecycle_handlers = { + added = added_handler + }, + zigbee_handlers = { + attr = { + [OccupancySensing.ID] = { + [OccupancySensing.attributes.Occupancy.ID] = occupancy_attr_handler + }, + [THIRDREALITY_TVOC_CLUSTER] = { + [THIRDREALITY_TVOC_VALUE] = tvoc_attr_handler + } + } + }, + can_handle = function(opts, driver, device, ...) + return device:get_manufacturer() == "Third Reality, Inc" and device:get_model() == "3RPL01084Z" + end +} + +return thirdreality_device_handler