Skip to content

Commit

Permalink
Add ThirdReality Driver for Matter Night Light (#1048)
Browse files Browse the repository at this point in the history
* Add ThirdReality Driver for Matter Night Light

* move third reality nl support to subdriver format

* rename profile file name -nl to illuminance-motion
clean third-reality/init useless code

* Add illuminance and motion to base matter-switch driver

* Commit:Add colorTemperature range 1000-15000k support in profile

* Commit: add new profile loight-color-level-illuminance-motion-1000-15000k;update the fingerptint

* Commit: update the file name to be light-color-level-illuminance-motion-1000K-15000K

* Commit: update device label by writing out "NL" to "Night Light"

* fix unit tests for illiminance motion light

---------

Co-authored-by: Zhangyi <[email protected]>
Co-authored-by: xdong <[email protected]>
Co-authored-by: Cooper Towns <[email protected]>
Co-authored-by: lelandblue <[email protected]>
  • Loading branch information
5 people authored Mar 17, 2024
1 parent 05b2f3f commit 561aa74
Show file tree
Hide file tree
Showing 5 changed files with 619 additions and 1 deletion.
7 changes: 7 additions & 0 deletions drivers/SmartThings/matter-switch/fingerprints.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
matterManufacturer:
#ThirdReality
- id: "ThirdReality/WiFi"
deviceLabel: THIRDREALITY Night Light
vendorId: 0x1407
productId: 0x1088
deviceProfileName: light-color-level-illuminance-motion-1000K-15000K

#Eve
- id: "Eve/Energy/US"
deviceLabel: Eve Energy
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: light-color-level-illuminance-motion-1000K-15000K
components:
- id: main
capabilities:
- id: switch
version: 1
- id: switchLevel
version: 1
- id: colorTemperature
version: 1
config:
values:
- key: "colorTemperature.value"
range: [ 1000, 15000 ]
- id: colorControl
version: 1
- id: motionSensor
version: 1
- id: illuminanceMeasurement
version: 1
- id: firmwareUpdate
version: 1
- id: refresh
version: 1
categories:
- name: Light

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: light-color-level-illuminance-motion
components:
- id: main
capabilities:
- id: switch
version: 1
- id: switchLevel
version: 1
- id: colorTemperature
version: 1
- id: colorControl
version: 1
- id: motionSensor
version: 1
- id: illuminanceMeasurement
version: 1
- id: firmwareUpdate
version: 1
- id: refresh
version: 1
categories:
- name: Light

26 changes: 25 additions & 1 deletion drivers/SmartThings/matter-switch/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,16 @@ local function color_cap_attr_handler(driver, device, ib, response)
end
end


local function illuminance_attr_handler(driver, device, ib, response)
local lux = math.floor(10 ^ ((ib.data.value - 1) / 10000))
device:emit_event_for_endpoint(ib.endpoint_id, capabilities.illuminanceMeasurement.illuminance(lux))
end

local function occupancy_attr_handler(driver, device, ib, response)
device:emit_event(ib.data.value == 0x01 and capabilities.motionSensor.motion.active() or capabilities.motionSensor.motion.inactive())
end

local function info_changed(driver, device, event, args)
if device.profile.id ~= args.old_st_store.profile.id then
device:subscribe()
Expand Down Expand Up @@ -374,6 +384,12 @@ local matter_driver_template = {
[clusters.ColorControl.attributes.CurrentX.ID] = x_attr_handler,
[clusters.ColorControl.attributes.CurrentY.ID] = y_attr_handler,
[clusters.ColorControl.attributes.ColorCapabilities.ID] = color_cap_attr_handler,
},
[clusters.IlluminanceMeasurement.ID] = {
[clusters.IlluminanceMeasurement.attributes.MeasuredValue.ID] = illuminance_attr_handler
},
[clusters.OccupancySensing.ID] = {
[clusters.OccupancySensing.attributes.Occupancy.ID] = occupancy_attr_handler,
}
},
fallback = matter_handler,
Expand All @@ -394,6 +410,12 @@ local matter_driver_template = {
[capabilities.colorTemperature.ID] = {
clusters.ColorControl.attributes.ColorTemperatureMireds,
},
[capabilities.illuminanceMeasurement.ID] = {
clusters.IlluminanceMeasurement.attributes.MeasuredValue
},
[capabilities.motionSensor.ID] = {
clusters.OccupancySensing.attributes.Occupancy
}
},
capability_handlers = {
[capabilities.switch.ID] = {
Expand All @@ -420,9 +442,11 @@ local matter_driver_template = {
capabilities.switchLevel,
capabilities.colorControl,
capabilities.colorTemperature,
capabilities.motionSensor,
capabilities.illuminanceMeasurement
},
sub_drivers = {
require("eve-energy")
require("eve-energy"),
}
}

Expand Down
Loading

0 comments on commit 561aa74

Please sign in to comment.