Skip to content

Commit

Permalink
Merge pull request #1294 from MaXinjian/smoke-reonboard
Browse files Browse the repository at this point in the history
fix aqara smoke detector reonboarding issue
  • Loading branch information
greens authored Apr 3, 2024
2 parents 3b1a87a + 95035c6 commit 95d91b3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
11 changes: 8 additions & 3 deletions drivers/SmartThings/zigbee-smoke-detector/src/aqara/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,24 @@ local function device_init(driver, device)
end

local function device_added(driver, device)
device:send(cluster_base.write_manufacturer_specific_attribute(device,
PRIVATE_CLUSTER_ID, PRIVATE_ATTRIBUTE_ID, MFG_CODE, data_types.Uint8, 0x01))
device:emit_event(capabilities.smokeDetector.smoke.clear())
device:emit_event(capabilities.audioMute.mute.unmuted())
device:emit_event(selfCheck.selfCheckState.idle())
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,
PRIVATE_CLUSTER_ID, PRIVATE_ATTRIBUTE_ID, MFG_CODE, data_types.Uint8, 0x01))
end

local aqara_gas_detector_handler = {
NAME = "Aqara Smoke Detector Handler",
lifecycle_handlers = {
init = device_init,
added = device_added
added = device_added,
doConfigure = do_configure
},
zigbee_handlers = {
attr = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,40 @@ test.register_coroutine_test(
"Handle added lifecycle",
function()
test.socket.device_lifecycle:__queue_receive({ mock_device.id, "added" })
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, 0x01) })
test.socket.capability:__expect_send(mock_device:generate_test_message("main", capabilities.smokeDetector.smoke.clear()))
test.socket.capability:__expect_send(mock_device:generate_test_message("main", capabilities.audioMute.mute.unmuted()))
test.socket.capability:__expect_send(mock_device:generate_test_message("main", selfCheck.selfCheckState.idle()))
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,
zigbee_test_utils.build_bind_request(mock_device, zigbee_test_utils.mock_hub_eui, PRIVATE_CLUSTER_ID)
})

local config_attr_message = zigbee_test_utils.build_attr_config(mock_device,
PRIVATE_CLUSTER_ID, PRIVATE_SMOKE_ZONE_STATUS_ATTRIBUTE_ID, 0x0001, 0x0E10, data_types.Uint16, 0x0001)
test.socket.zigbee:__expect_send({mock_device.id, config_attr_message})

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, 0x01) })
mock_device:expect_metadata_update({ provisioning_state = "PROVISIONED" })
end
)


test.register_coroutine_test(
Expand Down

0 comments on commit 95d91b3

Please sign in to comment.