Closed borpin closed 8 years ago
For more details see the thread on the forum https://groups.google.com/forum/m/#!topic/node-red/Z5FApuA_WHg
Hey. Thanks for the feedback. I am in holiday and will look into the issue when i am back home. Greets mapero
The problem is that you are referencing "Promise" which is only native in node.js after a certain version (not sure which). The underlying edimax-smartplug module uses the bluebird library to provide promises and so it works fine with older versions of node.
Many of us are using Node-Red on Pi's and are still working with older versions of node.js until we can update everything which isn't that easy.
I did a quick test by installing bluebird and defining:
var Promise = require("bluebird");
at the top of smartplug.js
just fyi - Node-RED already includes the "when" promise package - so it may be possible to re-use that rather than add yet another.... ?
The issue with that I think is that that package is only available in newer Node.js. As this is a Pi based system it would be better to work with the older one. In addition the underlying package uses bluebird.
Not a solution for the problem but i have to say: using a pi does not mean you have to use old Software. There are more distributions beside Debian/Ubuntu e.g. Arch Linux.
Agreed but it is a faf and I'd (and so would many) just work off standard repos. On 6 Jan 2016 9:25 pm, "mapero" notifications@github.com wrote:
Not a solution for the problem but i have to say: using a pi does not mean you have to use old Software. There are more distributions beside Debian/Ubuntu e.g. Arch Linux.
— Reply to this email directly or view it on GitHub https://github.com/mapero/node-red-contrib-smartplug/issues/1#issuecomment-169467441 .
I'm a bit confused by the comment about distribution as surely it fails against a version of nodejs, and would fail with that version of nodejs irrespective of OS. If the node-red-node requires a minimum version of nodejs then shouldn't that be included in the package.json file? But it would be a shame that those users who are trying out node-red which now comes preinstalled in the Rasbian Jessie image could make use of your code.
@ukmoose : It is a little confusing I agree. Basically, because the Pi is effectively an embedded system and it's most commonly used OS is based on Debian, some fast moving packages like node.js can be quite a long way out of date. Many people using Pi's are not Linux experts and so stick with the standard packages.
I totally agree that an module that relies on capabilities introduced in a particular version of node.js should have the required engine defined in package.json:
"engines": {
"node": "5.*"
}
Of course, in fairness with so much going on in the world of JS and node.js, it is easy to overlook dependency changes.
Also note that even with bluebird providing "Promise", the nodes still don't work properly.
On node v5, with the "repeating" function fix from the other issue, everything works as expected but that isn't true on a Pi running node v0.12 with bluebird. Nothing works.
Best solution would be to remove promise and rewrite the edimax interface. I did not add the dependency info since i did not check all versions of nodejs. It worked for me and i used it for 5months now. I shared it in github to let other use it. Never claimed to release a perfect product and this is the first time i got feedback at all. I did not know that someone is interested at all. So everybudy is free to contribute and create a pull request with a fix. If i have time at the weekend i will look into it.
Please ignore my last post. By moving the bluebird require into the "repeating" function everything now works.
One way to fix this would be to do an optional require for bluebird by looking up the version of node in use. Not terribly elegant but it will work fine.
I checked the current version with node 4.0.0 and 5.2.0 on linux. Can you please check if the latest changes fix your issues? Thanks.
Updated the node and all seems well on my Pi. Excellent, many thanks, saved me a chunk of work. On 8 Jan 2016 1:04 pm, "mapero" notifications@github.com wrote:
I checked the current version with node 4.0.0 and 5.2.0 on linux. Can you please check if the latest changes fix your issues? Thanks.
— Reply to this email directly or view it on GitHub https://github.com/mapero/node-red-contrib-smartplug/issues/1#issuecomment-169996035 .
Hi trying to use this and I get this error.