From 21aef6ec6c5213747f7a5a28c46147ad90916bbf Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Sat, 11 Jun 2022 20:28:39 +0300 Subject: [PATCH] sql_app: update monitor column Signed-off-by: HeshamTB --- sql_app/crud.py | 9 +++++++++ sql_app/main.py | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/sql_app/crud.py b/sql_app/crud.py index 3c16713..8fbd404 100644 --- a/sql_app/crud.py +++ b/sql_app/crud.py @@ -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) diff --git a/sql_app/main.py b/sql_app/main.py index f089f16..307c8a4 100644 --- a/sql_app/main.py +++ b/sql_app/main.py @@ -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)