Beispiel #1
0
    def setup(self):
        """ connect to serial port, and load configuration file"""
        # connect to serial port
        port = self.cfg['config']['port']
        self.ser = serial.Serial(port, 19200, timeout=0.5)

        # load devices from
        devices = []
        relays = self.cfg['relays']
        for k in relays:
            dev = new_dev(self, k[0], k[1], relays[k]['addr'],
                          relays[k]['type'])
            devices.append(dev)
        self.engine.add_devices(devices)

        # last step build the GW device
        gw = Device("gateway.basic")
        gw.address = self.cfg['config']['addr']
        gw.vendor_id = "JKX"
        gw.product_id = "HQ Product RF433 Gateway"
        gw.version = 0.1
        gw.info = "%s@%s" % (PACKAGE_NAME, platform.node())

        emb = gw.new_attribute('embedded', [])
        emb.value = [dev.address for dev in devices]
        self.engine.add_device(gw)
Beispiel #2
0
def build_dev(addr, devtype):
    dev = Device(devtype)
    dev.address = addr
    dev.vendor_id = "DIY Wireless Bug"
    dev.url = "http://dwb.ilhost.fr/"
    dev.version = 0.3
    return dev
Beispiel #3
0
def new_dev(gw, key, channel, addr, dtype):
    """ create e new xAAL device """
    dev = None
    if dtype == 'lamp':
        dev = Device("lamp.basic", addr)
        dev.product_id = "Lamp on HQ Product RF433 power relay"
        var = dev.new_attribute('light')
    else:
        dev = Device("powerrelay.basic", addr)
        dev.product_id = "HQ Product RF433 power relay"
        var = dev.new_attribute('power')

    dev.vendor_id = "JKX"
    dev.hw_id = '%s%s' % (key, channel)
    dev.version = 0.2
    dev.info = "%s@%s" % (PACKAGE_NAME, platform.node())

    # methods
    def on():
        if gw.switch_relay('ON', key, channel):
            var.value = True

    def off():
        if gw.switch_relay('OFF', key, channel):
            var.value = False

    dev.add_method('on', on)
    dev.add_method('off', off)
    return dev
Beispiel #4
0
def setup():
    """ setup xAAL Engine & Device. And start it in a Greenlet"""
    helpers.setup_console_logger()
    global monitor
    engine = Engine()
    cfg = tools.load_cfg(PACKAGE_NAME)
    if not cfg:
        logger.info('Missing config file, building a new one')
        cfg = tools.new_cfg(PACKAGE_NAME)
        cfg.write()

    dev = Device("hmi.basic")
    dev.address = cfg['config']['addr']
    dev.vendor_id = "IHSEV"
    dev.product_id = "WEB Interface"
    dev.version = 0.1
    dev.info = "%s@%s" % (PACKAGE_NAME, platform.node())

    engine.add_device(dev)
    db_server = None
    if 'db_server' in cfg['config']:
        db_server = cfg['config']['db_server']
    else:
        logger.info('You can set "db_server" in the config file')
    monitor = Monitor(dev, filter_func=monitor_filter, db_server=db_server)
    monitor.subscribe(event_handler)

    engine.start()
    green_let = Greenlet(xaal_loop, engine)
    green_let.start()
Beispiel #5
0
def build_dev(dtype, addr):
    dev = Device(dtype)
    dev.address = addr
    dev.vendor_id = "IHSEV"
    dev.product_id = "OpenWeatherMap"
    dev.info = "%s@%s" % (PACKAGE_NAME, platform.node())
    dev.url = "https://www.openweathermap.org"
    dev.version = 0.2
    return dev
Beispiel #6
0
def build_dev(dtype, addr):
    dev = Device(dtype)
    dev.address = addr
    dev.vendor_id = "NETATMO"
    dev.product_id = "NetatmoWeatherStation"
    dev.info = "%s@%s" % (PACKAGE_NAME, platform.node())
    dev.url = "https://dev.netatmo.com/"
    dev.version = 0.1
    return dev
