fishbigger / TapoP100

A module for controlling the TP-Link Tapo P100 Plugs
MIT License
566 stars 138 forks source link

How to work with multiple plugs? #98

Open goofy2k opened 1 year ago

goofy2k commented 1 year ago

I used the example from the README.md I notice that it takes a few seconds before the script returns the requested info. This could be due to the fact that logging in / hand-shaking takes some time.

What is a good way to poll a set of plugs?

Is there a way to keep each plug in the set logged in and perform other set/get tasks in a loop?

goofy2k commented 1 year ago

After having a better look at the example code, I think I can define multiple p110 variables and use these in calls for handshake, login and getEnergyUsage or getDeviceInfo. I will give that a try.

adrianmmiller commented 1 year ago

for what its worth i shred some example code for working with multiple plugs here, maybe it will be a good starting block?

most of the code is in the formatting the returned data (for my personal tastes)

https://github.com/fishbigger/TapoP100/issues/94

goofy2k commented 1 year ago

Great! That is exactly what I was thinking of.

Now I am wondering if it is possible to create an array of variables such as your p110 and login to them in a loop similar to yours.

Then either:

or (my preference, but don't know if it is possible)

Some things to check:

stylemessiah commented 1 year ago

I did point out it was perhaps my first ever python script and that it was just a beginning point :)

On Thu, 2 Feb 2023 at 20:59, Goofy2k @.***> wrote:

Great! That is exactly what I was thinking of.

Now I am wondering if it is possible to create an array of variables such as your p110 and login to them in a loop similar to yours.

Then either:

  • create a polling loop starting at returnedData.... which repeatedly polls all plugs without doing the login inside that loop

or (my preference, but don't know if it is possible)

-

login to all plugs as above

store the array of p110 variables

end the Python script

on the desired moments start an other script for retrieval of plug data, which....

gets the p110 variables from storage

collects and shares plug data

stops

— Reply to this email directly, view it on GitHub https://github.com/fishbigger/TapoP100/issues/98#issuecomment-1413456296, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACO4RXLN7DJOUBDCBQE7LR3WVOAORANCNFSM6AAAAAAUOKMJ64 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

goofy2k commented 1 year ago

Haha, nevertheless: thanks for your help !