Exemplo n.º 1
0
def print_stateEvaluator(stateEvaluator):
    if not stateEvaluator:
        return None
    if 'stateDescriptor' in stateEvaluator:
        stateType = get_stateType(
            stateEvaluator['stateDescriptor']['stateTypeId'])
        deviceName = devices.get_full_device_name(
            stateEvaluator['stateDescriptor']['deviceId'])
        print "%5s. -> %40s -> state: \"%s\"" % (0, deviceName,
                                                 stateType['name'])
        print "%50s %s %s" % (stateType['name'],
                              guh.get_valueOperator_string(
                                  stateEvaluator['stateDescriptor']['operator']
                              ), stateEvaluator['stateDescriptor']['value'])
    else:
        if not 'childEvaluators' in stateEvaluator:
            return None
        for i in range(len(stateEvaluator['childEvaluators'])):
            device = devices.get_device(stateEvaluator['childEvaluators'][i]
                                        ['stateDescriptor']['deviceId'])
            stateType = get_stateType(stateEvaluator['childEvaluators'][i]
                                      ['stateDescriptor']['stateTypeId'])
            print "(%s:%s" % (device['name'], stateType['name']),
            print guh.get_valueOperator_string(
                stateEvaluator['childEvaluators'][i]['stateDescriptor']
                ['operator']),
            print stateEvaluator['childEvaluators'][i]['stateDescriptor'][
                'value'], ")",
            if i != (len(stateEvaluator['childEvaluators']) - 1):
                print "%s%s" % (
                    guh.get_stateEvaluator_string(stateEvaluator['operator']),
                    guh.get_stateEvaluator_string(stateEvaluator['operator'])),
        print "\n"
Exemplo n.º 2
0
def print_eventDescriptors(eventDescriptors):
    for i in range(len(eventDescriptors)):
        eventDescriptor = eventDescriptors[i]
        deviceName = devices.get_full_device_name(eventDescriptor['deviceId'])
        eventType = get_eventType(eventDescriptor['eventTypeId'])
        paramDescriptors = eventDescriptor['paramDescriptors']
        print "%5s. -> %40s -> event: \"%s\"" % (i, deviceName,
                                                 eventType['displayName'])
        for i in range(len(paramDescriptors)):
            print "%50s %s %s" % (paramDescriptors[i]['name'],
                                  nymea.get_valueOperator_string(
                                      paramDescriptors[i]['operator']),
                                  paramDescriptors[i]['value'])
Exemplo n.º 3
0
def print_ruleActionList(actionList):
    for i in range(len(actionList)):
        action = actionList[i]
        deviceName = devices.get_full_device_name(action['deviceId'])
        actionType = actions.get_actionType(actionList[i]['actionTypeId'])
        actionParams = actionList[i]['ruleActionParams']
        print "%5s. -> %40s -> action: \"%s\"" % (i, deviceName,
                                                  actionType['displayName'])
        for i in range(len(actionParams)):
            if 'eventTypeId' in actionParams[i].keys():
                eventTypeId = actionParams[i]['eventTypeId']
                eventType = events.get_eventType(eventTypeId)
                print "%50s: -> value from event:  \"%s\" %s -> param \"%s\"" % (
                    parameters.getParamName(actionParams[i]['paramTypeId'],
                                            actionType['paramTypes']),
                    eventType['displayName'], eventTypeId,
                    parameters.getParamName(
                        actionParams[i]['eventParamTypeId'],
                        eventType['paramTypes']))
            else:
                print "%50s: %s" % (parameters.getParamName(
                    actionParams[i]['paramTypeId'],
                    actionType['paramTypes']), actionParams[i]['value'])