def __init__(self, bus=None, addr=None, **kwargs):
     """
     """
     oid = kwargs.pop('oid', 'rpilcdchar.screen')
     name = kwargs.pop('name', "Screen")
     product_name = kwargs.pop('product_name', "Screen")
     product_type = kwargs.pop('product_type', "Screen")
     JNTComponent.__init__(self, oid=oid, bus=bus, addr=addr, name=name,
             product_name=product_name, product_type=product_type, **kwargs)
     logger.debug("[%s] - __init__ node uuid:%s", self.__class__.__name__, self.uuid)
     uuid="message"
     self.values[uuid] = self.value_factory['action_string'](options=self.options, uuid=uuid,
         node_uuid=self.uuid,
         help='A message to print on the screen',
         label='Msg',
         default='Janitoo started',
         set_data_cb=self.set_message,
         is_writeonly = True,
         cmd_class=COMMAND_MOTOR,
         genre=0x01,
     )
     poll_value = self.values[uuid].create_poll_value(default=300)
     self.values[poll_value.uuid] = poll_value
     self.pin_lcd_rs        = 27  # Note this might need to be changed to 21 for older revision Pi's.
     self.pin_lcd_en        = 22
     self.pin_lcd_d4        = 25
     self.pin_lcd_d5        = 24
     self.pin_lcd_d6        = 23
     self.pin_lcd_d7        = 18
     self.pin_lcd_backlight = 4
     self.lcd_columns = 20
     self.lcd_rows    = 4
     self.lcd = Adafruit_CharLCD(self.pin_lcd_rs, self.pin_lcd_en, self.pin_lcd_d4, self.pin_lcd_d5, self.pin_lcd_d6, self.pin_lcd_d7,
                         self.lcd_columns, self.lcd_rows, self.pin_lcd_backlight)
    def __init__(self, bus=None, addr=None, **kwargs):
        """
        """
        oid = kwargs.pop('oid', '%s.ds1307'%OID)
        name = kwargs.pop('name', "Input")
        product_name = kwargs.pop('product_name', "RTC DS1307")
        product_type = kwargs.pop('product_type', "RTC DS1307 clock")
        JNTComponent.__init__(self, oid=oid, bus=bus, addr=addr, name=name,
                product_name=product_name, product_type=product_type, **kwargs)
        logger.debug("[%s] - __init__ node uuid:%s", self.__class__.__name__, self.uuid)

        uuid="addr"
        self.values[uuid] = self.value_factory['config_integer'](options=self.options, uuid=uuid,
            node_uuid=self.uuid,
            help='The I2C address of the DS1307 component',
            label='Addr',
            default=0x68,
        )

        uuid="now"
        self.values[uuid] = self.value_factory['sensor_string'](options=self.options, uuid=uuid,
            node_uuid=self.uuid,
            help='Return the current date (YY-DD-MM HH-MM-SS)',
            label='now',
            get_data_cb=self.now,
        )

        self.clock = None
示例#3
0
 def __init__(self, bus=None, addr=None, **kwargs):
     """
     """
     oid = kwargs.pop('oid', 'fake.component')
     name = kwargs.pop('name', "Fake component")
     JNTComponent.__init__(self, oid=oid, bus=bus, addr=addr, name=name,
             **kwargs)
     logger.debug("[%s] - __init__ node uuid:%s", self.__class__.__name__, self.uuid)
     uuid="test_basic"
     self.values[uuid] = JNTValue( uuid=uuid,
                 index=0,
                 genre=0x01,
             )
     uuid="test_user"
     self.values[uuid] = JNTValue( uuid=uuid,
                 index=0,
                 genre=0x02,
             )
     uuid="test_command"
     self.values[uuid] = JNTValue( uuid=uuid,
                 index=0,
                 genre=0x05,
             )
     uuid="test_config"
     self.values[uuid] = JNTValue( uuid=uuid,
                 index=0,
                 genre=0x03,
             )
    def __init__(self, bus=None, addr=None, **kwargs):
        """
        """
        oid = kwargs.pop('oid', '%s.ds18b20'%OID)
        name = kwargs.pop('name', "Onewire DS18B20 sensor")
        product_name = kwargs.pop('product_name', "DS18B20 sensor")
        product_type = kwargs.pop('product_type', "Temperature sensor")
        product_manufacturer = kwargs.pop('product_manufacturer', "Janitoo")
        JNTComponent.__init__(self, oid=oid, bus=bus, addr=addr, name=name,
                product_name=product_name, product_type=product_type, product_manufacturer=product_manufacturer, **kwargs)
        logger.debug("[%s] - __init__ node uuid:%s", self.__class__.__name__, self.uuid)

        uuid="temperature"
        self.values[uuid] = self.value_factory['sensor_temperature'](options=self.options, uuid=uuid,
            node_uuid=self.uuid,
            help='The temperature',
            label='Temp',
            get_data_cb=self.temperature,
        )
        poll_value = self.values[uuid].create_poll_value(default=300)
        self.values[poll_value.uuid] = poll_value

        uuid="hexadd"
        self.values[uuid] = self.value_factory['config_string'](options=self.options, uuid=uuid,
            node_uuid=self.uuid,
            help='The hexadecimal address of the DS18B20',
            label='Addr',
            default=kwargs.get("hexadd", "28-000005e2fdc3"),
        )
    def __init__(self, bus=None, addr=None, **kwargs):
        """
        """
        oid = kwargs.pop('oid', '%s.ads'%OID)
        name = kwargs.pop('name', "Input")
        product_name = kwargs.pop('product_name', "ADS")
        product_type = kwargs.pop('product_type', "Analog to binary converter")
        JNTComponent.__init__(self, oid=oid, bus=bus, addr=addr, name=name,
                product_name=product_name, product_type=product_type, **kwargs)
        logger.debug("[%s] - __init__ node uuid:%s", self.__class__.__name__, self.uuid)

        uuid="addr"
        self.values[uuid] = self.value_factory['config_integer'](options=self.options, uuid=uuid,
            node_uuid=self.uuid,
            help='The I2C address of the ADS component',
            label='Addr',
            default=0x77,
        )
        uuid="data"
        self.values[uuid] = self.value_factory['sensor_integer'](options=self.options, uuid=uuid,
            node_uuid=self.uuid,
            help='The data',
            label='data',
            get_data_cb=self.read_data,
        )
        poll_value = self.values[uuid].create_poll_value(default=300)
        self.values[poll_value.uuid] = poll_value

        self.sensor = None
