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
10 changes: 0 additions & 10 deletions drivers/SmartThings/zwave-lock/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ local Notification = (require "st.zwave.CommandClass.Notification")({version=3})
local capabilities = require "st.capabilities"

local consts = require "lock_utils.constants"
local lock_utils = require "lock_utils.utils"
local table_utils = require "lock_utils.tables"
local zwave_handlers = require "lock_handlers.zwave_responses"
local capability_handlers = require "lock_handlers.capabilities"
Expand All @@ -24,13 +23,6 @@ local capability_handlers = require "lock_handlers.capabilities"
local LockLifecycle = {}

function LockLifecycle.device_added(driver, device)
if device:supports_capability(capabilities.lockCodes) and device._provisioning_state == "TYPED" then
-- set the migrated field to true so new devices use lockCredentials/lockUsers from the start.
-- auto-migration is only run for typed devices, as provisioned devices have already been onboarded,
-- and should be migrated manually by the user.
device:emit_event(capabilities.lockCodes.migrated(true, { visibility = { displayed = false } }))
device:set_field(consts.DRIVER_STATE.SLGA_MIGRATED, true, { persist = true })
end
if device:supports_capability(capabilities.tamperAlert) then
device:emit_event(capabilities.tamperAlert.tamper.clear())
end
Expand All @@ -40,8 +32,6 @@ function LockLifecycle.device_added(driver, device)
command = capabilities.refresh.commands.refresh.NAME,
args = {}
})
-- ensure our user/credential state is accurate to the current device state
device.thread:call_with_delay(5, function() lock_utils.sync_device_state(device) end)
end

function LockLifecycle.init(driver, device)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@ local mock_device_base = test.mock_device.build_test_zwave_device({
zwave_endpoints = zwave_lock_endpoints,
})

-- Same profile but provisioning_state = "TYPED" (freshly fingerprinted)
local mock_device_typed = test.mock_device.build_test_zwave_device({
profile = t_utils.get_profile_definition("base-lock.yml"),
zwave_endpoints = zwave_lock_endpoints,
_provisioning_state = "TYPED",
})

-- lock-battery profile: lock + battery only (no lockCodes / lockCredentials)
local mock_device_battery = test.mock_device.build_test_zwave_device({
profile = t_utils.get_profile_definition("lock-battery.yml"),
Expand All @@ -62,31 +55,6 @@ end
-- added (device_added)
-- ============================================================================

test.register_coroutine_test(
"added: TYPED device with lockCodes emits migrated event, persists SLGA_MIGRATED, and injects refresh",
function()
test.socket.device_lifecycle:__queue_receive({ mock_device_typed.id, "added" })

-- Migrated event emitted for TYPED+lockCodes device
test.socket.capability:__expect_send(
mock_device_typed:generate_test_message("main",
capabilities.lockCodes.migrated(true, { visibility = { displayed = false } }))
)
-- inject_capability_command calls the refresh handler:
-- DoorLock:OperationGet, Battery:Get, UserCode:UsersNumberGet (no cached values)
test.socket.zwave:__expect_send(DoorLock:OperationGet({}):build_test_tx(mock_device_typed.id))
test.socket.zwave:__expect_send(Battery:Get({}):build_test_tx(mock_device_typed.id))
test.socket.zwave:__expect_send(UserCode:UsersNumberGet({}):build_test_tx(mock_device_typed.id))
test.wait_for_events()

assert(
mock_device_typed:get_field(constants.DRIVER_STATE.SLGA_MIGRATED) == true,
"SLGA_MIGRATED must be true after added fires for a TYPED device"
)
end,
{ test_init = make_test_init(mock_device_typed) }
)

test.register_coroutine_test(
"added: non-TYPED (PROVISIONED) device with lockCodes does NOT emit migrated but still injects refresh",
function()
Expand Down Expand Up @@ -163,36 +131,5 @@ test.register_coroutine_test(
{ test_init = make_test_init(mock_device_battery) }
)

-- ============================================================================
-- driverSwitched (LockLifecycle.driver_switched)
-- ============================================================================

test.register_coroutine_test(
"driver_switched: device with lockCodes and migrated=true persists SLGA_MIGRATED and updates metadata",
function()
test.socket.device_lifecycle:__queue_receive({ mock_device_typed.id, "added" })

-- Migrated event emitted for TYPED+lockCodes device
test.socket.capability:__expect_send(
mock_device_typed:generate_test_message("main",
capabilities.lockCodes.migrated(true, { visibility = { displayed = false } }))
)
-- inject_capability_command calls the refresh handler:
-- DoorLock:OperationGet, Battery:Get, UserCode:UsersNumberGet (no cached values)
test.socket.zwave:__expect_send(DoorLock:OperationGet({}):build_test_tx(mock_device_typed.id))
test.socket.zwave:__expect_send(Battery:Get({}):build_test_tx(mock_device_typed.id))
test.socket.zwave:__expect_send(UserCode:UsersNumberGet({}):build_test_tx(mock_device_typed.id))
test.wait_for_events()

-- driverSwitched occurs after added, so migrated=true is already set in the capability state cache
test.socket.device_lifecycle:__queue_receive({ mock_device_typed.id, "driver_switched" })
mock_device_typed:expect_metadata_update({ provisioning_state = "PROVISIONED" })
test.wait_for_events()

assert(mock_device_typed:get_field(constants.DRIVER_STATE.SLGA_MIGRATED) == true)
end,
{ test_init = make_test_init(mock_device_typed) }
)

-- ============================================================================
test.run_registered_tests()
3 changes: 0 additions & 3 deletions drivers/SmartThings/zwave-lock/src/test/test_keywe_lock.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ local DoorLock = (require "st.zwave.CommandClass.DoorLock")({ version = 1 })
local Battery = (require "st.zwave.CommandClass.Battery")({ version = 1 })
local Notification = (require "st.zwave.CommandClass.Notification")({ version = 3 })
local UserCode = (require "st.zwave.CommandClass.UserCode")({ version = 1 })
local lock_utils = require "lock_utils.constants".DRIVER_STATE

test.disable_startup_messages()

Expand Down Expand Up @@ -45,7 +44,6 @@ test.set_test_init_function(test_init)

local function added()
test.socket.device_lifecycle:__queue_receive({ mock_device.id, "added" })
test.socket.capability:__expect_send( mock_device:generate_test_message("main", capabilities.lockCodes.migrated(true, { visibility = { displayed = false } })))

test.socket.zwave:__expect_send(
DoorLock:OperationGet({}):build_test_tx(mock_device.id)
Expand All @@ -58,7 +56,6 @@ local function added()
)
test.socket.capability:__expect_send(mock_device:generate_test_message("main", capabilities.tamperAlert.tamper.clear()))
test.wait_for_events()
assert(mock_device:get_field(lock_utils.SLGA_MIGRATED) == true, "Device should be marked as migrated")
end

test.register_coroutine_test(
Expand Down
217 changes: 0 additions & 217 deletions drivers/SmartThings/zwave-lock/src/test/test_samsung_lock.lua

This file was deleted.

Loading
Loading