Skip to content
Merged
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
3 changes: 3 additions & 0 deletions drivers/SmartThings/matter-switch/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,9 @@ local function active_power_handler(driver, device, ib, response)
local watt_value = ib.data.value / CONVERSION_CONST_MILLIWATT_TO_WATT
if ib.endpoint_id ~= 0 then
device:emit_event_for_endpoint(ib.endpoint_id, capabilities.powerMeter.power({ value = watt_value, unit = "W"}))
if type(device.register_native_capability_attr_handler) == "function" then
device:register_native_capability_attr_handler("powerMeter","power")
end
else
-- when energy management is defined in the root endpoint(0), replace it with the first switch endpoint and process it.
device:emit_event_for_endpoint(device:get_field(ENERGY_MANAGEMENT_ENDPOINT), capabilities.powerMeter.power({ value = watt_value, unit = "W"}))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,14 @@ test.register_message_test(
direction = "send",
message = mock_device:generate_test_message("main", capabilities.powerMeter.power({value = 17.0, unit="W"}))
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_attr_handler",
{ device_uuid = mock_device.id, capability_id = "powerMeter", capability_attr_id = "power" }
}
}
}
)

Expand Down
3 changes: 3 additions & 0 deletions drivers/SmartThings/matter-thermostat/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1964,6 +1964,9 @@ local function active_power_handler(driver, device, ib, response)
if ib.data.value then
local watt_value = ib.data.value / 1000
device:emit_event_for_endpoint(ib.endpoint_id, capabilities.powerMeter.power({ value = watt_value, unit = "W" }))
if type(device.register_native_capability_attr_handler) == "function" then
device:register_native_capability_attr_handler("powerMeter","power")
end
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,14 @@ test.register_message_test(
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.powerMeter.power({ value = 15.0, unit = "W" }))
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_attr_handler",
{ device_uuid = mock_device.id, capability_id = "powerMeter", capability_attr_id = "power" }
}
}
}
)
Expand Down
4 changes: 3 additions & 1 deletion drivers/SmartThings/zwave-sensor/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ local driver_template = {
},
}

defaults.register_for_default_handlers(driver_template, driver_template.supported_capabilities)
defaults.register_for_default_handlers(driver_template,
driver_template.supported_capabilities,
{native_capability_attrs_enabled = true})
--- @type st.zwave.Driver
local sensor = ZwaveDriver("zwave_sensor", driver_template)
sensor:run()
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,14 @@ test.register_message_test(
channel = "capability",
direction = "send",
message = mock_fibaro_door_window_sensor1:generate_test_message("main", capabilities.contactSensor.contact.open())
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_attr_handler",
{ device_uuid = mock_fibaro_door_window_sensor1.id, capability_id = "switch", capability_attr_id = "switch" }
}
}
}
)
Expand All @@ -271,6 +279,14 @@ test.register_message_test(
channel = "capability",
direction = "send",
message = mock_fibaro_door_window_sensor1:generate_test_message("main", capabilities.contactSensor.contact.closed())
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_attr_handler",
{ device_uuid = mock_fibaro_door_window_sensor1.id, capability_id = "switch", capability_attr_id = "switch" }
}
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ test.register_message_test(
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.motionSensor.motion.active())
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_attr_handler",
{ device_uuid = mock_device.id, capability_id = "switch", capability_attr_id = "switch" }
}
}
}
)
Expand Down Expand Up @@ -276,6 +284,14 @@ test.register_message_test(
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.motionSensor.motion.active())
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_attr_handler",
{ device_uuid = mock_device.id, capability_id = "switch", capability_attr_id = "switch" }
}
}
}
)
Expand Down
30 changes: 22 additions & 8 deletions drivers/SmartThings/zwave-sensor/src/test/test_generic_sensor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -362,12 +362,12 @@ test.register_message_test(
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.contactSensor.contact.closed())
message = mock_device:generate_test_message("main", capabilities.waterSensor.water.dry())
},
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.waterSensor.water.dry())
message = mock_device:generate_test_message("main", capabilities.contactSensor.contact.closed())
},
{
channel = "capability",
Expand All @@ -378,9 +378,16 @@ test.register_message_test(
channel = "zwave",
direction = "send",
message = zw_test_utils.zwave_test_build_send_command(mock_device, Meter:Get({ scale = 2 }))
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_attr_handler",
{ device_uuid = mock_device.id, capability_id = "switch", capability_attr_id = "switch" }
}
}
},
{ inner_block_ordering = "relaxed" }
}
)

test.register_message_test(
Expand All @@ -396,12 +403,12 @@ test.register_message_test(
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.contactSensor.contact.open())
message = mock_device:generate_test_message("main", capabilities.waterSensor.water.wet())
},
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.waterSensor.water.wet())
message = mock_device:generate_test_message("main", capabilities.contactSensor.contact.open())
},
{
channel = "capability",
Expand All @@ -412,9 +419,16 @@ test.register_message_test(
channel = "zwave",
direction = "send",
message = zw_test_utils.zwave_test_build_send_command(mock_device, Meter:Get({ scale = 2 }))
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_attr_handler",
{ device_uuid = mock_device.id, capability_id = "switch", capability_attr_id = "switch" }
}
}
},
{ inner_block_ordering = "relaxed" }
}
)

test.register_message_test(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ test.register_message_test(
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.motionSensor.motion.active())
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_attr_handler",
{ device_uuid = mock_device.id, capability_id = "switch", capability_attr_id = "switch" }
}
}
}
)
Expand Down Expand Up @@ -212,6 +220,14 @@ test.register_message_test(
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.motionSensor.motion.active())
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_attr_handler",
{ device_uuid = mock_device.id, capability_id = "switch", capability_attr_id = "switch" }
}
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ test.register_message_test(
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.motionSensor.motion.active())
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_attr_handler",
{ device_uuid = mock_device.id, capability_id = "switch", capability_attr_id = "switch" }
}
}
}
)
Expand Down Expand Up @@ -189,6 +197,14 @@ test.register_message_test(
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.motionSensor.motion.active())
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_attr_handler",
{ device_uuid = mock_device.id, capability_id = "switch", capability_attr_id = "switch" }
}
}
}
)
Expand Down
32 changes: 32 additions & 0 deletions drivers/SmartThings/zwave-sensor/src/test/test_zwave_sensor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,14 @@ test.register_message_test(
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.motionSensor.motion.active())
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_attr_handler",
{ device_uuid = mock_device.id, capability_id = "switch", capability_attr_id = "switch" }
}
}
}
)
Expand Down Expand Up @@ -609,6 +617,14 @@ test.register_message_test(
channel = "capability",
direction = "send",
message = mock_motion_device:generate_test_message("main", capabilities.motionSensor.motion.active())
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_attr_handler",
{ device_uuid = mock_motion_device.id, capability_id = "switch", capability_attr_id = "switch" }
}
}
}
)
Expand All @@ -625,6 +641,14 @@ test.register_message_test(
channel = "capability",
direction = "send",
message = mock_water_device:generate_test_message("main", capabilities.waterSensor.water.wet())
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_attr_handler",
{ device_uuid = mock_water_device.id, capability_id = "switch", capability_attr_id = "switch" }
}
}
}
)
Expand All @@ -641,6 +665,14 @@ test.register_message_test(
channel = "capability",
direction = "send",
message = mock_contact_device:generate_test_message("main", capabilities.contactSensor.contact.open())
},
{
channel = "devices",
direction = "send",
message = {
"register_native_capability_attr_handler",
{ device_uuid = mock_contact_device.id, capability_id = "switch", capability_attr_id = "switch" }
}
}
}
)
Expand Down
2 changes: 1 addition & 1 deletion drivers/SmartThings/zwave-thermostat/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ local driver_template = {
}
}

defaults.register_for_default_handlers(driver_template, driver_template.supported_capabilities)
defaults.register_for_default_handlers(driver_template, driver_template.supported_capabilities, {native_capability_attrs_enabled = true})
--- @type st.zwave.Driver
local thermostat = ZwaveDriver("zwave_thermostat", driver_template)
thermostat:run()
Loading