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

devid not found on v3.4 Gateway #614

Open
mjpoo opened this issue Nov 24, 2022 · 11 comments
Open

devid not found on v3.4 Gateway #614

mjpoo opened this issue Nov 24, 2022 · 11 comments

Comments

@mjpoo
Copy link

mjpoo commented Nov 24, 2022

Thanks for adding support for devices running version 3.4

I can connect to my Silvercrest gateway but the data that is returned is devid not found.

The options I'm supplying are:

{
  id: 'abc',
  key: 'xyz',
  version: '3.4'
}
@Apollon77
Copy link
Collaborator

Please run with "DEBUG=Tuyapi* node ..." and provide a full log

@mjpoo
Copy link
Author

mjpoo commented Nov 24, 2022

Sure thing @Apollon77

Here are the logs. It's interesting to see that the payload.version is 3.3 even though I'm feeding it version 3.4

  TuyAPI Finding missing IP undefined or ID abc +0ms
  TuyAPI Received UDP message. +1s
  TuyAPI UDP data: +7ms
  TuyAPI {
  TuyAPI   payload: {
  TuyAPI     ip: '192.168.999.999',
  TuyAPI     gwId: 'abc',
  TuyAPI     active: 2,
  TuyAPI     ablilty: 0,
  TuyAPI     encrypt: true,
  TuyAPI     productKey: 'xyz',
  TuyAPI     version: '3.3',
  TuyAPI     token: true
  TuyAPI   },
  TuyAPI   leftover: false,
  TuyAPI   commandByte: 19,
  TuyAPI   sequenceN: 0
  TuyAPI } +1ms
  TuyAPI Connecting to 192.168.999.999... +18ms
  TuyAPI Socket connected. +11ms
Connected to Silvercrest
  TuyAPI GET Payload: +4ms
  TuyAPI {
  TuyAPI   gwId: 'abc',
  TuyAPI   devId: 'abc',
  TuyAPI   t: '1669285486',
  TuyAPI   dps: {},
  TuyAPI   uid: 'abc'
  TuyAPI } +0ms
  TuyAPI Received data: XXX +13ms
  TuyAPI Parsed: +2ms
  TuyAPI {
  TuyAPI   payload: 'devid not found',
  TuyAPI   leftover: false,
  TuyAPI   commandByte: 10,
  TuyAPI   sequenceN: 1
  TuyAPI } +2ms
  TuyAPI Received DATA packet +3ms
  TuyAPI data: 10 : "devid not found" +1ms

The log is obfuscations are:

  • abc = device ID
  • xyz = device key
  • 192.168.999.999 = gateway IP
  • XXX = data

@Apollon77
Copy link
Collaborator

Cna you show your code please?

@Apollon77
Copy link
Collaborator

BTW: In fcat the version tag from the UDP message wins against whatever you initially set in the constructor because UDP is "devicee self declaration".

Do you have the localkey ?

@mjpoo
Copy link
Author

mjpoo commented Nov 24, 2022

Cna you show your code please?

I am using the boilerplate Asynchronous Basic Usage example code and, yes, I'm using the local device key (xyz in my obfuscated example). I am able to get the childIDs from the gateway as a result. I just thought it would be useful to know about this error message being returned in the data.

@Apollon77
Copy link
Collaborator

I guess the error goes away if you use issueGetOnConnect = false in the constructor options. By default 8as per docs) it tries to issue a get after connect biut if this is a gateway then mpst likel ythere are no data to get on the gateway.

@mjpoo
Copy link
Author

mjpoo commented Nov 25, 2022

Yes, if I specify issueGetOnConnect: false then the error goes away but I don't get the child data that I get otherwise (because it is not listening for data because of the flag).

I have no problem but the devid not found message will be confusing to others as it makes it sound as if the gateway could not be found when in fact it is connected and supplying child data.

@Apollon77
Copy link
Collaborator

What you mean with "getting child data"? I do not see anything in the debug log above and the error is the respinse to the GET call

@mjpoo
Copy link
Author

mjpoo commented Nov 25, 2022

What you mean with "getting child data"? I do not see anything in the debug log above and the error is the respinse to the GET call

I was referring to being able to get the data from the child devices using a gateway.get (despite the devid not found message).

@Apollon77
Copy link
Collaborator

The topic is the following: the "default get" can only use the main device id and sets that as gwid and as devId as it is in defaulz.

If you do a manual get you are free to set gwId and devId differently to get the real data - but the "automatic get on connect" can not handle that because it do not have the information. So simply use that flag and do a manual get after connect ith the correct parameters

@mjpoo
Copy link
Author

mjpoo commented Nov 25, 2022

Yes, I get (pardon the pun!) this. The topic of this issue is simply the confusing devid not found message that is returned as data. It did not phase me but others might find it confusing and so either documenting it or handling it for them (as you were previously) may be helpful.

index.js:171

data === 'json obj data unvalid' || data === 'data format error' /* || data === 'devid not found' */

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

2 participants