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.
112 stars 39 forks source link

Cannot turn on P110 from different network #46

Open tomasj opened 1 month ago

tomasj commented 1 month ago

My code is following, and works ok as long, as it gets executed from the same network as the P110 is connected to.

// get the device - works ok regardless the network
const cloudApi = await cloudLogin(TAPO_USERNAME, TAPO_PASSWORD);
const devicesByType = await cloudApi.listDevicesByType('SMART.TAPOPLUG');
const deviceTarget = devicesByType.filter(device => device.deviceMac === TAPO_DEVICE_MAC)[0];
const device = await loginDevice(TAPO_USERNAME, .TAPO_PASSWORD, deviceTarget);

// turn on the power socket - fails when executed outside device's network
await device.turnOn();

The error is: TypeError: Cannot read properties of undefined (reading 'status').

The same error is returned when I call await device.getDeviceInfo();.

Can I do something in my code to fix that? Or the lib is intended to be used in the same network as the device?

dickydoouk commented 1 month ago

Hi @tomasj unfortunately the library only works on the same network at the moment. However the official Tapo app does turn on/off devices remotely however I'm not sure how that works or is passed through the cloud API. It is something I'd like to get working though.