GithubHelp home page GithubHelp logo

Comments (8)

graze1234 avatar graze1234 commented on May 23, 2024

if I set the IP:
let tuya = new TuyaDevice({id: 'xx',key: 'xx', ip: 'xx', uid: 'xx'});

and don't call tuya.resolveIds() it seems more reliable.

from tuyapi.

graze1234 avatar graze1234 commented on May 23, 2024

TuyAPI Device(s): +0ms
TuyAPI [ { id: '0020xxxxxxxxxce5e0',
TuyAPI key: '9cdxxxxxx1c66a',
TuyAPI ip: '192.x.x.x',
TuyAPI uid: 'cimxxxxxxxCY3',
TuyAPI type: 'outlet',
TuyAPI port: 6668,
TuyAPI version: 3.1,
TuyAPI cipher:
TuyAPI { algorithm: [Object],
TuyAPI mode: [Object],
TuyAPI blockSize: 16,
TuyAPI _finish: false,
TuyAPI _input: null,
TuyAPI output: null,
TuyAPI _op: [Function],
TuyAPI _decrypt: false } } ] +14ms
TuyAPI Payload: +33ms
TuyAPI { gwId: '002xxxxxxce5e0', devId: '002xxxxxxe5e0' } +1ms
TuyAPI Sending this data: 000055aa000000000000000a000xxxxxxxxxxxxxx23030373535363030313934346365356530222c226465764964223a22303032303xxxxxxxxx31393434636227d000000000000aa55 +8ms
TuyAPI connect attempt 1 +8ms
TuyAPI write attempt <Buffer 00 00 55 aa 00 00 xx xx xx xx xx xx 0a 00 00 00 46 7b 22 67 77 49 64 22 3a 22 30 30 32 30 30 37 35 35 36 30 30 31 39 34 34 63 65 35 65 30 22 2c 22 64 65 ... > +171ms
TuyAPI failed to communicate { Error: write EPIPE
at exports._errnoException (util.js:1020:11)
at WriteWrap.afterWrite (net.js:812:14) code: 'EPIPE', errno: 'EPIPE', syscall: 'write' } +12ms
(node:6222) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Error communicating with device. Make sure nothing else is trying to control it or connected to it.

from tuyapi.

graze1234 avatar graze1234 commented on May 23, 2024

possibly nothing to do with it - but google search of the EPIPE error came up with http://howcanfix.com/174188/nodejs-error-write-epipe-on-socks5-proxy - just wondered if related

from tuyapi.

graze1234 avatar graze1234 commented on May 23, 2024

OK- I feel a bit of an idiot posting here all my findings as you probably know them already :))

I'm using this code to try and automate a Jinvoo wifi plug using a raspberry pi, with cron jobs at the moment....the scheduling on the app is horrible if you need to be turning the plug on and off multiple times an hour...but with cron it's a few lines with an on and off script at whatever time intervals I need.

I'm getting those errors (EPIPE, ECONN etc) with the code when the Jinvoo app activates.. I guess it somehow takes priority and boots off other connections...if I "force stop" the app on my phone my code seems to work fine....maybe all I need is to install an app to make sure the jinvoo app is force stopped every time it opens and the pi can take over...and for others with the same error make sure nothing else can talk to the plug or device, ....sorry for boring you if you all know that already :)

from tuyapi.

graze1234 avatar graze1234 commented on May 23, 2024

ugh maybe that's all BS - cron job just failed to do what it should have done.

[added] it could be down to bad wifi on my network....trying to get this to automate some thing on a big area, could be amazing if I can hook it into weather forecast apis to do different things....if I can get it working :)

from tuyapi.

graze1234 avatar graze1234 commented on May 23, 2024

Sudo'ing the cron jobs seems to have solved it....as I said, i hope this isn't total newbie rubbish but might help someone in the future

from tuyapi.

codetheweb avatar codetheweb commented on May 23, 2024

The EPIPE error you were getting is interesting; I've never seen that before.

As the README says, you can't have anything else attempting to control it while using TuyAPI, including an app on your phone. As you've discovered, the app has to be force quit.

from tuyapi.

graze1234 avatar graze1234 commented on May 23, 2024

pretty horrible retry code..will make it cleaner and less duplication - but posting it in case it's any use to anyone (this is just on my status check script - same for on and off scripts, run via crontab on Pi) :

`tuya.get().then(status => console.log('Status: ' + status)).catch(function() {
console.log('error - retrying');
setTimeout(retryFunction, 20000); // waits 20 seconds and runs retryFunction....not pretty....
});

function retryFunction(){

tuya.get().then(status => console.log('Status: ' + status));
}`

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.