示例#6
0
 def stop(self):
     """
     """
     if self.sensor is not None:
         self.sensor.sleep()
     JNTComponent.stop(self)
     self.sensor = None
示例#7
0
    def stop(self):
        """Stop the component.

        """
        self.stop_check()
        JNTComponent.stop(self)
        return True
 def __init__(self, bus=None, addr=None, **kwargs):
     """
     """
     oid = kwargs.pop('oid', '%s.thermostat'%OID)
     name = kwargs.pop('name', "Timelapse")
     JNTComponent.__init__(self, oid=oid, bus=bus, addr=addr, name=name,
             **kwargs)
     logger.debug("[%s] - __init__ node uuid:%s", self.__class__.__name__, self.uuid)
示例#9
0
 def __init__(self, **kwargs):
     """
     """
     self._inputs = {}
     oid = kwargs.pop('oid', 'rpinxp.writer')
     product_name = kwargs.pop('product_name', "NXP Writer")
     name = kwargs.pop('name', "NXP Writer")
     JNTComponent.__init__(self, oid=oid, name=name, product_name=product_name, **kwargs)
 def __init__(self, **kwargs):
     """
     """
     self._inputs = {}
     oid = kwargs.pop('oid', 'voxgen.listener')
     product_name = kwargs.pop('product_name', "Voxgenerator listener")
     name = kwargs.pop('name', "Voxgenerator listener")
     JNTComponent.__init__(self, oid=oid, name=name, product_name=product_name, **kwargs)
示例#11
0
 def __init__(self, **kwargs):
     """
     """
     oid = kwargs.pop('oid', '%s.input'%OID)
     name = kwargs.pop('name', "Input")
     product_name = kwargs.pop('product_name', "Audio input")
     product_type = kwargs.pop('product_type', "Software")
     JNTComponent.__init__(self, oid=oid, name=name, product_name=product_name, product_type=product_type, **kwargs)
     logger.debug("[%s] - __init__ node uuid:%s", self.__class__.__name__, self.uuid)
示例#12
0
 def __init__(self, bus=None, addr=None, lock=None, unit="°C", **kwargs):
     """ Constructor.
     """
     JNTComponent.__init__(self,
         oid = kwargs.pop('oid', '%s.dawndusk'%OID),
         bus = bus,
         addr = addr,
         name = kwargs.pop('name', "Dawn/Dusk event"),
         product_name = kwargs.pop('product_name', "Dawn/Dusk event"),
         **kwargs)
示例#13
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 __init__(self, bus=None, addr=None, **kwargs):
     """
     """
     oid = kwargs.pop('oid', '%s.stepmotor'%OID)
     name = kwargs.pop('name', "Motor")
     product_name = kwargs.pop('product_name', "Motor")
     product_type = kwargs.pop('product_type', "Step Motor")
     product_manufacturer = kwargs.pop('product_manufacturer', "Janitoo")
     JNTComponent.__init__(self, oid=oid, bus=bus, addr=addr, name=name,
             product_name=product_name, product_type=product_type, product_manufacturer=product_manufacturer, **kwargs)
     logger.debug("[%s] - __init__ node uuid:%s", self.__class__.__name__, self.uuid)
 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()
示例#16
0
 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.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()
示例#18
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
示例#19
0
    def __init__(self, bus=None, addr=None, **kwargs):
        """
        """
        oid = kwargs.pop('oid', '%s.vcnl4000' % OID)
        name = kwargs.pop('name', "Input")
        product_name = kwargs.pop('product_name',
                                  "VCLN4000 proximity detector")
        product_type = kwargs.pop('product_type',
                                  "VCLN4000 proximity detector")
        JNTComponent.__init__(self,
                              oid=oid,
                              bus=bus,
                              addr=addr,
                              name=name,
                              product_name=product_name,
                              product_type=product_type,
                              **kwargs)
        logger.debug("[%s] - __init__ node uuid:%s", self.__class__.__name__,
                     self.uuid)

        uuid = "addr"
        self.values[uuid] = self.value_factory['config_integer'](
            options=self.options,
            uuid=uuid,
            node_uuid=self.uuid,
            help='The I2C address of the VCLN4000 component',
            label='Addr',
            default=VCNL40xx.VCNL40xx_ADDRESS,
        )
        uuid = "proximity"
        self.values[uuid] = self.value_factory['sensor_distance'](
            options=self.options,
            uuid=uuid,
            node_uuid=self.uuid,
            units='cm',
            get_data_cb=self.proximity,
        )
        poll_value = self.values[uuid].create_poll_value(default=300)
        self.values[poll_value.uuid] = poll_value

        uuid = "ambient"
        self.values[uuid] = self.value_factory['sensor_float'](
            options=self.options,
            uuid=uuid,
            node_uuid=self.uuid,
            help='The ambient light',
            label='ambient',
            get_data_cb=self.ambient,
        )
        poll_value = self.values[uuid].create_poll_value(default=300)
        self.values[poll_value.uuid] = poll_value
        self.vcnl = None
 def __init__(self, bus=None, addr=None, **kwargs):
     """
     """
     oid = kwargs.pop('oid', '%s.dcmotor'%OID)
     name = kwargs.pop('name', "Motor")
     product_name = kwargs.pop('product_name', "Motor")
     product_type = kwargs.pop('product_type', "DC Motor")
     JNTComponent.__init__(self, oid=oid, bus=bus, addr=addr, name=name,
             product_name=product_name, product_type=product_type, **kwargs)
     logger.debug("[%s] - __init__ node uuid:%s", self.__class__.__name__, self.uuid)
     uuid="speed"
     self.values[uuid] = self.value_factory['config_byte'](options=self.options, uuid=uuid,
         node_uuid=self.uuid,
         help='The speed of the motor. A byte from 0 to 255',
         label='Speed',
         default=0,
         set_data_cb=self.set_speed,
     )
     uuid="max_speed"
     self.values[uuid] = self.value_factory['config_byte'](options=self.options, uuid=uuid,
         node_uuid=self.uuid,
         help="The max speed supported by the motor. Some motor doesn't seems support 100% PWM. A byte from 0 to 255",
         label='Speed',
         default=255,
     )
     uuid="num"
     self.values[uuid] = self.value_factory['config_byte'](options=self.options, uuid=uuid,
         node_uuid=self.uuid,
         help='The number of the motor on the Hat board. A byte from 1 to 4',
         label='Num.',
     )
     uuid="actions"
     self.values[uuid] = self.value_factory['action_list'](options=self.options, uuid=uuid,
         node_uuid=self.uuid,
         help='The action on the DC motor',
         label='Actions',
         list_items=['forward', 'backward', 'release'],
         default='release',
         set_data_cb=self.set_action,
         is_writeonly = True,
         cmd_class=COMMAND_MOTOR,
         genre=0x01,
     )
     uuid="current_speed"
     self.values[uuid] = self.value_factory['sensor_integer'](options=self.options, uuid=uuid,
         node_uuid=self.uuid,
         help='The current speed of the motor. An integer from -255 to 255',
         label='CSpeed',
         get_data_cb=self.get_current_speed,
     )
     poll_value = self.values[uuid].create_poll_value(default=300)
     self.values[poll_value.uuid] = poll_value
 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()
示例#23
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
示例#24
0
 def __init__(self, bus=None, addr=None, **kwargs):
     """
     """
     oid = kwargs.pop('oid', 'remote.node')
     name = kwargs.pop('name', "Remote node")
     product_name = kwargs.pop('product_name', "Remote node")
     product_type = kwargs.pop('product_type', "Software")
     JNTComponent.__init__(self, oid=oid, bus=bus, addr=addr, name=name,
             product_name=product_name, product_type=product_type, **kwargs)
     logger.debug("[%s] - __init__ node uuid:%s", self.__class__.__name__, self.uuid)
     self.mqttc_heartbeat = None
     self.mqttc_values = None
     self.state = 'OFFLINE'
     self.remote_hadd = (None,None)
     uuid="remote_hadd"
     self.values[uuid] = self.value_factory['config_string'](options=self.options, uuid=uuid,
         node_uuid=self.uuid,
         help='HADD of the remote node that we will listen to',
         label='rhadd',
         default=None,
     )
     uuid="user_read"
     self.values[uuid] = self.value_factory['rread_value'](options=self.options, uuid=uuid,
         node_uuid=self.uuid,
         help='The user values to listen to : value_uuid:index',
         label='ruser',
         default=None,
     )
     uuid="user_write"
     self.values[uuid] = self.value_factory['rwrite_value'](options=self.options, uuid=uuid,
         node_uuid=self.uuid,
         help='The user values to listen to : value_uuid:index',
         label='wuser',
         default=None,
     )
     uuid="basic_read"
     self.values[uuid] = self.value_factory['rread_value'](options=self.options, uuid=uuid,
         node_uuid=self.uuid,
         help='The basic values to listen to : value_uuid:index',
         label='rbasic',
         default=None,
     )
     uuid="basic_write"
     self.values[uuid] = self.value_factory['rwrite_value'](options=self.options, uuid=uuid,
         node_uuid=self.uuid,
         help='The basic values to listen to : value_uuid:index',
         label='wbasic',
         default=None,
     )
