Skip to content

Added Battery Notification Script#746

Merged
avinashkranjan merged 9 commits into
avinashkranjan:masterfrom
pankaj892:master
Apr 14, 2021
Merged

Added Battery Notification Script#746
avinashkranjan merged 9 commits into
avinashkranjan:masterfrom
pankaj892:master

Conversation

@pankaj892
Copy link
Copy Markdown
Contributor

Description

This script notifies the user about the battery percentage left

Fixes #727

Have you read the Contributing Guidelines on Pull Requests?

  • Yes
  • No

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Documentation Update

Checklist:

  • My code follows the style guidelines(Clean Code) of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have created a helpful and easy to understand README.md
  • My documentation follows Template for README.md
  • My changes generate no new warnings
  • I have added tests/screenshots(if any) that prove my fix is effective or that my feature works.

Comment thread Battery-Notification/README.md
Comment on lines +14 to +16
```
## Run the program using command

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
```
## Run the program using command

Run the program using command

@santushtisharma10
Copy link
Copy Markdown
Contributor

@pankaj892 the code is working fine, just a few changes in readme file

@santushtisharma10 santushtisharma10 added the minor-change-not-bug Suggested a minor change in code, not a bug label Mar 26, 2021
pankaj892 and others added 2 commits March 26, 2021 21:31
Co-authored-by: Santushti Sharma <60578091+santushtisharma10@users.noreply.github.com>
@pankaj892
Copy link
Copy Markdown
Contributor Author

@santushtisharma10 I have made the necessary changes please review them

Copy link
Copy Markdown
Contributor

@santushtisharma10 santushtisharma10 left a comment

Choose a reason for hiding this comment

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

@pankaj892 💯

@santushtisharma10
Copy link
Copy Markdown
Contributor

@Kushal997-das

@santushtisharma10 santushtisharma10 added next review needed Approved by some mentors, more approvals needed and removed minor-change-not-bug Suggested a minor change in code, not a bug labels Mar 27, 2021
Copy link
Copy Markdown

@Kushal997-das Kushal997-das left a comment

Choose a reason for hiding this comment

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

LGTM 💯

Comment thread SCRIPTS.md
@@ -93,3 +93,4 @@
| 89\. | Voice-Assistant | Voice-Assistant Bot | [Take Me](https://github.com/avinashkranjan/Amazing-Python-Scripts/tree/master/Voice-Assistant) | [Avinash .K. Rajan](https://github.com/avinashkranjan) |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove this modification. We are looking to automate this process and therefore this updation is not needed as of now

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@kaustubhgupta as mentioned by you i have removed the modification please review and let me know if any further changes are required

Comment thread SCRIPTS.md Outdated
| 89\. | Voice-Assistant | Voice-Assistant Bot | [Take Me](https://github.com/avinashkranjan/Amazing-Python-Scripts/tree/master/Voice-Assistant) | [Avinash .K. Rajan](https://github.com/avinashkranjan) |
| 90\. | Website-Status-Checker | This script will check the status of the web address which you will input | [Take Me](https://github.com/avinashkranjan/Amazing-Python-Scripts/tree/master/Website-Status-Checker) | [Avinash .K. Rajan](https://github.com/avinashkranjan) |
| 91\. | Movie-Genre-Prediction-Chatbot | An chatbot will predict the genre of the movie based on the input text. | [Take Me](https://github.com/avinashkranjan/Amazing-Python-Scripts/tree/master/Movie-Genre-Prediction-Chatbot) | [Hritik Jaiswal](https://github.com/hritik5102) |
| 91\. | Movie-Genre-Prediction-Chatbot | An chatbot will predict the genre of the movie based on the input text. | [Take Me](https://github.com/avinashkranjan/Amazing-Python-Scripts/tree/master/Movie-Genre-Prediction-Chatbot) | [Hritik Jais
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you have modified the file, revert all the changes in this file to normal

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@kaustubhgupta I have made the changes to the file please review

@kaustubhgupta kaustubhgupta added the minor-change-not-bug Suggested a minor change in code, not a bug label Mar 28, 2021
@kaustubhgupta kaustubhgupta removed the minor-change-not-bug Suggested a minor change in code, not a bug label Mar 28, 2021
Comment thread Battery-Notification/Battery-Notification.py
@antrikshmisri
Copy link
Copy Markdown
Contributor

@pankaj892 You just added a timeout but didn't implement the logic. What you need to do is, add logic to only show notification when battery percentage changes. TO avoid the script spamming notification, add a time.sleep just before you compare the current level with the previous level. If any doubt feel free to ask

@pankaj892
Copy link
Copy Markdown
Contributor Author

@antrikshmisri I am confused as to how will i determine that there is a change in battery since when i try to measure battery after a delay i am not able to device a logic to find change.I know this doubt might seem silly.Please Help

@kaustubhgupta
Copy link
Copy Markdown
Contributor

@antrikshmisri I am confused as to how will i determine that there is a change in battery since when i try to measure battery after a delay i am not able to device a logic to find change.I know this doubt might seem silly.Please Help

Let me elaborate, store the previous battery level in a variable. When the time for giving notifications comes, compare that time battery level with that variable and define a threshold for this. If the diff in battery level is less than that threshold, don't show notification else show battery status and update that variable with the current level. Dry run example:

threshold = 5%

time: 8:48, battery level: 45%
prev_battery = 45

time: 8:50, battery level: 42%
|42 - 45| = 3 < 5, therefore no notification sent

time: 8:53, battery level: 39%
|39 - 45| = 6 > 5, send notification that "39% battery left"
prev_battery = 39

and so on...

Take the threshold value input from user before running loop

@antrikshmisri
Copy link
Copy Markdown
Contributor

@antrikshmisri I am confused as to how will i determine that there is a change in battery since when i try to measure battery after a delay i am not able to device a logic to find change.I know this doubt might seem silly.Please Help

Let me elaborate, store the previous battery level in a variable. When the time for giving notifications comes, compare that time battery level with that variable and define a threshold for this. If the diff in battery level is less than that threshold, don't show notification else show battery status and update that variable with the current level. Dry run example:

threshold = 5%

time: 8:48, battery level: 45%
prev_battery = 45

time: 8:50, battery level: 42%
|42 - 45| = 3 < 5, therefore no notification sent

time: 8:53, battery level: 39%
|39 - 45| = 6 > 5, send notification that "39% battery left"
prev_battery = 39

and so on...

Take the threshold value input from user before running loop

@pankaj892 implement the algorithm as suggested by @kaustubhgupta

@kaustubhgupta
Copy link
Copy Markdown
Contributor

@pankaj892 did you got my point?

@pankaj892
Copy link
Copy Markdown
Contributor Author

pankaj892 commented Apr 9, 2021

@kaustubhgupta I partly understood what you said. As you said I created two different variables holding current battery and battery after time.sleep but I am confused as to where should i use the while loop after comparing i should use the loop to print the battery percentage or i should start the loop before comparing itself.please help me on this?

@kaustubhgupta
Copy link
Copy Markdown
Contributor

start the loop before comparing

@kaustubhgupta kaustubhgupta added enhancement New feature or request hold Needs a second thought and removed next review needed Approved by some mentors, more approvals needed labels Apr 10, 2021
@pankaj892
Copy link
Copy Markdown
Contributor Author

@antrikshmisri As suggested by you I have made the changes to the script please review.Also @kaustubhgupta thanks for helping

Comment thread Battery-Notification/Battery-Notification.py
@kaustubhgupta kaustubhgupta added bug Something isn't working and removed enhancement New feature or request hold Needs a second thought labels Apr 11, 2021
pankaj892 and others added 2 commits April 11, 2021 12:25
Co-authored-by: Kaustubh Gupta <kaustubhgupta1828@gmail.com>
@pankaj892
Copy link
Copy Markdown
Contributor Author

@kaustubhgupta I have made the changes as per your suggestions please review.

@kaustubhgupta kaustubhgupta added next review needed Approved by some mentors, more approvals needed and removed bug Something isn't working labels Apr 12, 2021
@kaustubhgupta kaustubhgupta requested review from antrikshmisri and removed request for antrikshmisri April 12, 2021 05:36
@kaustubhgupta kaustubhgupta added Approved PR Approved and Ready to Merge gssoc23 Issues created for/by the GirlScript Summer of Code'23 Participants level1 Wiki or Major Documentation Work and removed next review needed Approved by some mentors, more approvals needed labels Apr 14, 2021
@avinashkranjan avinashkranjan merged commit 4a8bf7b into avinashkranjan:master Apr 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved PR Approved and Ready to Merge gssoc23 Issues created for/by the GirlScript Summer of Code'23 Participants level1 Wiki or Major Documentation Work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Battery percentage notification

6 participants