Skip to content

Instantly share code, notes, and snippets.

@rpoisel
Last active October 10, 2023 06:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rpoisel/e8587f9ed83e4f86cee4d134c38bd4ad to your computer and use it in GitHub Desktop.
Save rpoisel/e8587f9ed83e4f86cee4d134c38bd4ad to your computer and use it in GitHub Desktop.
This snippets sets the amperage of a NRGkick charging cable
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