Esempio n. 1
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
Esempio n. 2
0
def main(addr):
    if addr == None:
        addr = tools.get_random_uuid()
    dev = Device("lamp.dimmer", addr)
    dev.product_id = 'Dummy Dimming Lamp'
    dev.url = 'http://www.acme.org'

    # attributes
    light = dev.new_attribute('light')
    dimmer = dev.new_attribute('dimmer', 50)

    dev.dump()

    # methods
    def on():
        light.value = True
        print("%s ON" % dev)

    def off():
        light.value = False
        print("%s OFF" % dev)

    def dim(_target):
        dimmer.value = _target
        print("Dimming to %d" % _target)

    dev.add_method('on', on)
    dev.add_method('off', off)
    dev.add_method('dim', dim)

    eng = Engine()
    eng.add_device(dev)
    eng.run()
Esempio n. 3
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)
Esempio n. 4
0
def main(addr):
    if addr == None:
        addr = tools.get_random_uuid()
    dev = Device("switch.basic",addr)
    dev.product_id = 'One Simple test of Switch'
    dev.url = 'http://www.acme.org'

    # attributes
    state = dev.new_attribute('state')

    dev.dump()

    # methods
    def on():
        state.value = True
        print("%s ON" % dev)

    def off():
        state.value = False
        print("%s OFF" %dev)

    dev.add_method('on',on)
    dev.add_method('off',off)

    eng = Engine()
    eng.add_device(dev)
    #eng.run()
    eng.start()
Esempio n. 5
0
def main(addr):
    if addr == None:
        addr = tools.get_random_uuid()
    dev = Device("powerrelay.basic", addr)
    dev.product_id = 'Dummy Power Relay'
    dev.url = 'http://www.acme.org'

    # attributes
    power = dev.new_attribute('power')

    dev.dump()

    # methods
    def on():
        power.value = True
        print("%s ON" % dev)

    def off():
        power.value = False
        print("%s OFF" % dev)

    dev.add_method('on', on)
    dev.add_method('off', off)

    eng = Engine()
    eng.add_device(dev)
    eng.run()
Esempio n. 6
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)
Esempio n. 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 = "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)
Esempio n. 8
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
Esempio n. 9
0
def main(addr):
    if addr == None:
        addr = tools.get_random_uuid()
    dev = Device("controlerMedia.basic", addr)
    dev.product_id = 'Controler DLNA'
    dev.url = 'http://www.acme.org'

    # attributes
    destination_media = dev.new_attribute('destination_media')
    source_media = dev.new_attribute('source_media')
    state_media = dev.new_attribute('state_media')
    position_media = dev.new_attribute('position_media')

    dev.dump()

    # methods
    def get_attributes():
        print("Attributs")

    ########### Ensemble des methodes liees a la mise en place du media ##########
    def set_destination(_dest):
        # Met la valeur du media player a utiliser dans la variable "destination_media"
        destination_media.value = _dest
        print("Destination \"" + _dest + "\" is set")

    def get_destinations():
        # Interroge le dBus pour connaitre les media renderer en DLNA
        # Envoie à l'utilisateur les destinations sous forme de liste
        available_dest = {"renderer1": "salon", "renderer2": "cuisine"}
        print("Display destinations")
        return available_dest

    def set_source(_src):
        # Met la valeur du media server a utiliser dans la variable "source_media"
        source_media.value = _src
        print("Source \"" + _src + "\" is set")

    def get_sources():
        # Interroge le dBus pour connaitre les media server en DLNA
        # Envoie à l'utilisateur les medias sous forme de liste
        available_media = {"media1": "NAS\\video1", "media2": "NAS\\video2"}
        print("Display sources")
        return available_media

    ########## Ensemble des methodes liees a l'etat du media lorsqu'il est en cours de lecture #########
    def play():
        state_media.value = True
        # Commande DLNA pour lancer le media
        print("%s Play" % dev)

    def pause():
        state_media.value = False
        # Commande DLNA pour mettre le media sur pause
        print("%s Pause" % dev)

    def stop():
        print("Media is stop")

    def next():
        print("Next media is play")

    def prev():
        print("Previous media is play")

    def moving_forward():
        print("Media is forwarding of 10 secondes")

    def moving_back():
        print("Media is backing of 10 secondes")

    dev.add_method('get_attributes', get_attributes)
    dev.add_method('set_destination', set_destination)
    dev.add_method('get_destinations', get_destinations)
    dev.add_method('set_source', set_source)
    dev.add_method('get_sources', get_sources)
    dev.add_method('play', play)
    dev.add_method('pause', pause)
    dev.add_method('stop', stop)
    dev.add_method('next', next)
    dev.add_method('prev', prev)
    dev.add_method('moving_forward', moving_forward)
    dev.add_method('moving_back', moving_back)

    eng = Engine()
    eng.add_device(dev)
    eng.run()