Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions drivers/SmartThings/zigbee-switch/fingerprints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions drivers/SmartThings/zigbee-switch/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ local zigbee_switch_driver_template = {
capabilities.illuminanceMeasurement,
capabilities.relativeHumidityMeasurement,
capabilities.temperatureMeasurement,
capabilities.tvocMeasurement
},
sub_drivers = require("sub_drivers"),
zigbee_handlers = {
Expand Down
3 changes: 2 additions & 1 deletion drivers/SmartThings/zigbee-switch/src/sub_drivers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Original file line number Diff line number Diff line change
@@ -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
Loading