Skip to content

Commit

Permalink
Fix possible re-onboarding issue (#1366)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kwang-Hui authored May 13, 2024
1 parent fe0ed9e commit be2f7d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
10 changes: 7 additions & 3 deletions drivers/SmartThings/zigbee-illuminance-sensor/src/aqara/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,23 @@ local function device_init(driver, device)
end
end

local function do_configure(self, device)
device:configure()
device:send(cluster_base.write_manufacturer_specific_attribute(device, PRIVATE_CLUSTER_ID, PRIVATE_ATTRIBUTE_ID,
MFG_CODE, data_types.Uint8, 1))
end

local function added_handler(self, device)
device:emit_event(capabilities.illuminanceMeasurement.illuminance(0))
device:emit_event(detectionFrequency.detectionFrequency(FREQUENCY_DEFAULT_VALUE, {visibility = {displayed = false}}))
device:emit_event(capabilities.battery.battery(100))

device:send(cluster_base.write_manufacturer_specific_attribute(device, PRIVATE_CLUSTER_ID, PRIVATE_ATTRIBUTE_ID,
MFG_CODE, data_types.Uint8, 1))
end

local aqara_illuminance_handler = {
NAME = "Aqara Illuminance Handler",
lifecycle_handlers = {
init = device_init,
doConfigure = do_configure,
added = added_handler
},
capability_handlers = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,11 @@ test.register_coroutine_test(
test.socket.capability:__expect_send(mock_device:generate_test_message("main",
detectionFrequency.detectionFrequency(FREQUENCY_DEFAULT_VALUE, {visibility = {displayed = false}})))
test.socket.capability:__expect_send(mock_device:generate_test_message("main", capabilities.battery.battery(100)))

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) })
end
)

test.register_coroutine_test(
"Configure should configure all necessary attributes",
"Handle doConfigure lifecycle",
function()
test.socket.device_lifecycle:__queue_receive({ mock_device.id, "doConfigure" })
test.socket.zigbee:__set_channel_ordering("relaxed")
Expand Down Expand Up @@ -100,6 +96,11 @@ test.register_coroutine_test(
zigbee_test_utils.build_bind_request(mock_device, zigbee_test_utils.mock_hub_eui, PowerConfiguration.ID)
}
)

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

0 comments on commit be2f7d9

Please sign in to comment.