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

Request for smart lock support #162

Closed
JanekSMC opened this issue Apr 16, 2022 · 23 comments
Closed

Request for smart lock support #162

JanekSMC opened this issue Apr 16, 2022 · 23 comments

Comments

@JanekSMC
Copy link

Specifically the Orion grid connect wifi smart deadlock. But I note an absence of any smart locks in the list of supported devices (also possible I totally missed them somehow!!)

I’ve never made a request before, but I’m happy to provide any required info!

When I add devid up and local key it just times out with an unknown error.

thanks!!

@make-all
Copy link
Owner

After you add the device, and get either an error saying no matching devices or get offered simple switch as the only match, look in the Home Assistant logs. There should be a couple of warning messages from the tuya-local integration, one of which will have the actual data received from the device that it tried to match to a config.

That would be a starting point. Another good source of data if you signed up to the iot.tuya.com dev portal to get the local key, is under "Cloud" / "API Explorer", then "Smart Home Management System" / "Device Control" / "Get Device Specification Attributes". Choose the data center your device is registered to, and enter the device ID. This should contain an explanation of each field and ranges of the values, and tie the fields to local dp_ids. Often not all local dps are available in the cloud API, but the useful ones usually are.

@make-all make-all added the new device Unsupported device label Apr 16, 2022
@make-all
Copy link
Owner

Probably some work is required to support actual security locks, as the current support for locks is only used for child locks on other devices, so is very simple.

@JanekSMC
Copy link
Author

I’ll get into the API as soon as I can get to my laptop, it’s excruciating to use the cloud explorer site on mobile.

In all honesty, I would settle for remote lock, though remote unlock would be nice too, could make for some fantastic automations (especially with toddlers!!!)

@JanekSMC
Copy link
Author

From the debugging menu in tuya developer: Device name: DL017HA Wi-Fi Deadbolt

standard status set:

unlock_fingerprint Integer { "unit": "", "min": 0, "max": 999, "scale": 0, "step": 1 }
unlock_password Integer { "unit": "", "min": 0, "max": 999, "scale": 0, "step": 1 }
unlock_temporary Integer { "unit": "", "min": 0, "max": 999, "scale": 0, "step": 1 }
unlock_dynamic Integer { "min": 0, "max": 999, "scale": 0, "step": 1 }
unlock_card Integer { "unit": "", "min": 0, "max": 999, "scale": 0, "step": 1 }
alarm_lock Enum { "range": [ "wrong_finger", "wrong_password", "wrong_card", "wrong_face", "tongue_bad", "too_hot", "unclosed_time", "tongue_not_out", "pry", "key_in", "low_battery", "power_off", "shock" ] }
unlock_request Integer { "unit": "", "min": 0, "max": 90, "scale": 0, "step": 1 }
residual_electricity Integer { "unit": "", "min": 0, "max": 100, "scale": 0, "step": 1 }
unlock_app Integer { "unit": "", "min": 0, "max": 999, "scale": 0, "step": 1 }
hijack Boolean "{true,false}"
update_all_finger List {}
update_all_password List {}
update_all_card List {}

@make-all
Copy link
Owner

Please see the exact menu item I specified above. That is the only function in the cloud API that ties back to local commands.

@JanekSMC
Copy link
Author

{
"result": {
"category": "ms",
"functions": [],
"status": [
{
"code": "unlock_fingerprint",
"lang_config": {
"unit": ""
},
"name": "fingerprint unlock",
"type": "Integer",
"values": "{"unit":"","min":0,"max":999,"scale":0,"step":1}"
},
{
"code": "unlock_password",
"lang_config": {
"unit": ""
},
"name": "password unlock",
"type": "Integer",
"values": "{"unit":"","min":0,"max":999,"scale":0,"step":1}"
},
{
"code": "unlock_temporary",
"lang_config": {
"unit": ""
},
"name": "temporary password unlock",
"type": "Integer",
"values": "{"unit":"","min":0,"max":999,"scale":0,"step":1}"
},
{
"code": "unlock_dynamic",
"lang_config": {
"unit": ""
},
"name": "dynamic password unlock",
"type": "Integer",
"values": "{"min":0,"max":999,"scale":0,"step":1}"
},
{
"code": "unlock_card",
"lang_config": {
"unit": ""
},
"name": "card unlock",
"type": "Integer",
"values": "{"unit":"","min":0,"max":999,"scale":0,"step":1}"
},
{
"code": "alarm_lock",
"lang_config": {
"key_in": "key in use",
"low_battery": "low battery",
"power_off": "no power",
"pry": "forceful tamper alert",
"shock": "tamper alert",
"tongue_bad": "deadbolt stuck",
"tongue_not_out": "bolt extension unsuccessful",
"too_hot": "temperature too high",
"unclosed_time": "unlocked timeout",
"wrong_card": "invalid tag",
"wrong_face": "invalid facial recognition (not available)",
"wrong_finger": "invalid fingerprint",
"wrong_password": "invalid passcode"
},
"name": "lock alert",
"type": "Enum",
"values": "{"range":["wrong_finger","wrong_password","wrong_card","wrong_face","tongue_bad","too_hot","unclosed_time","tongue_not_out","pry","key_in","low_battery","power_off","shock"]}"
},
{
"code": "unlock_request",
"lang_config": {
"unit": ""
},
"name": "Remote Unlock Request",
"type": "Integer",
"values": "{"unit":"","min":0,"max":90,"scale":0,"step":1}"
},
{
"code": "residual_electricity",
"lang_config": {
"unit": ""
},
"name": "battery percentage",
"type": "Integer",
"values": "{"unit":"","min":0,"max":100,"scale":0,"step":1}"
},
{
"code": "unlock_app",
"lang_config": {
"unit": ""
},
"name": "app request unlock",
"type": "Integer",
"values": "{"unit":"","min":0,"max":999,"scale":0,"step":1}"
},
{
"code": "hijack",
"lang_config": {
"false": "off",
"true": "on"
},
"name": "unlock alert",
"type": "Boolean",
"values": "{}"
},
{
"code": "update_all_finger",
"lang_config": {
"unit": ""
},
"name": "Update all fingerprint",
"type": "List",
"values": "{}"
},
{
"code": "update_all_password",
"lang_config": {
"unit": ""
},
"name": "Update all password",
"type": "List",
"values": "{}"
},
{
"code": "update_all_card",
"lang_config": {
"unit": ""
},
"name": "Update all Card",
"type": "List",
"values": "{}"
}
]
},
"success": true,
"t": ,
"tid": ""
}

