codetheweb / tuyapi

🌧 An easy-to-use API for devices that use Tuya's cloud services. Documentation: https://codetheweb.github.io/tuyapi.
MIT License
2.04k stars 332 forks source link

Access control kit / lock not working #542

Closed Alexa-RR closed 2 years ago

Alexa-RR commented 2 years ago

Describe the bug I recently bought an access control kit from TMEZON that includes a doorbell and a screen, using the app I can open a gate, I wanted to try to do it locally so it would be faster/ be able to set up custom automatons, after registering the device with the tuya smart app I was able to connect to it and get its device logs, when I went to find what DP I need to use to open up the gate I was surprised to find that its not exposed in the tuya cloud api but I was able to use it in the app, so I thought I could set it locally and opened up device logs with debug options and press the gate unlock button on the app I found out the DP is 233 and the value to open it up is 0, meaning if I set the value to 0 the gate should open up, when I tried setting 233 to 0 It didn't do anything and just responded back with a DP_REFRESH event of the value 1, if the app was opened when I sent the local commend it would say "fault" in the middle of the screen.|

Also when I want to open the gate in the app it requires a 6 digit password to open

Expected behavior When setting DP 233 to 0 the gate would open

Debug Output Opening Using the app: (replaced ip, device id and key with xxxxxxxxxx)

[alexa@media-server ~]$ DEBUG=* tuya-cli get --ip xxxxxxxx --id xxxxxxxxxxxxx --key xxxxxxxxxxxxxx --protocol-version 3.3
  TuyAPI IP and ID are already both resolved. +0ms
  TuyAPI Connecting to xxxxxxxxxxxx... +5ms
  TuyAPI Socket connected. +6ms
  TuyAPI GET Payload: +2ms
  TuyAPI {
  TuyAPI   gwId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  TuyAPI   devId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx',
  TuyAPI   t: '1636912969',
  TuyAPI   dps: {},
  TuyAPI   uid: 'xxxxxxxxxxxxxx'
  TuyAPI } +0ms
  TuyAPI Received data: 000055aa000000010000000a0000002c00000001f78c6991423104bdd64c619da63fd47ddd470eaa067c5fca7b9be14aeabcc9474bdd2efd0000aa55 +14ms
  TuyAPI Parsed: +2ms
  TuyAPI {
  TuyAPI   payload: 'json obj data unvalid',
  TuyAPI   leftover: false,
  TuyAPI   commandByte: 10,
  TuyAPI   sequenceN: 1
  TuyAPI } +0ms
  TuyAPI Received DATA packet +0ms
  TuyAPI SET Payload: +1ms
  TuyAPI {
  TuyAPI   devId: 'xxxxxxxxxxxxxxxxxxxxxxxx',
  TuyAPI   gwId: 'xxxxxxxxxxxxxxxxxxxx',
  TuyAPI   uid: '',
  TuyAPI   t: 1636912969,
  TuyAPI   dps: { '1': null }
  TuyAPI } +0ms
  TuyAPI Received data: 000055aa00000002000000070000000c0000000018cfc5da0000aa55 +4ms
  TuyAPI Parsed: +1ms
  TuyAPI { payload: false, leftover: false, commandByte: 7, sequenceN: 2 } +0ms
  TuyAPI Got SET ack. +0ms
