def start(self, mqttc):
     """Start the component.
     """
     logger.warning("[%s] - Start component : %s ", self.__class__.__name__, self.values['rrd_file'].data)
     JNTComponent.start(self, mqttc)
     value_source = self.values['source']
     config = {}
     for i in range(0, value_source.get_max_index()+1):
         config[i] = value_source.get_config(value_source.node_uuid, i)
     self._bus.store.timer_add_config(self.values['rrd_file'].data, self.values['rrd_step'].data, config)
     return True
 def start(self, mqttc):
     """Start the bus
     """
     JNTComponent.start(self, mqttc)
     self._bus.i2c_acquire()
     try:
         self.sensor = MAX9744(address=self.values["addr"].data, i2c=self._bus.get_adafruit_i2c(), busnum=self._bus.get_busnum())
     except Exception:
         logger.exception("[%s] - Can't start component", self.__class__.__name__)
     finally:
         self._bus.i2c_release()
Esempio n. 3
0
 def start(self, mqttc):
     """Start the bus
     """
     JNTComponent.start(self, mqttc)
     self._bus.i2c_acquire()
     try:
         self.sensor = BMP085.BMP085(mode=self.values["mode"].data, address=self.values["addr"].data, i2c=self._bus._ada_i2c)
     except Exception:
         logger.exception("[%s] - Can't start component", self.__class__.__name__)
     finally:
         self._bus.i2c_release()
 def start(self, mqttc):
     """Start the bus
     """
     JNTComponent.start(self, mqttc)
     self._bus.i2c_acquire()
     try:
         self.clock = SDL_DS1307(address=self.values["addr"].data, busnum=self._bus.get_busnum())
     except Exception:
         logger.exception("[%s] - Can't start component", self.__class__.__name__)
     finally:
         self._bus.i2c_release()
Esempio n. 5
0
    def start(self, mqttc):
        """Start the component.

        """
        JNTComponent.start(self, mqttc)
        configs = len(self.values["add"].get_index_configs())
        for config in range(configs):
            try:
                pass
            except:
                logger.exception("Exception when starting NXP Reader component")
        return True
 def start(self, mqttc):
     """Start the bus
     """
     JNTComponent.start(self, mqttc)
     self._bus.i2c_acquire()
     try:
         self.clock = SDL_DS1307(address=self.values["addr"].data,
                                 busnum=self._bus.get_busnum())
     except Exception:
         logger.exception("[%s] - Can't start component",
                          self.__class__.__name__)
     finally:
         self._bus.i2c_release()
 def start(self, mqttc):
     """Start the component
     """
     JNTComponent.start(self, mqttc)
     self._bus.spi_acquire()
     try:
         device = self.values["device"].data
         dc_pin = self._bus.get_spi_device_pin(device)
         spi = self._bus.get_spi_device(device, max_speed_hz=1000000)
         self.setup_pn532(dc_pin, spi, self._ada_gpio)
     except Exception:
         logger.exception("[%s] - Can't start component", self.__class__.__name__)
     finally:
         self._bus.spi_release()
Esempio n. 8
0
    def start(self, mqttc):
        """Start the component.

        """
        JNTComponent.start(self, mqttc)
        configs = len(self.values["addr"].get_index_configs())
        if configs == 0:
            self.devices = [(0, self.values["addr"].data, 0)]
        else:
            self.devices = []
            for config in range(configs):
                self.devices += (config, self.values["addr"].instances[config]['data'])
        self.on_check()
        return True
 def start(self, mqttc):
     """Start the component
     """
     JNTComponent.start(self, mqttc)
     self._bus.spi_acquire()
     try:
         device = self.values["device"].data
         dc_pin = self._bus.get_spi_device_pin(device)
         spi = self._bus.get_spi_device(device, max_speed_hz=1000000)
         self.setup_pn532(dc_pin, spi, self._ada_gpio)
     except Exception:
         logger.exception("[%s] - Can't start component",
                          self.__class__.__name__)
     finally:
         self._bus.spi_release()
Esempio n. 10
0
 def start(self, mqttc):
     """Start the bus
     """
     JNTComponent.start(self, mqttc)
     self._bus.i2c_acquire()
     try:
         self.vcnl = Adafruit_VCNL40xx.VCNL4010(
             address=self.values["addr"].data,
             i2c=self._bus.get_adafruit_i2c(),
             busnum=self._bus.get_busnum())
     except Exception:
         logger.exception("[%s] - Can't start component",
                          self.__class__.__name__)
     finally:
         self._bus.i2c_release()
Esempio n. 11
0
 def start(self, mqttc):
     """Start the bus
     """
     JNTComponent.start(self, mqttc)
     self._bus.i2c_acquire()
     try:
         self.sensor = INA219(self.values["shunt_ohms"].data,
                              self.values["max_expected_amps"].data,
                              log_level=logger.getEffectiveLevel())
         self.sensor.configure(self.sensor.RANGE_16V, self.sensor.GAIN_AUTO)
         self.sensor.wake()
     except Exception:
         logger.exception("[%s] - Can't start component",
                          self.__class__.__name__)
     finally:
         self._bus.i2c_release()
Esempio n. 12
0
    def start(self, mqttc):
        """Start the component.
        """
        self.state = 'BOOT'
        JNTComponent.start(self, mqttc)
        hadd = self.values['remote_hadd'].data
        logger.debug("[%s] - Found remote HADD %s for node %s", self.__class__.__name__, hadd, self.node.uuid)
        if hadd is None:
            logger.debug("[%s] - No remote HADD. Exit ...", self.__class__.__name__)
            return False
        self.remote_hadd = hadd_split(hadd)
        if self.remote_hadd[0] is None or self.remote_hadd[1] is None:
            logger.warning("[%s] - Bad remote HADD %s", self.__class__.__name__, hadd)
            return False
        try:
            self.mqttc_heartbeat = MQTTClient(options=self.options.data)
            self.mqttc_heartbeat.connect()
            self.mqttc_heartbeat.subscribe(topic=TOPIC_HEARTBEAT_NODE%(hadd), callback=self.on_heartbeat)
            self.mqttc_heartbeat.start()
        except Exception:
            logger.exception("[%s] - start", self.__class__.__name__)
        values_read = self.get_read_values()
        values_write = self.get_write_values()
        logger.debug("[%s] - found %s values_read", self.__class__.__name__, len(values_read))
        logger.debug("[%s] - found %s values_write", self.__class__.__name__, len(values_write))
        topics = []
        for value in values_read:
            if value[0] == 'user':
                topic=TOPIC_VALUES_USER
            else:
                topic=TOPIC_VALUES_BASIC
            topic = topic%(hadd+'/'+value[1])
            topics.append((topic, 0))
            logger.debug("[%s] - subscribe to %s", self.__class__.__name__, topic)
        if len(topics)>0:
            try:
                self.mqttc_values = MQTTClient(options=self.options.data)
                self.mqttc_values.connect()
                self.mqttc_values.subscribe(topics=topics, callback=self.on_remote_value)
                self.mqttc_values.start()
            except Exception:
                logger.exception("[%s] - start", self.__class__.__name__)

        #~ print max_index
        #~ for index in range(max_index):
            #~ print index
        return True
    def start(self, mqttc):
        """Start the bus
        """
        res = JNTComponent.start(self, mqttc)
        self._bus.spi_acquire()
        try:

            device = self.values["device"].data
            reset = self.values["reset_pin"].data
            dc_pin = self._bus.get_spi_device_pin(device)
            spi = self._bus.get_spi_device(device, max_speed_hz=64000000)
            self.setup_ili9341(dc_pin, rst, spi, self._ada_gpio)
        except Exception:
            res = False
            logger.exception("[%s] - Can't start component",
                             self.__class__.__name__)
        finally:
            self._bus.spi_release()
        return res
Esempio n. 14
0
    def start(self, mqttc):
        """Start the component.

        """
        JNTComponent.start(self, mqttc)
        return True
Esempio n. 15
0
    def start(self, mqttc):
        """Start the component. Can be used to start a thread to acquire data.

        """
        self._bus.nodeman.add_daily_job(self.current_rotate)
        return JNTComponent.start(self, mqttc)