Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Scripts/Common.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

MORNING_7AM = 7
MORNING_8AM = 8
AFTERNOON_5PM = 17
EVENING_7PM = 19
EVENING_8PM = 20
NIGHT_10PM = 22
Expand Down
33 changes: 22 additions & 11 deletions Scripts/Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ def main():
valve2On = False
valve1StartTime = 0
valve2StartTime = 0
morningRunDone = False
eveningRunDone = False
morning8RunDone = False
aftrn5RunDone = False
evening9RunDone = False
motorStatus = "OFF"
lastMotorStatus = "OFF"
waterLevel = 0
Expand All @@ -90,8 +91,9 @@ def main():

# Reset daily flags
if now.day != lastDay:
morningRunDone = False
eveningRunDone = False
morning8RunDone = False
evening9RunDone = False
aftrn5RunDone = False
lastDay = now.day

rtDb = readRtDb()
Expand All @@ -104,26 +106,37 @@ def main():
print(f"Updated valve durations: Valve1={valve1Duration} min, Valve2={valve2Duration} min")

# Morning valve operation
if now.hour == MORNING_8AM and not morningRunDone:
if now.hour == MORNING_8AM and not morning8RunDone:
print("Morning run: Activating valves.")
gpio.output(VALVE1_PIN, True)
gpio.output(VALVE2_PIN, True)
valve1On = True
valve2On = True
valve1StartTime = currentTime
valve2StartTime = currentTime
morningRunDone = True
morning8RunDone = True

# Afternoon valve operation
if now.hour == AFTERNOON_5PM and not aftrn5RunDone:
print("Afternoon run: Activating valves.")
gpio.output(VALVE1_PIN, True)
gpio.output(VALVE2_PIN, True)
valve1On = True
valve2On = True
valve1StartTime = currentTime
valve2StartTime = currentTime
aftrn5RunDone = True

# Evening valve operation
if now.hour == EVENING_8PM and not eveningRunDone:
if now.hour == NIGHT_9PM and not evening9RunDone:
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable name 'evening9RunDone' is inconsistent with the timing. Since this runs at NIGHT_9PM (9 PM), it should be named 'night9RunDone' to match the actual execution time.

Copilot uses AI. Check for mistakes.
print("Evening run: Activating valves.")
gpio.output(VALVE1_PIN, True)
gpio.output(VALVE2_PIN, True)
valve1On = True
valve2On = True
valve1StartTime = currentTime
valve2StartTime = currentTime
eveningRunDone = True
evening9RunDone = True

# Check to turn off valves
if valve1On and (currentTime - valve1StartTime >= valve1Duration * 60):
Expand Down Expand Up @@ -156,9 +169,7 @@ def main():
# Automatic logic
motorStatus = "OFF"
if isNightTime(): # Check if it's night time between 10 PM and 7 AM
gpio.output(MOTOR_PIN, False)
motorStatus = "OFF"
print("Night time: Motor OFF")
print("Night time: Automatic motor control disabled. Only manual control available!")
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The motor is not explicitly turned off during night time. The previous logic ensured the motor was turned off with gpio.output(MOTOR_PIN, False), but this line only prints a message. This could leave the motor running automatically during night hours.

Suggested change
print("Night time: Automatic motor control disabled. Only manual control available!")
print("Night time: Automatic motor control disabled. Only manual control available!")
gpio.output(MOTOR_PIN, False)
motorStatus = "OFF"

Copilot uses AI. Check for mistakes.
preNightFillActive = False
else:
if now.hour == NIGHT_9PM and waterLevel < ONE_THIRD_LEVEL and not preNightFillActive:
Expand Down
4 changes: 2 additions & 2 deletions Scripts/PinDescription.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
ULTRASONIC_TRIG = 40
ULTRASONIC_ECHO = 38

VALVE1_PIN = 36
VALVE2_PIN = 37
VALVE1_PIN = 11
VALVE2_PIN = 13
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
appVersion: 1.2.0.1003
appVersion: 1.2.1.1004