Error [ERR_UNHANDLED_ERROR]: Unhandled error. ('Timeout waiting for status response from device id: bfc946065e84873d01tqwg')
    at new NodeError (internal/errors.js:322:7)
    at TuyaDevice.emit (events.js:389:17)
    at /usr/local/lib/node_modules/@tuyapi/cli/node_modules/tuyapi/index.js:369:12
    at Timeout._onTimeout (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/p-timeout/index.js:25:13)
    at listOnTimeout (internal/timers.js:557:17)
    at processTimers (internal/timers.js:500:7) {
  code: 'ERR_UNHANDLED_ERROR',
  context: 'Timeout waiting for status response from device id: xxxxxxxxxxxxxxxxxxxxxx'
}
  TuyAPI Pinging xxxxxxxxxxxxxxxxxxxxxxxxxxx +10s
  TuyAPI Received data: 000055aa00000000000000090000000c00000000b051ab030000aa55 +3ms
  TuyAPI Parsed: +0ms
  TuyAPI { payload: false, leftover: false, commandByte: 9, sequenceN: 0 } +0ms
  TuyAPI Pong from xxxxxxxxxxxxxxxx +1ms
  TuyAPI Pinging xxxxxxxxxxxxxxxxxx +10s
  TuyAPI Received data: 000055aa00000000000000090000000c00000000b051ab030000aa55 +2ms
  TuyAPI Parsed: +0ms
  TuyAPI { payload: false, leftover: false, commandByte: 9, sequenceN: 0 } +0ms
  TuyAPI Pong from xxxxxxxxxxxxxxx +1ms
  TuyAPI Pinging xxxxxxxxxxxxxx +10s
  TuyAPI Received data: 000055aa00000000000000090000000c00000000b051ab030000aa55 +2ms
  TuyAPI Parsed: +0ms
  TuyAPI { payload: false, leftover: false, commandByte: 9, sequenceN: 0 } +0ms
  TuyAPI Pong from xxxxxxxxxxxxxxxxxx +0ms
  TuyAPI Received data: 000055aa00000000000000080000004b00000000332e330000000000000da0000000013beb262dc611bf0922eb07cda477469e2017ae6f75da63edecd0a2dd6beba7047ea4dade4c8ec4155ba97ec05542882d7e1553da0000aa55 +656ms
  TuyAPI Parsed: +1ms
  TuyAPI {
  TuyAPI   payload: { dps: { '233': '0' }, t: 1636912999 },
  TuyAPI   leftover: false,
  TuyAPI   commandByte: 8,
  TuyAPI   sequenceN: 0
  TuyAPI } +0ms
  TuyAPI Received DP_REFRESH packet. +1ms

Opening using commend

DEBUG=* tuya-cli set --ip xxxxxxxxxx --id xxxxxxxxxxxxxx --key xxxxxxxxxxxxxxxxx --protocol-version 3.3 --dps 233 --set 0
  TuyAPI IP and ID are already both resolved. +0ms
  TuyAPI Connecting to xxxxxxxxxxxxxxx... +4ms
  TuyAPI Socket connected. +4ms
  TuyAPI SET Payload: +2ms
  TuyAPI {
  TuyAPI   devId: 'xxxxxxxxxxxxx',
  TuyAPI   gwId: 'xxxxxxxxxxxxxxxxxx',
  TuyAPI   uid: '',
  TuyAPI   t: 1636913095,
  TuyAPI   dps: { '233': 0 }
  TuyAPI } +0ms
  TuyAPI Received data: 000055aa00000001000000070000000c00000000a505a9140000aa55 +11ms
  TuyAPI Parsed: +1ms
  TuyAPI { payload: false, leftover: false, commandByte: 7, sequenceN: 1 } +0ms
  TuyAPI Got SET ack. +1ms
  TuyAPI Received data: 000055aa00000000000000080000004b00000000332e330000000000000da100000001b9cee97480970804b8e8599072ec625974ab5245bd8fa822aae3acb043d0775c8b48243d79e94ff963247b2748c4426e37bac5490000aa55 +8ms
  TuyAPI Parsed: +1ms
  TuyAPI {
  TuyAPI   payload: { dps: { '233': '1' }, t: 1636913095 },
  TuyAPI   leftover: false,
  TuyAPI   commandByte: 8,
  TuyAPI   sequenceN: 0
  TuyAPI } +0ms
  TuyAPI Received DP_REFRESH packet. +0ms
  TuyAPI Disconnect +1ms
Set succeeded.
  TuyAPI Socket closed: xxxxxxxxxxxxxx +1ms

When I try to open the gate using the app it looks like this:

IMG-0080

When I try to open the gate using the commend above: IMG-0081

Desktop (please complete the following information):

codetheweb commented 2 years ago

From working with the cloud API for locks before, I'm guessing they either use a slightly different local protocol or (more likely) don't support local control at all.

Converting to discussion as I don't have plans at the moment to add support for locks (and/or it would be out of scope).