@JanekSMC
Copy link
Author

Actually, apologies, that wasnt from the SHM segment of the developer console. I think this is what you're after? This is from "Get Device Specification Attribute" as opposed to "Get device specification attributes". the singular attribute page seems to me to have data more aligned with local control

{
"result": {
"category": "ms",
"functions": [],
"status": [
{
"code": "unlock_fingerprint",
"dp_id": 1,
"type": "Integer",
"values": "{"unit":"","min":0,"max":999,"scale":0,"step":1}"
},
{
"code": "unlock_password",
"dp_id": 2,
"type": "Integer",
"values": "{"unit":"","min":0,"max":999,"scale":0,"step":1}"
},
{
"code": "unlock_temporary",
"dp_id": 3,
"type": "Integer",
"values": "{"unit":"","min":0,"max":999,"scale":0,"step":1}"
},
{
"code": "unlock_dynamic",
"dp_id": 4,
"type": "Integer",
"values": "{"min":0,"max":999,"scale":0,"step":1}"
},
{
"code": "unlock_card",
"dp_id": 5,
"type": "Integer",
"values": "{"unit":"","min":0,"max":999,"scale":0,"step":1}"
},
{
"code": "alarm_lock",
"dp_id": 8,
"type": "Enum",
"values": "{"range":["wrong_finger","wrong_password","wrong_card","wrong_face","tongue_bad","too_hot","unclosed_time","tongue_not_out","pry","key_in","low_battery","power_off","shock"]}"
},
{
"code": "unlock_request",
"dp_id": 9,
"type": "Integer",
"values": "{"unit":"","min":0,"max":90,"scale":0,"step":1}"
},
{
"code": "residual_electricity",
"dp_id": 12,
"type": "Integer",
"values": "{"unit":"","min":0,"max":100,"scale":0,"step":1}"
},
{
"code": "unlock_app",
"dp_id": 15,
"type": "Integer",
"values": "{"unit":"","min":0,"max":999,"scale":0,"step":1}"
},
{
"code": "hijack",
"dp_id": 16,
"type": "Boolean",
"values": "{}"
},
{
"code": "update_all_finger",
"dp_id": 25,
"type": "List",
"values": "{}"
},
{
"code": "update_all_password",
"dp_id": 26,
"type": "List",
"values": "{}"
},
{
"code": "update_all_card",
"dp_id": 27,
"type": "List",
"values": "{}"
}
]
},
"success": true,
"t": ,
"tid": ""
}

@make-all
Copy link
Owner

make-all commented Apr 17, 2022

So based on this, it seems it isn't possible to control the device (maybe only applies to from the cloud), only to monitor status. I guess maybe for local API, the remote and/or app unlock dps can also be used to unlock, but I don't know if there will need to be some code provided for security.

@make-all
Copy link
Owner

make-all commented Jul 3, 2022

I've read Tuya's documentation on WiFi smart locks, and this seems to almost follow that reference design (unlock_app is documented as a boolean, while here is is documented as an integer). One issue is that it doesn't seem to report the current status of the lock - unless a non-zero report in one of the unlock_.. fields is indicating that (the docs say it reports the last finger etc that unlocked the lock, but if it clears back to 0 when the door is locked, then it could work as an indicator).

