sql_app: update monitor column

Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
HeshamTB 2022-06-11 20:28:39 +03:00
parent 20dfa6dcc4
commit 21aef6ec6c
2 changed files with 11 additions and 1 deletions

View File

@ -217,6 +217,15 @@ def record_room_sensor_data(db: Session, entry: schemas.MonitorUpdateReadings,
db.commit()
db.refresh(db_item)
monitor.humidity = entry.humidity
monitor.temperature = entry.temperature
monitor.people = entry.people
monitor.smoke_sensor_reading = entry.smoke_sensor_reading
db.add(monitor)
db.commit()
db.refresh(monitor)
def increment_door_access_list_counter(db: Session, iot_entity: models.IotEntity):
iot_entity.acces_list_counter = iot_entity.acces_list_counter + 1
db.add(iot_entity)

View File

@ -401,8 +401,9 @@ def polling_method_for_room_monitor(request: schemas.MonitorUpdateReadings,
detail="Could not validate credentials")
crud.record_room_sensor_data(db, request, device)
if request.temperature >= EMERG_TEMP or request.smoke_sensor_reading >= EMERG_SMOKE:
crud.record_emergancy_entry(db, request, device.id)
print("********EMERGENCY AT %s********" % device.description)
# TODO: Get door, and open
crud.record_emergancy_entry(db, request, device.id)
# Call into a hook to notify with room and people
print(request)