-
Notifications
You must be signed in to change notification settings - Fork 0
Fix motor maunall control at night #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||||||
|
|
@@ -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() | ||||||||||
|
|
@@ -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: | ||||||||||
| 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): | ||||||||||
|
|
@@ -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!") | ||||||||||
|
||||||||||
| 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,5 +2,5 @@ | |
| ULTRASONIC_TRIG = 40 | ||
| ULTRASONIC_ECHO = 38 | ||
|
|
||
| VALVE1_PIN = 36 | ||
| VALVE2_PIN = 37 | ||
| VALVE1_PIN = 11 | ||
| VALVE2_PIN = 13 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| appVersion: 1.2.0.1003 | ||
| appVersion: 1.2.1.1004 | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.