-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrol_charging.py
More file actions
47 lines (33 loc) · 1.31 KB
/
Copy pathcontrol_charging.py
File metadata and controls
47 lines (33 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""Example showing charging control."""
import asyncio
from keba_kecontact import KebaClient
async def main():
"""Example showing how to control charging."""
charger_ip = "192.168.1.100"
async with KebaClient(charger_ip) as client:
print("Checking charger state...")
report2 = await client.get_report_2()
print(f"Current state: {report2.state}")
print(f"Plug connected: {report2.plug}")
print("\nSetting charging current to 10A...")
await client.set_current(10000)
print("Enabling charging...")
await client.enable()
print("\nMonitoring charging for 10 seconds...")
for i in range(10):
await asyncio.sleep(1)
report3 = await client.get_report_3()
print(f" Power: {report3.power_kw:.2f} kW")
print("\nIncreasing current to 16A...")
await client.set_current(16000)
print("Monitoring for another 10 seconds...")
for i in range(10):
await asyncio.sleep(1)
report3 = await client.get_report_3()
print(f" Power: {report3.power_kw:.2f} kW")
print("\nStopping charging...")
await client.stop_charging()
print("Disabling charger...")
await client.disable()
if __name__ == "__main__":
asyncio.run(main())