Skip to content

fix the issue of motor on when the water is 90#11

Merged
arghyabi merged 1 commit into
masterfrom
fix_motor_on_during_less_90
Sep 26, 2025
Merged

fix the issue of motor on when the water is 90#11
arghyabi merged 1 commit into
masterfrom
fix_motor_on_during_less_90

Conversation

@arghyabi
Copy link
Copy Markdown
Owner

No description provided.

@arghyabi arghyabi requested a review from Copilot September 26, 2025 09:37
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_DISTANCE directly instead of subtracting from TANK_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.

Comment thread Scripts/Main.py
Comment on lines 262 to 264
else:
print(f"Unknown mode '{currentMode}', defaulting to Auto mode behavior")
writeRtDb(mode = "Auto")
Copy link

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@arghyabi arghyabi force-pushed the fix_motor_on_during_less_90 branch from 3038750 to fb3ba59 Compare September 26, 2025 09:47
Signed-off-by: Arghya Biswas <arghyabiswas05@gmail.com>
@arghyabi arghyabi force-pushed the fix_motor_on_during_less_90 branch from fb3ba59 to 5f0510a Compare September 26, 2025 09:50
@arghyabi arghyabi requested a review from Copilot September 26, 2025 09:50
@arghyabi arghyabi merged commit 7d608c1 into master Sep 26, 2025
1 check passed
@arghyabi arghyabi deleted the fix_motor_on_during_less_90 branch September 26, 2025 09:53
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment thread Scripts/Main.py
Comment on lines +208 to +216
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)
Copy link

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment thread Scripts/Main.py
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}")
Copy link

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
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)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants