def __init__(self):
        '''
        Load initial RFXtrx configuration from rfxtrx.conf
        '''   
        config_file = config_to_location('rfxtrx.conf')
        
        config = ConfigParser.RawConfigParser()
        config.read(os.path.join(config_file))
        self.port = config.get("serial", "port")

        # Get broker information (ZeroMQ)
        self.coordinator_host = config.get("coordinator", "host")
        self.coordinator_port = config.getint("coordinator", "port")
        
        self.loglevel = config.get('general', 'loglevel')
        self.id = config.get('general', 'id')

        callbacks = {'custom': self.cb_custom}
        self.pluginapi = pluginapi.PluginAPI(self.id, 'RFXtrx', 
                                             broker_host=self.coordinator_host, 
                                             broker_port=self.coordinator_port, **callbacks)
        
        log = Logging("RFXtrx", console=True)
        log.set_level(self.loglevel)
        
        self.protocol = RFXtrxProtocol(self, log) 
        myserial = SerialPort (self.protocol, self.port, reactor)
        myserial.setBaudRate(38400)
        reactor.run(installSignalHandlers=0)
        return True
    def __init__(self):
        '''
        Load initial Astral configuration from Astral.conf
        '''   
        config_file = config_to_location('Astral.conf')
        
        self.config = ConfigParser.RawConfigParser()
        self.config.read(os.path.join(config_file))

        # Get broker information (ZeroMQ)
        self.coordinator_host = self.config.get("coordinator", "host")
        self.coordinator_port = self.config.getint("coordinator", "port")
        
        self.loglevel = self.config.get('general', 'loglevel')
        self.log = Logging("Astral", console=True)
        self.log.set_level(self.loglevel)
        
        self.id = self.config.get('general', 'id')
        callbacks = {}
        self.pluginapi = pluginapi.PluginAPI(self.id, 'Astral', 
                                             broker_host=self.coordinator_host, 
                                             broker_port=self.coordinator_port,
                                             **callbacks)
        self.pluginapi.ready()
        
        c = CronSchedule("* * * * *")
        s = ScheduledCall(f=self.fire_minute)
        s.start(c)
                                
        reactor.run()
        return True
Exemple #3
0
    def get_configurationparameters(self):
        '''
        This function parses configuration parameters from the zwave.conf file.
        Fallback values are assigned in case the configuration file or parameter 
        is not found.
        '''
        
        config = ConfigParser.RawConfigParser()

        # Try and load the plugin config file from the plugin directory under 
        # HouseAgent config directory.
        self.config_file = config_to_location('zwave.conf')
        if not os.path.exists(self.config_file):
            # Maybe we are running development, just load the config file in 
            # current working directory.
            self.config_file = os.path.join(os.getcwd(), 'zwave.conf')
        if not os.path.exists(self.config_file):
            # With no config, we can't continue
            raise ConfigFileNotFound("/etc or working directory.")
        
        # Read in the configuration from the file.
        config.read(self.config_file)
        
        self.loglevel = config.get('general', 'loglevel')
        self.id = config.get('general', 'id')
        
        self.broker_host = config.get('broker', 'host')
        self.broker_port = config.getint('broker', 'port')
        
        self.ozw_interface = config.get('openzwave', 'port')
        self.ozw_config_data = config.get('openzwave', 'config_data')
        self.ozw_poll_interval = config.getint('openzwave', 'poll_interval')
        self.ozw_logging = config.get('openzwave', 'logging')
        
        try:
            report_values = json.loads(config.get("openzwave", "report_values"))
        except: 
            report_values = []
      
        self.report_values = report_values