示例#25
0
    def __init__(self, bus=None, addr=None, lock=None, unit="°C", **kwargs):
        """ Constructor.

        Arguments:
            bus:
                a 1-Wire instance representing the bus this device is
                connected to
            addr:
                the 1-Wire device address (in 7 bits format)
        """
        JNTComponent.__init__(self, 'onewire.ds18b20', bus=bus, addr=addr, name="DS18B20 range sensor", **kwargs)
        uuid = '%s_%s'%('ds18b20','c')
        value = JNTValue( uuid=uuid,
                help='The temperature',
                label='Temp',
                units='°C',
                index=0,
                cmd_class=COMMAND_METER,
                genre=0x02,
                type=0x03,
                get_data_cb=self.read_temp_c,
                is_writeonly=False,
                is_polled=True,
                poll_delay=300,
                )
        self.values[uuid] = value
        uuid = '%s_%s'%('ds18b20','c_poll')
        value = value_config_poll( uuid, self.poll_tempc_get, self.poll_tempc_set)
        self.values[uuid] = value
        uuid = '%s_%s'%('ds18b20','f')
        value = JNTValue( uuid=uuid,
                help='The temperature',
                label='Temp',
                units='°F',
                index=0,
                cmd_class=COMMAND_METER,
                genre=0x02,
                type=0x03,
                get_data_cb=self.read_temp_f,
                is_writeonly=False,
                is_polled=False,
                poll_delay=300,
                )
        self.values[uuid] = value
        uuid = '%s_%s'%('ds18b20','f_poll')
        value = value_config_poll( uuid, self.poll_tempf_get, self.poll_tempf_set, default=0)
        self.values[uuid] = value
        self.cmd_classes.append(COMMAND_METER)
        self.cmd_classes.append(COMMAND_CONFIGURATION)
示例#26
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()
示例#27
0
 def __init__(self, **kwargs):
     """
     """
     self._inputs = {}
     oid = kwargs.pop('oid', 'rpinxp.reader')
     product_name = kwargs.pop('product_name', "NXP Reader")
     name = kwargs.pop('name', "NXP Reader")
     JNTComponent.__init__(self, oid=oid, name=name, product_name=product_name, **kwargs)
     uuid="add"
     self.values[uuid] = self.value_factory['config_string'](options=self.options, uuid=uuid,
         node_uuid=self.uuid,
         help='An RFID address',
         label='RFID add',
         default=None,
     )
    def __init__(self, bus=None, addr=None, **kwargs):
        """
        """
        JNTComponent.__init__(self, bus=bus, addr=addr, **kwargs)
        logger.debug("[%s] - __init__ node uuid:%s", self.__class__.__name__, self.uuid)

        uuid = "hflip"
        self.values[uuid] = self.value_factory["config_boolean"](
            options=self.options, uuid=uuid, node_uuid=self.uuid, help="Horizontal flip.", label="Hflip", default=False
        )

        uuid = "vflip"
        self.values[uuid] = self.value_factory["config_boolean"](
            options=self.options, uuid=uuid, node_uuid=self.uuid, help="Vertical flip.", label="Vflip", default=False
        )
示例#29
0
 def __init__(self, **kwargs):
     """
     """
     oid = kwargs.pop('oid', '%s.input' % OID)
     name = kwargs.pop('name', "Input")
     product_name = kwargs.pop('product_name', "Audio input")
     product_type = kwargs.pop('product_type', "Software")
     JNTComponent.__init__(self,
                           oid=oid,
                           name=name,
                           product_name=product_name,
                           product_type=product_type,
                           **kwargs)
     logger.debug("[%s] - __init__ node uuid:%s", self.__class__.__name__,
                  self.uuid)
 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()
示例#31
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()
 def __init__(self, bus=None, addr=None, **kwargs):
     """
     """
     oid = kwargs.pop('oid', '%s.pn532'%OID)
     name = kwargs.pop('name', "Screen")
     product_name = kwargs.pop('product_name', "RFID component")
     product_type = kwargs.pop('product_type', "RFID component")
     JNTComponent.__init__(self, oid=oid, bus=bus, addr=addr, name=name,
             product_name=product_name, product_type=product_type, **kwargs)
     logger.debug("[%s] - __init__ node uuid:%s", self.__class__.__name__, self.uuid)
     uuid="device"
     self.values[uuid] = self.value_factory['config_byte'](options=self.options, uuid=uuid,
         node_uuid=self.uuid,
         help='Either the device number on the hardware bus or the SPI CS pin of the software one',
         label='device',
         default=0,
     )
     uuid="listen"
     self.values[uuid] = self.value_factory['action_boolean'](options=self.options, uuid=uuid,
         node_uuid=self.uuid,
         help='Activate/deactivate the listen mode',
         label='Listen',
         default=False,
         set_data_cb=self.set_listen,
         is_writeonly = True,
         cmd_class=COMMAND_CONTROLLER,
         genre=0x01,
     )
     self.pn532 = None
     self.listen_timer = None
     uuid="listen_delay"
     self.values[uuid] = self.value_factory['config_integer'](options=self.options, uuid=uuid,
         node_uuid=self.uuid,
         help='The delay between 2 listens',
         label='Delay',
         default=1,
     )
     uuid="status"
     self.values[uuid] = self.value_factory['sensor_list'](options=self.options, uuid=uuid,
         node_uuid=self.uuid,
         help='The status of the pn532',
         label='Status',
         default='sleeping',
         list_items=['sleeping', 'listening', 'write_ok', 'write_error'],
     )
     poll_value = self.values[uuid].create_poll_value(default=300)
     self.values[poll_value.uuid] = poll_value
