Esempio n. 1
0
def create_device():
    ### create the device, and if ok, get its id in device_id
    client_id  = "plugin-{0}.{1}".format(plugin, get_sanitized_hostname())
    print("Creating the irtrans device...")
    td = TestDevice()
    params = td.get_params(client_id, "irtrans.irtrans_lan")
        # fill in the params
    params["device_type"] = "irtrans.irtrans_lan"
    params["name"] = "test_IRTrans_LAN"
    params["reference"] = "IRTrans Lan client"
    params["description"] = "Handle IRTrans modul"
    for idx, val in enumerate(params['global']):
        if params['global'][idx]['key'] == 'ir_coder' :  params['global'][idx]['value'] = ENCODER
        if params['global'][idx]['key'] == 'server_path' :  params['global'][idx]['value'] = DEVICE_PATH
        if params['global'][idx]['key'] == 'ip_server' :  params['global'][idx]['value'] = DEVICE_IP_SERVER
        if params['global'][idx]['key'] == 'irtrans_ip' :  params['global'][idx]['value'] = DEVICE_IP_IRTRANS

    for idx, val in enumerate(params['xpl']):
        params['xpl'][idx]['value'] = DEVICE_NAME

    # go and create
    td.create_device(params)
    print "Device IRTrans Lan {0} configured".format(DEVICE_NAME) 
    
    print("Creating the irwsserver device...")
    td = TestDevice()
    params = td.get_params(client_id, "irtrans.irwsserver")
        # fill in the params
    params["device_type"] = "irtrans.irwsserver"
    params["name"] = "test_IRTrans_WS"
    params["reference"] = "IR WebSockect client"
    params["description"] = "Handle IR WebSockect modul"
    for idx, val in enumerate(params['global']):
        if params['global'][idx]['key'] == 'ir_coder' :  params['global'][idx]['value'] = ENCODER
        elif params['global'][idx]['key'] == 'ip_server' :  params['global'][idx]['value'] = DEVICE2_IP_SERVER
        elif params['global'][idx]['key'] == 'port_server' :  params['global'][idx]['value'] = DEVICE2_PORT_SERVER
        elif params['global'][idx]['key'] == 'ssl_activate' :  params['global'][idx]['value'] = DEVICE2_SSL
        elif params['global'][idx]['key'] == 'ssl_certificate' :  params['global'][idx]['value'] = DEVICE2_CERTIFICATE
        elif params['global'][idx]['key'] == 'ssl_key' :  params['global'][idx]['value'] = DEVICE2_KEY
        elif params['global'][idx]['key'] == 'ir_repeat' :  params['global'][idx]['value'] = 3
        elif params['global'][idx]['key'] == 'ir_tolerance' :  params['global'][idx]['value'] = 150
        elif params['global'][idx]['key'] == 'ir_large_tolerance' :  params['global'][idx]['value'] = 300
        elif params['global'][idx]['key'] == 'ir_max_out' :  params['global'][idx]['value'] = 10

    for idx, val in enumerate(params['xpl']):
        params['xpl'][idx]['value'] = DEVICE2_NAME

    # go and create
    td.create_device(params)
    print "Device irwsserver {0} configured".format(DEVICE2_NAME) 
def create_device():
    ### create the device, and if ok, get its id in device_id
    client_id = "plugin-{0}.{1}".format(plugin, get_sanitized_hostname())
    print "Creating the SMS  device..."
    td = TestDevice()
    params = td.get_params(client_id, "notify.smsweb")
    # fill in the params
    params["device_type"] = "notify.smsweb"
    params["name"] = DEVICE_NAME
    params["reference"] = "reference"
    params["description"] = "description"
    for idx, val in enumerate(params['global']):
        if params['global'][idx]['key'] == 'operator':
            params['global'][idx]['value'] = OPERATOR
        if params['global'][idx]['key'] == 'login':
            params['global'][idx]['value'] = OP_LOGIN
        if params['global'][idx]['key'] == 'pwd':
            params['global'][idx]['value'] = OP_PWD

    for idx, val in enumerate(params['xpl']):
        params['xpl'][idx]['value'] = PHONE_TEL

    # go and create
    td.create_device(params)
    print "Device SMS {0} configured".format(DEVICE_NAME_NOTIFRY)

    print("Creating the Newtifry  device...")
    td = TestDevice()
    params = td.get_params(client_id, "notify.newtifry")
    # fill in the params
    params["device_type"] = "notify.newtifry"
    params["name"] = DEVICE_NAME_NOTIFRY
    params["reference"] = "reference"
    params["description"] = "description"
    for idx, val in enumerate(params['global']):
        if params['global'][idx]['key'] == 'sourcekey':
            params['global'][idx]['value'] = SOURCE_KEY
        if params['global'][idx]['key'] == 'defaulttitle':
            params['global'][idx]['value'] = 'Test message'
        if params['global'][idx]['key'] == 'backend':
            params['global'][idx]['value'] = BACKEND

    for idx, val in enumerate(params['xpl']):
        params['xpl'][idx]['value'] = TO

    # go and create
    td.create_device(params)

    print "Device Newtifry {0} configured".format(DEVICE_NAME_NOTIFRY)
