Example #1
0
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
Example #2
0
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
            }
        })
Example #3
0
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')
Example #4
0
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
Example #5
0
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')
Example #6
0
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}})