# -*- coding: utf-8 -*- """Module allowing to command and control a plug which is not an SPC300""" import time import power_strip import list_utils import plug config = { "plugs": { #(Power strip index, # Power plug index, # Identifier (this parameter is optional and is needed only if there # are several plugs connected to the same power plug via another # power strip): #(MAC address, # device model, # device version) (1, 6): ("00:1c:23:1e:a0:7a", "AT6400", "1.0.2"), (1, 7, "plug_1"): ("00:1c:23:1e:a0:7b", "AT6400", "1.0.2"), (1, 8, "plug_2"): ("00:1c:23:1e:a0:7c", "AT6400", "1.0.2") } } def update_config(new_config): """Update the configuration""" global config config = new_config def get_mac_address(key): """Gives the MAC address corresponding to a power strip key""" return config["plugs"][key][0] def get_model(key): """Gives the model corresponding to a power strip key""" return config["plugs"][key][1] def get_version(key): """Gives the version corresponding to a power strip key""" return config["plugs"][key][2] def switch_on(keys): if type(keys) != list: keys = [keys] if keys == []: return print "Starting the plug(s)", keys,"... {" power_plugs_keys = plug.get_power_plugs_keys(keys) for power_plug_key in power_plugs_keys: power_strip.switch("on", power_plug_key) duration = 10 print "Waiting", duration, "seconds..." time.sleep(duration) print "}"