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 Flows crash when using kasa node. #38

Open larrybell opened 3 years ago

larrybell commented 3 years ago

Has anyone had this issue? My node-red crashes when I use the kasa node.

Background I have been using other contrib-tplink nodes without any issue. When I found yours I installed it and replaced all my old nodes with the kasa node. When I saved it the page never reloads. I have to manually edit the flow file and remove all instances of the kasa node before node-red will load again.

I am wondering if there is a conflict with some other nodes. But I don't know how to troubleshoot it.

Thoughts?

larrybell commented 3 years ago

I have some more info. Node-red is crashing and restarting here is what I find in the logs

Error: Could not determine device from sysinfo 0|node-red | at Client.getDeviceFromSysInfo (/home/larry/.node-red/node_modules/node-red-contrib-tplink/node_modules/tplink-smarthome-api/lib/client.js:221:15) 0|node-red | at process (/home/larry/.node-red/node_modules/node-red-contrib-tplink/node_modules/tplink-smarthome-api/lib/client.js:445:31) 0|node-red | at Client.createOrUpdateDeviceFromSysInfo (/home/larry/.node-red/node_modules/node-red-contrib-tplink/node_modules/tplink-smarthome-api/lib/client.js:465:13) 0|node-red | at Socket.socket.on (/home/larry/.node-red/node_modules/node-red-contrib-tplink/node_modules/tplink-smarthome-api/lib/client.js:380:22) 0|node-red | at emitTwo (events.js:126:13) 0|node-red | at Socket.emit (events.js:214:7) 0|node-red | at UDP.onMessage [as onmessage] (dgram.js:659:8)

hufftheweevil commented 3 years ago

The "other" contrib-tplink is simply the older version of this same repo. The old version (0.x.x) is not compatible with the new one (1.x.x), so all nodes need to be replaced. There should be no conflicts, though, because all of the node types were renamed.

Try starting Node-RED in safe mode (using the --safe-mode flag from the command line), so that it doesn't deploy immediately on startup. Then remove (or disable) all of the kasa/tplink nodes, and deploy. If all is well, then re-enable or re-add each node and re-deploy after each one to determine if there is still an issue node.

The error above stems from the underlying client library (tplink-smarthome-api). Based on the code, it appears that whatever device it thinks it has, it can't determine if it is a plug or a bulb. If it occurs again after trying to above, let us know and we can look into it further.

larrybell commented 3 years ago

Justin,

This is what happens when I start node-red in safe mode. Also I had already removed all TPLINK nodes, removed all the repos, restarted node-red and installed your nodes. currently the only way to get node-red to start up is I have manually edit the flows file removing the kasa node.

larry@node-red:~$ larry@node-red:~$ node-red --safe-mode 19 Sep 11:22:14 - [info] Node.js version: v8.10.0 19 Sep 11:22:14 - [info] Linux 5.4.0-47-generic x64 LE 19 Sep 11:22:15 - [info] Loading palette nodes 19 Sep 11:22:17 - [info] Dashboard version 2.19.4 started at /ui 19 Sep 11:22:18 - [info] Settings file : /home/larry/.node-red/settings.js 19 Sep 11:22:18 - [info] Context store : 'default' [module=memory] 19 Sep 11:22:18 - [info] User directory : /home/larry/.node-red 19 Sep 11:22:18 - [warn] Projects disabled : editorTheme.projects.enabled=false 19 Sep 11:22:18 - [info] Flows file : /home/larry/.node-red/flows_node-red.json 19 Sep 11:22:18 - [info] Server now running at http://127.0.0.1:1880/ 19 Sep 11:22:18 - [warn]


Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials file will not be recoverable, you will have to delete it and re-enter your credentials.

You should set your own key using the 'credentialSecret' option in your settings file. Node-RED will then re-encrypt your credentials file using your chosen key the next time you deploy a change.

19 Sep 11:22:18 - [info] Starting flows 19 Sep 11:22:19 - [info] Started flows 19 Sep 11:22:19 - [info] [mqtt-broker:MQTT Broker on Ubuntu] Connected to broker: mqtt://172.16.30.116:1883 19 Sep 11:22:19 - [error] [api-current-state:Shop Door] Entity could not be found in cache for entity_id: cover.shop_door 19 Sep 11:22:19 - [info] [server:Home Assistant] WebSocket Connected to http://172.16.30.226:8123 19 Sep 11:22:19 - [red] Uncaught Exception: 19 Sep 11:22:19 - Error: Could not determine device from sysinfo at Client.getDeviceFromSysInfo (/home/larry/.node-red/node_modules/tplink-smarthome-api/lib/client.js:221:15) at process (/home/larry/.node-red/node_modules/tplink-smarthome-api/lib/client.js:445:31) at Client.createOrUpdateDeviceFromSysInfo (/home/larry/.node-red/node_modules/tplink-smarthome-api/lib/client.js:465:13) at Socket.socket.on (/home/larry/.node-red/node_modules/tplink-smarthome-api/lib/client.js:380:22) at emitTwo (events.js:126:13) at Socket.emit (events.js:214:7) at UDP.onMessage [as onmessage] (dgram.js:659:8)

