Exemplo n.º 1
0
def buildings_building_id_sensors_post(buildingId):
    """ method to post a sensor using sensor id """
    try:
        building = Building.get(buildingId)
    except Exception:
        return 'Building with id=%s does not exist.' % (buildingId)
    newid = str(uuid.uuid4())
    newobj = Sensor(id=newid, buildingId=buildingId)
    newobj.save()
    return newobj.attribute_values
Exemplo n.º 2
0
def buildings_building_id_sensors_post(buildingId) -> str:
    try:
        building = Building.get(buildingId)
    except Exception as e:
        print(e)
        return 'Building with id=%s does not exist.' % (buildingId)
    newID = str(uuid.uuid4())
    newObj = Sensor(id=newID, buildingId=buildingId)
    newObj.save()
    return newObj.attribute_values
def buildings_building_id_sensors_post(buildingId):
    """ method to post a sensor using sensor id """
    try:
        building = Building.get(buildingId)
    except Exception:
        return 'Building with id=%s does not exist.' % (buildingId)
    newid = str(uuid.uuid4())
    newobj = Sensor(id=newid, buildingId=buildingId)
    newobj.save()
    return newobj.attribute_values
Exemplo n.º 4
0
def buildings_building_id_sensors_post(buildingId) -> str:
    try:
        building = Building.get(buildingId)
    except Exception as e:
        print(e)
        return 'Building with id=%s does not exist.' % (buildingId)
    newID = str(uuid.uuid4())
    newObj = Sensor(id=newID, buildingId=buildingId)
    newObj.save()
    return newObj.attribute_values
def sensors_post(newSensor=[]):
    """ method to post a new sensor """
    newid = str(uuid.uuid4())
    sensor = Sensor(id=newid)
    sensor.save()
    #sensorobj.save()
    #sensor = Sensor.get(newid)
    if newSensor:
        attributes = sensor.attribute_values.keys()
        for key in newSensor.keys():
            if key in attributes and key != 'id':
                if newSensor[key] == '':
                    sensor.update_item(key, value=' ', action='PUT')
                else:
                    sensor.update_item(key, value=newSensor[key], action='PUT')
    return sensor.attribute_values
Exemplo n.º 6
0
def sensors_post() -> str:
    newID = str(uuid.uuid4())
    sensorObj = Sensor(id=newID)
    sensorObj.save()
    return sensorObj.attribute_values
Exemplo n.º 7
0
def sensors_post():
    """ method to post a new sensor """
    newid = str(uuid.uuid4())
    sensorobj = Sensor(id=newid)
    sensorobj.save()
    return sensorobj.attribute_values
Exemplo n.º 8
0
from storageModels import Sensor, Building

mySens = Sensor(sensorId='yet another id',
                sensorType='type',
                buildingId='theHASH',
                roomId='another hash',
                data=['data', 'moredata'])
mySens.save()

newBuilding = Building(id='one other id something',
                       buildingId='1',
                       building='Franks shop',
                       rooms=['a', 'b'],
                       owner=1,
                       users=['a', 'b'],
                       sensors=['a', 'b'],
                       robots=['a', 'b'])
newBuilding.save()
Exemplo n.º 9
0
def sensors_post():
    """ method to post a new sensor """
    newid = str(uuid.uuid4())
    sensorobj = Sensor(id=newid)
    sensorobj.save()
    return sensorobj.attribute_values
Exemplo n.º 10
0
def sensors_post() -> str:
    newID = str(uuid.uuid4())
    sensorObj = Sensor(id=newID)
    sensorObj.save()
    return sensorObj.attribute_values
Exemplo n.º 11
0
from storageModels import Sensor, Building


mySens = Sensor(sensorId = 'yet another id',
                sensorType='type',
                buildingId = 'theHASH',
                roomId = 'another hash',
                data=['data', 'moredata'])
mySens.save()


newBuilding = Building(id = 'one other id something',
                       buildingId = '1',
                       building='Franks shop',
                       rooms = ['a', 'b'],
                       owner = 1,
                       users = ['a', 'b'],
                       sensors = ['a', 'b'],
                       robots = ['a', 'b'])
newBuilding.save()