add support for entering params when adding a device via cmdmgr
This commit is contained in:
parent
e4f3c9aba1
commit
7d8199aac5
@ -107,19 +107,25 @@ def list_configured_devices():
|
|||||||
print "=== Configured Devices ==="
|
print "=== Configured Devices ==="
|
||||||
|
|
||||||
|
|
||||||
|
def read_params(paramTypes):
|
||||||
|
params = []
|
||||||
|
for paramType in paramTypes:
|
||||||
|
paramValue = raw_input("Please enter value for parameter %s (type: %s): " % (paramType['name'], paramType['type']))
|
||||||
|
param = {}
|
||||||
|
param[paramType['name']] = paramValue
|
||||||
|
params.append(param)
|
||||||
|
print "got params:", params
|
||||||
|
return params
|
||||||
|
|
||||||
def discover_device(deviceClassId = None):
|
def discover_device(deviceClassId = None):
|
||||||
if deviceClassId == None:
|
if deviceClassId == None:
|
||||||
deviceClassId = select_deviceClass()
|
deviceClassId = select_deviceClass()
|
||||||
deviceClass = get_deviceClass(deviceClassId)
|
deviceClass = get_deviceClass(deviceClassId)
|
||||||
discoveryParams = []
|
|
||||||
for paramType in deviceClass['discoveryParamTypes']:
|
|
||||||
paramValue = raw_input("Please enter value for parameter %s" % paramType['name'])
|
|
||||||
dp = {}
|
|
||||||
dp[paramType['name']] = paramValue
|
|
||||||
discoveryParams.append(dp)
|
|
||||||
|
|
||||||
params = {}
|
params = {}
|
||||||
params['deviceClassId'] = deviceClassId
|
params['deviceClassId'] = deviceClassId
|
||||||
|
|
||||||
|
discoveryParams = read_params(deviceClass['paramTypes'])
|
||||||
if len(discoveryParams) > 0:
|
if len(discoveryParams) > 0:
|
||||||
params['discoveryParams'] = discoveryParams
|
params['discoveryParams'] = discoveryParams
|
||||||
|
|
||||||
@ -155,9 +161,18 @@ def get_actionType(actionTypeId):
|
|||||||
print "got actionType", response
|
print "got actionType", response
|
||||||
return response['params']['actionType']
|
return response['params']['actionType']
|
||||||
|
|
||||||
|
|
||||||
def add_configured_device(deviceClassId):
|
def add_configured_device(deviceClassId):
|
||||||
|
deviceClass = get_deviceClass(deviceClassId)
|
||||||
|
|
||||||
params = {}
|
params = {}
|
||||||
params['deviceClassId'] = deviceClassId
|
params['deviceClassId'] = deviceClassId
|
||||||
|
|
||||||
|
deviceParams = read_params(deviceClass['paramTypes'])
|
||||||
|
if len(deviceParams) > 0:
|
||||||
|
params['deviceParams'] = deviceParams
|
||||||
|
|
||||||
|
print "adddevice command params:", params
|
||||||
response = send_command("Devices.AddConfiguredDevice", params)
|
response = send_command("Devices.AddConfiguredDevice", params)
|
||||||
if response['params']['success'] != "true":
|
if response['params']['success'] != "true":
|
||||||
print "Error executing method: %s" % response['params']['errorMessage']
|
print "Error executing method: %s" % response['params']['errorMessage']
|
||||||
|
|||||||
Reference in New Issue
Block a user