示例#1
0
def getDeviceIdAndName(input):
    if (input.isdigit()):
        deviceId = int(input)
        deviceName = td.getName(int(input))
    else:
        deviceId, deviceName = td.getDeviceIdFromStr(input)

    return deviceId, deviceName
示例#2
0
def getDeviceIdAndName(In):
    if (In.isdigit()):
        deviceId = int(In)
        deviceName = td.getName(int(In))
    else:
        deviceId, deviceName = td.getDeviceIdFromStr(In)

    return deviceId, deviceName
示例#3
0
def getDeviceIdAndName(input):
    if (input.isdigit()):
        deviceId = int(input)
        deviceName = td.getName(int(input))
    else:
        deviceId, deviceName = td.getDeviceIdFromStr(input)

    return deviceId, deviceName
示例#4
0
 def action_list(self):
     '''
     List available devices, and return result like this:
        [
         {'id': 1, 'name': 'office_roof',       'value': 250 },
         {'id': 1, 'name': 'livingroom_corner', 'value': 255 },
        ]
     '''
     result = []
     for i in range(td.getNumberOfDevices()):
         id = td.getDeviceId(i)
         result.append({
             'id': id,
             'name': td.getName(id),
             'value': self.states.get('lamp-%s' % id)
         })
     return result
示例#5
0
文件: __init__.py 项目: auduny/chains
 def action_list(self):
     '''
     List available devices, and return result like this:
        [
         {'id': 1, 'name': 'office_roof',       'value': 250 },
         {'id': 1, 'name': 'livingroom_corner', 'value': 255 },
        ]
     '''
     result = [] 
     for i in range(td.getNumberOfDevices()):
        id = td.getDeviceId(i)
        result.append({
            'id':    id,
            'name':  td.getName(id),
            'value': self.states.get('lamp-%s' % id)
        })
     return result
示例#6
0
def listDevices():

    print 'Number of devices:', td.getNumberOfDevices()
    for i in range(td.getNumberOfDevices()):
        deviceId = td.getDeviceId(i)
        cmd = td.lastSentCommand(deviceId, readable = True)
        if cmd == 'DIM':
            cmd += ':' + str(td.lastSentValue(i))
        # For 3.2 Name = NewName(td.getName(deviceId))
        Name = td.getName(deviceId)
        if len(str(Name)) <= 7:
            # print("Short Name:", len(Name))
            while len(Name) < 8:
                Name = Name + " "

        #  print (deviceId, '\t', Name, '\t', cmd, '\t\t', td.methods(deviceId, readable = True))
        print deviceId, '\t', Name, '\t', cmd, '\t\t'
    print ''

    
示例#7
0
 def getName(self,devId):
     return td.getName(devId)
示例#8
0
def myDeviceChangeEvent(deviceId, changeEvent, changeType, callbackId):
    print '%d: DeviceChangeEvent Device: %d - %s' %(time.time(), deviceId, td.getName(deviceId))
    print '  changeEvent: %d' %( changeEvent )
    print '  changeType: %d' %( changeType )
示例#9
0
def myDeviceEvent(deviceId, method, data, callbackId):
    print '%d: DeviceEvent Device: %d - %s' %( time.time(), deviceId, td.getName(deviceId) )
    print '  method: %d - %s, data: %s' %( method, td.methodsReadable.get(method, 'Unknown' ), data )
示例#10
0
        print 'Sending bell to:', deviceId, deviceName, '-', res


    elif options.on == None and options.off == None and options.bell == None and options.list == True and options.dim == None and options.learn == None and options.event == False:

        #
        #    LIST
        #

        print 'Number of devices:', td.getNumberOfDevices()
        for i in range(td.getNumberOfDevices()):
            deviceId = td.getDeviceId(i)
            cmd = td.lastSentCommand(deviceId, readable = True)
            if cmd == 'DIM':
                cmd += ':' + str(td.lastSentValue(i))
            print deviceId, '\t', td.getName(deviceId), '\t\t', cmd, '\t\t', td.methods(deviceId, readable = True)
        print ''

    elif options.on == None and options.off == None and options.bell == None and options.list == False and options.dim != None and options.dimlevel != None and options.learn == None and options.event == False:
 
         #
        #    DIM
        #

        try:
            dimlevel = int(options.dimlevel)
        except:
            parser.error('--dimlevel LEVEL needs to be an integer and 0-255')

        if dimlevel < 0 or dimlevel > 255:
            parser.error('--dimlevel LEVEL needs to be an integer and 0-255')
示例#11
0
def myDeviceChangeEvent(deviceId, changeEvent, changeType, callbackId):
    print '%d: DeviceChangeEvent Device: %d - %s' % (time.time(), deviceId,
                                                     td.getName(deviceId))
    print '  changeEvent: %d' % (changeEvent)
    print '  changeType: %d' % (changeType)
示例#12
0
def myDeviceEvent(deviceId, method, data, callbackId):
    print '%d: DeviceEvent Device: %d - %s' % (time.time(), deviceId,
                                               td.getName(deviceId))
    print '  method: %d - %s, data: %s' % (
        method, td.methodsReadable.get(method, 'Unknown'), data)
示例#13
0
    elif options.on == None and options.off == None and options.bell == None and options.list == True and options.dim == None and options.learn == None and options.event == False:

        #
        #    LIST
        #

        print 'Number of devices:', td.getNumberOfDevices()
        for i in range(td.getNumberOfDevices()):
            deviceId = td.getDeviceId(i)
            cmd = td.lastSentCommand(deviceId,
                                     methodsSupported=td.TELLSTICK_ALL,
                                     readable=True)
            value = td.lastSentValue(deviceId)
            if value:
                value = " (%s)" % value
            print deviceId, '\t', td.getName(
                deviceId), '\t\t', cmd, value, '\t\t', td.methods(
                    deviceId, methodsSupported=td.TELLSTICK_ALL, readable=True)
        sensors = td.getSensors()
        print '\nNumber of sensors:', len(sensors)
        for s in sensors:
            print "Sensor: %-40s %-11s: %12s %s" % (
                "%s.%s.%s" % (s.protocol, s.model, s.id),
                td.sensorValueTypeReadable[s.dataType] or "Unknown", s.value,
                datetime.fromtimestamp(
                    s.timestamp).strftime('%Y-%m-%d %H:%M:%S'))
        print '\n'

    elif options.on == None and options.off == None and options.bell == None and options.list == False and options.dim != None and options.dimlevel != None and options.learn == None and options.event == False:

        #
        #    DIM