Tuya-BLE icon indicating copy to clipboard operation
Tuya-BLE copied to clipboard

Add support: KNOB LOCK (pkhl2zbs, jtmspro) — new-security FD50 variant requiring sec_key [lock+unlock verified]

Open darianmis opened this issue 2 weeks ago • 1 comments

Add support: "KNOB LOCK" (pkhl2zbs, category jtmspro) — new-security FD50 variant (needs sec_key)

Reporting a working local-BLE integration for a jtmspro lock that the current FD50 code does not handle out of the box. Lock and unlock are verified on real hardware (unlock→lock→unlock→lock, all DPS_V4 acked status=0, LEDs matched). Happy to turn this into a PR.

Device

  • Category: jtmspro
  • Product ID: pkhl2zbs
  • Cloud/product name: KNOB LOCK (knob/cylinder style)
  • BLE local name: KNOB
  • GATT: only the FD50 service is present (no legacy a201):
    • Service 0000fd50-0000-1000-8000-00805f9b34fb
    • Write 00000001-0000-1001-8001-00805f9b07d0 (write / write-no-rsp)
    • Notify 00000002-0000-1001-8001-00805f9b07d0
  • Advertisement: manufacturer_data id 0x07D0, protocol byte = 0x00.

Why existing FD50 profiles fail on this model

The classic path (flag 0x04 login + MD5(local_key[:6])) and the existing hc7n0urm / ikphogdj FD50 framings all time out on the DEVICE_INFO/login exchange — the lock drops the link ~1–2 s after the first write (same symptom as issue #26 / ajk32biq). This model uses Tuya's "new-security" scheme, which needs a per-device sec_key:

Step What works on this lock
Login flag / key 0x0E, key = MD5(local_key + sec_key)
Session flag / key 0x0F, key = MD5(local_key + sec_key + srand)
DEVICE_INFO payload 00 f4 (declare MTU 244) sent as a single large write
PAIR classic 44-byte body; status = 2 ("already paired") = OK
After PAIR must answer the 0x8011 TIME1 request immediately, or the lock drops the link
Commands FUN_SENDER_DPS_V4 (0x0027)
Reports 0x8006: 7-byte header, then DP TLVs with a 2-byte length field

sec_key

This is the missing piece vs. the already-supported FD50 locks. sec_key is not exposed by the Tuya OpenAPI (cloud) — it only comes from the Smart Life mobile API (thing.m.device.get), i.e. the same mobile-login path asemenov566/tuya_smartlock_local_ble and ha-tuya-ble mobile login use. Owners fetch their own device's sec_key once and store it alongside local_key / uuid / device_id / ble_unlock_check.

Datapoints

  • manual_lock = DP 46 (bool) — remote lock
  • unlock trigger = DP 6 (the integration's remote-unlock DP)
  • ble_unlock_check = DP 71 (raw) — used to build the V4 unlock command
  • lock_motor_state = DP 47 (bool), residual_electricity = DP 8, closed_opened = DP 40, unlock_ble = DP 19, lock_record = DP 20
  • Note: on this unit DP 47 did not reliably flip between commanded lock/unlock in quick reads, so I drive state optimistically from the command rather than trusting DP 47. (Confirmation welcome.)

Verified command map

Lock — DP 46 bool true (01). LED: green = locked.

Unlock — a DP 71 raw V4 write built from ble_unlock_check (do not send the raw cloud status bytes). 19-byte wire payload:

ff ff 00 01 | ble_unlock_check[4:12] (8 ASCII digits) | 01 | unix_ts (uint32 BE) | 00 01

(The cloud ble_unlock_check status itself is laid out 00 01 ff ff | … | 00 00; the transform above is what the lock accepts.) LED: green + red flash = unlocked.

Suggested change

Add pkhl2zbs to the jtmspro device table + lock mapping (dp_id_lock=46, dp_id_unlock=6, state dp=47, nop=52), and gate it onto the new-security (0x0E/0x0F + sec_key) login path with the 00 f4 DEVICE_INFO single-write framing and the TIME1 answer. I can submit a PR with a tested device profile if that's useful — let me know the preferred shape.

(All testing done on my own lock, on my own Smart Life account. No credentials included here — local_key / sec_key / ble_unlock_check are per-device secrets.)

darianmis avatar Nov 17 '26 05:11 darianmis

As stated earlier, if you want a new device supported, you'll have to open a PR for it. The same LLM that you used to write this issue report can help you do that.

ShonP40 avatar Nov 18 '26 06:11 ShonP40