Hi @GG07, as @Gunner stated, with this piece of code, the variable “oldstatus” changes depending on last mode selected before click on “Manual/Auto” button to turn on/off the light manually.
This way, if I press the “Manual/Auto” button again to change to “Auto”, the function “restorelastbuttonpressed” remember your last choice “Monday-Friday”, “Saturday-Sunday”, “All days” or “Uptoyou” mode and fix the buttons accordingly
Please, check the full code cause only the part you are showing is not doing all the process.
HTH