diff --git a/drivers/Aqara/aqara-lock/src/init.lua b/drivers/Aqara/aqara-lock/src/init.lua index 9afe6bb77e..a5b163f7f1 100644 --- a/drivers/Aqara/aqara-lock/src/init.lua +++ b/drivers/Aqara/aqara-lock/src/init.lua @@ -23,7 +23,6 @@ local CLOUD_PUBLIC_KEY = "__cloud_public_key" local SUPPORTED_ALARM_VALUES = { "damaged", "forcedOpeningAttempt", "unableToLockTheDoor", "notClosedForALongTime", "highTemperature", "attemptsExceeded" } local SERIAL_NUM_TX = "serial_num_tx" -local SERIAL_NUM_RX = "serial_num_rx" local SEQ_NUM = "seq_num" local THRESHOLD_BATTERY = { ["aqara.lock.akr011"] = { low = 47, dryout = 28 }, -- K100 @@ -67,7 +66,6 @@ local function comp_supported_alarm_values(last_alarm_values) end local function device_init(self, device) - device:set_field(SERIAL_NUM_RX, 0) device:set_field(SERIAL_NUM_TX, 1) device:set_field(SEQ_NUM, 0) local last_alarm_values = device:get_latest_state("main", LockAlarm.ID, LockAlarm.supportedAlarmValues.NAME) or {} @@ -240,7 +238,6 @@ local function lock_state_handler(driver, device, value, zb_rx) if res then print(res) end - device:set_field(SERIAL_NUM_RX, 0) device:set_field(SERIAL_NUM_TX, 1) elseif shared_key == nil then request_generate_shared_key(device) @@ -252,17 +249,10 @@ local function lock_state_handler(driver, device, value, zb_rx) local text = string.sub(msg, 5, string.len(msg)) local payload = string.sub(text, 4, string.len(text)) local func_id = toValue(payload, 1, 1) .. "." .. toValue(payload, 2, 1) .. "." .. toValue(payload, 3, 2) - local serial_num = toValue(msg, 3, 2) - local last_serial_num = device:get_field(SERIAL_NUM_RX) or 0 - - if serial_num > last_serial_num then - device:set_field(SERIAL_NUM_RX, serial_num) - if resource_id[func_id] then - resource_id[func_id].event_handler(driver, device, resource_id[func_id].event_name, - toValue(payload, 6, string.byte(payload, 5))) - end - else - request_generate_shared_key(device) + + if resource_id[func_id] then + resource_id[func_id].event_handler(driver, device, resource_id[func_id].event_name, + toValue(payload, 6, string.byte(payload, 5))) end end end