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

Node red errors occur when kasa device is off #48

Open grumpazoid opened 3 years ago

grumpazoid commented 3 years ago

I have a Kasa KL110B bulb and am running node red 1.2.9 on raspberry pi 3b.

Problem 1 If the Kasa bulb is powered off (at the mains) when node red starts I get an error generated in the console. Even if the bulb is then switched on, the Kasa node does not work until node red is restarted.

TCP 192.168.20.17:9999 Error: TCP Timeout after 1000ms 192.168.20.17:9999 {"system":{"get_sysinfo":{}}} at Timeout._onTimeout (/home/pi/.node-red/node_modules/tplink-smarthome-api/lib/network/tcp-socket.js:59:36) at listOnTimeout (internal/timers.js:554:17) at processTimers (internal/timers.js:497:7)

Problem 2 If the bulb is switched on when node red starts but is then powered off (at the mains), lots of errors are generated in the console as follows:

TCP 192.168.20.17:9999 Error: TCP Timeout after 1000ms 192.168.20.17:9999 {"smartlife.iot.common.emeter":{"get_realtime":{}},"smartlife.iot.smartbulb.lightingservice":{"get_light_state":{}},"smartlife.iot.common.schedule":{"get_next_action":{}},"system":{"get_sysinfo":{}},"smartlife.iot.common.cloud":{"get_info":{}}} at Timeout._onTimeout (/home/pi/.node-red/node_modules/tplink-smarthome-api/lib/network/tcp-socket.js:59:36) at listOnTimeout (internal/timers.js:554:17) at processTimers (internal/timers.js:497:7) [Kasa1] device.send() Error: TCP Timeout after 1000ms 192.168.20.17:9999 {"smartlife.iot.common.emeter":{"get_realtime":{}},"smartlife.iot.smartbulb.lightingservice":{"get_light_state":{}},"smartlife.iot.common.schedule":{"get_next_action":{}},"system":{"get_sysinfo":{}},"smartlife.iot.common.cloud":{"get_info":{}}} at Timeout._onTimeout (/home/pi/.node-red/node_modules/tplink-smarthome-api/lib/network/tcp-socket.js:59:36) at listOnTimeout (internal/timers.js:554:17) at processTimers (internal/timers.js:497:7)

The bulb is able to be controlled fine at all times via the Kasa app and via alexa app / echo device.

hufftheweevil commented 3 years ago

Hmm - this is rather tricky for me to test, as I don't use any Kasa bulbs; only switches (diehard Lifx house here). I'll see what I can work on this week to figure out what's going on. However, I'm thinking this is going to be an underlying API issue.

grumpazoid commented 3 years ago

@hufftheweevil Thanks for the reply. I think you may be right about it being the underlying API.

I tested out your node again this morning. When the bulb is switched on it does not get picked up by the node and is not usable until it is switched on and node red restarted.

I have also tried node-red-contrib-tplink-smarthome. I think this uses the same API?
I still get errors when the device is not powered - but the difference here is that when the device is powered back on it reconnects straight away and is useable again from node red.

I am suspecting it is the same issue as mentioned here You will notice I have also commented on that.

Due to the lack of comments I am suspecting that either not many users experience this, or they have not noticed the logs. Maybe they leave all their tplink devices powered up all the time?