Skip to content

Commit 201fee6

Browse files
hcarter-775claude
andcommitted
Revert "Z-Wave Lock: Restore Migration on Device Added (#3323)"
This reverts commit 91a7498. Conflicts with later changes (#3337, #3339, #3346) in the zwave-lock tests were resolved by dropping the tests added by #3323 and keeping the lock_utils require and Schlage mock device that remaining code and tests still use. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent e37c85b commit 201fee6

5 files changed

Lines changed: 0 additions & 557 deletions

File tree

‎drivers/SmartThings/zwave-lock/src/init.lua‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@ local capability_handlers = require "lock_handlers.capabilities"
2424
local LockLifecycle = {}
2525

2626
function LockLifecycle.device_added(driver, device)
27-
if device:supports_capability(capabilities.lockCodes) and device._provisioning_state == "TYPED" then
28-
-- set the migrated field to true so new devices use lockCredentials/lockUsers from the start.
29-
-- auto-migration is only run for typed devices, as provisioned devices have already been onboarded,
30-
-- and should be migrated manually by the user.
31-
device:emit_event(capabilities.lockCodes.migrated(true, { visibility = { displayed = false } }))
32-
device:set_field(consts.DRIVER_STATE.SLGA_MIGRATED, true, { persist = true })
33-
end
3427
if device:supports_capability(capabilities.tamperAlert) then
3528
device:emit_event(capabilities.tamperAlert.tamper.clear())
3629
end

‎drivers/SmartThings/zwave-lock/src/test/test_init_lifecycle_handlers.lua‎

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@ local mock_device_base = test.mock_device.build_test_zwave_device({
3838
zwave_endpoints = zwave_lock_endpoints,
3939
})
4040

41-
-- Same profile but provisioning_state = "TYPED" (freshly fingerprinted)
42-
local mock_device_typed = test.mock_device.build_test_zwave_device({
43-
profile = t_utils.get_profile_definition("base-lock.yml"),
44-
zwave_endpoints = zwave_lock_endpoints,
45-
_provisioning_state = "TYPED",
46-
})
47-
4841
-- Schlage manufacturer (reports its own PIN length via configuration)
4942
local mock_device_schlage = test.mock_device.build_test_zwave_device({
5043
profile = t_utils.get_profile_definition("base-lock.yml"),
@@ -79,31 +72,6 @@ end
7972
-- added (device_added)
8073
-- ============================================================================
8174

82-
test.register_coroutine_test(
83-
"added: TYPED device with lockCodes emits migrated event, persists SLGA_MIGRATED, and injects refresh",
84-
function()
85-
test.socket.device_lifecycle:__queue_receive({ mock_device_typed.id, "added" })
86-
87-
-- Migrated event emitted for TYPED+lockCodes device
88-
test.socket.capability:__expect_send(
89-
mock_device_typed:generate_test_message("main",
90-
capabilities.lockCodes.migrated(true, { visibility = { displayed = false } }))
91-
)
92-
-- inject_capability_command calls the refresh handler:
93-
-- DoorLock:OperationGet, Battery:Get, UserCode:UsersNumberGet (no cached values)
94-
test.socket.zwave:__expect_send(DoorLock:OperationGet({}):build_test_tx(mock_device_typed.id))
95-
test.socket.zwave:__expect_send(Battery:Get({}):build_test_tx(mock_device_typed.id))
96-
test.socket.zwave:__expect_send(UserCode:UsersNumberGet({}):build_test_tx(mock_device_typed.id))
97-
test.wait_for_events()
98-
99-
assert(
100-
mock_device_typed:get_field(constants.DRIVER_STATE.SLGA_MIGRATED) == true,
101-
"SLGA_MIGRATED must be true after added fires for a TYPED device"
102-
)
103-
end,
104-
{ test_init = make_test_init(mock_device_typed) }
105-
)
106-
10775
test.register_coroutine_test(
10876
"added: non-TYPED (PROVISIONED) device with lockCodes does NOT emit migrated but still injects refresh",
10977
function()
@@ -270,36 +238,5 @@ test.register_coroutine_test(
270238
{ test_init = make_test_init(mock_device_battery) }
271239
)
272240

273-
-- ============================================================================
274-
-- driverSwitched (LockLifecycle.driver_switched)
275-
-- ============================================================================
276-
277-
test.register_coroutine_test(
278-
"driver_switched: device with lockCodes and migrated=true persists SLGA_MIGRATED and updates metadata",
279-
function()
280-
test.socket.device_lifecycle:__queue_receive({ mock_device_typed.id, "added" })
281-
282-
-- Migrated event emitted for TYPED+lockCodes device
283-
test.socket.capability:__expect_send(
284-
mock_device_typed:generate_test_message("main",
285-
capabilities.lockCodes.migrated(true, { visibility = { displayed = false } }))
286-
)
287-
-- inject_capability_command calls the refresh handler:
288-
-- DoorLock:OperationGet, Battery:Get, UserCode:UsersNumberGet (no cached values)
289-
test.socket.zwave:__expect_send(DoorLock:OperationGet({}):build_test_tx(mock_device_typed.id))
290-
test.socket.zwave:__expect_send(Battery:Get({}):build_test_tx(mock_device_typed.id))
291-
test.socket.zwave:__expect_send(UserCode:UsersNumberGet({}):build_test_tx(mock_device_typed.id))
292-
test.wait_for_events()
293-
294-
-- driverSwitched occurs after added, so migrated=true is already set in the capability state cache
295-
test.socket.device_lifecycle:__queue_receive({ mock_device_typed.id, "driver_switched" })
296-
mock_device_typed:expect_metadata_update({ provisioning_state = "PROVISIONED" })
297-
test.wait_for_events()
298-
299-
assert(mock_device_typed:get_field(constants.DRIVER_STATE.SLGA_MIGRATED) == true)
300-
end,
301-
{ test_init = make_test_init(mock_device_typed) }
302-
)
303-
304241
-- ============================================================================
305242
test.run_registered_tests()

‎drivers/SmartThings/zwave-lock/src/test/test_keywe_lock.lua‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ local DoorLock = (require "st.zwave.CommandClass.DoorLock")({ version = 1 })
99
local Battery = (require "st.zwave.CommandClass.Battery")({ version = 1 })
1010
local Notification = (require "st.zwave.CommandClass.Notification")({ version = 3 })
1111
local UserCode = (require "st.zwave.CommandClass.UserCode")({ version = 1 })
12-
local lock_utils = require "lock_utils.constants".DRIVER_STATE
1312

1413
test.disable_startup_messages()
1514

@@ -45,7 +44,6 @@ test.set_test_init_function(test_init)
4544

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

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

6461
test.register_coroutine_test(

‎drivers/SmartThings/zwave-lock/src/test/test_samsung_lock.lua‎

Lines changed: 0 additions & 224 deletions
This file was deleted.

0 commit comments

Comments
 (0)