Comments (7)
I just published an update that allows you to log some useful information to the console. Update tuyapi
, then run your script with DEBUG=* node script.js
.
Post the output here, and maybe we can figure out what's going on.
from tuyapi.
Same problem, I just used
process.on('unhandledRejection', (reason, p) => {
console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
process.exit(1);
});
in my main code to intentionally exit the program and used forever-monitor:
var forever = require('forever-monitor');
var child = new (forever.Monitor)('main.js');
child.on('watch:restart', function(info) {
console.error('Restaring script because ' + info.file + ' changed');
});
child.on('restart', function() {
console.error('Forever restarting script for ' + child.times + ' time');
});
child.on('exit:code', function(code) {
console.error('Forever detected script exited with code ' + code);
});
child.start();
to keep it going.
Just an idea, hope it helps.
-- Simon
from tuyapi.
[01:24:46] openhabian@debra:/etc/openhab2/scripts$ DEBUG=* node njstuya.js -ip 192.168.2.81 -id 012001865ccf7f598277 -key 00cfs888v58f12a TOGGLE
TuyAPI Device(s): +0ms
TuyAPI [ { id: '01200***5ccf7f598277',
TuyAPI key: '00cfs***2v58f12a',
TuyAPI type: 'outlet',
TuyAPI uid: '',
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 } } ] +2ms
TuyAPI Received UDP message. +444ms
TuyAPI Parsing this data to JSON: 000055aa00000000000000000000009e000000007b226970223a223139322e3136382e322e3831222c2267774964223a223031323030313836356363663766353938323737222c22616374697665223a322c226162696c697479223a302c226d6f6465223a302c22656e6372797074223a747275652c2270726f647563744b6579223a2271484c4e417a6d7252644139454d586c222c2276657273696f6e223a22332e31227dabd0b1910000aa55 +1ms
TuyAPI Parsing this data to JSON: 000055aa00000000000000000000009e000000007b226970223a223139322e3136382e322e3831222c2267774964223a223031323030313836356363663766353938323737222c22616374697665223a322c226162696c697479223a302c226d6f6465223a302c22656e6372797074223a747275652c2270726f647563744b6579223a2271484c4e417a6d7252644139454d586c222c2276657273696f6e223a22332e31227dabd0b1910000aa55 +0ms
TuyAPI Received UDP message. +2s
TuyAPI Parsing this data to JSON: 000055aa00000000000000000000009f000000007b226970223a223139322e3136382e322e313435222c2267774964223a223031323030313836356363663766353937633162222c22616374697665223a322c226162696c697479223a302c226d6f6465223a302c22656e6372797074223a747275652c2270726f647563744b6579223a2271484c4e417a6d7252644139454d586c222c2276657273696f6e223a22332e31227dd494f9ea0000aa55 +0ms
TuyAPI Payload: +1ms
TuyAPI { gwId: '01200***ccf7f598277', devId: '01200***5ccf7f598277' } +0ms
TuyAPI Sending this data: 000055aa000000000000000a000000467b2267774964223a223031323030313836356363663766353938323737222c226465764964223a223031323030313836356363663766353938323737227d000000000000aa55 +1ms
TuyAPI Received data back. +10ms
TuyAPI Parsing this data to JSON: 000055aa000000000000000a0000003e000000007b226465764964223a223031323030313836356363663766353938323737222c22647073223a7b2231223a66616c73657d7df2b3e53c0000aa55 +0ms
TuyAPI Payload: +1ms
TuyAPI { devId: '01200***ccf7f598277',
TuyAPI uid: '',
TuyAPI t: '1517189326',
TuyAPI dps: { '1': true } } +0ms
TuyAPI Sending this data: 000055aa000000000000000700000087332e3137313962333433386237353063326436686b777a37724a553247356a45684365466935374a4a424c596131683444674668786f546172324d7a4d5438447130624869446a714e4c4565537138486e56344f79683756506f666644667244597851627947366c467648524c44646949764f494e53575a38676f6146553d000000000000aa55 +3ms
(node:7225) 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.
(node:7225) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
from tuyapi.
Weird. Everything looks fine. (Just a note: my setup works with ~95% reliability.) I'm sorry but there's not much I can help you with. Are you sure nothing else is trying to control it?
from tuyapi.
I'm pretty sure I don't have any other apps open and tried closing everything on the phone. But I'm playing about with virtually every home automation ecosystem, I've seen some bump into each other by mistake. What would the best way be to see everything talking to the switch? Can I simply fire up wireshark or would I need to set up some kind of proxy gateway to connect the switch through to monitor everything?
from tuyapi.
If every possible device that could be controlling it is connected via WiFi, it should be possible to monitor connections to it with Wireshark (although I'm not 100% sure on this).
I'm currently in the process of adding a retry function if net.connect()
returns with a ECONNRESET
error. Hopefully this will reduce errors for you.
from tuyapi.
I've made a few changes so not sure what has fixed it. I've got locking and some small time delays to prevent the script being run to close to a previous run. Errors are infrequent now, and when I come into contact with one I just rerun the command.
I'm closing this since I'm having difficulty even creating the error anymore.
from tuyapi.
Related Issues (20)
- Error: GET_TOKEN_FAILED 1114, your ip(xxx.xxx.xxx.xxx) don't have access to this API HOT 1
- 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
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.