Larry Bell larrybell@legaltechsupport.com 214-797-2201


From: Justin notifications@github.com Sent: Friday, September 18, 2020 8:22 PM To: caseyjhol/node-red-contrib-tplink node-red-contrib-tplink@noreply.github.com Cc: Larry Bell larrybell@LEGALTECHSUPPORT.COM; Author author@noreply.github.com Subject: Re: [caseyjhol/node-red-contrib-tplink] Node-Red Flows crash when using kasa node. (#38)

The "other" contrib-tplink is simply the older version of this same repo. The old version (0.x.x) is not compatible with the new one (1.x.x), so all nodes need to be replaced. There should be no conflicts, though, because all of the node types were renamed.

Try starting Node-RED in safe mode (using the --safe-mode flag from the command line), so that it doesn't deploy immediately on startup. Then remove (or disable) all of the kasa/tplink nodes, and deploy. If all is well, then re-enable or re-add each node and re-deploy after each one to determine if there is still an issue node.

The error above stems from the underlying client library (tplink-smarthome-api). Based on the code, it appears that whatever device it thinks it has, it can't determine if it is a plug or a bulb. If it occurs again after trying to above, let us know and we can look into it further.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/caseyjhol/node-red-contrib-tplink/issues/38#issuecomment-695144666, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIIT555Q4P6LPDOU7LDPRUTSGQBUTANCNFSM4RSOAYXQ.

larrybell commented 3 years ago

I was reading that that api no longer supports node.js versions older than 10. I am running 8.10.0. So I am going to try updating node.js to version 12 or 14.

larrybell commented 3 years ago

tried updating nodejs to version 12. Still same problem.

Any help you can provide would be greatly appreciated.

hufftheweevil commented 3 years ago

My apologizes, the correct flag to use is --safe to start in safe mode. What happened above is that it didn't actually start in safe mode. You will know it is in safe mode when the log shows Flows stopped in safe mode. Deploy to start. So try it with --safe and then enable each kasa node one at a time and try deploying. If at any point it errors/crashes, I would suspect it to be with that node/device. Copy the code makeup for that node (use Export) so we can evaluate it and go from there.

larrybell commented 3 years ago

I did a fresh install of Ubuntu 18.04, nodejs 12 and node-red last night. Only installed node-red-contrib-tplink and deployed 1 Kasa node. It does the same thing. Do you think it has anything to do with Ubuntu?

Larry

On Sep 20, 2020, at 8:40 AM, Justin notifications@github.com wrote:



My apologizes, the correct flag to use is --safe to start in safe mode. What happened above is that it didn't actually start in safe mode. You will know it is in safe mode when the log shows Flows stopped in safe mode. Deploy to start. So try it with --safe and then enable each kasa node one at a time and try deploying. If at any point it errors/crashes, I would suspect it to be with that node/device. Copy the code makeup for that node (use Export) so we can evaluate it and go from there.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/caseyjhol/node-red-contrib-tplink/issues/38#issuecomment-695788482, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIIT555NR4VTADQWORVDW3DSGYA3DANCNFSM4RSOAYXQ.

hufftheweevil commented 3 years ago

I can't image it is Ubuntu, as that is pretty solid. Can you paste the code that defines the node?

larrybell commented 3 years ago
[
    {
        id: "946d9864.cd3668",
        type: "kasa",
        z: "eae522c4.e9299",
        name: "",
        device: "",
        interval: 60000,
        eventInterval: 15000,
        payload: "getInfo",
        payloadType: "info",
        debug: true,
        x: 360,
        y: 220,
        wires: [[]],
    },
]

this is the only node in the flow. This particular attempt does not even have anything defined in the node. I tried different devices, light switches, plugs. All have the same result.

The one thing i see different about your code is that when I populate the ip address it automatically pulls the name from the device, which is really cool.

Larry Bell larrybell@legaltechsupport.com 214-797-2201


From: Justin notifications@github.com Sent: Sunday, September 20, 2020 9:04 AM To: caseyjhol/node-red-contrib-tplink node-red-contrib-tplink@noreply.github.com Cc: Larry Bell larrybell@LEGALTECHSUPPORT.COM; Author author@noreply.github.com Subject: Re: [caseyjhol/node-red-contrib-tplink] Node-Red Flows crash when using kasa node. (#38)

I can't image it is Ubuntu, as that is pretty solid. Can you paste the code that defines the node?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/caseyjhol/node-red-contrib-tplink/issues/38#issuecomment-695790976, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIIT55ZJPJEM4LKOUIXAMUDSGYDXZANCNFSM4RSOAYXQ.

larrybell commented 3 years ago

This one works fine in my flows

node-red-contrib-tplink-smarthome

how is it different?

Larry Bell larrybell@legaltechsupport.com 214-797-2201


From: Justin notifications@github.com Sent: Sunday, September 20, 2020 9:04 AM To: caseyjhol/node-red-contrib-tplink node-red-contrib-tplink@noreply.github.com Cc: Larry Bell larrybell@LEGALTECHSUPPORT.COM; Author author@noreply.github.com Subject: Re: [caseyjhol/node-red-contrib-tplink] Node-Red Flows crash when using kasa node. (#38)

I can't image it is Ubuntu, as that is pretty solid. Can you paste the code that defines the node?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/caseyjhol/node-red-contrib-tplink/issues/38#issuecomment-695790976, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIIT55ZJPJEM4LKOUIXAMUDSGYDXZANCNFSM4RSOAYXQ.

larrybell commented 3 years ago

maybe this will be helpful as well. It seems to be doing a discovery of devices.

login as: larry larry@172.16.30.185's password: Welcome to Ubuntu 18.04.5 LTS (GNU/Linux 5.4.0-47-generic x86_64)

0 packages can be updated. 0 updates are security updates.

Your Hardware Enablement Stack (HWE) is supported until April 2023.

The programs included with the Ubuntu system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.

larry@node-red-test:~$ node-red 20 Sep 09:38:04 - [info]

Welcome to Node-RED

20 Sep 09:38:04 - [info] Node-RED version: v1.1.3 20 Sep 09:38:04 - [info] Node.js version: v12.18.4 20 Sep 09:38:05 - [info] Linux 5.4.0-47-generic x64 LE 20 Sep 09:38:05 - [info] Loading palette nodes 20 Sep 09:38:06 - [info] Settings file : /home/larry/.node-red/settings.js 20 Sep 09:38:06 - [info] Context store : 'default' [module=memory] 20 Sep 09:38:06 - [info] User directory : /home/larry/.node-red 20 Sep 09:38:06 - [warn] Projects disabled : editorTheme.projects.enabled=false 20 Sep 09:38:06 - [info] Flows file : /home/larry/.node-red/flows_node-red-t est.json 20 Sep 09:38:06 - [info] Server now running at http://127.0.0.1:1880/ 20 Sep 09:38:06 - [warn]


Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials file will not be recoverable, you will have to delete it and re-enter your credentials.

You should set your own key using the 'credentialSecret' option in your settings file. Node-RED will then re-encrypt your credentials file using your chosen key the next time you deploy a change.

20 Sep 09:38:06 - [info] Starting flows client.startDiscovery({"discoveryInterval":60000,"offlineTolerance":1,"breakoutC hildren":false}) 20 Sep 09:38:06 - [info] Started flows client.socket: UDP IPv4 listening on 0.0.0.0:55497 client.sendDiscovery(255.255.255.255, [], 1) client.startDiscovery(): socket:message From: 172.16.30.147 9999 Message: {"syst em":{"get_sysinfo":{"sw_ver":"1.5.1 Build 171109 Rel.165500","hw_ver":"1.0","typ e":"IOT.SMARTPLUGSWITCH","model":"HS105(US)","mac":"AC:84:C6:B6:93:DF","dev_name ":"Smart Wi-Fi Plug Mini","alias":"TP1","relay_state":0,"on_time":0,"active_mode ":"none","feature":"TIM","updating":0,"icon_hash":"","rssi":-34,"led_off":0,"lon gitude_i":-962401,"latitude_i":329409,"hwId":"E5D7E6089B060EF662783C23AE110522", "fwId":"00000000000000000000000000000000","deviceId":"8006CE8C37C79C8B7E1B93E601 0304BB1A354E1A","oemId":"003E098AF0D44D4BAB796B3F6A7A830E","err_code":0}}} device.constructor({"client":"not shown","_sysInfo":{"sw_ver":"1.5.1 Build 17110 9 Rel.165500","hw_ver":"1.0","type":"IOT.SMARTPLUGSWITCH","model":"HS105(US)","m ac":"AC:84:C6:B6:93:DF","devname":"Smart Wi-Fi Plug Mini","alias":"TP1","relay state":0,"on_time":0,"active_mode":"none","feature":"TIM","updating":0,"icon_has h":"","rssi":-34,"led_off":0,"longitude_i":-962401,"latitude_i":329409,"hwId":"E 5D7E6089B060EF662783C23AE110522","fwId":"00000000000000000000000000000000","devi ceId":"8006CE8C37C79C8B7E1B93E6010304BB1A354E1A","oemId":"003E098AF0D44D4BAB796B 3F6A7A830E","err_code":0},"host":"172.16.30.147","port":9999,"defaultSendOptions ":{"timeout":15000,"transport":"tcp","useSharedSocket":false,"sharedSocketTimeou t":20000}}) plug.constructor() [TP1] device sysInfo set [TP1] plug sysInfo set [TP1] plug.emitEvents() inUse: false relayState: false lastState: {"inUse":false ,"relayState":false} client.startDiscovery(): socket:message From: 172.16.30.139 9999 Message: {"syst em":{"get_sysinfo":{"sw_ver":"1.5.1 Build 171109 Rel.165500","hw_ver":"1.0","typ e":"IOT.SMARTPLUGSWITCH","model":"HS105(US)","mac":"AC:84:C6:39:FA:EA","dev_name ":"Smart Wi-Fi Plug Mini","alias":"Shop Fan","relay_state":0,"on_time":0,"active _mode":"none","feature":"TIM","updating":0,"icon_hash":"","rssi":-36,"led_off":0 ,"longitude_i":-962401,"latitude_i":329409,"hwId":"E5D7E6089B060EF662783C23AE110 522","fwId":"00000000000000000000000000000000","deviceId":"8006F1F42F9FD6C971186 BB70E6FB9F519F1EDCA","oemId":"003E098AF0D44D4BAB796B3F6A7A830E","err_code":0}}} device.constructor({"client":"not shown","_sysInfo":{"sw_ver":"1.5.1 Build 17110 9 Rel.165500","hw_ver":"1.0","type":"IOT.SMARTPLUGSWITCH","model":"HS105(US)","m ac":"AC:84:C6:39:FA:EA","dev_name":"Smart Wi-Fi Plug Mini","alias":"Shop Fan","r elay_state":0,"on_time":0,"active_mode":"none","feature":"TIM","updating":0,"ico n_hash":"","rssi":-36,"led_off":0,"longitude_i":-962401,"latitude_i":329409,"hwI d":"E5D7E6089B060EF662783C23AE110522","fwId":"00000000000000000000000000000000", "deviceId":"8006F1F42F9FD6C971186BB70E6FB9F519F1EDCA","oemId":"003E098AF0D44D4BA B796B3F6A7A830E","err_code":0},"host":"172.16.30.139","port":9999,"defaultSendOp tions":{"timeout":15000,"transport":"tcp","useSharedSocket":false,"sharedSocketT imeout":20000}}) plug.constructor() [Shop Fan] device sysInfo set [Shop Fan] plug sysInfo set [Shop Fan] plug.emitEvents() inUse: false relayState: false lastState: {"inUse": false,"relayState":false} client.startDiscovery(): socket:message From: 172.16.30.140 9999 Message: {"syst em":{"get_sysinfo":{"sw_ver":"1.5.4 Build 180904 Rel.092245","hw_ver":"2.0","mic type":"IOT.SMARTPLUGSWITCH","model":"HS200(US)","mac":"AC:84:C6:3C:31:DA","dev name":"Smart Wi-Fi Light Switch","alias":"Shop Inside Light","relay_state":0,"on _time":0,"active_mode":"none","feature":"TIM","updating":0,"icon_hash":"","rssi" :-41,"led_off":0,"longitude_i":-962401,"latitude_i":329409,"hwId":"1265795080008 5A27A64E9E775C8A7A7","fwId":"00000000000000000000000000000000","deviceId":"80060 ED764D9BD9C6FB154D3E14E7F0519F6D73F","oemId":"4748FB6E209D782A854A4B5AEDC89284", "next_action":{"type":-1},"err_code":0}}} device.constructor({"client":"not shown","_sysInfo":{"sw_ver":"1.5.4 Build 18090 4 Rel.092245","hw_ver":"2.0","mic_type":"IOT.SMARTPLUGSWITCH","model":"HS200(US) ","mac":"AC:84:C6:3C:31:DA","dev_name":"Smart Wi-Fi Light Switch","alias":"Shop Inside Light","relay_state":0,"on_time":0,"active_mode":"none","feature":"TIM"," updating":0,"icon_hash":"","rssi":-41,"led_off":0,"longitude_i":-962401,"latitud e_i":329409,"hwId":"12657950800085A27A64E9E775C8A7A7","fwId":"000000000000000000 00000000000000","deviceId":"80060ED764D9BD9C6FB154D3E14E7F0519F6D73F","oemId":"4 748FB6E209D782A854A4B5AEDC89284","next_action":{"type":-1},"err_code":0},"host": "172.16.30.140","port":9999,"defaultSendOptions":{"timeout":15000,"transport":"t cp","useSharedSocket":false,"sharedSocketTimeout":20000}}) plug.constructor() [Shop Inside Light] device sysInfo set [Shop Inside Light] plug sysInfo set [Shop Inside Light] plug.emitEvents() inUse: false relayState: false lastState: {"inUse":false,"relayState":false} client.startDiscovery(): socket:message From: 172.16.30.133 9999 Message: {"syst em":{"get_sysinfo":{"sw_ver":"1.5.4 Build 180904 Rel.092245","hw_ver":"2.0","mic type":"IOT.SMARTPLUGSWITCH","model":"HS200(US)","mac":"AC:84:C6:06:E0:95","dev name":"Smart Wi-Fi Light Switch","alias":"Shop Lights","relay_state":0,"on_time" :0,"active_mode":"none","feature":"TIM","updating":0,"icon_hash":"","rssi":-47," led_off":0,"longitude_i":-962401,"latitudei":329409,"hwId":"12657950800085A27A6 4E9E775C8A7A7","fwId":"00000000000000000000000000000000","deviceId":"800618CCAC4 9A496FE1173CB2906748419CFAD5D","oemId":"4748FB6E209D782A854A4B5AEDC89284","next action":{"type":-1},"err_code":0}}} device.constructor({"client":"not shown","_sysInfo":{"sw_ver":"1.5.4 Build 18090 4 Rel.092245","hw_ver":"2.0","mic_type":"IOT.SMARTPLUGSWITCH","model":"HS200(US) ","mac":"AC:84:C6:06:E0:95","dev_name":"Smart Wi-Fi Light Switch","alias":"Shop Lights","relay_state":0,"on_time":0,"active_mode":"none","feature":"TIM","updati ng":0,"icon_hash":"","rssi":-47,"led_off":0,"longitude_i":-962401,"latitude_i":3 29409,"hwId":"12657950800085A27A64E9E775C8A7A7","fwId":"000000000000000000000000 00000000","deviceId":"800618CCAC49A496FE1173CB2906748419CFAD5D","oemId":"4748FB6 E209D782A854A4B5AEDC89284","next_action":{"type":-1},"err_code":0},"host":"172.1 6.30.133","port":9999,"defaultSendOptions":{"timeout":15000,"transport":"tcp","u seSharedSocket":false,"sharedSocketTimeout":20000}}) plug.constructor() [Shop Lights] device sysInfo set [Shop Lights] plug sysInfo set [Shop Lights] plug.emitEvents() inUse: false relayState: false lastState: {"inUs e":false,"relayState":false} client.startDiscovery(): socket:message From: 172.16.30.163 9999 Message: {"syst em":{"get_sysinfo":{"sw_ver":"1.5.5 Build 181204 Rel.081041","hw_ver":"2.0","mic type":"IOT.SMARTPLUGSWITCH","model":"HS200(US)","mac":"AC:84:C6:3C:17:F4","dev name":"Smart Wi-Fi Light Switch","alias":"Office Light","relay_state":0,"on_time ":0,"active_mode":"none","feature":"TIM","updating":0,"icon_hash":"","rssi":-41, "led_off":0,"longitude_i":-962401,"latitude_i":329409,"hwId":"12657950800085A27A 64E9E775C8A7A7","fwId":"00000000000000000000000000000000","deviceId":"80069EA0F3 60BCD106AD2975ECC0E2C319F6F26E","oemId":"4748FB6E209D782A854A4B5AEDC89284","next _action":{"type":-1},"err_code":0}}} device.constructor({"client":"not shown","_sysInfo":{"sw_ver":"1.5.5 Build 18120 4 Rel.081041","hw_ver":"2.0","mic_type":"IOT.SMARTPLUGSWITCH","model":"HS200(US) ","mac":"AC:84:C6:3C:17:F4","dev_name":"Smart Wi-Fi Light Switch","alias":"Offic e Light","relay_state":0,"on_time":0,"active_mode":"none","feature":"TIM","updat ing":0,"icon_hash":"","rssi":-41,"led_off":0,"longitude_i":-962401,"latitude_i": 329409,"hwId":"12657950800085A27A64E9E775C8A7A7","fwId":"00000000000000000000000 000000000","deviceId":"80069EA0F360BCD106AD2975ECC0E2C319F6F26E","oemId":"4748FB 6E209D782A854A4B5AEDC89284","next_action":{"type":-1},"err_code":0},"host":"172. 16.30.163","port":9999,"defaultSendOptions":{"timeout":15000,"transport":"tcp"," useSharedSocket":false,"sharedSocketTimeout":20000}}) plug.constructor() [Office Light] device sysInfo set [Office Light] plug sysInfo set [Office Light] plug.emitEvents() inUse: false relayState: false lastState: {"inU se":false,"relayState":false} client.startDiscovery(): socket:message From: 172.16.30.138 9999 Message: {"syst em":{"get_sysinfo":{"sw_ver":"1.5.1 Build 171109 Rel.165500","hw_ver":"1.0","typ e":"IOT.SMARTPLUGSWITCH","model":"HS105(US)","mac":"AC:84:C6:3A:04:3E","dev_name ":"Smart Wi-Fi Plug Mini","alias":"Office Lamp","relay_state":0,"on_time":0,"act ive_mode":"none","feature":"TIM","updating":0,"icon_hash":"","rssi":-34,"led_off ":0,"longitude_i":-962401,"latitude_i":329409,"hwId":"E5D7E6089B060EF662783C23AE 110522","fwId":"00000000000000000000000000000000","deviceId":"8006E6E059432D5652 211EC110B5F21319F172A5","oemId":"003E098AF0D44D4BAB796B3F6A7A830E","err_code":0} }} device.constructor({"client":"not shown","_sysInfo":{"sw_ver":"1.5.1 Build 17110 9 Rel.165500","hw_ver":"1.0","type":"IOT.SMARTPLUGSWITCH","model":"HS105(US)","m ac":"AC:84:C6:3A:04:3E","dev_name":"Smart Wi-Fi Plug Mini","alias":"Office Lamp" ,"relay_state":0,"on_time":0,"active_mode":"none","feature":"TIM","updating":0," icon_hash":"","rssi":-34,"led_off":0,"longitude_i":-962401,"latitude_i":329409," hwId":"E5D7E6089B060EF662783C23AE110522","fwId":"0000000000000000000000000000000 0","deviceId":"8006E6E059432D5652211EC110B5F21319F172A5","oemId":"003E098AF0D44D 4BAB796B3F6A7A830E","err_code":0},"host":"172.16.30.138","port":9999,"defaultSen dOptions":{"timeout":15000,"transport":"tcp","useSharedSocket":false,"sharedSock etTimeout":20000}}) plug.constructor() [Office Lamp] device sysInfo set [Office Lamp] plug sysInfo set [Office Lamp] plug.emitEvents() inUse: false relayState: false lastState: {"inUs e":false,"relayState":false} client.startDiscovery(): socket:message From: 172.16.30.128 9999 Message: {"syst em":{"get_sysinfo":{"err_code":0,"sw_ver":"1.2.5 Build 171206 Rel.090404","hw_ve r":"1.0","mic_type":"IOT.SMARTPLUGSWITCH","model":"HS200(US)","mac":"70:4F:57:FD :47:72","deviceId":"8006D6F1BF78C25C759ADBA7BAD162D8194C402B","hwId":"A0E3CC8F5C 1166B27A16D56BE262A6D3","fwId":"00000000000000000000000000000000","oemId":"4AFE4 4A41F868FD2340E6D1308D8551D","alias":"Office Fan","dev_name":"Wi-Fi Smart Light Switch","icon_hash":"","relay_state":0,"on_time":0,"active_mode":"schedule","fea ture":"TIM","updating":0,"rssi":-43,"led_off":0,"latitude":32.940975,"longitude" :-96.240176}}} device.constructor({"client":"not shown","_sysInfo":{"err_code":0,"sw_ver":"1.2. 5 Build 171206 Rel.090404","hw_ver":"1.0","mic_type":"IOT.SMARTPLUGSWITCH","mode l":"HS200(US)","mac":"70:4F:57:FD:47:72","deviceId":"8006D6F1BF78C25C759ADBA7BAD 162D8194C402B","hwId":"A0E3CC8F5C1166B27A16D56BE262A6D3","fwId":"000000000000000 00000000000000000","oemId":"4AFE44A41F868FD2340E6D1308D8551D","alias":"Office Fa n","dev_name":"Wi-Fi Smart Light Switch","icon_hash":"","relay_state":0,"on_time ":0,"active_mode":"schedule","feature":"TIM","updating":0,"rssi":-43,"led_off":0 ,"latitude":32.940975,"longitude":-96.240176},"host":"172.16.30.128","port":9999 ,"defaultSendOptions":{"timeout":15000,"transport":"tcp","useSharedSocket":false ,"sharedSocketTimeout":20000}}) plug.constructor() [Office Fan] device sysInfo set [Office Fan] plug sysInfo set [Office Fan] plug.emitEvents() inUse: false relayState: false lastState: {"inUse ":false,"relayState":false} client.startDiscovery(): socket:message From: 172.16.30.148 9999 Message: {"syst em":{"get_sysinfo":{"sw_ver":"1.5.1 Build 171109 Rel.165500","hw_ver":"1.0","typ e":"IOT.SMARTPLUGSWITCH","model":"HS105(US)","mac":"AC:84:C6:B6:7E:03","dev_name ":"Smart Wi-Fi Plug Mini","alias":"TP2","relay_state":1,"on_time":138820,"active _mode":"none","feature":"TIM","updating":0,"icon_hash":"","rssi":-57,"led_off":0 ,"longitude_i":-962401,"latitude_i":329409,"hwId":"E5D7E6089B060EF662783C23AE110 522","fwId":"00000000000000000000000000000000","deviceId":"8006EAF70DA432F23B7BA 6CD2F76447A1A35C9B0","oemId":"003E098AF0D44D4BAB796B3F6A7A830E","err_code":0}}} device.constructor({"client":"not shown","_sysInfo":{"sw_ver":"1.5.1 Build 17110 9 Rel.165500","hw_ver":"1.0","type":"IOT.SMARTPLUGSWITCH","model":"HS105(US)","m ac":"AC:84:C6:B6:7E:03","devname":"Smart Wi-Fi Plug Mini","alias":"TP2","relay state":1,"on_time":138820,"active_mode":"none","feature":"TIM","updating":0,"ico n_hash":"","rssi":-57,"led_off":0,"longitude_i":-962401,"latitude_i":329409,"hwI d":"E5D7E6089B060EF662783C23AE110522","fwId":"00000000000000000000000000000000", "deviceId":"8006EAF70DA432F23B7BA6CD2F76447A1A35C9B0","oemId":"003E098AF0D44D4BA B796B3F6A7A830E","err_code":0},"host":"172.16.30.148","port":9999,"defaultSendOp tions":{"timeout":15000,"transport":"tcp","useSharedSocket":false,"sharedSocketT imeout":20000}}) plug.constructor() [TP2] device sysInfo set [TP2] plug sysInfo set [TP2] plug.emitEvents() inUse: true relayState: true lastState: {"inUse":false," relayState":false} client.startDiscovery(): socket:message From: 172.16.30.157 9999 Message: {"syst em":{"get_sysinfo":{"err_code":0,"system":{"sw_ver":"2.3.1 Build 20200723 rel.33 983","hw_ver":"1.0","model":"KC120(US)","hwId":"CB7107D55354DEEFA98A18A06C4B65CD ","oemId":"69CC720CF36BB0DBB673B7AA7AAE9CD6","deviceId":"801A8230A41C1CB92A44E53 7906F2EE21A3D7780","dev_name":"Kasa Cam","c_opt":[0,1],"a_type":2,"type":"IOT.IP CAMERA","alias":"DogCam","mic_mac":"AC84C6C838F3","mac":"AC:84:C6:C8:38:F3","lon gitude":-96.240176,"latitude":32.940975,"rssi":-48,"system_time":1600612684,"led _status":"off","updating":false,"status":"configured","resolution":"1080P","came ra_switch":"on","bind_status":true,"last_activity_timestamp":1600606217}}}} 20 Sep 09:38:06 - [red] Uncaught Exception: 20 Sep 09:38:06 - Error: Could not determine device from sysinfo at Client.getDeviceFromSysInfo (/home/larry/.node-red/node_modules/tplink-sm arthome-api/lib/client.js:221:15) at process (/home/larry/.node-red/node_modules/tplink-smarthome-api/lib/clie nt.js:445:31) at Client.createOrUpdateDeviceFromSysInfo (/home/larry/.node-red/node_module s/tplink-smarthome-api/lib/client.js:465:13) at Socket. (/home/larry/.node-red/node_modules/tplink-smarthome-a pi/lib/client.js:380:22) at Socket.emit (events.js:315:20) at UDP.onMessage [as onmessage] (dgram.js:910:8) larry@node-red-test:~$

Larry Bell larrybell@legaltechsupport.com 214-797-2201


From: Justin notifications@github.com Sent: Sunday, September 20, 2020 9:04 AM To: caseyjhol/node-red-contrib-tplink node-red-contrib-tplink@noreply.github.com Cc: Larry Bell larrybell@LEGALTECHSUPPORT.COM; Author author@noreply.github.com Subject: Re: [caseyjhol/node-red-contrib-tplink] Node-Red Flows crash when using kasa node. (#38)

I can't image it is Ubuntu, as that is pretty solid. Can you paste the code that defines the node?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/caseyjhol/node-red-contrib-tplink/issues/38#issuecomment-695790976, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIIT55ZJPJEM4LKOUIXAMUDSGYDXZANCNFSM4RSOAYXQ.

hufftheweevil commented 3 years ago

Bingo! That last bit of log shows it found a Kasa Cam (KC120), and that must be throwing everything out of whack because it's neither a Plug nor a Bulb.

And yes, it is designed to do discovery at the Connection Poll Interval, to emit Online/Offline events. If you don't need that, then set Connection Poll Interval to 0 to disable it. That should fix your issue for now.

Alternatively, you can add a Catch node and it should catch those errors instead of crashing Node-RED.

Meanwhile, I'll see if we are able to put a fix into this library to catch those non-Plug/Bulb devices. We may need to request a PR for the underlying library.

larrybell commented 3 years ago

That worked.

Thank you for the help....

Larry Bell larrybell@legaltechsupport.com 214-797-2201


From: Justin notifications@github.com Sent: Sunday, September 20, 2020 10:01 AM To: caseyjhol/node-red-contrib-tplink node-red-contrib-tplink@noreply.github.com Cc: Larry Bell larrybell@LEGALTECHSUPPORT.COM; Author author@noreply.github.com Subject: Re: [caseyjhol/node-red-contrib-tplink] Node-Red Flows crash when using kasa node. (#38)

Bingo! That last bit of log shows it found a Kasa Cam (KC120), and that must be throwing everything out of whack because it's neither a Plug nor a Bulb.

And yes, it is designed to do discovery at the Connection Poll Interval, to emit Online/Offline events. If you don't need that, then set Connection Poll Interval to 0 to disable it. That should fix your issue for now.

Alternatively, you can add a Catch node and it should catch those errors instead of crashing Node-RED.

Meanwhile, I'll see if we are able to put a fix into this library to catch those non-Plug/Bulb devices. We may need to request a PR for the underlying library.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/caseyjhol/node-red-contrib-tplink/issues/38#issuecomment-695796973, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIIT553F4ZXSFIYB7XEH753SGYKL3ANCNFSM4RSOAYXQ.

hufftheweevil commented 3 years ago

@caseyjhol I traced the call stack to here https://github.com/plasticrake/tplink-smarthome-api/blob/4f684a55f9db919e2ee4274fd60b0c52dcfdb75f/src/client.ts#L605 which is inside a callback. Unless I'm missing something, there is no way we can catch that here. Thoughts?

larrybell commented 3 years ago

What I did was create a new wifi network with a new IP address range and moved the cameras to that new subnet. The discovery only works on the same subnet so moving the cameras to a new ip subnet resolves the problem.

Larry F. Bell Senior Systems Architect MED IT Associates bell@meditassociates.com Office: 972-265-0907 Cell: 214-797-2201

On Sep 23, 2020, at 3:01 PM, Justin notifications@github.com wrote:



@caseyjholhttps://github.com/caseyjhol I traced the call stack to here https://github.com/plasticrake/tplink-smarthome-api/blob/4f684a55f9db919e2ee4274fd60b0c52dcfdb75f/src/client.ts#L605 which is inside a callback. Unless I'm missing something, there is no way we can catch that here. Thoughts?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/caseyjhol/node-red-contrib-tplink/issues/38#issuecomment-697941420, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIIT55ZYYOWJKUAR762S7MLSHJHZLANCNFSM4RSOAYXQ.

hufftheweevil commented 3 years ago

@caseyjhol I traced the call stack to here https://github.com/plasticrake/tplink-smarthome-api/blob/4f684a55f9db919e2ee4274fd60b0c52dcfdb75f/src/client.ts#L605 which is inside a callback. Unless I'm missing something, there is no way we can catch that here. Thoughts?

I'm not sure what I was thinking, actually. We should be able to put the client.startDiscovery() call inside a try/catch. Correct?

caseyjhol commented 3 years ago

That seems like that should do the trick. Checking into it...

hufftheweevil commented 3 years ago

Thanks. I don't have any KC devices to test it with. Not sure how I would set up a test for it.

caseyjhol commented 3 years ago

I don't have any either unfortunately. We'll have to test to make sure it doesn't interfere with other Kasa devices, and check back after we push out the update.

tribbles3 commented 1 year ago

Just got a Kasa camera and it crashed node-red, which led me here. I set all the nodes to Poll Interval = 0 for now but I use that to alert me when a device is offline. Is there a permanent fix for this?