def getDeviceIdAndName(input): if (input.isdigit()): deviceId = int(input) deviceName = td.getName(int(input)) else: deviceId, deviceName = td.getDeviceIdFromStr(input) return deviceId, deviceName
def getDeviceIdAndName(In): if (In.isdigit()): deviceId = int(In) deviceName = td.getName(int(In)) else: deviceId, deviceName = td.getDeviceIdFromStr(In) return deviceId, deviceName
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
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 ''
def getName(self,devId): return td.getName(devId)
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 )
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 )
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')
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)
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)
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