Using Energenie Power Plugs

Forget Energenie's own sample.  See http://bennuttall.com/whats-new-gpio-zero-v1-2/

https://pypi.python.org/pypi/energenie

 

from energenie import switch_on, switch_off
from time import sleep

# turn all plug sockets on and off
switch_on()
switch_off()

# turn a plug socket on and off by number
switch_on(3)
switch_off(3)

sudo apt-get install python-pip
sudo pip install energenie

sudo apt-get install mysql-client python-mysqldb -y