def action_on(self, id): ''' Turn a lamp on @param id int ID of device in tellstick.conf ''' id = self.parseId(id) td.turnOn(id) self.deviceEventCallback(id, td.TELLSTICK_TURNON, self.maxLampValue, 1)
def SendOn(device): deviceId, deviceName = getDeviceIdAndName(device) resCode = td.turnOn(deviceId) if resCode != 0: res = td.getErrorString(resCode) else: res = 'Success' print('Turning on device:', deviceId, deviceName, '-', res)
def turnOn(self, devId): resCode = td.turnOn(devId) return self.getErrorString(resCode).lower()
(options, args) = parser.parse_args() td.init( defaultMethods = td.TELLSTICK_TURNON | td.TELLSTICK_TURNOFF ) #Application can configure to support different methods # td.init() if options.on != None and options.off == None and options.bell == None and options.list == False and options.dim == None and options.learn == None and options.event == False: # # ON # deviceId, deviceName = getDeviceIdAndName(options.on) if deviceId == -1: parser.error('unknown device: ' + options.on) resCode = td.turnOn(deviceId) if resCode != 0: res = td.getErrorString(resCode) else: res = 'Success' print 'Turning on device:', deviceId, deviceName, '-', res elif options.on == None and options.off != None and options.bell == None and options.list == False and options.dim == None and options.learn == None and options.event == False: # # OFF #
td.init(defaultMethods=td.TELLSTICK_TURNON | td.TELLSTICK_TURNOFF ) #Application can configure to support different methods # td.init() if options.on != None and options.off == None and options.bell == None and options.list == False and options.dim == None and options.learn == None and options.event == False: # # ON # deviceId, deviceName = getDeviceIdAndName(options.on) if deviceId == -1: parser.error('unknown device: ' + options.on) resCode = td.turnOn(deviceId) if resCode != 0: res = td.getErrorString(resCode) else: res = 'Success' print 'Turning on device:', deviceId, deviceName, '-', res elif options.on == None and options.off != None and options.bell == None and options.list == False and options.dim == None and options.learn == None and options.event == False: # # OFF # deviceId, deviceName = getDeviceIdAndName(options.off)