Closed JanekSMC closed 1 year ago
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.
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.
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!!!)
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 | {}Please see the exact menu item I specified above. That is the only function in the cloud API that ties back to local commands.
{ "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": "" }
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": "" }
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.
I've read Tuya's documentation on WiFi smart locks, and this seems to almost follow that reference design (unlockapp 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.
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?
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.
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.
I should be receiving my tuya wifi lock very soon. Should i post the logs here or just open a new issue?
Please open a new issue if it is not the same device.
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.
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.
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 :(
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.
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..
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.
Bluetooth and zigbee locks should now be possible to work via hubs in 2023.5.0. One such lock has already been added.
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?
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.
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!!