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
    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 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 PLCBUS  device..."
    td = TestDevice()
    params = td.get_params(client_id, "plcbus.switch")
    # fill in the params
    params["name"] = DEVICE_NAME
    params["reference"] = "reference"
    params["description"] = "description"

    for idx, val in enumerate(params["xpl"]):
        params["xpl"][idx]["value"] = ADDRESS

    # go and create
    td.create_device(params)
    print "Device PLCBUS {0} configured".format(DEVICE_NAME_PLCBUS)
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 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)
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 primary controller device...")
    td = TestDevice()
    params = td.get_params(client_id, "primary.controller")
    # fill in the params
    params["device_type"] = "primary.controller"
    params["name"] = "test_ozw_crtl"
    params["reference"] = "Z-Stick2"
    params["description"] = "Z-Stick2 USB"
    for idx, val in enumerate(params['global']):
#        if params['global'][idx]['key'] == 'network_id' :  params['global'][idx]['value'] = NETWORK_ID
        if params['global'][idx]['key'] == 'driver' :  params['global'][idx]['value'] = DRIVER
    for idx, val in enumerate(params['xpl']):
        params['xpl'][idx]['value'] = NETWORK_ID
    # go and create
    td.create_device(params)
    print "Device primary controller configured"
Esempio n. 8
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 UPS device...")
    td = TestDevice()
    params = td.get_params(client_id, "ups.device")
        # fill in the params
    params["device_type"] = "ups.device"
    params["name"] = "test_UPS_Monitor"
    params["reference"] = "NUT Sockect client"
    params["description"] = "Monitor UPS"
    for idx, val in enumerate(params['global']):
        if params['global'][idx]['key'] == 'timer_poll' :  params['global'][idx]['value'] = TIMER_POLL

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

    # go and create
    td.create_device(params)
    print "Device UPS {0} configured".format(DEVICE_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 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) 
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)
    ### 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: 
        print(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:
        params = td.get_params(client_id, "rfxcom.temperature_humidity")
   
        for dev in devices:
            # fill in the params
            params["device_type"] = "rfxcom.temperature_humidity"
            params["name"] = "test_device_rfxcom_type52_{0}".format(dev)
            params["reference"] = "reference"
            params["description"] = "description"
            # global params
            pass # there are no global params for this plugin
            # xpl params
            for the_param in params['xpl']:
                if the_param['key'] == "device":
                    the_param['value'] = dev
            print params['xpl']
            # create
Esempio n. 13
0
    ### 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: 
        print(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:
        params = td.get_params(client_id, "wol.wol")
   
        for dev in devices:
            # fill in the params
            params["device_type"] = "wol.wol"
            params["name"] = "test_device_wol_{0}_é".format(dev)
            params["reference"] = "reference"
            params["description"] = "description"
            # global params
            pass # there are no global params for this plugin
            # xpl params
            # usually we configure the xpl parameters. In this device case, we can have multiple addresses
            # so the parameters are configured on xpl_stats level
            for the_param in params['xpl']:
                if the_param['key'] == "device":
                    the_param['value'] = dev
    # 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:
        print(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_teleinfo", "teleinfo.electric_meter")
        
        params = td.get_params(client_id, "teleinfo.electric_meter")
    
        # fill in the params
        params["device_type"] = "teleinfo.electric_meter"
        params["name"] = "test_device_teleinfo"
        params["reference"] = "reference"
        params["description"] = "description"
        # global params
        for the_param in params['global']:
            if the_param['key'] == "interval":
                the_param['value'] = interval
            if the_param['key'] == "device":
                the_param['value'] = device
        print params['global']
        # xpl params
        pass # there are no xpl params for this plugin
Esempio n. 15
0
    # 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:
        print(
            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:
        params = td.get_params(client_id, "ping.ping")

        for dev in devices:
            print("DEV={0}".format(dev))
            # fill in the params
            params["device_type"] = "ping.ping"
            params["name"] = "test_device_ping_{0}_é".format(dev)
            params["reference"] = "reference"
            params["description"] = "description"
            # global params
            pass  # there are no global params for this plugin
            # xpl params
            # usually we configure the xpl parameters. In this device case, we can have multiple addresses
            # so the parameters are configured on xpl_stats level
            for the_param in params['global']:
                if the_param['key'] == "interval":
    # 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")

        params = td.get_params(client_id, "rfplayer.rfp1000")

        # fill in the params
        params["device_type"] = "rfplayer.rfp1000"
        params["name"] = "test_device_RFPlayer"
        params["reference"] = "reference"
        params["description"] = "description"
        # global params
        for the_param in params['global']:
            if the_param['key'] == "timer_status":
                the_param['value'] = timer_status
            if the_param['key'] == "device":
                the_param['value'] = device
        print params['global']
        # xpl params
        pass  # there are no xpl params for this plugin
    # 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:
        print (
            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:
        params = td.get_params(client_id, "rfxcom.smoke_sensor")

        for dev in devices:
            # fill in the params
            params["device_type"] = "rfxcom.smoke_sensor"
            params["name"] = "test_device_rfxcom_type20_{0}".format(dev)
            params["reference"] = "reference"
            params["description"] = "description"
            # global params
            pass  # there are no global params for this plugin
            # xpl params
            for the_param in params["xpl"]:
                if the_param["key"] == "device":
                    the_param["value"] = dev
            print params["xpl"]
            # create
Esempio n. 18
0
    # 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:
        print(
            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:
        params = td.get_params(client_id, "ping.ping")

        for dev in devices:
            print("DEV={0}".format(dev))
            # fill in the params
            params["device_type"] = "ping.ping"
            params["name"] = "test_device_ping_{0}_é".format(dev)
            params["reference"] = "reference"
            params["description"] = "description"
            # global params
            pass  # there are no global params for this plugin
            # xpl params
            # usually we configure the xpl parameters. In this device case, we can have multiple addresses
            # so the parameters are configured on xpl_stats level
            for the_param in params["global"]:
                if the_param["key"] == "interval":
Esempio n. 19
0
    ### 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: 
        print(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:
        params = td.get_params(client_id, "script.info_binary")
   
        for dev in devices:
            # fill in the params
            params["device_type"] = "script.info_binary"
            params["name"] = "test_device_script_{0}_é".format(dev)
            params["reference"] = "reference"
            params["description"] = "description"
            # global params
            for the_param in params['global']:
                if the_param['key'] == "interval":
                    the_param['value'] = interval
            print params['global']
            # xpl params
            # usually we configure the xpl parameters. In this device case, we can have multiple addresses
            # so the parameters are configured on xpl_stats level
    # 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:
        print(
            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:
        params = td.get_params(client_id, "rfxcom.open_close")

        for dev in devices:
            # fill in the params
            params["device_type"] = "rfxcom.open_close"
            params["name"] = "test_device_rfxcom_type11_{0}".format(dev)
            params["reference"] = "reference"
            params["description"] = "description"
            # global params
            pass  # there are no global params for this plugin
            # xpl params
            # usually we configure the xpl parameters. In this device case, we can have multiple addresses
            # so the parameters are configured on xpl_stats level
            #for the_param in params['xpl']:
            for the_param in params['xpl_stats']['open_close']:
                if the_param['key'] == "address":
    # 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:
        print(
            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:
        params = td.get_params(client_id, "rfxcom.smoke_sensor")

        for dev in devices:
            # fill in the params
            params["device_type"] = "rfxcom.smoke_sensor"
            params["name"] = "test_device_rfxcom_type20_{0}".format(dev)
            params["reference"] = "reference"
            params["description"] = "description"
            # global params
            pass  # there are no global params for this plugin
            # xpl params
            for the_param in params['xpl']:
                if the_param['key'] == "device":
                    the_param['value'] = dev
            print params['xpl']
            # create
    ### 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: 
        print(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:
        params = td.get_params(client_id, "rfxcom.switch_lighting2")
   
        for dev in devices:
            # fill in the params
            params["device_type"] = "rfxcom.switch_lighting2"
            params["name"] = "test_device_rfxcom_type11_{0}".format(dev)
            params["reference"] = "reference"
            params["description"] = "description"
            # global params
            pass # there are no global params for this plugin
            # xpl params
            # usually we configure the xpl parameters. In this device case, we can have multiple addresses
            # so the parameters are configured on xpl_stats level
            #for the_param in params['xpl']:
            for the_param in params['xpl_stats']['switch_lighting2']:
                if the_param['key'] == "address":
    ### 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: 
        print(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:
        params = td.get_params(client_id, "rfxcom.open_close")
   
        for dev in devices:
            # fill in the params
            params["device_type"] = "rfxcom.open_close"
            params["name"] = "test_device_rfxcom_type11_{0}".format(dev)
            params["reference"] = "reference"
            params["description"] = "description"
            # global params
            pass # there are no global params for this plugin
            # xpl params
            # usually we configure the xpl parameters. In this device case, we can have multiple addresses
            # so the parameters are configured on xpl_stats level
            #for the_param in params['xpl']:
            for the_param in params['xpl_stats']['open_close']:
                if the_param['key'] == "address":
Esempio n. 24
0
    ### 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: 
        print(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:
        params = td.get_params(client_id, "geoloc.position_degrees")

        # fill in the params
        params["device_type"] = "geoloc.position_degrees"
        params["name"] = "test_device_geoloc"
        params["reference"] = "reference"
        params["description"] = "description"
        # global params
        # xpl params
        for the_param in params['xpl']:
            if the_param['key'] == "device":
                the_param['value'] = device_name
        print("PARAMS={0}".format(params))
        # create
        device_id = td.create_device(params)['id']
Esempio n. 25
0
    # 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:
        print(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_teleinfo", "teleinfo.electric_meter")
        
        params = td.get_params(client_id, "teleinfo.electric_meter")
    
        # fill in the params
        params["device_type"] = "teleinfo.electric_meter"
        params["name"] = "test_device_teleinfo"
        params["reference"] = "reference"
        params["description"] = "description"
        # global params
        for the_param in params['global']:
            if the_param['key'] == "interval":
                the_param['value'] = interval
            if the_param['key'] == "device":
                the_param['value'] = device
        print params['global']
        # xpl params
        pass # there are no xpl params for this plugin
Esempio n. 26
0
    ### 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: 
        print(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:
        params = td.get_params(client_id, "script.info_number")
   
        for dev in devices:
            # fill in the params
            params["device_type"] = "script.info_number"
            params["name"] = "test_device_script_{0}_é".format(dev)
            params["reference"] = "reference"
            params["description"] = "description"
            # global params
            for the_param in params['global']:
                if the_param['key'] == "interval":
                    the_param['value'] = interval
            print params['global']
            # xpl params
            # usually we configure the xpl parameters. In this device case, we can have multiple addresses
            # so the parameters are configured on xpl_stats level
Esempio n. 27
0
from domogik.tests.common.testdevice import TestDevice
from domogik.common.utils import get_sanitized_hostname

cid = "plugin-test.{0}".format(get_sanitized_hostname())
t = TestDevice()

# an xpl device
params = t.get_params(cid, "test.xpltest")
params['name'] = 'Test-xpl-device'
params['reference'] = 'Test-xpl-reference'
params['description'] = 'Test-xpl-description'
params['global'][0]['value'] = 'xpl-set-global'
params['xpl'][0]['value'] = 'xpl-set-devicetype'
params['xpl_stats']['test_xpl_stat'][0]['value'] = 'xpl-stat-set-device' 
params['xpl_commands']['test_xpl_command'][0]['value'] = 'xpl-cmd-set-device' 
dev = t.create_device(params)

# an mq device
params = t.get_params(cid, "test.mqtest")
params['name'] = 'Test-mq-device'
params['reference'] = 'Test-mq-reference'
params['description'] = 'Test-mq-description'
params['global'][0]['value'] = 'mq-set-global'
dev = t.create_device(params)
Esempio n. 28
0
    ### 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: 
        print(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:
        params = td.get_params(client_id, "script.action")
   
        for dev in devices:
            # fill in the params
            params["device_type"] = "script.action"
            params["name"] = "test_device_script_{0}_é".format(dev)
            params["reference"] = "reference"
            params["description"] = "description"
            # global params
            pass # there are no global params for this plugin
            # xpl params
            # usually we configure the xpl parameters. In this device case, we can have multiple addresses
            # so the parameters are configured on xpl_stats level
            for the_param in params['xpl']:
                if the_param['key'] == "command":
                    the_param['value'] = dev
#!/usr/bin/python
# -*- coding: utf-8 -*-


from domogik.tests.common.testdevice import TestDevice
from domogik.common.utils import get_sanitized_hostname


if __name__ == "__main__":

    client_id = "plugin-diskfree.{0}".format(get_sanitized_hostname())
    td = TestDevice()
    params = td.get_params(client_id, "diskfree.disk_usage")

    # fill in the params
    params["device_type"] = "diskfree.disk_usage"
    params["name"] = "TestDevice"
    params["reference"] = "reference"
    params["description"] = "description"
    for idx, val in enumerate(params['global']):
        params['global'][idx]['value'] = 60
    for idx, val in enumerate(params['xpl']):
        params['xpl'][idx]['value'] = '/'

    # go and create
    td.create_device(params)


Esempio n. 30
0
    ### 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: 
        print(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:
        params = td.get_params(client_id, "callerid.callerid")
   
        for dev in devices:
            # fill in the params
            params["device_type"] = "callerid.callerid"
            params["name"] = "test_device_callerid_{0}".format(dev)
            params["reference"] = "reference"
            params["description"] = "description"
            # global params
            for the_param in params['global']:
                if the_param['key'] == "device":
                    the_param['value'] = dev
                if the_param['key'] == "cid_command":
                    the_param['value'] = "AT#CID=1"
            # xpl params
            pass # there are no xpl params for this plugin
    ### 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:
        print(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:
        params = td.get_params(client_id, "ups.device")
            # fill in the params
        params["device_type"] = "ups.device"
        params["name"] = "test_UPS_Monitor"
        params["reference"] = "NUT Sockect client"
        params["description"] = "Monitor UPS"
        for idx, val in enumerate(params['global']):
            if params['global'][idx]['key'] == 'timer_poll' :  params['global'][idx]['value'] = TIMER_POLL
    
        for idx, val in enumerate(params['xpl']):
            params['xpl'][idx]['value'] = DEVICE_NAME
    
        # go and create
        td.create_device(params)
        print "Device UPS {0} configured".format(DEVICE_NAME) 
    except:
Esempio n. 32
0
    # 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:
        print (
            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:
        params = td.get_params(client_id, "script.info_string")

        for dev in devices:
            # fill in the params
            params["device_type"] = "script.info_string"
            params["name"] = "test_device_script_{0}_é".format(dev)
            params["reference"] = "reference"
            params["description"] = "description"
            # global params
            for the_param in params["global"]:
                if the_param["key"] == "interval":
                    the_param["value"] = interval
            print params["global"]
            # xpl params
            # usually we configure the xpl parameters. In this device case, we can have multiple addresses
            # so the parameters are configured on xpl_stats level