caseyjhol / node-red-contrib-tplink

A collection of Node-RED nodes for TP-Link Smart Home devices
https://www.npmjs.com/package/node-red-contrib-tplink-iot
MIT License
16 stars 15 forks source link

KASA node stalls after several hours of operation #54

Open WombatHollow opened 3 years ago

WombatHollow commented 3 years ago

The KASA node appears to stop working after some time of operation, I have witnessed this at least twice now. The node shows it is connected to device but no output comes from the node nor does the switch status data change, even when I use KASA app on phone to turn device (a HS110) off and on (switch responds appropriately to app).

I have two nodes (for two different devices) and both were stalled (do not know if they stalled at same time)

I got the node working by opening edit dialogue and turn on debug then redeployed modified Nodes. Had to do this to each node to get each working. Haven't yet had the opportunity so see if anything else kicks the node back to life.

To Reproduce just wait, I have not seen any triggers, just find it stalled Here are my nodes [{"id":"ba94847e.d34758","type":"kasa","z":"680af530.4620ec","name":"Dam Transfer Pump Control","device":"10.0.0.182","interval":"10000","eventInterval":"5000","payload":"getMeterInfo","payloadType":"info","debug":false,"x":620,"y":700,"wires":[["2c0099ca.e8cde6","fac20855.2f6428","9ef0e080.e44ed"]]},{"id":"2c0099ca.e8cde6","type":"debug","z":"680af530.4620ec","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":890,"y":620,"wires":[]},{"id":"fd418aac.276618","type":"inject","z":"680af530.4620ec","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"On","payloadType":"str","x":130,"y":700,"wires":[["ba94847e.d34758"]]},{"id":"69501e5f.6ea56","type":"inject","z":"680af530.4620ec","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Off","payloadType":"str","x":130,"y":760,"wires":[["ba94847e.d34758"]]},{"id":"52b7c6b7.134208","type":"inject","z":"680af530.4620ec","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"toggle","payloadType":"str","x":130,"y":640,"wires":[["ba94847e.d34758"]]},{"id":"cc437afb.bed5c8","type":"inject","z":"680af530.4620ec","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"startMeterEvents","payloadType":"str","x":150,"y":840,"wires":[["ba94847e.d34758"]]},{"id":"df1b82c2.0b78d","type":"kasa","z":"680af530.4620ec","name":"Shed Flat Powerpoint","device":"10.0.0.181","interval":"10000","eventInterval":"5000","payload":"getMeterInfo","payloadType":"info","debug":false,"x":620,"y":380,"wires":[["164c1a65.b25756","fac20855.2f6428"]]},{"id":"164c1a65.b25756","type":"debug","z":"680af530.4620ec","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":890,"y":460,"wires":[]},{"id":"c903e600.df3028","type":"change","z":"680af530.4620ec","name":"","rules":[{"t":"delete","p":"topic","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":380,"wires":[["df1b82c2.0b78d","164c1a65.b25756"]]},{"id":"a20c18fa.e509f8","type":"inject","z":"680af530.4620ec","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"On","payloadType":"str","x":150,"y":380,"wires":[["c903e600.df3028"]]},{"id":"67764c19.8b9844","type":"inject","z":"680af530.4620ec","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"OFF","payloadType":"str","x":150,"y":440,"wires":[["c903e600.df3028"]]},{"id":"d2936230.00157","type":"inject","z":"680af530.4620ec","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"toggle","payloadType":"str","x":160,"y":320,"wires":[["c903e600.df3028"]]},{"id":"5a0a77e0.83fbd8","type":"inject","z":"680af530.4620ec","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"startMeterEvents","payloadType":"str","x":140,"y":240,"wires":[["df1b82c2.0b78d"]]},{"id":"3a40dcb7.fb3be4","type":"inject","z":"680af530.4620ec","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"getInfo","payloadType":"str","x":120,"y":500,"wires":[["df1b82c2.0b78d","ba94847e.d34758"]]},{"id":"7c5d1eb4.1042d","type":"inject","z":"680af530.4620ec","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"getQuickInfo","payloadType":"str","x":130,"y":540,"wires":[["df1b82c2.0b78d","ba94847e.d34758"]]},{"id":"8ea4208e.d3679","type":"inject","z":"680af530.4620ec","name":"","props":[{"p":"payload"}],"repeat":"5","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"getMeterInfo","payloadType":"str","x":140,"y":580,"wires":[["df1b82c2.0b78d"]]}]

Node-Red 1.3.5 Node version 1.0.0 RasPi 3B+ updated to latest Raspbian 2 ofHS110 connected over local network

I will add more as I find it.

WombatHollow commented 3 years ago

A bit more info, still using same above script. Within 5 hours one had stall but the other Kasa node was still working after 17 hours. Tried the following to see if it restarted to no avail

  1. Changed tabs
  2. Deployed changed Flow (after tweaking another node)

It did restart when change event poll interval in the stopped node and redeployed the flow.

Now wait for it to stop again to try something else.

WombatHollow commented 3 years ago

One Node connected only to HS110 #1 failed again. But I have set up another KASA node (3rd in flow) which has a blank Device IP and relies on msg.topic to set up device IP. This is connected to both HS110 #1 and #2 and it did not stall so was still functioning with HS110 #1. Looking in logs but as they were only working to console I had no history. just moving the node and redploy did not get it working. Changing the Name and redploy did get it working.

gmow1 commented 3 years ago

It fails for me as well, in Node-Red I do a search of IPs and change the device. It comes online and then I change it back to my desired device. Stays online but fails(offline) after a few hours.

Scott-St commented 3 years ago

Same issue. Some seem to last forever, some last hours to weeks. Seemingly random. I tried creating a timeout function that would send the stopPowerEvents which didnt work. I then tried to make it so it would request from a different IP then switch back. This also doesnt seem to work as I think when you send another IP it just adds it to its array of devices it polls. The only thing that consistently brings it back to life is in the node, change the IP then change it back.

This also looks like it causes a memory leak. Once a plug stops responding the memory footprint keeps going up until i restart nodered.

gmow1 commented 3 years ago

Any updates or is this duplicated in other issues?

SDupuie commented 1 year ago

For what it's worth I have found disconnects to be more of an issue with the HS300 Power Strip than individual wi-fi switches.

A "reset" input to the node that kick starts it back into operation would be real nice. That would enable programmatically detecting and restarting the node. Currently, I have not found a way to re-establish connection other than re-deploying the flow or restarting Node-RED.