fix the issue of motor on when the water is 90#11
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a water level motor control issue when water reaches 90% capacity by correcting the minimum water level calculation and refining motor control logic.
- Fixed minimum water level calculation to use
BOTTOM_FULL_DISTANCEdirectly instead of subtracting fromTANK_HEIGHT - Removed automatic motor OFF behavior in auto mode to prevent premature shutoff
- Updated configuration comment for clarity
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| config.yaml | Version bump to 1.3.2.1009 |
| Scripts/Utility.py | Fixed minimum water level calculation logic |
| Scripts/Main.py | Removed automatic motor OFF logic and clarified config comment |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| else: | ||
| print(f"Unknown mode '{currentMode}', defaulting to Auto mode behavior") | ||
| writeRtDb(mode = "Auto") |
There was a problem hiding this comment.
The removal of the motor OFF logic in lines 262-265 creates incomplete control flow. When the tank level is OK in auto mode, there's no logic to turn the motor OFF, which could lead to overflow conditions.
3038750 to
fb3ba59
Compare
Signed-off-by: Arghya Biswas <arghyabiswas05@gmail.com>
fb3ba59 to
5f0510a
Compare
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| while True: | ||
| distance = readDistance(gpio, ULTRASONIC_TRIG, ULTRASONIC_ECHO) | ||
| if distanceIsValid(distance, lastDistance): | ||
| print(f"Distance: {distance} cm") | ||
| lastDistance = distance | ||
| break | ||
| else: | ||
| print(f"Invalid distance reading: {distance} cm; SKIP;") | ||
| time.sleep(0.5) |
There was a problem hiding this comment.
The infinite while loop has no timeout mechanism. If the sensor consistently returns invalid readings, this will block the main thread indefinitely. Add a maximum retry counter or timeout to prevent infinite loops.
| gpio.output(MOTOR_PIN, False) | ||
| motorStatus = "OFF" | ||
| print("Auto mode - Tank level OK: Motor OFF") | ||
| print(f"Auto mode - Tank level OK: No Motor Update; Currently Motor {motorStatus}") |
There was a problem hiding this comment.
The motor status is not being updated in the database when the tank level is OK. This could lead to inconsistent state between the actual motor control logic and the stored motor status. Consider calling writeRtDb(motorStatus=motorStatus) to maintain consistency.
| print(f"Auto mode - Tank level OK: No Motor Update; Currently Motor {motorStatus}") | |
| print(f"Auto mode - Tank level OK: No Motor Update; Currently Motor {motorStatus}") | |
| writeRtDb(motorStatus=motorStatus) |
No description provided.