-
Notifications
You must be signed in to change notification settings - Fork 9
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
support for changing multiple sockets at once #7
Conversation
allow socket specification to be an iterable e.g. set(1,3,4)
Library deprecated. See #15. |
bummer. so now i have to figure out your new library which doesn't have this feature and re-implement it for the benefit of the community. actually no, screw it, i'll keep my code to myself. |
> from gpiozero import Energenie
> sockets = [Energenie(i) for i in range(4)]
> [s.on() for s in sockets] or: > from gpiozero import Energenie
> sockets = [Energenie(i) for i in range(4)]
> def on():
> [s.on() for s in sockets]
> on() or: > from gpiozero import Energenie
> lamp = Energenie(1)
> fan = Energenie(2)
> def on(*sockets):
> [s.on() for s in sockets]
> on(lamp, fan) @waveform80 maybe there's call for a composite Energenie device? |
And passive aggressive over-reaction of the week goes to...
@bennuttall possibly - though I'm not sure it's that useful. Given the limited number of devices controllable by these sockets (i.e. 4), if someone wanted to control multiple in concert wouldn't they just control an adapter with one socket rather than waste a channel on another device? And if individual control is required we're back to separate devices anyway. I'd also add, you could cheat and use a tuple literal too: from gpiozero import Energenie
from time import sleep
lamp = Energenie(1)
fan = Energenie(2)
lamp.on(), fan.on()
sleep(10)
lamp.on(), fan.off()
# etc. etc. |
Fair enough. I hadn't thought of using commas that way. Interesting but looks weird! Alternatively, and essentially the same: lamp.on(); fan.on() |
I'm sorry, I just hadn't tried to use a PR before and was disappointed about not hearing anything for so long As it happens I use it because the things I want to switch on are in different rooms. And the set_state feature is useful when I want to match the state to something else (in my case an http request) I submitted the code mainly because someone else had also requested the feature, though not sure where now, as you point out both this and the set_state are just convenience to save a little typing. |
Backwards compatible--just supply more arguments to switch_on or switch_off.
Also a new method set_state that allows the sockets to be controlled using a boolean value.
I guess that's 2 change recommendations, sorry. Not done a pull request before.
I haven't updated the version number, not sure what the etiquette is there. I didn't see an obvious development branch.