It is also unclear to me whether all of these dps are always reported, I suspect at least the update_... ones are only reported when there is an update, as they are potentially large fields (maybe 500 bytes each after hex encoding). Getting a list of the dps actually reported by the lock would help clear this up. You should see such a list in a Warning message in the Home Assistant log when you try to add the device and it is unrecognised.

It seems from the Tuya docs that there should be a dp_id 10 which is used to remotely unlock the door in response to a request on dp_id 9 - though the documentation says it is read-only, which is confusing. dp_id 9 can also be used to set the countdown timer in which a request needs to be approved after the request is made. The above dps list should also clear up whether this is reported, or a write only field.

@make-all make-all added enhancement New feature or request awaiting feedback Needs more information labels Jul 3, 2022
make-all added a commit that referenced this issue Jul 3, 2022
Issue #162

- enhancements to lock to support jam detection, and reporting how the lock was unlocked, along with a request/approval unlock flow.
@make-all make-all added awaiting confirmation Wating for confirmation the issue is solved unreleased Will be in next release and removed enhancement New feature or request labels Jul 3, 2022
@ferbulous
Copy link

Hi @make-all great work on adding this since not even the official integration has lock support.
Could any tuya wifi lock work with this?

@make-all
Copy link
Owner

Other wifi locks could potentially work with this, but there are some other features in the Tuya docs such as face recognition unsupported by this lock which I have not implemented yet, so there is potentially more work needed.

@make-all make-all removed new device Unsupported device unreleased Will be in next release awaiting feedback Needs more information labels Jul 16, 2022
@make-all
Copy link
Owner

0.18.0 has the config I wrote for this lock. However, as there was no capture of the local data, only the Tuya portal info, I am not 100% sure it will work. If it is not detected still, please supply the WARNING messages from the Home Assistant log that relate to this device.

@ferbulous
Copy link

I should be receiving my tuya wifi lock very soon.
Should i post the logs here or just open a new issue?

@make-all
Copy link
Owner

Please open a new issue if it is not the same device.

@JanekSMC
Copy link
Author

Apologies I’ve been offline for so long, school holidays and all…

Wow, amazing work! Thankyou!! You are simply incredible! I am having issues connecting to the lock and I’m not sure what’s going on. I have my local ip, MAC address, devID localkey but it refuses to connect. I’ll dig up the logs ASAP for you.

@make-all
Copy link
Owner

make-all commented Aug 3, 2022

Just note if you pair with the app again, it will reassign a new local key. If you've already registered with the iot.tuya.com portal, you should be able to find the local key under some of the Cloud / API Explorer functions to confirm whether it has changed.

Also, tuya devices in general only handle one local connection at a time, so maybe turn off WiFi on your phone while you try connecting to HA to make sure the phone app is not hogging the local connection in the background.

@JanekSMC
Copy link
Author

JanekSMC commented Sep 9, 2022

Something odd is happening with my lock, it only ever pops online for a moment when it’s activated externally. I cannot seem to access it from any software, including the phone app. it doesn’t appear in my router as active or anything. That includes assigning PINs to it or temporary access codes. Frustrating!!!! Therefore I can’t even add it to the integration at all :(

@make-all
Copy link
Owner

make-all commented Sep 9, 2022

I think that is not unusual for battery powered devices. Generally such devices will only work properly via the cloud, as they only wake periodically to contact the server then go back to sleep.

@make-all make-all added device behaviour The device itself causes this behaviour and removed awaiting confirmation Wating for confirmation the issue is solved labels Sep 10, 2022
@make-all make-all added the bug Something isn't working label Sep 11, 2022
@make-all make-all added the cloud label Dec 11, 2022
@danieljohngomez
Copy link

danieljohngomez commented Feb 7, 2023

I just got this kind of smart lock today. Sleep mode is a bummer as it prevents us from sending commands to the device. If only there is a way to wake the device up..

@make-all make-all removed device behaviour The device itself causes this behaviour bug Something isn't working labels Feb 18, 2023
@jaydisc
Copy link

jaydisc commented Mar 31, 2023

Orion GridConnect sells quite a few Bluetooth locks that can integrate with their Bluetooth to WiFi hub. Is there a chance this integration could work through that hub, or does the hub prevent it? Thank you.

I've ordered one. Happy to be the guinea pig.

@make-all
Copy link
Owner

make-all commented May 7, 2023

Bluetooth and zigbee locks should now be possible to work via hubs in 2023.5.0. One such lock has already been added.

@make-all make-all closed this as completed May 7, 2023
@NicoxDJ
Copy link

NicoxDJ commented May 8, 2023

Hey @make-all I'm planning to buy this one BT Tuya lock: https://www.aliexpress.com/item/1005005145369411.html
There is also usb wifi hub in the description. Is it compatible with your software?

@make-all
Copy link
Owner

make-all commented May 9, 2023

Support for tuya hubs was just added. There have only been two reports though, one positive and one negative so it is not yet mature enough to give a definitive yes.

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

No branches or pull requests

6 participants