Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Nice Digi X1 Smart Lock #71

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bb12489
Copy link

@bb12489 bb12489 commented Sep 13, 2023

Added support for Nice Digi X1 Smart Lock based on @raphaeleduardo42 PR

The sensors and volume/language settings all work, but the BLE unlock doesn't appear to work.

Added support for Nice Digi X1 Smart Lock based on @raphaeleduardo42 PR
@pccr10001
Copy link

I did reverse engineering on unlocking lock for supporting dp_id 71 and now my lock is working on unlocking.
You need to know the devUnlockId and ins parameters from Tuya IoT platform.
Instruction to get devUnlockId and ins:

  • Go to Device Debugging page on Tuya IoT platform, select DP_ID to Ble unlock(with key) and click Search, payload will show in Event Details.
  • Go to Cloud API Explorer and select Device Control -> Query Properties, enter device ID and code ble_unlock_check, then click Submit Request, payload will show in result.properties[0].value

The payload from platform is encoded by Base64, the format of payload:

[ xx xx ][ ff ff ][ 31 32 33 34 35 36 37 38 ][ xx xx xx xx xx xx xx ][ 00 ][ 0x ]
[ devUnlockId ][ fixed ][ ins ][ epoch ][ fixed ][ 00 is fine to unlock]

Datapoint value to send by BLE is different format:

[ ff ff ][ xx xx ][ 31 32 33 34 35 36 37 38 ][ 01 ][ xx xx xx xx xx xx xx ][ 00 ][ 0x ]
[ fixed ][ devUnlockId ][ ins ][01][ epoch ][ fixed ][ 00 is fine to unlock]

So I can unlock my lock with following code:

datapoint = self._device.datapoints.get_or_create(
    self._mapping.dp_unlock_id,  """ dp_id for unlock is 71 """
    TuyaBLEDataPointType.DT_RAW
    )
d = "ffff" + devUnlockId + ins + "01" + int(time.time()).to_bytes(4, 'big').hex() + "0000"
new_value = bytes.fromhex(d)

Hope my research can help you for developing this integration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants