Skip to content
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

[Feature Request] Turn off charging when batt hits 95% #4

Open
ebabel opened this issue Oct 26, 2017 · 4 comments
Open

[Feature Request] Turn off charging when batt hits 95% #4

ebabel opened this issue Oct 26, 2017 · 4 comments

Comments

@ebabel
Copy link
Collaborator

ebabel commented Oct 26, 2017

via Kasa (TP-Link) or ?

@ebabel
Copy link
Collaborator Author

ebabel commented Oct 26, 2017

Jay Fornow on on Facebook says:
It's a simple formula.

The amount of minutes to set in timer = (Y - Z) x 22.5 seconds /60 seconds

Y=Desired Percentage
Z=Current Battery Percentage.

For example: If I want to stop charging the battery at 96% and current charge is 40%.

(96-40)x 22.5/60= 21 minutes

@ebabel
Copy link
Collaborator Author

ebabel commented Oct 26, 2017

Looks like we can connect to Kasa via IFTTT.com, too bad Kasa can't just take an intent

@kwatkins
Copy link
Collaborator

Oh wow, interesting... yeah we can add intents/broadcasts/a service?/tasker integration etc for the stats, not sure what we can do past that. For what it's worth, I have a raspberry pi running home assistant for controlling/automating my house and created a sensor, a script, that uses ble tools to pull the % directly. Then I can create actions based on that, like turning off the charging.
image

onewheel_stats.py

#!/usr/bin/env python3
import argparse,subprocess

text = 'This program returns stats from an Onewheel BLE device'
parser = argparse.ArgumentParser(description = text)
parser.add_argument("address",help="mac address of device")
parser.add_argument("--battery", help="get battery level",action="store_true")
args = parser.parse_args()


if __name__ == "__main__":
    if args.battery:
        p = subprocess.Popen("/usr/bin/gatttool -b {0} --char-read --handle=0x0021".format(args.address), stdout=subprocess.PIPE, shell=True)
        (output, err) = p.communicate()
        p_status = p.wait()

        p_out = output.decode('ascii').split()
        if len(p_out) > 0:
            r = '{0}{1}'.format(p_out[2],p_out[3])
            print(int(r,16))
        else:
            print(-1)

@kwatkins
Copy link
Collaborator

kwatkins commented Nov 2, 2017

Hmm also the protocol used for the smart plug been reversed engineered https://github.com/softScheck/tplink-smartplug/blob/master/tddp-client/tddp-client.py - so there is the possibility of adding a shared preference option of "if battery level gets to 100% tell smart plug at 192.168.86.20 to turn off". That being said, connecting into IFTTT would open it up to their services and broader triggers etc. Might be a bit of work to getting the OW app added as a "service", a workflow that would work would be creating a custom notification of battery % and use the IFTTT "android device" service & "Notification received from a specific app" -> "Filter by notification keyword".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants