mirror of https://github.com/nymea/nymea.git
fixed valueOperator and added allowedValues selection
parent
fcdee6cb32
commit
a8265c36a1
|
|
@ -29,7 +29,6 @@ def get_selection(title, options):
|
||||||
if not selection:
|
if not selection:
|
||||||
print "-> error in selection"
|
print "-> error in selection"
|
||||||
return
|
return
|
||||||
|
|
||||||
return int(selection)
|
return int(selection)
|
||||||
|
|
||||||
def send_command(method, params = None):
|
def send_command(method, params = None):
|
||||||
|
|
@ -68,6 +67,7 @@ def select_vendor():
|
||||||
selection = get_selection("Please select vendor", vendorList)
|
selection = get_selection("Please select vendor", vendorList)
|
||||||
if selection != None:
|
if selection != None:
|
||||||
return vendorIdList[selection]
|
return vendorIdList[selection]
|
||||||
|
|
||||||
|
|
||||||
def get_deviceClasses(vendorId = None):
|
def get_deviceClasses(vendorId = None):
|
||||||
params = {};
|
params = {};
|
||||||
|
|
@ -136,26 +136,41 @@ def list_configured_devices():
|
||||||
def read_params(paramTypes):
|
def read_params(paramTypes):
|
||||||
params = []
|
params = []
|
||||||
for paramType in paramTypes:
|
for paramType in paramTypes:
|
||||||
paramValue = raw_input("Please enter value for parameter %s (type: %s): " % (paramType['name'], paramType['type']))
|
if any("allowedValues" in item for item in paramType):
|
||||||
param = {}
|
selection = get_selection("Please select one of following allowed values:", paramType['allowedValues'])
|
||||||
param['name'] = paramType['name']
|
paramValue = paramType['allowedValues'][selection]
|
||||||
param['value'] = paramValue
|
param = {}
|
||||||
# param[paramType['name']] = paramValue
|
param['name'] = paramType['name']
|
||||||
|
param['value'] = paramValue
|
||||||
|
else:
|
||||||
|
paramValue = raw_input("Please enter value for parameter %s (type: %s): " % (paramType['name'], paramType['type']))
|
||||||
|
param = {}
|
||||||
|
param['name'] = paramType['name']
|
||||||
|
param['value'] = paramValue
|
||||||
params.append(param)
|
params.append(param)
|
||||||
print "got params:", params
|
print "got params:", params
|
||||||
return params
|
return params
|
||||||
|
|
||||||
|
|
||||||
def select_valueOperator():
|
def select_valueOperator():
|
||||||
valueOperators = ["OperatorTypeEquals", "OperatorTypeNotEquals", "OperatorTypeLess", "OperatorTypeGreater"]
|
valueOperators = ["ValueOperatorEquals", "ValueOperatorNotEquals", "ValueOperatorLess", "ValueOperatorGreater", "ValueOperatorLessOrEqual", "ValueOperatorGreaterOrEqual"]
|
||||||
selection = get_selection("Please select an operator to compare this parameter: ", valueOperators)
|
selection = get_selection("Please select an operator to compare this parameter: ", valueOperators)
|
||||||
if selection != None:
|
if selection != None:
|
||||||
return valueOperators[selection]
|
return valueOperators[selection]
|
||||||
|
|
||||||
|
|
||||||
|
def select_stateOperator():
|
||||||
|
stateOperators = ["StateOperatorAnd", "StateOperatorOr"]
|
||||||
|
selection = get_selection("Please select an operator to compare this state: ", stateOperators)
|
||||||
|
if selection != None:
|
||||||
|
return stateOperators[selection]
|
||||||
|
|
||||||
|
|
||||||
def read_paramDescriptors(paramTypes):
|
def read_paramDescriptors(paramTypes):
|
||||||
params = []
|
params = []
|
||||||
for paramType in paramTypes:
|
for paramType in paramTypes:
|
||||||
paramValue = raw_input("Please enter value for parameter %s (type: %s): " % (paramType['name'], paramType['type']))
|
print paramType['allowedValues']
|
||||||
|
paramValue = raw_input("Please enter value for parameter <%s> (type: %s): " % (paramType['name'], paramType['type']))
|
||||||
operator = select_valueOperator()
|
operator = select_valueOperator()
|
||||||
param = {}
|
param = {}
|
||||||
param['name'] = paramType['name']
|
param['name'] = paramType['name']
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue