Skip to content

Move write_manufacturer_specific_attribute from added to doConfigure event #1291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 2, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ local function added_handler(self, device)
device:emit_event(detectionFrequency.detectionFrequency(aqara_utils.PREF_FREQUENCY_VALUE_DEFAULT, {visibility = {displayed = false}}))
device:emit_event(sensitivityAdjustment.sensitivityAdjustment.Medium())
device:emit_event(capabilities.battery.battery(100))
end

local function do_configure(self, device)
device:configure()
device:send(cluster_base.write_manufacturer_specific_attribute(device, aqara_utils.PRIVATE_CLUSTER_ID,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. device:configure() is needed
  2. Need to update TC

aqara_utils.PRIVATE_ATTRIBUTE_ID,
aqara_utils.MFG_CODE, data_types.Uint8, 1))
Expand All @@ -92,7 +95,8 @@ end
local aqara_high_precision_motion_handler = {
NAME = "Aqara High Precision Motion Handler",
lifecycle_handlers = {
added = added_handler
added = added_handler,
doConfigure = do_configure
},
capability_handlers = {
[sensitivityAdjustment.ID] = {
Expand Down
6 changes: 5 additions & 1 deletion drivers/SmartThings/zigbee-motion-sensor/src/aqara/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ local function added_handler(self, device)
device:emit_event(capabilities.illuminanceMeasurement.illuminance(0))
device:emit_event(detectionFrequency.detectionFrequency(aqara_utils.PREF_FREQUENCY_VALUE_DEFAULT, {visibility = {displayed = false}}))
device:emit_event(capabilities.battery.battery(100))
end

local function do_configure(self, device)
device:configure()
device:send(cluster_base.write_manufacturer_specific_attribute(device, aqara_utils.PRIVATE_CLUSTER_ID,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. device:configure() is needed
  2. Need to update TC

aqara_utils.PRIVATE_ATTRIBUTE_ID,
aqara_utils.MFG_CODE, data_types.Uint8, 1))
Expand All @@ -101,7 +104,8 @@ local aqara_motion_handler = {
NAME = "Aqara Motion Handler",
lifecycle_handlers = {
init = device_init,
added = added_handler
added = added_handler,
doConfigure = do_configure
},
capability_handlers = {
[detectionFrequency.ID] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,26 @@ test.register_coroutine_test(
sensitivityAdjustment.sensitivityAdjustment.Medium()))
test.socket.capability:__expect_send(mock_device:generate_test_message("main",
capabilities.battery.battery(100)))
end
)

test.register_coroutine_test(
"Handle doConfigure lifecycle",
function()
test.socket.device_lifecycle:__queue_receive({ mock_device.id, "doConfigure" })
test.socket.zigbee:__expect_send({
mock_device.id,
zigbee_test_utils.build_bind_request(mock_device, zigbee_test_utils.mock_hub_eui, PowerConfiguration.ID)
})
test.socket.zigbee:__expect_send({
mock_device.id,
PowerConfiguration.attributes.BatteryVoltage:configure_reporting(mock_device, 30, 3600, 1)
})
test.socket.zigbee:__expect_send({ mock_device.id,
cluster_base.write_manufacturer_specific_attribute(mock_device, PRIVATE_CLUSTER_ID, PRIVATE_ATTRIBUTE_ID, MFG_CODE
,
data_types.Uint8, 1) })
mock_device:expect_metadata_update({ provisioning_state = "PROVISIONED" })
end
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,26 @@ test.register_coroutine_test(
test.socket.capability:__expect_send(mock_device:generate_test_message("main",
detectionFrequency.detectionFrequency(PREF_FREQUENCY_VALUE_DEFAULT, {visibility = {displayed = false}})))
test.socket.capability:__expect_send(mock_device:generate_test_message("main", capabilities.battery.battery(100)))
end
)

test.register_coroutine_test(
"Handle doConfigure lifecycle",
function()
test.socket.device_lifecycle:__queue_receive({ mock_device.id, "doConfigure" })
test.socket.zigbee:__expect_send({
mock_device.id,
zigbee_test_utils.build_bind_request(mock_device, zigbee_test_utils.mock_hub_eui, PowerConfiguration.ID)
})
test.socket.zigbee:__expect_send({
mock_device.id,
PowerConfiguration.attributes.BatteryVoltage:configure_reporting(mock_device, 30, 3600, 1)
})
test.socket.zigbee:__expect_send({ mock_device.id,
cluster_base.write_manufacturer_specific_attribute(mock_device, PRIVATE_CLUSTER_ID, PRIVATE_ATTRIBUTE_ID, MFG_CODE
,
data_types.Uint8, 1) })
mock_device:expect_metadata_update({ provisioning_state = "PROVISIONED" })
end
)

Expand Down