def createDevice(dataJson):
    td = TestDevice()
    # create a test device
    try:
        params = td.get_params(client_id, dataJson["device_type"])
        # fill in the params
        params["device_type"] = dataJson["device_type"]
        params["name"] = dataJson['name']
        params["reference"] = "reference"
        params["description"] = "description"
        # global params
        for the_param in params['global']:
            for p in dataJson["parameters"]:
                if the_param["key"] == p["key"]:
                    the_param["value"] = p["value"]
                    break
        print params['global']
        # xpl params
        pass  # there are no xpl params for this plugin
        # create
        return td.create_device(params)['id'], td
    except:
        Printc.err(u"Error while creating the test devices {0} : {1}".format(
            device, traceback.format_exc()))
        return False, td
def create_device():
    ### create the device, and if ok, get its id in device_id
    print(u"Creating the vigilocation device...")
    td = TestDevice()
    td.create_device("plugin", plugin, get_sanitized_hostname(), "test_vigilocation", "vigilightning.vigilocation")
    td.configure_global_parameters({"latitude " : "46.739868", "longitude" : "2.328084",
                "criticalradius" : 1, "nearbyradius" : 3, "approachradius" : 5,
                "releasetimes" : 3})
    print "Device vigilocation configured"
Esempio n. 5
0
def create_device():
    ### create the device, and if ok, get its id in device_id
    client_id = "plugin-{0}.{1}".format(plugin, get_sanitized_hostname())
    print "Creating the knx device..."
    td = TestDevice()
    params = td.get_params(client_id, "mirror")
    # fill in the params
    params["device_type"] = "switch"
    params["name"] = DEVICE_NAME_MIRROR
    params["Cmd_Datapoint"] = "1.001"
    params["Stat_Datapoint"] = "1.001"
    params["address_cmd"] = "1/1/1"
    params["address_stat"] = "1/0/1"

    # go and create
    td.create_device(params)
    print "Device KNX {0} configured".format(DEVICE_NAME_KAROTZ)
Esempio n. 6
0
def create_device():
    ### create the device, and if ok, get its id in device_id
    client_id = "plugin-{0}.{1}".format(plugin, get_sanitized_hostname())
    print "Creating the Hue device..."
    td = TestDevice()
    params = td.get_params(client_id, "hue")
    # fill in the params
    params["device_type"] = "hue"
    params["name"] = DEVICE_NAME_MIRROR
    params["address"] = ADDRESS
    for idx, val in enumerate(params['global']):
        if params['global'][idx]['key'] == 'name':
            params['global'][idx]['value'] = NAME
        if params['global'][idx]['key'] == 'address':
            params['global'][idx]['value'] = ADDRESS

    # go and create
    td.create_device(params)
    print "Device Hue {0} configured".format(DEVICE_NAME_KAROTZ)
def create_device():
    ### create the device, and if ok, get its id in device_id
    client_id = "plugin-{0}.{1}".format(plugin, get_sanitized_hostname())
    print("Creating the Remote device...")
    td = TestDevice()
    params = td.get_params(client_id, "daikcode.remotearc")
    # fill in the params
    params["device_type"] = "daikcode.remotearc"
    params["name"] = "test_daikcode.remotearc"
    params["reference"] = "ARC Remote"
    params["description"] = "Connected to {0}".format(DEVICE_IR)
    for idx, val in enumerate(params['global']):
        if params['global'][idx]['key'] == 'irdevice':
            params['global'][idx]['value'] = DEVICE_IR
        if params['global'][idx]['key'] == 'datatype':
            params['global'][idx]['value'] = DEVICE_DATATYPE

    for idx, val in enumerate(params['xpl']):
        params['xpl'][idx]['value'] = DEVICE_NAME

    # go and create
    td.create_device(params)
    print "Device Remote {0} configured".format(DEVICE_NAME)
    # set up the plugin name
    name = "rfplayer"

    # set up the configuration of the plugin
    # configuration is done in test_0010_configure_the_plugin with the cfg content
    # notice that the old configuration is deleted before
    cfg = {'configured': True, 'auto_startup': 'N'}

    # specific configuration for test mdode (handled by the manager for plugin startup)
    cfg['test_mode'] = True
    cfg['test_option'] = "{0}/x10_protocol_data.json".format(test_folder)

    ### start tests
    # load the test devices class
    td = TestDevice()

    # delete existing devices for this plugin on this host
    client_id = "{0}-{1}.{2}".format("plugin", name, get_sanitized_hostname())
    try:
        td.del_devices_by_client(client_id)
    except:
        Printc.err(
            u"Error while deleting all the test device for the client id '{0}' : {1}"
            .format(client_id, traceback.format_exc()))
        sys.exit(1)

    # create a test device
    try:
        #device_id = td.create_device(client_id, "test_device_RFPlayer", "RFPlayer.electric_meter")