def __init__(self): ''' Load initial CM11 configuration from hacm11.conf ''' from utils.generic import get_configurationpath self.config_path = get_configurationpath() config = ConfigParser.RawConfigParser() config.read(os.path.join(self.config_path, 'hacm11.conf')) print "DEBUG: get_configurationpath: ", self.config_path print "DEBUG: os.getcwd: ", os.getcwd( ) print "DEBUG: sys.path:", sys.path # Get serial port information self.port = config.get("serial", "port") # Get broker information (RabbitMQ) self.broker_host = config.get("broker", "host") self.broker_port = config.getint("broker", "port") self.broker_user = config.get("broker", "username") self.broker_pass = config.get("broker", "password") self.broker_vhost = config.get("broker", "vhost") self.logging = config.getboolean('general', 'logging') self.id = config.get('general', 'id') self.pluginapi = PluginAPI(plugin_id=self.id, plugin_type='x10', logging=self.logging, broker_ip=self.broker_host, broker_port=self.broker_port, username=self.broker_user, password=self.broker_pass, vhost=self.broker_vhost) self.pluginapi.register_poweron(self) self.pluginapi.register_poweroff(self) self.pluginapi.register_dim(self) self.pluginapi.register_custom(self) self.protocol = CM11Protocol(self) self.reactor = None # Initialize in-memory device list from xml file xml_file = os.path.join(self.config_path, 'x10.xml') try: xmldoc = ET.parse(xml_file) devices = xmldoc.findall('device') for device in devices: newdevice = Device(device.get('hcdc')) newdevice.standarddim = (device.findtext('standarddim', 'False').lower() == "true") newdevice.presetdim = (device.findtext('presetdim', 'False').lower() == "true") newdevice.allunitsoff = (device.findtext('allunitsoff', 'False').lower() == "true") newdevice.alllightsoff = (device.findtext('alllightsoff', 'False').lower() == "true") newdevice.alllightson = (device.findtext('alllightson', 'False').lower() == "true") newdevice.statusrequest = (device.findtext('statusrequest','False').lower() == "true") newdevice.reportstatus = (device.findtext('reportstatus','False').lower() == "true") listDevices.append(newdevice) except: log.msg("Error opening or reading '%s' (%s)" % (xml_file, sys.exc_info()[1]))
def __init__(self): ''' Load initial JeeLabs configuration from jeelabs.conf ''' from utils.generic import get_configurationpath config_path = get_configurationpath() config = ConfigParser.RawConfigParser() config.read(os.path.join(config_path, 'jeelabs.conf')) self.port = config.get("serial", "port") # Get broker information (RabbitMQ) self.broker_host = config.get("broker", "host") self.broker_port = config.getint("broker", "port") self.broker_user = config.get("broker", "username") self.broker_pass = config.get("broker", "password") self.broker_vhost = config.get("broker", "vhost") self.logging = config.getboolean('general', 'logging') self.id = config.get('general', 'id')