Esempio n. 1
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
Esempio n. 2
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
Esempio n. 3
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 ''

    
Esempio n. 4
0
 def getDeviceId(self,i):
     return td.getDeviceId(i)
Esempio n. 5
0
            res = td.getErrorString(resCode)
        else:
            res = 'Success'

        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:
Esempio n. 6
0
        if resCode != 0:
            res = td.getErrorString(resCode)
        else:
            res = 'Success'

        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,
                                     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,