Comments (22)
from tuyapi.
@kirkbrownOK should be working now. Update the CLI tool with npm i @tuyapi/[email protected] -g
and please try again.
from tuyapi.
As there hasn't been any activity in the last 18 days on this, I'm closing it. Feel free to re-open it @kirkbrownOK if you're still having problems.
from tuyapi.
Hi
I have been struggling for while to control my tuya smart plug though njstuya api file.. I have followed the exact steps mentioned in git hub repository.
Appreciate your help in resolving the below issue.
$sudo node njstuya -ip 192.168.XX.XX -id adkepsh9u7acdv98h -key w4duxc9vkrsajt9gy7 OFF
/etc/openhab2/scripts/node_modules/node-forge/lib/aes.js:203
var len = tmp.length();
^
TypeError: tmp.length is not a function
at forge.aes.Algorithm.initialize (/etc/openhab2/scripts/node_modules/node-forge/lib/aes.js:203:19)
at new forge.cipher.BlockCipher (/etc/openhab2/scripts/node_modules/node-forge/lib/cipher.js:118:18)
at Object.forge.cipher.createCipher (/etc/openhab2/scripts/node_modules/node-forge/lib/cipher.js:42:10)
at new TuyaCipher (/etc/openhab2/scripts/node_modules/tuyapi/lib/cipher.js:13:30)
at new TuyaDevice (/etc/openhab2/scripts/node_modules/tuyapi/index.js:43:24)
at Object. (/etc/openhab2/scripts/njsTuya/scripts/njstuya.js:26:12)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
Also wanted to let you know that when I am trying to connect to the device through link wizard, it is throwing an error.
$sudo tuya-cli link-wizard
Make the indicator light on your device flash.
For most devices, this means holding down the main button.
Press return when it's blinking. Yes
? What's your WiFi called? IOT
? What's the password for your WiFi? [hidden]
? How many devices do you want to link? 1
? Do you want to save devices that are successfully linked? Yes
� Device(s) failed to be registered!
Device(s) failed to be registered!
{ code: 'SING_VALIDATE_FALED_4',
message: 'Parameter or Data Error' }
from tuyapi.
Two things:
- That appears to be the wrong format for the ID parameter, it should look more like this:
07200178dc4f223f4800
(20 characters long, vs. your ID which is 17 characters long). - If you simply want to toggle a device with a single property over the command line, I'd suggest using
@tuyapi/cli
instead as njstuya doesn't appear to be maintained. You can install the official CLI package like this:npm i @tuyapi/cli -g
and use it like this:tuya-cli set --id [your-id] --key w4duxc9vkrsajt9gy7 --set false
.
from tuyapi.
@codetheweb
Thanks for your quick reply.
In spite of using the correct ID format and CLI package @tuyapi/cli I am getting the below error.
pi@raspberrypi:/etc/openhab2/scripts $ tuya-cli set --id 0120057360019492b55d --key w4duxc9v3vkrsajt8gy7 --set false
/usr/local/lib/node_modules/@tuyapi/cli/node_modules/node-forge/lib/aes.js:203
var len = tmp.length();
^
TypeError: tmp.length is not a function
at forge.aes.Algorithm.initialize (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/node-forge/lib/aes.js:203:19)
at new forge.cipher.BlockCipher (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/node-forge/lib/cipher.js:118:18)
at Object.forge.cipher.createCipher (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/node-forge/lib/cipher.js:42:10)
at new TuyaCipher (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/tuyapi/lib/cipher.js:13:30)
at new TuyaDevice (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/tuyapi/index.js:43:24)
at parseConfig (/usr/local/lib/node_modules/@tuyapi/cli/lib/control.js:24:10)
at Object.set (/usr/local/lib/node_modules/@tuyapi/cli/lib/control.js:50:15)
at Command.program.command.description.option.option.option.option.option.action.options (/usr/local/lib/node_modules/@tuyapi/cli/cli.js:59:11)
at Command.listener (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/commander/index.js:315:8)
at Command.emit (events.js:182:13)
Note : I retrieve the ID of a smart plug from tuya app installed in my phone. Is there any other way to fetch the ID. I tried tuya-cli link-wizard but it did not work.
from tuyapi.
@RR2301 that looks like the right ID but still the wrong format for the key. Try following this guide to get the ID and key.
from tuyapi.
from tuyapi.
There's no other way to acquire the IDs and keys other than (a) performing a MITM attack on your phone (what tuya-cli list app
and the Android method do) or (b) generating an official linking token using Tuya's API and transmitting it to the device. The first method is relatively easy, the second is not and now costs money after Tuya has updated their API.
All that to say that you have to follow the guide to get the parameters. What's not working with list-app
? Do you have an iPhone? Did you trust the certificate (different than installing the certificate)?
from tuyapi.
from tuyapi.
People have been having issues with link-wizard
. If the list-app
command is working, you should be able to get your parameters from that. If not, you said you can see traffic in Charles so I'd advise looking through those requests to get the ID and key.
from tuyapi.
from tuyapi.
Does the tuya-cli set
work? You can do --set false
and --set true
to respectively turn your device off and on.
The other option would be to write your own script file in NodeJS using TuyAPI.
from tuyapi.
from tuyapi.
Hmm, your ID looks good but the key still looks too long (should be 16 characters). Could you post a link to the device that you bought? And how did you get those parameters?
Also, please make sure that your Node version is >=6.0.0. You can check with node -v
.
from tuyapi.
from tuyapi.
Your device looks fine, I have a very similar one. Can you please check your Node version? Did you get the above parameters with tuya-cli list-app
?
from tuyapi.
from tuyapi.
The list
command just outputs saved API keys and device parameters.
Do you have an iOS or Android smartphone?
from tuyapi.
from tuyapi.
from tuyapi.
It looks like it's only capturing the CONNECT requests for some reason, not actual traffic. Did you trust the certificate?
from tuyapi.
Related Issues (20)
- Some of my localtuya devices periodically become unavailable HOT 2
- App show "no access". I turn on all permissions when creating new Cloud Project. And I cheched my region. All right. HOT 1
- Implement 3.5 protocol
- Setting brightness overrides color / set multiple properties only applies last HOT 2
- Weird encrypted response from tuya bulb ? HOT 6
- Philips Avent Baby Monitor uses Tuya HOT 3
- Virtual device timed out HOT 1
- Tuya IOT Platform error 1106: permission deny HOT 1
- Cannot install with "npm install codetheweb/tuyapi" HOT 1
- device.get() never returns HOT 9
- Not being able to connect using device.connect() HOT 7
- tuya-cli get does not work, ECONNRESET error. HOT 1
- 302 status on my TuyaPlatform plugin HOT 1
- `dp-refresh` fire for all devices of the gateway instead of the only one concerned HOT 1
- is there a breaking change at tuya ? HOT 6
- Use Insecure Algorithm AES-ECB as Default Encryption Method HOT 1
- npm install codetheweb/tuyapi Infinite loading occurs during installation.
- virtual ID HOT 1
- Just lost all my Local Tuya devices HOT 1
- Smart plug doesn't return Received data HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tuyapi.