Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to work with multiple plugs? #98

Open
goofy2k opened this issue Feb 1, 2023 · 5 comments
Open

How to work with multiple plugs? #98

goofy2k opened this issue Feb 1, 2023 · 5 comments

Comments

@goofy2k
Copy link

goofy2k commented Feb 1, 2023

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
Copy link
Author

goofy2k commented Feb 1, 2023

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
Copy link

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)

#94

@goofy2k
Copy link
Author

goofy2k commented Feb 2, 2023

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

Some things to check:

  • the connection with the plugs must survive ending of the login script.
  • increase of speed because login and handshake can be time consuming
  • the persisted connection (if successful) should not block attempts to connect by other scripts (does a plug accept multiple simultaneous connections? )

@stylemessiah
Copy link

stylemessiah commented Feb 2, 2023 via email

@goofy2k
Copy link
Author

goofy2k commented Feb 2, 2023

Haha, nevertheless: thanks for your help !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants