mapero / node-red-contrib-smartplug

MIT License
3 stars 4 forks source link

Must restart Nod-RED to get some Node value changes to be accepted #4

Closed JonMurphy closed 8 years ago

JonMurphy commented 8 years ago

@mapero - This is a copy of an issue I posted on the Node-RED Google group. Looking through the Member List I could not determine of you subscribe.

Here is what I wrote on google groups: "Hoping you can point me in the right direction. I am not sure if this is a cockpit issue (my error), or a Node-RED issue or a Node issue. . . (I removed the question about the Nest Node) . Last night I ran into a situation with the just downloaded Edimax Smartplug Node (node-red-contrib-smartplug 0.0.5). When I change the Interval(ms) from the default of 1000 (or any other number) to the new number of 300000 the change does not happen after a Deploy. To get the change to “set” or “take” I must stop & start Node-RED. Is stopping & starting Node-RED just part of the Deploy process when a change to a value is made?

Details: The Node-RED is running on an Open Energy Monitor http://openenergymonitor.org/emon/ emonPi box with Jessie Minibian (v 2015-11-12). emonCMS version low-write 9.3 on 2015.12.30. Node-RED version: v0.12.5 and Node.js version: v0.12.9. The Node-RED and node.js were part of Jessie build (or OEM build) and were not added by me.

Thank you! Jon"

PS-Thank you for creating the Edimax SmartPlug node. It is just what I was looking for!

JonMurphy commented 8 years ago

@mapero - Here is the 2nd part of the note:

"...be aware I stumbled across another odd item. I was cleaning up my EdiPlug flow (Edimax SmartPlug SP-2101W) and I was deleting all of the flows and nodes on Sheet 2. Sheet 2 is now blank. I clicked the Node-RED Deploy and the EdiPlug node kept running. The debug info was something similar to EHOSTUNREACH error (sorry I cannot locate the exact statement in my logs). So I did a Node-RED stop & start. And the EHOSTUNREACH error did not go away. In the hamburger menu in the Config Menu and the EdiPlug was a greyed out (i.e., EdiPlug 0). I deleted it but the errors kept coming. I ended up having to reboot the Pi box to get rid of the EHOSTUNREACH errors and the EdiPlug node. I am assuming like the above items, this is not normal. ... Best regards! Jon"

Here is a link to the thread: https://groups.google.com/d/msg/node-red/kikPSNqNcoM/4w3fl9txAgAJ

Thank you! Jon

mapero commented 8 years ago

Hey Jon,

thanks for your feedback. I'll look into this on the weekend. At the moment i can not reproduce the behaviour on my local instance. If the node is deleted the timer should be reset. I'll check this.

Best regards Jochen

mapero commented 8 years ago

Tried to reproduce, but deleting worked fine for me. Can you please provide further steps to reproduce the problem? npm list -g | grep node-red-contrib-smartplug npm list | grep node-red-contrib-smartplug

Thanks.

JonMurphy commented 8 years ago

Hi Jochen,

pi@emonpi:~/data/node-red$ npm list -g | grep node-red-contrib-smartplug pi@emonpi:~/data/node-red$ npm list | grep node-red-contrib-smartplug ├─┬ node-red-contrib-smartplug@0.0.5 pi@emonpi:~/data/node-red$

Concerning the Interval(ms) - It seems to be an issue when I make a big jump. From 1000 to 300000 will cause an issue. The Interval(ms) will stay at 1000 after I click the Deploy in Node-RED. This doesn't happen every time. But maybe 50% of the time. The only way to get the change to be accepted is to Stop Node-RED and then Start Node-RED. Another "Deploy" using a simple change in the Comments Node will not cause the 300000 to be accepted.

It seems to work OK when decreasing from 300000 to 1000 (no Stop/Start of Node-RED needed)

Best regards, Jon

JonMurphy commented 8 years ago

Here is how the smartplug node is configured:

screen shot 2016-01-23 at 6 06 41 pm_thumb

screen shot 2016-01-23 at 6 12 11 pm_thumb

JonMurphy commented 8 years ago

Here is my experimental flow with the SmartPlug Node. I am a beginner so LOTS of Debug nodes. One of the functions is only partially complete as I figure out how all of this works.

Jon

