Giter VIP home page Giter VIP logo

Comments (8)

codetheweb avatar codetheweb commented on May 23, 2024

First make sure you're running the latest version of tuyapi. Running npm list tuyapi should result in output starting with [email protected].
If that looks good, your device may be the problem. Maybe it uses a slightly different protocol. Try running your test script a few times and see if the issue crops up each time.

from tuyapi.

clach04 avatar clach04 commented on May 23, 2024

One of the things I've not yet had time to do is add debug trace logging to https://github.com/clach04/python-tuya for this sort of scenario where the response payload is unexpected.

from tuyapi.

danlakey avatar danlakey commented on May 23, 2024

@codetheweb thank you for you're reply. Ran npm list tuyapi and the output was [email protected]
Ran the test script 6 more times with the outlet starting in the turned on state and the result as I posted originally was the same each time.
Ran the test script a few more times with the outlet starting in the turned off state and the result is slightly different, in that in cannot return the status at all, goes right to the:

SyntaxError: Unexpected token � in JSON at position 56 at Object.parse (native) at _send.then.err (/home/utladmin/node/tuyapi/node_modules/tuyapi/index.js:64:19) at process._tickCallback (internal/process/next_tick.js:109:7)

Seems like the getStatus cannot communicate with the device when it's in the off state. The specific device I'm working with the MartinJerry mini Smart Plug.

Totally could believe that that this specific device is slightly different than what you guys are working with. I may also try to re-run through the instructions on how I pulled the access info (uid, key, etc) and see if I see any different/additional details.

Thanks again for everyone's time looking into my post, I do appreciate it.

from tuyapi.

codetheweb avatar codetheweb commented on May 23, 2024

Weird. I'm currently really busy, but I'll try to add a flag to the constructor in the next few days that outputs some debug information to the console. Hopefully that helps us pin down this issue.

from tuyapi.

clach04 avatar clach04 commented on May 23, 2024

I think I know what is going on... I've no idea why though 🎱

Sometimes status returns an encrypted payload. Again I've no idea why/when this occurs. I can induce this sometimes by making a bunch of status requests in a row. See clach04/python-tuya#6 for a Python test case (and fix).

I've resolved this by decrypting the result and sending back the status dictionary. What is interesting is that this payload has additional keys. t is epoch seconds, s I'm still trying to workout.

from tuyapi.

codetheweb avatar codetheweb commented on May 23, 2024

This should be fixed by v2.0 @danlakey. Please update tuyapi, update your code (v2.0 includes breaking changes), and it should now work.

from tuyapi.

danlakey avatar danlakey commented on May 23, 2024

Apologies for the late response, guys. Winter storms knocked out my system and just got everything back online. The change v2.0 worked! I updated from NPM, then used the updated sample code and was able to turn the switch on/off. Thank you!

from tuyapi.

codetheweb avatar codetheweb commented on May 23, 2024

Glad to here it.

from tuyapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.