Пример #1
0
def create_actuator_device(transaction):
    template_id = create_actuator_template();
    if not 'proprietary' in transaction:
        transaction['proprietary'] = {}
    transaction['proprietary']['template_id'] = template_id
    device = {
        "label": "test_device",
        "templates": [template_id]
    }
    req = {
        'headers': {
            'authorization': generate_token(),
            'Content-Type': 'application/json'
        },
        'args': {
            'count': 1,
            'verbose': False
        },
        'body': json.dumps(device)
    }

    params = {
            'count': '1',
            'verbose': 'False',
            'content_type': 'application/json',
            'data': json.dumps(device)
        }


    result = DeviceHandler.create_device(params, generate_token())
    device_id = result['devices'][0]['id']
    transaction['proprietary']['device_id'] = device_id
    return device_id
Пример #2
0
def create_single_device(transaction):
    global template_id, device_id
    create_sample_template()
    device = {"label": "test_device", "templates": [template_id]}
    req = {
        'headers': {
            'authorization': generate_token(),
            'Content-Type': 'application/json'
        },
        'args': {
            'count': 1,
            'verbose': False
        },
        'body': json.dumps(device)
    }
    result = DeviceHandler.create_device(Request(req))
    device_id = result['devices'][0]['id']