[{"id":"b96ad173.46953","type":"smartplug-device","z":"","name":"edimax smartplug","host":"192.168.40.235","timeout":"10","retry":"5"},{"id":"784cc38e.87b33c","type":"debug","z":"3aba851.fc5457a","name":"EdiPlug Debug","active":true,"console":"false","complete":"payload","x":443,"y":123,"wires":[]},{"id":"e2b445fe.1d4bb8","type":"smartplug-in","z":"3aba851.fc5457a","name":"EdiPlug","topic":"","device":"b96ad173.46953","interval":"120000","deviceinfo":false,"schedule":false,"status":true,"x":239,"y":122,"wires":[["784cc38e.87b33c","178ec73b.e87139","f1ac10ac.0e53f"]]},{"id":"47d8f664.b82708","type":"smartplug-out","z":"3aba851.fc5457a","name":"ESP Out","topic":"","device":"b96ad173.46953","response":false,"x":521,"y":321,"wires":[[]]},{"id":"dbb69c17.24496","type":"inject","z":"3aba851.fc5457a","name":"","topic":"","payload":"false","payloadType":"string","repeat":"","crontab":"","once":false,"x":340,"y":321,"wires":[["47d8f664.b82708"]]},{"id":"198d3cd.fe672c3","type":"inject","z":"3aba851.fc5457a","name":"","topic":"","payload":"true","payloadType":"string","repeat":"","crontab":"","once":false,"x":335,"y":378,"wires":[["47d8f664.b82708"]]},{"id":"e5c3dd22.1a3c2","type":"delay","z":"3aba851.fc5457a","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":603,"y":231,"wires":[["47d8f664.b82708"]]},{"id":"d464308b.2b9bd","type":"function","z":"3aba851.fc5457a","name":"","func":"msg.payload = true;\nreturn msg;","outputs":1,"noerr":0,"x":463,"y":231,"wires":[["e5c3dd22.1a3c2"]]},{"id":"178ec73b.e87139","type":"switch","z":"3aba851.fc5457a","name":"","property":"payload.status.state","rules":[{"t":"false"}],"checkall":"true","outputs":1,"x":332,"y":230,"wires":[["d464308b.2b9bd"]]},{"id":"f1ac10ac.0e53f","type":"function","z":"3aba851.fc5457a","name":"","func":"\nmsg.time = Math.round((Date.now() / 1000));\nstr1 = msg.payload.status.state;\nstr2 = msg.payload.status.nowPower;\nstr3 = msg.payload.status.nowCurrent;\n\nreturn msg;","outputs":1,"noerr":0,"x":439,"y":180,"wires":[["edf375e2.120c88"]]},{"id":"edf375e2.120c88","type":"debug","z":"3aba851.fc5457a","name":"func msg pay","active":false,"console":"false","complete":"payload","x":612,"y":171,"wires":[]},{"id":"ea6d3b75.1592c8","type":"comment","z":"3aba851.fc5457a","name":"","info":" ","x":130,"y":57,"wires":[]}]

JonMurphy commented 8 years ago

Jochen, Concerning Deleting the SmartPlug Node - It took lots of experimenting but I think I figured some of it out. Hopefully this helps.

Background: It was the end of the day and earlier in the evening I had unplugged the Edimax Smartplug from the wall and I was getting this message every 8 seconds "[error] [smartplug-in:EdiPlug] Error: connect EHOSTUNREACH". I was worried about filling up the log area on the Raspberry Pi 2. So I decided to save the flow (above) and delete the entire flow (completely clear off the Sheet).

Jan 23 18:38:18 - I made my last change and clicked the Node-RED Deploy. Shortly after I headed out for dinner (forgot about my testing and left the flow run). The flow ran with the EHOSTUNREACH error for about 3 hours.

Jan 23 21:45:04 - I deleted the entire flow and clicked the Deploy button. So the Screen 2 is completely blank. This did not stop the EHOSTUNREACH errors.

Next - I click on the hamburger menu (in the upper right corner) and opened the Config window, saw the ediplug greyed out and set to zero. I double clicked the ediplug and deleted the "edit smartplig-device config node" (pictured above). I clicked the Deploy. This did not stop the EHOSTUNREACH errors.

Jan 23 21:49:00 - I stopped and the started Node-RED. And the EHOSTUNREACH error was finally gone.

Hope this helps. I was not able to recreate this by adding a ediplug flow and then deleting it within a few minutes. For some odd reason it took time before the flow delete to get the error to happen. I am guessing this is an unlikely situation so I wouldn't make this a high priority!

Best regards, Jon

ediplug - Terminal Saved Output 2.pdf

mapero commented 8 years ago

Should be gone with all the changes in the past. Else, reopen please.

JonMurphy commented 8 years ago

Jochen - we are good to close this. All the above it working well. Thank you! Jon