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

support for changing multiple sockets at once #7

Closed
wants to merge 10 commits into from
Closed

support for changing multiple sockets at once #7

wants to merge 10 commits into from

Conversation

drawk-cab
Copy link

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.

@bennuttall
Copy link

Library deprecated. See #15.

@bennuttall bennuttall closed this Jun 9, 2016
@drawk-cab
Copy link
Author

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.

@bennuttall
Copy link

> 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?

@waveform80
Copy link
Member

... actually no, screw it, i'll keep my code to myself.

And passive aggressive over-reaction of the week goes to...

@waveform80 maybe there's call for a composite Energenie device?

@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.

@bennuttall
Copy link

Fair enough.

I hadn't thought of using commas that way. Interesting but looks weird!

Alternatively, and essentially the same:

lamp.on(); fan.on()

@drawk-cab
Copy link
Author

drawk-cab commented Jun 10, 2016

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.

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

Successfully merging this pull request may close these issues.

3 participants