How to end infinite while loop from uplink

Thanks for the reply! i am not sure to fully understand, sorry i am a new programmer (and programming for fun).

Here is my main uplink code, i am not sure how to include the thread and call it on anvil server module.

image

That calls the open or close function as shown below (i also included open and close button on my anvil server, this i why i have separate functions):

image

Again, my idea is to be able to stop the auto mode, maybe the infinite loop is not the best way? The auto mode simply opens or closes the door at sunraise/sunset.

In addition, i want to modify a text label using data binding. I tried to create a data table in my anvil server that is modified with the door_status variable.
1- how can i modify the door_status value in my table? do i need to add a row each time>
2- how to have the door_status value displayed as my text label (text label will change depending on door_status value)?