mapero / node-red-contrib-smartplug

MIT License
3 stars 4 forks source link

Status does not update #2

Closed borpin closed 8 years ago

borpin commented 8 years ago

I have the node running (by adding in var Promise = require("bluebird"); at the top and installing bluebird) but the status does not change as the plug is switched on and off (either manually or by the app). If I redeploy the flows it updates to the latest status but then does not change again if the plug is switched.

borpin commented 8 years ago

Ok so I have solved it; I think. Line 54 ('function repeating') should be before line 41 so it reads a new status every time.

TotallyInformation commented 8 years ago

Not sure that does fix it.

I've made that change on both a node.js v5 based Windows system and a node v0.12 based system on a Raspberry Pi. It works on the Windows install but not on the Pi.

TotallyInformation commented 8 years ago

Please ignore that last post. As suggested in the forum, moving the require into the "repeating" function fixes the issue and moving the function to after node.indexes = []; and before if (n.deviceinfo){ makes it all work.

Making the require dependent on the version of node using process.version would fix the Promise dependency for everyone. Not sure when Promises were introduced though, was it v4?

mapero commented 8 years ago

Problem was that the promises where resolved and the functions are not called again. Promises are now newly created for every call. Can you check with the new version?

TotallyInformation commented 8 years ago

Checked and now working thanks.