Beispiel #7
0
    def setup_gw(self):
        # last step build the GW device
        gw = Device("gateway.basic")
        gw.address = self.cfg['config']['addr']
        gw.vendor_id = "IHSEV"
        gw.product_id = "IPX-800 Ethernet Control System"
        gw.version = 0.1
        gw.url = "http://gce-electronics.com/fr/home/57-module-ip-rail-din-webserver-8-relais-ipx800-v3.html"
        gw.info = "%s@%s" % (PACKAGE_NAME, platform.node())

        emb = gw.new_attribute('embedded', [])
        emb.value = [io.dev.address for io in self.in_out]
        self.engine.add_device(gw)
Beispiel #8
0
    def setup_gw(self):
        # last step build the GW device
        gw = Device("gateway.basic")
        gw.address = self.cfg['config']['addr']
        gw.vendor_id = "DIY Wireless Bug"
        gw.product_id = "bugOne Gateway"
        gw.version = 0.3
        gw.url = "http://dwb.ilhost.fr/"
        gw.info = "%s@%s" % (PACKAGE_NAME, platform.node())

        emb = gw.new_attribute('embedded', [])
        for node in self.nodes.values():
            for dev in node.get_devices():
                emb.value.append(dev.address)
        self.engine.add_device(gw)
Beispiel #9
0
def monitor_example(engine):
    # load config
    cfg = tools.load_cfg_or_die(PACKAGE_NAME)
    # create a device & register it
    dev = Device("hmi.basic")
    dev.address = cfg['config']['addr']
    dev.vendor_id = "IHSEV"
    dev.product_id = "Monitor Example"
    dev.version = 0.1
    dev.info = "%s@%s" % (PACKAGE_NAME, platform.node())
    engine.add_device(dev)
    # start the monitoring
    mon = Monitor(dev)
    mon.subscribe(display_event)
    return mon
Beispiel #10
0
    def __init__(self,ipx,channel,addr,state_name,group):
        dev = Device("changeme.basic",addr)
        dev.vendor_id  = "IHSEV"
        dev.version    = 0.1
        dev.hw_id = channel
        dev.group_id = group
        
        # attribute
        self.state = dev.new_attribute(state_name)
        
        # method 
        dev.add_method('on',self.on)
        dev.add_method('off',self.off)

        self.chan = channel
        self.ipx = ipx 
        self.dev = dev
Beispiel #11
0
    def setup(self):
        addr = self.cfg['config']['addr']
        dev = Device("metadatadb.basic")
        dev.address = addr
        dev.vendor_id = "IHSEV"
        dev.product_id = "Metadata database"
        dev.version = 0.1
        dev.info = "%s@%s" % (PACKAGE_NAME, platform.node())

        dev.add_method('getDevices', self.get_devices)
        dev.add_method('getKeysValues', self.get_keys_values)
        dev.add_method('getValue', self.get_value)
        dev.add_method('updateKeysValues', self.update_keys_values)
        dev.add_method('addKeysValues', self.add_keys_values)

        self.dev = dev
        self.engine.add_device(dev)
        self.engine.add_timer(self.periodic_save, 60)
Beispiel #12
0
def setup_xaal():
    """ setup xAAL Engine & Device. And start it in a Greenlet"""
    global monitor
    engine = Engine()
    cfg = tools.load_cfg_or_die(PACKAGE_NAME)

    dev = Device("hmi.basic")
    dev.address = cfg['config']['addr']
    dev.vendor_id = "IHSEV"
    dev.product_id = "REST API"
    dev.version = 0.1
    dev.info = "%s@%s" % (PACKAGE_NAME, platform.node())

    engine.add_device(dev)
    monitor = Monitor(dev, filter_func=monitor_filter)
    engine.start()
    green_let = Greenlet(xaal_loop, engine)
    green_let.start()
Beispiel #13
0
    def setup(self):
        cfg = self.cfg

        client = influxdb.InfluxDBClient(
                host=cfg['host'],
                port=int(cfg['port']),
                username=cfg['user'],
                password=cfg['password'],
                database=cfg['database'],
                ssl=(cfg['ssl'] == "true"))
        self.influxdb = client

        dev = Device("logger.basic")
        dev.address    = self.cfg['addr']
        dev.vendor_id  = "IHSEV"
        dev.product_id = "InfluxDB Logger"
        dev.url        = "https://www.influxdata.com"
        dev.version    = 0.1
        dev.info  = "%s@%s:%s" % (cfg['database'],cfg['host'],cfg['port'])
        self.eng.add_device(dev)