Closed amitn16 closed 5 years ago
Sorry the readme got overwritten by the wrong version. Check out the readme below. You just need to clone my repo and install one of the dependencies.
https://github.com/unparagoned/njsTuya/blob/master/README.md
I'll leave this open since I expect that I should find out how to set it up so people can just install my repo and it will install any dependencies.
Hi, I am able to toggle, on and off my smart plug using command prompt, but still when i create switch in openhab..it is not working.. using items and sitemap to create simple switch to make on/off the device. please help.
Openhab has an issue with rules, where an item can receive a command and trigger a rule before it updates the item's state. So when you send an ON command to the item, the rule triggers and then turns the switch off since that was the state of the item. I've fixed the rule below You just need to fix the rule to use the receivedCommand which will be correct rather than the item's state, which needs a few ms to update.. See below.
rule "Switch heater"
when
Item LivingRoomHeater received command
then
if(db) { logInfo("LivingRoomHeater change", "turning heater to {}", receivedCommand) }
if (receivedCommand.toString.toLowerCase.contains("on")) {
LivingRoomHeaterCommand.sendCommand("ON")
}
else {
LivingRoomHeaterCommand.sendCommand("OFF")
}
end
Then stick this in your sitemap
Switch item=LivingRoomHeater
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..
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 npm@6.2.0 3 info using node@v10.9.0 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#