tuya-local
tuya-local copied to clipboard
[Device Support Request] Security Camera with Lock Control
Hello,
Complete newbie here.
I have a Tuya powered security camera which controls my gate. I don't want to get the camera working in homeassistant. However, this device is the only way which I can control my gate using IoT.
Unfortunately, the official Tuya integration only supports the camera (and very poorly since it goes from local to EU cloud back to local).
Thus far I have bumbled my way into discovering that in order to trigger the relay which opens/ closes my gate I need to issue a get request to DPS 148.
I've done this using tuya-cli by issuing the following command:
tuya-cli get --ip XXX --id XXX --key XXX--dps 148 --full --protocol-version 3.3
This returns true if the command was successful.
That is where my knowledge of how this all works ends though. Ideally, I want to create a button entity in HA which issues this command when pushed but I have no idea how/ where to begin.
I'm sure you will need more information from me regarding what this device is - please provide instructions and I will do my utmost to help.
Thanks
Currently the integration only supports devices that conform to a simple model where all available status are returned by an empty get request, and commands are optionally available as set requests to change individual values from the DPS returned by the get request.
I guess security devices are more commonly using obscure commands like this (a get request for a dp that is not visible in the default dps returned by the empty get request), and currently they are not really supported well.
Okay. Thank you for letting me know. It's a shame that even the official tuya integration doesn't properly support this application. I'm using an extremely hacky/ bodge way to get this working right now (tuya-cli installed on HAOS and running a shell command to open the gate)/
I know this isn't a tech support forum but is there a way to get devices to list the available DPS?
Since you have tuya-cli installed, I think you can use tuya-cli get --id DEVICE_ID --key LOCAL_KEY -a replacing DEVICE_ID and LOCAL_KEY with the appropriate values for your device.
Based on some changes in the tuya-cli repository, you may need to use --full instead of -a with newer versions of tuya-cli.
Further information on discovery of DPs: the most complete info seems to be available by using the iot.tuya.com device debugging feature, along with the browser development tools to capture the code used in the request (which happens to be the same code used for the local DPS index). Instructions are here (some is only relevant to zigbee devices, but mostly it is generic).
https://www.zigbee2mqtt.io/advanced/support-new-devices/03_find_tuya_data_points.html
Since this method reveals DPs that are not normally broadcast by the device, even if they are not listed in the API Explorer methods on iot.tuya.com, it seems to be the most complete source of info (though for DPs listed in the API Explorer, there is more information there on range of possible values, whereas the debug interface only gives you snapshots of actual values reported recently by your device).
As you mentioned in #365, you are right. My device doesn't broadcast status at all besides giving the usual semaphore I'm alive response to Tuya Cloud.
It seems it only provides status updates when things change and assumes you know what you are doing. Running tuya-cli get -full seemingly crashes the device.
What I have been able to figure out from messing about is (more for my benefit in the future in case your awesome integration is changed):
- dps: 148
description: Gate Controller
values: true, false
action: Will switch to true for 2 seconds while unlocking the gate, then switch to false. Attempting to query or set this DPS to anything will cause the gate to open.
- dps: 136
description: Doorbell
values: -1 (I'm assuming this is a signed binary number)
action: Will report a value of -1 when the doorbell is pressed. Otherwise, doesn't report anything. Attempting to query or set this DPS triggers the Doorbell.
- dps: 154
description: Doorbell Snapshot
values: Base64 Encoded URL
action: Will report a Base64 Encoded URL with a https link to a jpeg image of the camera when the doorbell was pressed. Link expires after 60s.
These 3 dps seem to match the rl_video_intercom from #462, which had a similar issue with dps not showing up by default. It may be a variant of the same device, so try that config and see if it can work.
Closing on assumption that the rl_video_intercom config is sufficient to support this device also
@make-all Sorry about being so slow to get back to you here... this was stalled for a long while and I didn't see the update.
This update doesn't work and I think I know why. Using tuya-cli I've never been able to get a status response using tuya-cli get --full or any other commands - I assume this is deliberately some kind of hardening against attacks because the device takes itself completely offline when you do this (and it can only be rectified by powering the device off then on again). When no status response is provided tuya-local assumes the device isn't working and gives the connection error specified.
The device is 100% working because I can use tuya-cli to manually do what I want it to do - just a pain to have to use shell commands and include tuya-cli to my install to open and close my gate.