happyleavesaoc / python-orvibo

MIT License
36 stars 20 forks source link

Unable to control more than one device #2

Closed olimpiurob closed 8 years ago

olimpiurob commented 8 years ago

Suppose we have 2 S20 switches, when we instantiate the first one, it binds port 10000 on 0.0.0.0, this makes it impossible to create another object, due to port 10000 beeing already binded.

A quick workaround would be to move the socket declaration from the S20 init method into the _udp_transact method and close the socket before returning retval. The downside would be that, we'd no longer get state changes if they happen from a different controller, unless we do some sort of polling.

Is there another way to fix this issue?

happyleavesaoc commented 8 years ago

Thanks for the issue report - you are correct. Might be able to move the socket to module-level and have it shared amongst all objects. Anyway, I've a second device on the way - I'll resolve this shortly.

happyleavesaoc commented 8 years ago

I just pushed a commit that should enable control of multiple devices. Let me know if it works for you.

olimpiurob commented 8 years ago

Yes, thank you. Better solution than what I made :)

olimpiurob commented 8 years ago

There still seem to be some issues, with the subscriptions when there are more switches(One works in changing state, the other two, do not, and the state is not fetched either). Unfortunately, I do not have time to look at this in more detail at this moment.

happyleavesaoc commented 8 years ago

I pushed another commit to address this issue. I hope it works better!

olimpiurob commented 8 years ago

For the first time I am able to control all 3 of my S20 from home-assistant. I had to remove and recreate my docker containers for them to work after your last update. Thanks, the issue can be closed.

happyleavesaoc commented 8 years ago

Great, I'm glad to hear that it works. home-assistant caches modules in .homeassistant/lib, so it must be cleared in certain upgrade cases.