unparagoned / njstuya Goto Github PK
View Code? Open in Web Editor NEWOpenhab interface for Tuya home automation devices sold under various names
Openhab interface for Tuya home automation devices sold under various names
I have Smart Life wall outlets that have 2 outlets each. They are labeled as "[device_id]_1" and [device_id]_2. If I want to turn both on (I'm using openHAB), I send the command "[device_id] ON" and that works fine. However, when the status is obtained, I send the command "[device_id] STATUS and it returns all my devices. That is because it doesn't associate that only treat them as a group and never individually. I have actually modified the njstuya.js file to support this scenario. I only modified the runCloud function as that is the only one I'm using, but I replaced the line that reads
const status = ((tuyaID.length > 0) && deviceStates[tuyaID]) || deviceStates;
to the following:
var status;
if (tuyaID.length > 0) {
status = deviceStates[tuyaID];
if (!status) {
status = deviceStates[tuyaID + "_1"];
if (!status) status = "undefined"; //deviceStates;
}
}
Can you considered incorporating a solution to handle this case?
How can Io manage Curtain switch?
When i get schma I received empty DPSes
TuyAPI Parsed response data: +2ms
TuyAPI { devId: '50758014840d8e91941b', dps: { '1': '3' } } +1ms
njstuya runCommand has started with data {"devId":"50758014840d8e91941b","dps":{"1":"3"}} +26ms
Now and then there are connection errors. Might be due to to there only being one connection at at time. Maybe there are too many in a short period or maybe old connections aren't being closed.
`{ Error: read ECONNRESET
at exports._errnoException (util.js:1050:11)
at TCP.onread (net.js:582:26) code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }`
Why are my results different when using local vs cloud mode? Why don't I have all the devices for local mode?
[14:25:08] openhabian@openHAB:/srv/openhab2-conf$ node /etc/openhab2/scripts/node_modules/njstuya
{ "devices": [
{ "id": 04200099b4e62d136fea, "broadcast": {"ip":"172.31.10.226","gwId":"04200099b4e62d136fea","active":2,"ability":0,"mode":0,"encrypt":true,"productKey":"JxRc0L3YeVkRanNf","version":"3.1"}, "schema": {"devId":"04200099b4e62d136fea","dps":{"1":false,"2":0}} },
] }
{ "devices": [ {"04200099b4e62d136fea":{"ip":"172.31.10.226","gwId":"04200099b4e62d136fea","active":2,"ability":0,"mode":0,"encrypt":true,"productKey":"JxRc0L3YeVkRanNf","version":"3.1","devId":"04200099b4e62d136fea","dps":{"1":false,"2":0}}} ] }
[14:25:37] openhabian@openHAB:/srv/openhab2-conf$ node /etc/openhab2/scripts/node_modules/njstuya -mode cloud
{
'04200099b4e62d136fea': 'OFF',
'04200099b4e62d13684c': 'OFF',
'10670365bcddc2f9d58c_1': 'OFF',
'10670365bcddc2f9d58c_2': 'OFF',
'06200045dc4f2236e565_1': 'OFF',
'06200045dc4f2236e565_2': 'OFF',
'10670365bcddc2fa4c7c_1': 'OFF',
'10670365bcddc2fa4c7c_2': 'OFF',
'0620004568c63abd5ad0_1': 'OFF',
'0620004568c63abd5ad0_2': 'OFF'
}
Hi, I am getting error running the script njstuya.js
the actual node node_modules/njstuya works fine....
any suggestions?
root@lasermini:/opt/openhab/conf/scripts/node_modules# node njstuya.js
internal/modules/cjs/loader.js:638
throw err;
^Error: Cannot find module '/opt/openhab/conf/scripts/node_modules/njstuya.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
@renegade2k
@Ericmas001
@jhoughtelin
You should cd into the dir of the script then install tuyapi
cd /etc/openhab2/scripts
npm install codetheweb/tuyapi
Let me know if that works
Hello,
Hello, I tried Njstuya, it work fine with teckin in local, but with Emylo SS-8839-03 there is an error :
When I launch this command :
node njstuya.js -mode local -ip 192.168.1.XX -id 4620XXXXXXX0029 -key f7edXXXXXX2b ON
I received this error :
(node:2189) UnhandledPromiseRejectionWarning: undefined
(node:2189) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:2189) [DEP0018] 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.
But when i try with cloud mode and device id, it work fine. Any ideas please ?
Also with this command node node_modules/njstuya , njstuya detect all Teckin devices in local, but never Emylo device.
Thank you
Is there a way to have the status updated if the Smart Life switched is turned on via another source (e.g. Alex)?
I am following following steps to install njsTuya and getting error message. please help
cd /etc/openhab2/scripts/
git clone https://github.com/unparagoned/njsTuya.git
cd njsTuya
npm init
npm install njsTuya.. after running this command below error is coming..
root@openhab:/etc/openhab2/scripts/njsTuya#
npm install njsTuya
npm ERR! code E404
npm ERR! 404 Not Found: njsTuya@latest
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-08-22T20_46_11_341Z-debug.log
root@openhab:/etc/openhab2/scripts/njsTuya# cat /root/.npm/_logs/2018-08-22T20_46_11_341Z-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'install', 'njsTuya' ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session 05c915bd6766d948
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 404 https://registry.npmjs.org/njsTuya 944ms
8 silly fetchPackageMetaData error for njsTuya@latest 404 Not Found: njsTuya@latest
9 timing stage:rollbackFailedOptional Completed in 1ms
10 timing stage:runTopLevelLifecycles Completed in 1308ms
11 verbose stack Error: 404 Not Found: njsTuya@latest
11 verbose stack at fetch.then.res (/usr/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/fetch.js:42:19)
11 verbose stack at tryCatcher (/usr/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
11 verbose stack at Promise._settlePromiseFromHandler (/usr/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:512:31)
11 verbose stack at Promise._settlePromise (/usr/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:569:18)
11 verbose stack at Promise._settlePromise0 (/usr/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:614:10)
11 verbose stack at Promise._settlePromises (/usr/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:693:18)
11 verbose stack at Async._drainQueue (/usr/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:133:16)
11 verbose stack at Async._drainQueues (/usr/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:143:10)
11 verbose stack at Immediate.Async.drainQueues [as _onImmediate] (/usr/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:17:14)
11 verbose stack at runCallback (timers.js:693:18)
11 verbose stack at tryOnImmediate (timers.js:664:5)
11 verbose stack at processImmediate (timers.js:646:5)
12 verbose cwd /etc/openhab2/scripts/njsTuya
13 verbose Linux 4.4.0-130-generic
14 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "njsTuya"
15 verbose node v10.9.0
16 verbose npm v6.2.0
17 error code E404
18 error 404 Not Found: njsTuya@latest
19 verbose exit [ 1, true ]
root@openhab:/etc/openhab2/scripts/njsTuya#
Hello,
i want install the npm and have follow errors
hope you can help me
Thanks
[12:01:30] openhabian@openHABianPi:/etc/openhab2/scripts$ sudo npm install unparagoned/njsTuya
npm ERR! code 128
npm ERR! Command failed: git clone --mirror -q git://github.com/unparagoned/njsTuya.git /root/.npm/_cacache/tmp/git-clone-935de498/.git
npm ERR! fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-935de498/.git'
npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-02-26T11_03_20_401Z-debug.log
LOG:
sudo cat /root/.npm/_logs/2019-02-26T11_03_20_401Z-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node',
1 verbose cli '/usr/bin/npm',
1 verbose cli 'install',
1 verbose cli 'unparagoned/njsTuya' ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session 6bd878f94f845d5d
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 silly fetchPackageMetaData error for github:unparagoned/njsTuya Command failed: git clone --mirror -q git://github.com/unparagoned/njsTuya.git /root/.npm/_cacache/tmp/git-clone-935de498/.git
7 silly fetchPackageMetaData fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-935de498/.git'
8 timing stage:rollbackFailedOptional Completed in 2ms
9 timing stage:runTopLevelLifecycles Completed in 773ms
10 verbose stack Error: Command failed: git clone --mirror -q git://github.com/unparagoned/njsTuya.git /root/.npm/_cacache/tmp/git-clone-935de498/.git
10 verbose stack fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-935de498/.git'
10 verbose stack
10 verbose stack at ChildProcess.exithandler (child_process.js:294:12)
10 verbose stack at ChildProcess.emit (events.js:189:13)
10 verbose stack at maybeClose (internal/child_process.js:970:16)
10 verbose stack at Socket.stream.socket.on (internal/child_process.js:389:11)
10 verbose stack at Socket.emit (events.js:189:13)
10 verbose stack at Pipe._handle.close (net.js:600:12)
11 verbose cwd /etc/openhab2/scripts
12 verbose Linux 4.14.98-v7+
13 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "unparagoned/njsTuya"
14 verbose node v10.15.1
15 verbose npm v6.8.0
16 error code 128
17 error Command failed: git clone --mirror -q git://github.com/unparagoned/njsTuya.git /root/.npm/_cacache/tmp/git-clone-935de498/.git
17 error fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-935de498/.git'
18 verbose exit [ 1, true ]
[12:04:36] openhabian@openHABianPi:/etc/openhab2/scripts$
I have a rule that turns on 2 other switches -- remote subwoofer (HomeCinema_Subwoofer) and seat rumblers (HomeCinema_SeatRumblers) -- when my theater rack (HomeCinema_Rack) turns on. I'm getting the following error in the openHAB logs when I issue the command:
2019-05-09 13:03:28.039 [ome.event.ItemCommandEvent] - Item 'GF_HomeCinema_Rack' received command ON
I've been struggling with this for a few days now and can't seem to figure it out. It seems like it isn't getting a response from the device, but why?
2019-05-09 13:03:28.074 [vent.ItemStateChangedEvent] - GF_HomeCinema_Rack changed from OFF to ON
2019-05-09 13:03:28.081 [GroupItemStateChangedEvent] - gPower changed from OFF to ON through GF_HomeCinema_Rack
==> /var/log/openhab2/openhab.log <==
2019-05-09 13:03:28.101 [INFO ] [se.smarthome.model.script.CinemaRack] - Running Script
2019-05-09 13:03:28.109 [INFO ] [se.smarthome.model.script.CinemaRack] - Turning ON
==> /var/log/openhab2/events.log <==
2019-05-09 13:03:28.113 [ome.event.ItemCommandEvent] - Item 'cmdSmartLife_HomeCinema_Rack_Args' received command ON
2019-05-09 13:03:28.131 [ome.event.ItemCommandEvent] - Item 'GF_HomeCinema_SeatRumblers' received command ON
2019-05-09 13:03:28.139 [ome.event.ItemCommandEvent] - Item 'GF_HomeCinema_Subwoofer' received command ON
==> /var/log/openhab2/openhab.log <==
2019-05-09 13:03:28.124 [INFO ] [.model.script.SmartLife command exec] - Result: (node:27491) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'header' of undefined
at setStateCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:176:11)
at processTicksAndRejections (internal/process/task_queues.js:89:5)
at async runCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:189:5)
(node:27491) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:27491) [DEP0018] 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.
(node:27491) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'header' of undefined
at setStateCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:176:11)
at processTicksAndRejections (internal/process/task_queues.js:89:5)
at async runCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:189:5)
(node:27491) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:27491) [DEP0018] 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.
==> /var/log/openhab2/events.log <==
2019-05-09 13:03:28.148 [ome.event.ItemCommandEvent] - Item 'cmdSmartLife_HomeCinema_Rack' received command ON
2019-05-09 13:03:28.153 [nt.ItemStatePredictedEvent] - cmdSmartLife_HomeCinema_Rack_Args predicted to become ON
2019-05-09 13:03:28.174 [vent.ItemStateChangedEvent] - cmdSmartLife_HomeCinema_Rack_Args changed from OFF to ON
2019-05-09 13:03:28.178 [vent.ItemStateChangedEvent] - cmdSmartLife_HomeCinema_Rack changed from OFF to ON
2019-05-09 13:03:28.212 [vent.ItemStateChangedEvent] - GF_HomeCinema_SeatRumblers changed from OFF to ON
2019-05-09 13:03:28.222 [vent.ItemStateChangedEvent] - GF_HomeCinema_Subwoofer changed from OFF to ON
2019-05-09 13:03:28.225 [nt.ItemStatePredictedEvent] - cmdSmartLife_HomeCinema_Rack predicted to become ON
2019-05-09 13:03:28.231 [ome.event.ItemCommandEvent] - Item 'cmdSmartLife_HomeCinema_SeatRumblers_Args' received command ON
2019-05-09 13:03:28.241 [nt.ItemStatePredictedEvent] - cmdSmartLife_HomeCinema_SeatRumblers_Args predicted to become NULL
2019-05-09 13:03:28.265 [ome.event.ItemCommandEvent] - Item 'cmdSmartLife_HomeCinema_Subwoofer_Args' received command ON
2019-05-09 13:03:28.273 [nt.ItemStatePredictedEvent] - cmdSmartLife_HomeCinema_Subwoofer_Args predicted to become ON
==> /var/log/openhab2/openhab.log <==
2019-05-09 13:03:28.285 [INFO ] [.model.script.SmartLife command exec] - Result: OFF
==> /var/log/openhab2/events.log <==
2019-05-09 13:03:28.295 [ome.event.ItemCommandEvent] - Item 'cmdSmartLife_HomeCinema_Subwoofer' received command ON
2019-05-09 13:03:28.327 [vent.ItemStateChangedEvent] - cmdSmartLife_HomeCinema_Subwoofer_Args changed from OFF to ON
2019-05-09 13:03:28.331 [vent.ItemStateChangedEvent] - cmdSmartLife_HomeCinema_Subwoofer changed from OFF to ON
2019-05-09 13:03:28.334 [nt.ItemStatePredictedEvent] - cmdSmartLife_HomeCinema_Subwoofer predicted to become ON
2019-05-09 13:03:31.288 [vent.ItemStateChangedEvent] - cmdSmartLife_HomeCinema_Rack changed from ON to OFF
2019-05-09 13:03:31.309 [vent.ItemStateChangedEvent] - cmdSmartLife_HomeCinema_Rack_Output changed from (node:27491) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'header' of undefined
at setStateCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:176:11)
at processTicksAndRejections (internal/process/task_queues.js:89:5)
at async runCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:189:5)
(node:27491) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:27491) [DEP0018] 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.
(node:27491) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'header' of undefined
at setStateCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:176:11)
at processTicksAndRejections (internal/process/task_queues.js:89:5)
at async runCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:189:5)
(node:27491) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:27491) [DEP0018] 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. to (node:27935) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'header' of undefined
at setStateCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:176:11)
at processTicksAndRejections (internal/process/task_queues.js:89:5)
at async runCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:187:5)
(node:27935) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:27935) [DEP0018] 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.
(node:27935) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'header' of undefined
at setStateCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:176:11)
at processTicksAndRejections (internal/process/task_queues.js:89:5)
at async runCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:187:5)
(node:27935) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:27935) [DEP0018] 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.
2019-05-09 13:03:31.380 [vent.ItemStateChangedEvent] - cmdSmartLife_HomeCinema_Subwoofer changed from ON to OFF
2019-05-09 13:03:31.389 [vent.ItemStateChangedEvent] - cmdSmartLife_HomeCinema_Subwoofer_Output changed from OFF to (node:27958) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'header' of undefined
at setStateCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:176:11)
at processTicksAndRejections (internal/process/task_queues.js:89:5)
at async runCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:187:5)
(node:27958) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:27958) [DEP0018] 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.
(node:27958) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'header' of undefined
at setStateCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:176:11)
at processTicksAndRejections (internal/process/task_queues.js:89:5)
at async runCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:187:5)
(node:27958) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:27958) [DEP0018] 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.
2019-05-09 13:03:31.394 [vent.ItemStateChangedEvent] - cmdSmartLife_HomeCinema_Rack_Output changed from (node:27935) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'header' of undefined
at setStateCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:176:11)
at processTicksAndRejections (internal/process/task_queues.js:89:5)
at async runCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:187:5)
(node:27935) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:27935) [DEP0018] 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.
(node:27935) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'header' of undefined
at setStateCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:176:11)
at processTicksAndRejections (internal/process/task_queues.js:89:5)
at async runCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:187:5)
(node:27935) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:27935) [DEP0018] 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. to (node:27945) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'header' of undefined
at setStateCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:176:11)
at processTicksAndRejections (internal/process/task_queues.js:89:5)
at async runCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:187:5)
(node:27945) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:27945) [DEP0018] 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.
(node:27945) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'header' of undefined
at setStateCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:176:11)
at processTicksAndRejections (internal/process/task_queues.js:89:5)
at async runCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:187:5)
(node:27945) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:27945) [DEP0018] 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.
2019-05-09 13:03:31.818 [vent.ItemStateChangedEvent] - cmdSmartLife_HomeCinema_Subwoofer_Output changed from (node:27958) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'header' of undefined
at setStateCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:176:11)
at processTicksAndRejections (internal/process/task_queues.js:89:5)
at async runCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:187:5)
(node:27958) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:27958) [DEP0018] 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.
(node:27958) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'header' of undefined
at setStateCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:176:11)
at processTicksAndRejections (internal/process/task_queues.js:89:5)
at async runCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:187:5)
(node:27958) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:27958) [DEP0018] 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. to ON
From the console the set/get command that works fine on both windows and linux is "{ \"dps\": 1, \"set\": true }"
.
But using the openhab rules and execcommand it needs to be of the following format on linux, '{ "dps": 1, "set": true }'
.
I've set the docs to reccomend the former, but don't know what issues this will cause for people using openhab on windows.
Helooo,
Please add support for wattmeter.
No data Voltage, Current, Power....
cloudtuya { payload: { devices: [ [Object] ], scenes: [] },
cloudtuya header: { code: 'SUCCESS', payloadVersion: 1 } } +3s
cloudtuya [ { data: { online: true, state: false },
cloudtuya name: '2dinwattletr',
cloudtuya icon: 'https://images.tuyaeu.com/smart/product_icon/cz.png',
cloudtuya id: '02448046bcddc25938da',
cloudtuya dev_type: 'switch',
cloudtuya ha_type: 'switch' } ] +21ms
cloudtuya prefilter [{"data":{"online":true,"state":false},"name":"2dinwattletr","icon":"https://images.tuyaeu.com/smart/product_icon/cz.png","id":"02448046bcddc25938da","dev_type":"switch","ha_type":"switch"}] +14ms
I can provide a cloud account with a wattmeter connected.
Thankssss
[email protected]
Greetings,
When I run ‘node node_modules/njstuya’ the returned devices are only my two Smart Power Strips. I also have four WiFi Smart Plugs WiFi Smart plugs with Energy Monitoring from Amazon:
https://www.amazon.com/gp/product/B07SGP1BCY/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1
They work great with the Smart Life app and with IFTTT but they don’t appear as devices with the command above. They showed up as “ThinkTurn_#### on my router. And Smart Life shows them as running Firmware 1.4.1 (with no update available) whereas the Power Strips show firmware 1.0.4 (with no update available).
Any recommendations or help would be appreciated.
Hi,
When I test your thing with the command line and test : node njstuya.js -ip 192.168.X.X -id 062007as2qedsdsc2e7d888 -key 881da7sdasdasdas4fd5a State I get :
resolveIds() is deprecated since v3.0.0. Will be removed in v4.0.0. Use resolveId() instead.
and then I receive the State.
When I try : node njstuya.js -ip 192.168.X.X -id 062007as2qedsdsc2e7d888 -key 881da7sdasdasdas4fd5a ON or OFF I get :
resolveIds() is deprecated since v3.0.0. Will be removed in v4.0.0. Use resolveId() instead.
Error: Timeout waiting for response
And nothing happen ...
The schema of my device is maybe in chinese?
When I run node node_modules/njstuya -ip 192.168.1.13 -get '{ "schema": true}'
the payload is apparently unreadable.
njstuya booting njstuya +0ms njstuya "{argName} value is: 192.168.1.13 +4ms njstuya "{argName} value is: { +0ms njstuya local mode +1ms njstuya api {} or undefined +1ms TuyAPI Finding missing IP 192.168.1.13 or ID +0ms TuyAPI Received UDP message. +4s TuyAPI UDP data: +9ms TuyAPI { TuyAPI payload: { TuyAPI ip: '192.168.1.13', TuyAPI gwId: 'xxxxxxxxxxxxxxxxxxxxx', TuyAPI active: 2, TuyAPI ablilty: 0, TuyAPI encrypt: true, TuyAPI productKey: 'xxxxxxxxxxxxxxxxxxxxx', TuyAPI version: '3.3' TuyAPI }, TuyAPI leftover: false, TuyAPI commandByte: 19, TuyAPI sequenceN: 0 TuyAPI } +0ms njstuya ip undefined id: undefined +4s TuyAPI Connecting to 192.168.1.13... +21ms TuyAPI Socket connected. +68ms njstuya Connected to device! +75ms TuyAPI GET Payload: +4ms TuyAPI { TuyAPI gwId: 'xxxxxxxxxxxxxxxxxxxxx', TuyAPI devId: 'xxxxxxxxxxxxxxxxxxxxx', TuyAPI t: '1600941684', TuyAPI dps: {}, TuyAPI uid: 'xxxxxxxxxxxxxxxxxxxxx' TuyAPI } +1ms TuyAPI Received data: 000055aa000000010000000a0000002c0000000143f419dc669d9137904f7f66bd026f20c4e1dc5dff0aaf61cbdcf2ad87dc02ad1db3708b0000aa55 +21ms TuyAPI Parsed: +3ms TuyAPI { TuyAPI payload: 'C�\u0019�f��7�O⌂f�\u0002o ���]�\n�a����\u0002�', TuyAPI leftover: false, TuyAPI commandByte: 10, TuyAPI sequenceN: 1 TuyAPI } +2ms njstuya runCommand has started with data "C�\u0019�f��7�O⌂f�\u0002o ���]�\n�a����\u0002�" +33ms (node:4824) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '1' of undefined at TuyaDevice.runCommand (C:\Users\jcwal\Documents\Kitematic\openhab\openhab\conf\scripts\node_modules\njstuya\njstuya.js:300:33) at TuyaDevice.emit (events.js:315:20) at TuyaDevice._packetHandler (C:\Users\jcwal\Documents\Kitematic\openhab\openhab\conf\scripts\node_modules\tuyapi\index.js:444:10) at C:\Users\jcwal\Documents\Kitematic\openhab\openhab\conf\scripts\node_modules\tuyapi\index.js:343:43 at Array.forEach (<anonymous>) at Socket.<anonymous> (C:\Users\jcwal\Documents\Kitematic\openhab\openhab\conf\scripts\node_modules\tuyapi\index.js:339:19) at Socket.emit (events.js:315:20) at addChunk (_stream_readable.js:297:12) at readableAddChunk (_stream_readable.js:273:9) at Socket.Readable.push (_stream_readable.js:214:10) (node:4824) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag
--unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:4824) [DEP0018] 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. TuyAPI Disconnect +5s njstuya undefined +5s TuyAPI Socket closed: 192.168.1.13 +3ms njstuya Disconnected from device. +1ms
I updated (actually removed and installed) to version 2.3.5 of njstuya and 1.07 of cloudtuya and now I'm getting the following using the same user-id and password. Before upgrading I was just getting the can't auth twice in 60 seconds error. FYI: it would be nice if an upgrade preserved the old key.json file so that it would not need to be recreated.
njstuya booting njstuya +0ms
njstuya "{argName} value is: 06200045dc4f2236e565_2 +4ms
njstuya "{argName} value is: cloud +1ms
njstuya api {"Instructions":"Complete with tuya/smart_life app email/pass/dialingCode/region then rename to key.json","userName":"[hidden]","password":"[hidden]","countryCode":"44","bizType":"smart_life","region":"EU"} or [hidden] +4ms
njstuya Error: ENOENT: no such file or directory, open './cloudToken.json'
njstuya at Object.openSync (fs.js:462:3)
njstuya at Object.readFileSync (fs.js:364:35)
njstuya at runCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:205:28)
njstuya at main (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:387:34)
njstuya at Object.<anonymous> (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:390:1)
njstuya at Module._compile (internal/modules/cjs/loader.js:999:30)
njstuya at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
njstuya at Module.load (internal/modules/cjs/loader.js:863:32)
njstuya at Function.Module._load (internal/modules/cjs/loader.js:708:14)
njstuya at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) +2ms
cloudtuya {"responseStatus":"error","errorMsg":"Get accesstoken failed. Username or password error!"} +0ms
cloudtuya {
cloudtuya responseStatus: 'error',
cloudtuya errorMsg: 'Get accesstoken failed. Username or password error!'
cloudtuya } +1ms
Get accesstoken failed. Username or password error!
(node:8356) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'expires_in' of null
at runCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:212:43)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:8356) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:8356) [DEP0018] 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.
Hi
By mistake I upgraded firmware to version 1.1.7 (MCU Wifi)
and now I cannot connect njsTuya to the device
Is anybody who had the same issue?
Or how can I do firmware downgrade of tthe Wifi module on the switch ?
[11:45:40] openhabian@openhab:/etc/openhab2/scripts/njsTuya$ node njstuya.js -ip 192.168.x.152 -get '{ "schema": true}'
(node:3228) UnhandledPromiseRejectionWarning: undefined
(node:3228) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:3228) [DEP0018] 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.
(node:3228) UnhandledPromiseRejectionWarning: Error: find() timed out. Is the device powered on and the ID or IP correct?
at timeout (/etc/openhab2/scripts/njsTuya/node_modules/tuyapi/index.js:654:13)
at Timeout.setTimeout [as _onTimeout] (/etc/openhab2/scripts/njsTuya/node_modules/p-timeout/index.js:19:13)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)
(node:3228) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
[11:45:55] openhabian@openhab:/etc/openhab2/scripts/njsTuya$
I read that the Woox products are based on Tuya chips but when running the following command I'm getting an error:
node node_modules/njstuya
Error: find() timed out. Is the device powered on and the ID or IP correct?
(node:13637) UnhandledPromiseRejectionWarning: undefined
(node:13637) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:13637) [DEP0018] 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.
(node:13637) UnhandledPromiseRejectionWarning: Error: find() timed out. Is the device powered on and the ID or IP correct?
(node:13637) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
Is there anything known why the tuyaAPI is not collecting the changes any more?
Here is an example from my side:
node /etc/openhab2/scripts/node_modules/njstuya/njstuya.js -mode cloud -id xxxxx ON
Result ON
But nothing on the APP or the switch
If I try it directly again I get the following error
(node:7345) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'code' of undefined
at switchStateCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:188:18)
at processTicksAndRejections (internal/process/task_queues.js:86:5)
(node:7345) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:7345) [DEP0018] 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.
When I run:
node njstuya.js -ip xx -id xx OFF
I get the error message from the subject.
Did anyone yet have this error?
Stacktrace:
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 TuyaDevice (/etc/openhab2/scripts/node_modules/tuyapi/index.js:65:43)
at Object. (/etc/openhab2/scripts/node_modules/tuyapi/njstuya.js:26:12)
at Module._compile (module.js:577:32)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
Please advise, if additional data is required.
Cheers,
Bastian
Hi, I am a newbie in nodejs and openhab.
Could You please explain also Configuration section, where to create this rule?
var resp = executeCommandLine("node /etc/openhab2/scripts/node_modules/njstuya" + command, 50000)
logInfo("Tuya", "Run Command: [{}] Result {}", command, resp)
I get an timeout error, when I run "sudo node node_modules/njstuya" with next error message
Error: find() timed out. Is the device powered on and the ID or IP correct? (node:3489) UnhandledPromiseRejectionWarning: undefined (node:3489) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:3489) [DEP0018] 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. (node:3489) UnhandledPromiseRejectionWarning: Error: find() timed out. Is the device powered on and the ID or IP correct? (node:3489) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
when I run it without sudo there is another error according to port 6666:
Error: bind EADDRINUSE 0.0.0.0:6666 (node:3525) UnhandledPromiseRejectionWarning: Error: bind EADDRINUSE 0.0.0.0:6666 (node:3525) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:3525) [DEP0018] 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. (node:3525) UnhandledPromiseRejectionWarning: undefined (node:3525) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
Could you please advise, how to troubleshoot this kind of error?
platform:
Lubuntu
Linux szotyesz 4.15.0-50-generic #54-Ubuntu SMP Mon May 6 18:46:08 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
installed apps:
nodejs: v8.10.0
openhab: 2.4.0
Thank you very much for help
Have a nice day
PS: I updated nodejs to 12.8.0 but did not help
I seems to be able to connect to my device just fine, but am getting an error when requesting the schema. I also get the same error trying the -get '{ "dps": 1 }' command. Any thoughts?
[20:15:47] openhabian@openHABianPi:/etc/openhab2/scripts$ DEBUG=* node njsTuya -ip 192.168.15.148 -id 40052637dc4f22e5ca84 -key c777f0da21c37e89 -get '{ "schema": true}'
njstuya booting njstuya +0ms
njstuya "{argName} value is: 192.168.15.148 +9ms
njstuya "{argName} value is: 40052637dc4f22e5ca84 +1ms
njstuya "{argName} value is: c777f0da21c37e89 +1ms
njstuya "{argName} value is: { "schema": true} +0ms
njstuya api {} or undefined +21ms
TuyAPI Connecting to 192.168.15.148... +0ms
TuyAPI Socket connected. +54ms
njstuya Connected to device! +63ms
TuyAPI GET Payload: +3ms
TuyAPI { gwId: '40052637dc4f22e5ca84', devId: '40052637dc4f22e5ca84' } +1ms
TuyAPI Disconnect +10s
(node:32683) UnhandledPromiseRejectionWarning: undefined
(node:32683) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:32683) [DEP0018] 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.
TuyAPI Socket closed: 192.168.15.148 +11ms
njstuya Disconnected from device. +10s
[
I have 12 switch (plug type) of 2 different types working as expected with the njsTuya commands. A new type "GuSund Light Switch SW1" disconnects on the commands. Tried multiple -get commands but none work. Any suggestions as to what might be done to get it to respond.
Example Command issued-
DEBUG=* node njstuya/njstuya.js -mode local -ip 192.168.1.202 -id 63120466c44f33863bf1 -key yyy -get '{ "dps":1, "status":true}'
njstuya booting njstuya +0ms
njstuya "{argName} value is: 192.168.1.202 +1ms
njstuya "{argName} value is: 63120466c44f33863bf1 +0ms
njstuya "{argName} value is: 2a01319284afd5ed +0ms
njstuya "{argName} value is: { "dps":1, "status":true} +0ms
njstuya "{argName} value is: local +0ms
njstuya api {} or undefined +1ms
TuyAPI Connecting to 192.168.1.202... +0ms
TuyAPI Socket connected. +112ms
njstuya Connected to device! +114ms
TuyAPI GET Payload: +2ms
TuyAPI { gwId: '63120466c44f33863bf1', devId: 'yyy' } +0ms
TuyAPI Disconnect +10s
TuyAPI Socket closed: 192.168.1.202 +4ms
njstuya Disconnected from device. +10s
key was found using the tuya-cli list-app with the ucomen iphone ap (which identified 4 of the other working switches as well so the keys should be correct). Tuya-cli list-app does not work with the smartlife app on iphone 7. before you ask, the other 8 device keys were identified a long time ago using a different method. I am on Ubuntu 18.04 and everything is updated to the latest as of 2020/01/15. also tried
DEBUG=* node njstuya/njstuya.js -mode local -ip 192.168.1.202 -id yyy -get '{ "schema": true}'
njstuya booting njstuya +0ms
njstuya "{argName} value is: 192.168.1.202 +1ms
njstuya "{argName} value is: 63120466c44f33863bf1 +0ms
njstuya "{argName} value is: { "schema": true} +0ms
njstuya "{argName} value is: local +0ms
njstuya api {} or undefined +2ms
TuyAPI Connecting to 192.168.1.202... +0ms
TuyAPI Socket connected. +135ms
njstuya Connected to device! +137ms
TuyAPI GET Payload: +2ms
TuyAPI { gwId: '63120466c44f33863bf1', devId: 'yyy' } +0ms
TuyAPI Disconnect +10s
TuyAPI Socket closed: 192.168.1.202 +3ms
njstuya Disconnected from device. +10s
Quick fix to status, means it also sets the current state. Should rewrite it so it just gets the state
After I did an upgrade of my pi (acting as my openhab server), I starting receiving the following output:
njstuya booting njstuya +0ms
njstuya "{argName} value is: 06200045dc4f2236e565_2 +7ms
njstuya "{argName} value is: cloud +0ms
njstuya api {"userName":"[blanked]","password":"[blanked]","countryCode":"1","bizType":"smart_life","region":"us"} or [blanked] +4ms
cloudtuya {"responseStatus":"error","errorMsg":"you cannot auth exceed once in 60 seconds"} +0ms
cloudtuya {
cloudtuya responseStatus: 'error',
cloudtuya errorMsg: 'you cannot auth exceed once in 60 seconds'
cloudtuya } +2ms
njstuya Token {"responseStatus":"error","errorMsg":"you cannot auth exceed once in 60 seconds"} +510ms
cloudtuya { devId: '06200045dc4f2236e565_2' } +5ms
cloudtuya INVAILD_REQUEST_2 +436ms
(node:4100) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'devices' of undefined
at CloudTuya.find (/etc/openhab2/scripts/node_modules/cloudtuya/cloudtuya.js:101:23)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async CloudTuya.state (/etc/openhab2/scripts/node_modules/cloudtuya/cloudtuya.js:147:19)
at async runCloud (/etc/openhab2/scripts/node_modules/njstuya/njstuya.js:206:26)
(node:4100) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:4100) [DEP0018] 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.
____ ____ ___ ____ / / / / | / __ )
/ __ \/ __ \/ _ \/ __ \/ /_/ / /| | / __ |
/ /_/ / /_/ / __/ / / / __ / ___ |/ /_/ /
\____/ .___/\___/_/ /_/_/ /_/_/ |_/_____/
/_/ 2.5.10
Release Build
Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown openHAB.
openhab>
That's happen when I tried to use your scripts within openhab.
(I'm able to use njstuya.js with node and get working right) but when trying to use both scripts (items and rules) within openhab, this is shown every 2 minutes (cron entry):
any idea?
I cann't integrate ir with openhab which would be very usefull.
2018-03-04 13:36:14.921 [INFO ] [.eclipse.smarthome.model.script.Tuya] - Execute action [NULL STATUS] : resp [/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 TuyaDevice (/etc/openhab2/scripts/node_modules/tuyapi/index.js:62:43)
at Object. (/etc/openhab2/scripts/njstuya.js:26:12)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)]
I would like to set the color on my Tuya light bulb
I can see there is a way to set multiple dps at one time. like here is an example:
I want to set the scene on my tuya light bulb: so I need to set dps 2 and dps 6 at the same time:
node c:/openhab2/userdata/etc/scripts/node_modules/njstuya/njstuya.js -ip 192.168.0.38 -id asdasdasd -key asdasdasdasd -set "[{ "dps": 2, "set": "scene" },{ "dps": 6, "set": "bd76000168ffff" }]" should work but it does not.
-set "[ { "dps": 2, "set": "scene" },{ "dps": 6, "set": "bd76000168ffff" } ]" is a valid JSON string. Let's call this string myJsonString. If you would var obj = JSON.parse(tuyaSet). On myJsonString you would get the valid JSON obj. if you then convert it to an array you can see that the array length is greater than 1. The call to tuya.set(obj) could then be adjusted but you would need a new function to convert the myJsonString or tuyaSet to the Data format: insted of { "dps": 2, "set": "scene" } you need { '1': true, '2': 'scene', '3': 255, '4': 255, '5': 'xxx', '6': 'xxx', '7': 'xxxx', '8': 'xxxx', '9': 'xxxx', etc} which tuyapi is calling the obj.data object. He also has a obj.multiple defined that when you pass the obj.data to tuya.set you set to true.
`if multiple dps need setting then call a function to convert tuyaSet to obj.data format
await tuya.set( { obj.multiple=true, obj.data }) and his routine will set the dps values `
otherwise just call like you always have tuya.set(stateObj);
i have tried to mess around but I am not half as good as you are with Java Script
Could you please consider enabling the feature to set multiple dps values in one call to your secript
Thank you for your time
EDIT: Edit to remove id and key
Thank you very much for sharing this wrapper! 👍
I am able to control my dimmer switch via njsTuya or even via homebridge-tuya (so device id and key is correct). I started all of this, trying to figure out why my dimmer switch isn’t reacting to my mqtt command topic in OpenHAB.
Via njsTuya I get my device to switch on with
node njstuya.js -ip <deviceip> -id <deviceid> -key <devicekey> -set "{ \"dps\": 1, \"set\": true }"
and off with
node njstuya.js -ip <deviceip> -id <deviceid> -key <devicekey> -set "{ \"dps\": 1, \"set\": false }"
Does anyone here maybe has a suggestion on where to look for a fix? Suggestions on this are very welcome.
Seems like getStatus() and SetStatus() have changed to get() and set().
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.