def sendDeviceCommand(command): success = False for d in deviceDB.find({'id':command.deviceID}): s = pickle.loads(d.get('ffObject')) s.sendCommand(command) d = pickle.dumps(s) deviceDB.update_one({'id':command.deviceID},{'$set': {'ffObject':d}, '$currentDate': {'lastModified': True}}) success = True return success
def sendEventToDevice(event): for d in deviceDB.find({'id': event.deviceID}): s = pickle.loads(d.get('ffObject')) s.sendEvent(event) d = pickle.dumps(s) deviceDB.update_one({'id': event.deviceID}, { '$set': { 'ffObject': d }, '$currentDate': { 'lastModified': True } })
def update_status(status): try: deviceID = status.get('deviceID') device = deviceDB.find_one({'id':deviceID}) if device: currentStatus = device.get('status') if currentStatus != status: deviceDB.update_one({'id':deviceID},{'$set': {'status': status}}) #, "$currentDate": {"lastModified": True}}) return True else: return False else: return True except: logging.critical('ERROR UPDATING STATUS')
def sendDeviceCommand(command): success = False for d in deviceDB.find({'id': command.deviceID}): s = pickle.loads(d.get('ffObject')) s.sendCommand(command) d = pickle.dumps(s) deviceDB.update_one({'id': command.deviceID}, { '$set': { 'ffObject': d }, '$currentDate': { 'lastModified': True } }) success = True return success
def update_status(status): try: deviceID = status.get('deviceID') device = deviceDB.find_one({'id': deviceID}) if device: currentStatus = device.get('status') if currentStatus != status: deviceDB.update_one( {'id': deviceID}, {'$set': { 'status': status }}) #, "$currentDate": {"lastModified": True}}) return True else: return False else: return True except: logging.critical('ERROR UPDATING STATUS')
def sendEventToDevice(event): for d in deviceDB.find({'id':event.deviceID}): s = pickle.loads(d.get('ffObject')) s.sendEvent(event) d = pickle.dumps(s) deviceDB.update_one({'id':event.deviceID},{'$set': {'ffObject':d}, '$currentDate': {'lastModified': True}})