Beispiel #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
Beispiel #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
            }
        })
Beispiel #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')
Beispiel #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
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')
Beispiel #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}})