Partly a question on efficiency and a piece of code that others might find useful.
I have a block of conditional code that governs when some events should run (based on sensor inputs), however one of these events is a pump that recharges the main pressure tank (Aeroponics)
My cut off points in the code below are 22:16 (to stop triggering) and then begin again at 7:16)
So for anyone not familiar with the code in the basic form - it means that after 10:15pm the events will not trigger again until 7:16am…
now = datetime.datetime.now()
hour = now.hour
minute = now.minute
if ((hour >= 22 and minute <= 15) or (hour <= 7 and minute <=15)):
trigger = False
print("False value Triggered")
trigger = True
print("TRUE value Triggered")
I’m wondering if there is there a more efficient way of running the time code to determine if the events should trigger than I have here?