Mar-02-2023, 12:05 PM
Time is essentially a number, but you treat it as a string. 2am is '02:00:00' and 7am is '07:00:00'. Both of these are less than '2:00:00', so your test will never be True. Treat time like a datetime object, as Griboulilis recommends, and this should work. Kind of.
If you want to turn lights on at 2am and off at 7am, why not schedule an event to turn the lights on at 2am and off at 7am? Have you looked at the sched library?
https://docs.python.org/3/library/sched.html
If you want to turn lights on at 2am and off at 7am, why not schedule an event to turn the lights on at 2am and off at 7am? Have you looked at the sched library?
https://docs.python.org/3/library/sched.html