dickydoouk / tp-link-tapo-connect

Unofficial Node.js library for connecting to TP-Link Tapo devices. Currently limited to the P100 & P105 smart plugs and L510E smart bulbs.
114 stars 40 forks source link

TypeError: Cannot read properties of undefined (reading 'ip') #28

Open olalonde opened 2 years ago

olalonde commented 2 years ago

I'm getting this error when running the example:

> node src/index.js

TypeError: Cannot read properties of undefined (reading 'ip')
    at /Users/redacted/code/test/node_modules/tp-link-tapo-connect/dist/network-tools.js:51:118
    at step (/Users/redacted/code/test/node_modules/tp-link-tapo-connect/dist/network-tools.js:33:23)
    at Object.next (/Users/redacted/code/test/node_modules/tp-link-tapo-connect/dist/network-tools.js:14:53)
    at fulfilled (/Users/redacted/code/test/node_modules/tp-link-tapo-connect/dist/network-tools.js:5:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
const devices = await listDevicesByType(cloudToken, 'SMART.TAPOPLUG');

    const smartPlug = devices[0];

    const deviceToken = await loginDevice(email, password, smartPlug);
    const getDeviceInfoResponse = await getDeviceInfo(deviceToken);
    console.log(getDeviceInfoResponse);

The device is on a remote network.

BartaG512 commented 1 year ago

Getting the same error. return tidyMac(device.mac) == tidyMac(mac); }).ip]; ^

TypeError: Cannot read properties of undefined (reading 'ip') at app\node_modules\tp-link-tapo-connect\dist\network-tools.js:52:56 at step (app\node_modules\tp-link-tapo-connect\dist\network-tools.js:33:23) at Object.next (app\node_modules\tp-link-tapo-connect\dist\network-tools.js:14:53) at fulfilled (app\node_modules\tp-link-tapo-connect\dist\network-tools.js:5:58) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

ercksen commented 1 year ago

Had the same issue and my problem was with ARP. I am using a WiFi to LAN Bridge in my case which is not transparent, so it was not able to find the correct MAC address. As no non-null assertion is made, you get this error.

Feedback could be better, but the actual problem probably has to do with your ARP setup. Are you running inside Docker?

valinotti4 commented 1 year ago

Any workaround for this issue? I am also trying to run the script from an external network. If I run it from the same network as the smart plug is conected, it works fine.

Thanks!