From 21d72f17b26901a6a4db5addd91ba5d621d13c9f Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Thu, 9 Jun 2022 22:41:07 +0300 Subject: [PATCH] sql_app: fixed error while setting door state Old code was taking state from device itself, meaning it never changes. Now it is set from the incoming request. Signed-off-by: HeshamTB --- sql_app/main.py | 5 +++-- sql_app/schemas.py | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sql_app/main.py b/sql_app/main.py index 1bf1b70..9c66e44 100644 --- a/sql_app/main.py +++ b/sql_app/main.py @@ -382,11 +382,12 @@ def polling_method_for_iot_entity(request: schemas.IotDoorPollingRequest, open_command=device.open_request, acces_list_counter=device.acces_list_counter, time_seconds=device.time_seconds, - force_close=device.force_close) + force_close=device.force_close, + state=device.state) # Reset open_request to False crud.clear_open_door_request(db, device.id) crud.clear_close_door_request(db, device.id) - crud.set_door_state(db, device, device.state) + crud.set_door_state(db, device, bool(request.state)) return response diff --git a/sql_app/schemas.py b/sql_app/schemas.py index 5f8b038..f9d8686 100644 --- a/sql_app/schemas.py +++ b/sql_app/schemas.py @@ -104,6 +104,7 @@ class IotDoorPollingResponse(BaseModel): acces_list_counter : int time_seconds : int force_close: bool + state: bool class IotMonitorRoomInfo(BaseModel): humidity : int