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

Can i recreate a Bulb list without discovering them? #3

Open
VinzzB opened this issue Aug 29, 2015 · 1 comment
Open

Can i recreate a Bulb list without discovering them? #3

VinzzB opened this issue Aug 29, 2015 · 1 comment

Comments

@VinzzB
Copy link

VinzzB commented Aug 29, 2015

Hello Smarthall,

I just tested your script and it works well. I still have some minor questions:

Is it possible to add Bulbs manually to the internal list without using discovery?
Can i simply create a Device object by passing the right arguments to its CTOR (DeviceId, Host, Client)?
How can i disable discovery when creating the Client? Can i place the next lines into an IF block: self.discover() and the _discoverpoll calls? I would create separate methods for this (start/stop discovery)

What i'm actually looking for is a way to re-create the bulblist from a (db) store. Once it knows (dicovered) the bulbs, there is no need to discover them again. (unless you want to make sure that they are on-line). It should see changes in the bulbs (when the are on-line) as your script does now.

So my main question: Is there an easy way to store/restore bulbs?

Also, please mention in your docs that this is a Python 2.x script.

@smarthall
Copy link
Owner

Hi @VinzzB

Sorry for the late reply.

If you add an if block around these lines you will have a switch for enabling/disabling discovery. I'd suggest making th switch depend on the discover argument on the constructor, for example if its set to None. I'd welcome a PR for this. Keep in mind that discovery doesn't just ensure that new devices are discovered, it is also responsible for detecting devices that may have moved to a new IP address.

As for exporting and loading the current devices this is how I would approach it:

  1. Add a function to Client that's used to create a new device from a device_id and host and return it.
  2. Refactor Client._servicepacket to use this new function
  3. Add a function to Client that takes a list of device_id and host pairs creates them with the new function, then when done calls Client.poll_devices (to test availability).
  4. Add a function to Client that exports the device_id and host pairs in the same way the other function takes them

For extra points add hooks so that the Client object itself can be serialised and deserialised with Pickle. 😄

I'll probably get around to this eventually, but I welcome a PR if you need it sooner.

@smarthall smarthall reopened this Sep 24, 2015
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

2 participants