示例#33
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
示例#34
0
    def __init__(self, **kwargs):
        """
        """
        oid = kwargs.pop('oid', '%s.generic'%OID)
        name = kwargs.pop('name', "Input")
        product_name = kwargs.pop('product_name', "GPIO")
        product_type = kwargs.pop('product_type', "Software")
        JNTComponent.__init__(self, oid=oid, name=name, product_name=product_name, product_type=product_type, **kwargs)
        logger.debug("[%s] - __init__ node uuid:%s", self.__class__.__name__, self.uuid)

        uuid="pin"
        self.values[uuid] = self.value_factory['config_integer'](options=self.options, uuid=uuid,
            node_uuid=self.uuid,
            help='The pin number on the board',
            label='Pin',
            default=kwargs.pop('pin', 1),
        )
示例#35
0
 def __init__(self, bus=None, addr=None, **kwargs):
     """ Constructor.
     """
     oid = kwargs.pop('oid', '%s.device' % OID)
     product_name = kwargs.pop('product_name', "Unknown device")
     product_type = kwargs.pop('product_type', "Tellstick device")
     product_manufacturer = kwargs.pop('product_manufacturer', "Janitoo")
     name = kwargs.pop('name', "Telldus device")
     JNTComponent.__init__(self,
                           oid=oid,
                           bus=bus,
                           addr=addr,
                           name=name,
                           product_name=product_name,
                           product_type=product_type,
                           product_manufacturer=product_manufacturer,
                           **kwargs)
 def stop(self):
     """
     """
     self.stop_listen()
     JNTComponent.stop(self)
     if self._bus.spi_locked():
         logger.warning('[%s] - Bus is locked. Close device anyway.', self.__class__.__name__)
         if self.pn532 is not None:
             self.pn532.close()
     self._bus.spi_acquire()
     try:
         self.pn532.close()
     except Exception:
         logger.exception('[%s] - Exception when stopping', self.__class__.__name__)
     finally:
         self.pn532 = None
         self._bus.spi_release()
    def __init__(self, bus=None, addr=None, **kwargs):
        JNTComponent.__init__(self,
            oid = kwargs.pop('oid', '%s.lmsensor'%OID),
            bus = bus,
            addr = addr,
            name = kwargs.pop('name', "LmSensor sensors"),
            product_name = kwargs.pop('product_name', "LmSensor"),
            product_type = kwargs.pop('product_type', "Software"),
            product_manufacturer = kwargs.pop('product_manufacturer', "Janitoo"),
            **kwargs)
        self._lock =  threading.Lock()
        logger.debug("[%s] - __init__ node uuid:%s", self.__class__.__name__, self.uuid)
        self._lmsensor_last = False
        self._lmsensor_next_run = datetime.now() + timedelta(seconds=15)

        uuid="config_filename"
        self.values[uuid] = self.value_factory['config_string'](options=self.options, uuid=uuid,
            node_uuid=self.uuid,
            help='The full path/name of config file to use',
            label='File',
            default='/etc/sensors3.conf',
        )

        uuid="temperature"
        self.values[uuid] = self.value_factory['sensor_temperature'](options=self.options, uuid=uuid,
            node_uuid=self.uuid,
            help='The temperatures from lm-sensors',
            label='Temperature',
            get_data_cb=self.get_temperature,
        )
        config_value = self.values[uuid].create_config_value(help='The name of the lmsensor', label='sensor_name', type=0x08)
        self.values[config_value.uuid] = config_value
        poll_value = self.values[uuid].create_poll_value(default=60)
        self.values[poll_value.uuid] = poll_value

        uuid="voltage"
        self.values[uuid] = self.value_factory['sensor_voltage'](options=self.options, uuid=uuid,
            node_uuid=self.uuid,
            help='The voltage from lm-sensors',
            label='Voltage',
            get_data_cb=self.get_volt,
        )
        config_value = self.values[uuid].create_config_value(help='The name of the lmsensor', label='sensor_name', type=0x08)
        self.values[config_value.uuid] = config_value
        poll_value = self.values[uuid].create_poll_value(default=90)
        self.values[poll_value.uuid] = poll_value
示例#38
0
 def __init__(self, bus=None, addr=None, **kwargs):
     """
     """
     oid = kwargs.pop('oid', 'rpilcdchar.screen')
     name = kwargs.pop('name', "Screen")
     product_name = kwargs.pop('product_name', "Screen")
     product_type = kwargs.pop('product_type', "Screen")
     JNTComponent.__init__(self,
                           oid=oid,
                           bus=bus,
                           addr=addr,
                           name=name,
                           product_name=product_name,
                           product_type=product_type,
                           **kwargs)
     logger.debug("[%s] - __init__ node uuid:%s", self.__class__.__name__,
                  self.uuid)
     uuid = "message"
     self.values[uuid] = self.value_factory['action_string'](
         options=self.options,
         uuid=uuid,
         node_uuid=self.uuid,
         help='A message to print on the screen',
         label='Msg',
         default='Janitoo started',
         set_data_cb=self.set_message,
         is_writeonly=True,
         cmd_class=COMMAND_MOTOR,
         genre=0x01,
     )
     poll_value = self.values[uuid].create_poll_value(default=300)
     self.values[poll_value.uuid] = poll_value
     self.pin_lcd_rs = 27  # Note this might need to be changed to 21 for older revision Pi's.
     self.pin_lcd_en = 22
     self.pin_lcd_d4 = 25
     self.pin_lcd_d5 = 24
     self.pin_lcd_d6 = 23
     self.pin_lcd_d7 = 18
     self.pin_lcd_backlight = 4
     self.lcd_columns = 20
     self.lcd_rows = 4
     self.lcd = Adafruit_CharLCD(self.pin_lcd_rs, self.pin_lcd_en,
                                 self.pin_lcd_d4, self.pin_lcd_d5,
                                 self.pin_lcd_d6, self.pin_lcd_d7,
                                 self.lcd_columns, self.lcd_rows,
                                 self.pin_lcd_backlight)
示例#39
0
    def __init__(self, bus=None, addr=None, **kwargs):
        """
        """
        oid = kwargs.pop('oid', 'rpibasic.dht')
        name = kwargs.pop('name', "Input")
        product_name = kwargs.pop('product_name', "DHT")
        product_type = kwargs.pop('product_type', "Temperature/humidity sensor")
        product_manufacturer = kwargs.pop('product_manufacturer', "Janitoo")
        JNTComponent.__init__(self, oid=oid, bus=bus, addr=addr, name=name,
                product_name=product_name, product_type=product_type, product_manufacturer=product_manufacturer, **kwargs)
        logger.debug("[%s] - __init__ node uuid:%s", self.__class__.__name__, self.uuid)

        uuid="pin"
        self.values[uuid] = self.value_factory['config_integer'](options=self.options, uuid=uuid,
            node_uuid=self.uuid,
            help='The pin number on the board',
            label='Pin',
            default=kwargs.pop('pin', 1),
        )
        uuid="sensor"
        self.values[uuid] = self.value_factory['config_integer'](options=self.options, uuid=uuid,
            node_uuid=self.uuid,
            help='The sensor type : 11,22,2302',
            label='Type',
            default=kwargs.pop('sensor', 11),
        )
        uuid="temperature"
        self.values[uuid] = self.value_factory['sensor_temperature'](options=self.options, uuid=uuid,
            node_uuid=self.uuid,
            help='The temperature',
            label='Temp',
            get_data_cb=self.temperature,
        )
        poll_value = self.values[uuid].create_poll_value(default=300)
        self.values[poll_value.uuid] = poll_value

        uuid="humidity"
        self.values[uuid] = self.value_factory['sensor_humidity'](options=self.options, uuid=uuid,
            node_uuid=self.uuid,
            help='The humidity',
            label='Hum',
            get_data_cb=self.humidity,
        )
        poll_value = self.values[uuid].create_poll_value(default=300)
        self.values[poll_value.uuid] = poll_value
        self._dht_lock =  threading.Lock()
 def stop(self):
     """
     """
     self.stop_listen()
     JNTComponent.stop(self)
     if self._bus.spi_locked():
         logger.warning('[%s] - Bus is locked. Close device anyway.',
                        self.__class__.__name__)
         if self.pn532 is not None:
             self.pn532.close()
     self._bus.spi_acquire()
     try:
         self.pn532.close()
     except Exception:
         logger.exception('[%s] - Exception when stopping',
                          self.__class__.__name__)
     finally:
         self.pn532 = None
         self._bus.spi_release()
 def __init__(self, bus=None, addr=None, **kwargs):
     """
     """
     oid = kwargs.pop('oid', '%s.pwm'%OID)
     name = kwargs.pop('name', "Motor")
     product_name = kwargs.pop('product_name', "PWM channel")
     product_type = kwargs.pop('product_type', "PWM channel")
     product_manufacturer = kwargs.pop('product_manufacturer', "Janitoo")
     JNTComponent.__init__(self, oid=oid, bus=bus, addr=addr, name=name,
             product_name=product_name, product_type=product_type, product_manufacturer=product_manufacturer, **kwargs)
     logger.debug("[%s] - __init__ node uuid:%s", self.__class__.__name__, self.uuid)
     uuid="level"
     self.values[uuid] = self.value_factory['action_switch_multilevel'](options=self.options, uuid=uuid,
         node_uuid=self.uuid,
         help='The level of the LED. A byte from 0 to 100',
         label='Level',
         default=0,
         set_data_cb=self.set_level,
     )
     poll_value = self.values[uuid].create_poll_value(default=300)
     self.values[poll_value.uuid] = poll_value
     uuid="max_level"
     self.values[uuid] = self.value_factory['config_byte'](options=self.options, uuid=uuid,
         node_uuid=self.uuid,
         help="The max level supported by the LED. Some LED doesn't seems support 100% PWM. A byte from 0 to 100",
         label='Max level',
         default=100,
     )
     uuid="num"
     self.values[uuid] = self.value_factory['config_byte'](options=self.options, uuid=uuid,
         node_uuid=self.uuid,
         help='The number of the LED on the board. A byte from 0 to 15',
         label='Num.',
     )
     uuid="switch"
     self.values[uuid] = self.value_factory['action_switch_binary'](options=self.options, uuid=uuid,
         node_uuid=self.uuid,
         set_data_cb=self.set_switch,
     )
     poll_value = self.values[uuid].create_poll_value(default=300)
     self.values[poll_value.uuid] = poll_value
 def __init__(self, bus=None, addr=None, **kwargs):
     """
     """
     oid = kwargs.pop('oid', '%s.servo'%OID)
     name = kwargs.pop('name', "Servo")
     product_name = kwargs.pop('product_name', "Servo")
     product_type = kwargs.pop('product_type', "Servo")
     product_manufacturer = kwargs.pop('product_manufacturer', "Janitoo")
     JNTComponent.__init__(self, oid=oid, bus=bus, addr=addr, name=name,
             product_name=product_name, product_type=product_type, product_manufacturer=product_manufacturer, **kwargs)
     logger.debug("[%s] - __init__ node uuid:%s", self.__class__.__name__, self.uuid)
     uuid="num"
     self.values[uuid] = self.value_factory['config_byte'](options=self.options, uuid=uuid,
         node_uuid=self.uuid,
         help='The number of the servo on board. A byte from 0 to 15',
         label='Num.',
     )
     uuid="pulse_min"
     self.values[uuid] = self.value_factory['config_integer'](options=self.options, uuid=uuid,
         node_uuid=self.uuid,
         help='The minimal pulse',
         label='Pulsemin',
         default=200,
     )
     uuid="pulse_max"
     self.values[uuid] = self.value_factory['config_integer'](options=self.options, uuid=uuid,
         node_uuid=self.uuid,
         help='The maximal pulse',
         label='Pulsemax',
         default=700,
     )
     uuid="angle"
     self.values[uuid] = self.value_factory['action_string'](options=self.options, uuid=uuid,
         node_uuid=self.uuid,
         set_data_cb=self.set_angle,
         help='Set the angle of the servo. Format is value|angle_min|angle_max',
         label='angle',
     )
     poll_value = self.values[uuid].create_poll_value(default=300)
     self.values[poll_value.uuid] = poll_value
    def __init__(self, bus=None, addr=None, **kwargs):
        """
        """
        oid = kwargs.pop('oid', '%s.ds1307' % OID)
        name = kwargs.pop('name', "Input")
        product_name = kwargs.pop('product_name', "RTC DS1307")
        product_type = kwargs.pop('product_type', "RTC DS1307 clock")
        JNTComponent.__init__(self,
                              oid=oid,
                              bus=bus,
                              addr=addr,
                              name=name,
                              product_name=product_name,
                              product_type=product_type,
                              **kwargs)
        logger.debug("[%s] - __init__ node uuid:%s", self.__class__.__name__,
                     self.uuid)

        uuid = "addr"
        self.values[uuid] = self.value_factory['config_integer'](
            options=self.options,
            uuid=uuid,
            node_uuid=self.uuid,
            help='The I2C address of the DS1307 component',
            label='Addr',
            default=0x68,
        )

        uuid = "now"
        self.values[uuid] = self.value_factory['sensor_string'](
            options=self.options,
            uuid=uuid,
            node_uuid=self.uuid,
            help='Return the current date (YY-DD-MM HH-MM-SS)',
            label='now',
            get_data_cb=self.now,
        )

        self.clock = None
    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
 def stop(self):
     """
     """
     res = JNTComponent.stop(self)
     if self._bus.spi_locked():
         logger.warning('[%s] - Bus is locked. Close device anyway.',
                        self.__class__.__name__)
         if self.tft is not None:
             self.tft.close()
     self._bus.spi_acquire()
     try:
         self.tft.close()
     except Exception:
         logger.exception('[%s] - Exception when clearing',
                          self.__class__.__name__)
     try:
         self.tft = None
     except Exception:
         logger.exception('[%s] - Exception when stopping',
                          self.__class__.__name__)
     finally:
         self._bus.spi_release()
     return res
 def __init__(self, bus=None, addr=None, **kwargs):
     """
     """
     oid = kwargs.pop('oid', '%s.ili9341' % OID)
     name = kwargs.pop('name', "Screen")
     product_name = kwargs.pop('product_name', "Screen")
     product_type = kwargs.pop('product_type', "Screen")
     JNTComponent.__init__(self,
                           oid=oid,
                           bus=bus,
                           addr=addr,
                           name=name,
                           product_name=product_name,
                           product_type=product_type,
                           **kwargs)
     logger.debug("[%s] - __init__ node uuid:%s", self.__class__.__name__,
                  self.uuid)
     uuid = "device"
     self.values[uuid] = self.value_factory['config_byte'](
         options=self.options,
         uuid=uuid,
         node_uuid=self.uuid,
         help=
         'Either the device number on the hardware bus or the SPI CS pin of the software one',
         label='device',
         default=0,
     )
     uuid = "reset_pin"
     self.values[uuid] = self.value_factory['config_byte'](
         options=self.options,
         uuid=uuid,
         node_uuid=self.uuid,
         help='The reset pin',
         label='reset',
         default=None,
     )
     uuid = "message"
     self.values[uuid] = self.value_factory['action_string'](
         options=self.options,
         uuid=uuid,
         node_uuid=self.uuid,
         help='A message to print on the screen',
         label='Msg',
         default='Janitoo started',
         set_data_cb=self.set_message,
         is_writeonly=True,
         cmd_class=COMMAND_SCREEN_MESSAGE,
         genre=0x01,
     )
     uuid = "draw"
     self.values[uuid] = self.value_factory['action_string'](
         options=self.options,
         uuid=uuid,
         node_uuid=self.uuid,
         help=
         'Draw an image on the screen. The image must be base64 encoded.',
         label='Draw',
         default=None,
         set_data_cb=self.set_draw,
         is_writeonly=True,
         cmd_class=COMMAND_SCREEN_DRAW,
         genre=0x01,
     )
     uuid = "clear"
     self.values[uuid] = self.value_factory['action_string'](
         options=self.options,
         uuid=uuid,
         node_uuid=self.uuid,
         help='Clear the screen with the color give parameter',
         label='Clear',
         default='0,0,0',
         set_data_cb=self.set_clear,
         is_writeonly=True,
         cmd_class=COMMAND_SCREEN_CLEAR,
         genre=0x01,
     )
     uuid = "reset"
     self.values[uuid] = self.value_factory['action_string'](
         options=self.options,
         uuid=uuid,
         node_uuid=self.uuid,
         help='Reset the screen',
         label='Reset',
         default=None,
         set_data_cb=self.set_reset,
         is_writeonly=True,
         cmd_class=COMMAND_SCREEN_CLEAR,
         genre=0x01,
     )
     poll_value = self.values[uuid].create_poll_value(default=300)
     self.tft = None
     self.tft_lock = threading.Lock()
     self.tft_lock_last = None
     self.tft_timer = None
示例#47
0
    def __init__(self, bus=None, addr=None, **kwargs):
        """
        """
        oid = kwargs.pop('oid', '%s.ina219' % OID)
        name = kwargs.pop('name', "Input")
        product_name = kwargs.pop('product_name', "INA219")
        product_type = kwargs.pop('product_type', "Cuurent and power sensor")
        JNTComponent.__init__(self,
                              oid=oid,
                              bus=bus,
                              addr=addr,
                              name=name,
                              product_name=product_name,
                              product_type=product_type,
                              **kwargs)
        logger.debug("[%s] - __init__ node uuid:%s", self.__class__.__name__,
                     self.uuid)

        uuid = "addr"
        self.values[uuid] = self.value_factory['config_integer'](
            options=self.options,
            uuid=uuid,
            node_uuid=self.uuid,
            help='The I2C address of the INA219 component',
            label='Addr',
            default=0x40,
        )
        uuid = "shunt_ohms"
        self.values[uuid] = self.value_factory['config_float'](
            options=self.options,
            uuid=uuid,
            node_uuid=self.uuid,
            help='The shunt of the INA219 component',
            label='shunt',
            default=0.1,
        )
        uuid = "max_expected_amps"
        self.values[uuid] = self.value_factory['config_float'](
            options=self.options,
            uuid=uuid,
            node_uuid=self.uuid,
            help='The max current expected for the INA219 component',
            label='Max amps',
            units='A',
            default=0.2,
        )
        uuid = "voltage"
        self.values[uuid] = self.value_factory['sensor_voltage'](
            options=self.options,
            uuid=uuid,
            node_uuid=self.uuid,
            help='The voltage',
            label='Voltage',
            get_data_cb=self.read_voltage,
            units='V',
        )
        poll_value = self.values[uuid].create_poll_value(default=300)
        self.values[poll_value.uuid] = poll_value
        uuid = "current"
        self.values[uuid] = self.value_factory['sensor_current'](
            options=self.options,
            uuid=uuid,
            node_uuid=self.uuid,
            help='The current',
            label='Current',
            units='mA',
            get_data_cb=self.read_current,
        )
        poll_value = self.values[uuid].create_poll_value(default=300)
        self.values[poll_value.uuid] = poll_value
        uuid = "power"
        self.values[uuid] = self.value_factory['sensor_power'](
            options=self.options,
            uuid=uuid,
            node_uuid=self.uuid,
            help='The power',
            label='Power',
            get_data_cb=self.read_power,
            units='mW',
        )
        poll_value = self.values[uuid].create_poll_value(default=300)
        self.values[poll_value.uuid] = poll_value

        self.sensor = None
 def __init__(self, bus=None, addr=None, **kwargs):
     """
     """
     oid = kwargs.pop('oid', '%s.pn532' % OID)
     name = kwargs.pop('name', "Screen")
     product_name = kwargs.pop('product_name', "RFID component")
     product_type = kwargs.pop('product_type', "RFID component")
     JNTComponent.__init__(self,
                           oid=oid,
                           bus=bus,
                           addr=addr,
                           name=name,
                           product_name=product_name,
                           product_type=product_type,
                           **kwargs)
     logger.debug("[%s] - __init__ node uuid:%s", self.__class__.__name__,
                  self.uuid)
     uuid = "device"
     self.values[uuid] = self.value_factory['config_byte'](
         options=self.options,
         uuid=uuid,
         node_uuid=self.uuid,
         help=
         'Either the device number on the hardware bus or the SPI CS pin of the software one',
         label='device',
         default=0,
     )
     uuid = "listen"
     self.values[uuid] = self.value_factory['action_boolean'](
         options=self.options,
         uuid=uuid,
         node_uuid=self.uuid,
         help='Activate/deactivate the listen mode',
         label='Listen',
         default=False,
         set_data_cb=self.set_listen,
         is_writeonly=True,
         cmd_class=COMMAND_CONTROLLER,
         genre=0x01,
     )
     self.pn532 = None
     self.listen_timer = None
     uuid = "listen_delay"
     self.values[uuid] = self.value_factory['config_integer'](
         options=self.options,
         uuid=uuid,
         node_uuid=self.uuid,
         help='The delay between 2 listens',
         label='Delay',
         default=1,
     )
     uuid = "status"
     self.values[uuid] = self.value_factory['sensor_list'](
         options=self.options,
         uuid=uuid,
         node_uuid=self.uuid,
         help='The status of the pn532',
         label='Status',
         default='sleeping',
         list_items=['sleeping', 'listening', 'write_ok', 'write_error'],
     )
     poll_value = self.values[uuid].create_poll_value(default=300)
     self.values[poll_value.uuid] = poll_value
 def stop(self):
     """
     """
     JNTComponent.stop(self)
     self.clock = None
示例#50
0
 def stop(self):
     """
     """
     JNTComponent.stop(self)
     self.vcnl = None