Last active
October 10, 2023 06:51
-
-
Save rpoisel/e8587f9ed83e4f86cee4d134c38bd4ad to your computer and use it in GitHub Desktop.
This snippets sets the amperage of a NRGkick charging cable
This file contains 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
from typing import Union | |
import asyncio | |
from bleak import BleakClient | |
from bleak.backends.device import BLEDevice | |
async def main(address: Union[BLEDevice, str]) -> None: | |
async with BleakClient(address) as client: | |
await client.pair() | |
print(client.is_connected) | |
for amperage in range(6, 13 + 1): | |
await client.write_gatt_char( | |
char_specifier='ecbb79c5-6972-47ce-abbe-787a003c4f5d', | |
data=bytes.fromhex( | |
f'0200420a2c0802180120022a2431396234656165382d333239662d343266352d396239642d656361366133333734353964120a0a0865363761653239391a0622040a0208{amperage:02x}' | |
), | |
response=True | |
) | |
await asyncio.sleep(1) | |
if __name__ == "__main__": | |
address = "34:94:54:xx:xx:xx" # CHANGE ME | |
asyncio.run(main(address)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment