anker-prime-driver 0.7.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. anker_prime_driver-0.7.3/LICENSE +22 -0
  2. anker_prime_driver-0.7.3/PKG-INFO +113 -0
  3. anker_prime_driver-0.7.3/pyproject.toml +83 -0
  4. anker_prime_driver-0.7.3/readme.md +81 -0
  5. anker_prime_driver-0.7.3/setup.cfg +4 -0
  6. anker_prime_driver-0.7.3/src/anker_prime_driver.egg-info/PKG-INFO +113 -0
  7. anker_prime_driver-0.7.3/src/anker_prime_driver.egg-info/SOURCES.txt +90 -0
  8. anker_prime_driver-0.7.3/src/anker_prime_driver.egg-info/dependency_links.txt +1 -0
  9. anker_prime_driver-0.7.3/src/anker_prime_driver.egg-info/entry_points.txt +2 -0
  10. anker_prime_driver-0.7.3/src/anker_prime_driver.egg-info/requires.txt +7 -0
  11. anker_prime_driver-0.7.3/src/anker_prime_driver.egg-info/top_level.txt +1 -0
  12. anker_prime_driver-0.7.3/src/ankerprime/__init__.py +6 -0
  13. anker_prime_driver-0.7.3/src/ankerprime/__main__.py +8 -0
  14. anker_prime_driver-0.7.3/src/ankerprime/api/__init__.py +7 -0
  15. anker_prime_driver-0.7.3/src/ankerprime/api/ble.py +54 -0
  16. anker_prime_driver-0.7.3/src/ankerprime/api/cloud.py +192 -0
  17. anker_prime_driver-0.7.3/src/ankerprime/cli/__init__.py +1 -0
  18. anker_prime_driver-0.7.3/src/ankerprime/cli/aliases.py +206 -0
  19. anker_prime_driver-0.7.3/src/ankerprime/cli/base.py +420 -0
  20. anker_prime_driver-0.7.3/src/ankerprime/cli/commands/__init__.py +40 -0
  21. anker_prime_driver-0.7.3/src/ankerprime/cli/commands/account.py +97 -0
  22. anker_prime_driver-0.7.3/src/ankerprime/cli/commands/bluetooth.py +46 -0
  23. anker_prime_driver-0.7.3/src/ankerprime/cli/commands/chargers.py +123 -0
  24. anker_prime_driver-0.7.3/src/ankerprime/cli/commands/control.py +309 -0
  25. anker_prime_driver-0.7.3/src/ankerprime/cli/commands/energy.py +75 -0
  26. anker_prime_driver-0.7.3/src/ankerprime/cli/commands/reading.py +131 -0
  27. anker_prime_driver-0.7.3/src/ankerprime/cli/config.py +130 -0
  28. anker_prime_driver-0.7.3/src/ankerprime/cli/main.py +124 -0
  29. anker_prime_driver-0.7.3/src/ankerprime/cli/parsing.py +121 -0
  30. anker_prime_driver-0.7.3/src/ankerprime/cli/render.py +281 -0
  31. anker_prime_driver-0.7.3/src/ankerprime/cli/style.py +167 -0
  32. anker_prime_driver-0.7.3/src/ankerprime/cli/terminal.py +45 -0
  33. anker_prime_driver-0.7.3/src/ankerprime/cloud/__init__.py +19 -0
  34. anker_prime_driver-0.7.3/src/ankerprime/cloud/auth.py +278 -0
  35. anker_prime_driver-0.7.3/src/ankerprime/cloud/client.py +317 -0
  36. anker_prime_driver-0.7.3/src/ankerprime/cloud/credential_files.py +70 -0
  37. anker_prime_driver-0.7.3/src/ankerprime/cloud/crypto.py +75 -0
  38. anker_prime_driver-0.7.3/src/ankerprime/cloud/http.py +38 -0
  39. anker_prime_driver-0.7.3/src/ankerprime/cloud/payload.py +245 -0
  40. anker_prime_driver-0.7.3/src/ankerprime/cloud/regions.py +137 -0
  41. anker_prime_driver-0.7.3/src/ankerprime/device/__init__.py +1 -0
  42. anker_prime_driver-0.7.3/src/ankerprime/device/a2345.py +675 -0
  43. anker_prime_driver-0.7.3/src/ankerprime/device/a2687.py +730 -0
  44. anker_prime_driver-0.7.3/src/ankerprime/device/base.py +226 -0
  45. anker_prime_driver-0.7.3/src/ankerprime/energy/__init__.py +7 -0
  46. anker_prime_driver-0.7.3/src/ankerprime/energy/meter.py +105 -0
  47. anker_prime_driver-0.7.3/src/ankerprime/energy/recorder.py +187 -0
  48. anker_prime_driver-0.7.3/src/ankerprime/energy/store.py +144 -0
  49. anker_prime_driver-0.7.3/src/ankerprime/interfaces/__init__.py +25 -0
  50. anker_prime_driver-0.7.3/src/ankerprime/interfaces/channel.py +60 -0
  51. anker_prime_driver-0.7.3/src/ankerprime/interfaces/charger.py +184 -0
  52. anker_prime_driver-0.7.3/src/ankerprime/interfaces/http.py +41 -0
  53. anker_prime_driver-0.7.3/src/ankerprime/interfaces/mqtt.py +112 -0
  54. anker_prime_driver-0.7.3/src/ankerprime/interfaces/storage.py +34 -0
  55. anker_prime_driver-0.7.3/src/ankerprime/model/__init__.py +70 -0
  56. anker_prime_driver-0.7.3/src/ankerprime/model/capabilities.py +43 -0
  57. anker_prime_driver-0.7.3/src/ankerprime/model/enums.py +160 -0
  58. anker_prime_driver-0.7.3/src/ankerprime/model/errors.py +67 -0
  59. anker_prime_driver-0.7.3/src/ankerprime/model/product.py +352 -0
  60. anker_prime_driver-0.7.3/src/ankerprime/model/serialize.py +109 -0
  61. anker_prime_driver-0.7.3/src/ankerprime/model/state.py +622 -0
  62. anker_prime_driver-0.7.3/src/ankerprime/protocol/__init__.py +1 -0
  63. anker_prime_driver-0.7.3/src/ankerprime/protocol/a2345/__init__.py +1 -0
  64. anker_prime_driver-0.7.3/src/ankerprime/protocol/a2345/codes.py +65 -0
  65. anker_prime_driver-0.7.3/src/ankerprime/protocol/a2345/commands.py +344 -0
  66. anker_prime_driver-0.7.3/src/ankerprime/protocol/a2345/frame.py +193 -0
  67. anker_prime_driver-0.7.3/src/ankerprime/protocol/a2345/messages.py +595 -0
  68. anker_prime_driver-0.7.3/src/ankerprime/protocol/a2345/settings.py +1312 -0
  69. anker_prime_driver-0.7.3/src/ankerprime/protocol/a2345/tracker.py +225 -0
  70. anker_prime_driver-0.7.3/src/ankerprime/protocol/a2687/__init__.py +1 -0
  71. anker_prime_driver-0.7.3/src/ankerprime/protocol/a2687/codes.py +125 -0
  72. anker_prime_driver-0.7.3/src/ankerprime/protocol/a2687/commands.py +129 -0
  73. anker_prime_driver-0.7.3/src/ankerprime/protocol/a2687/crypto.py +107 -0
  74. anker_prime_driver-0.7.3/src/ankerprime/protocol/a2687/frame.py +116 -0
  75. anker_prime_driver-0.7.3/src/ankerprime/protocol/a2687/handshake.py +316 -0
  76. anker_prime_driver-0.7.3/src/ankerprime/protocol/a2687/telemetry.py +360 -0
  77. anker_prime_driver-0.7.3/src/ankerprime/protocol/a2687/tlv.py +189 -0
  78. anker_prime_driver-0.7.3/src/ankerprime/protocol/a2687/tracker.py +168 -0
  79. anker_prime_driver-0.7.3/src/ankerprime/protocol/codes.py +34 -0
  80. anker_prime_driver-0.7.3/src/ankerprime/protocol/ff09.py +213 -0
  81. anker_prime_driver-0.7.3/src/ankerprime/py.typed +0 -0
  82. anker_prime_driver-0.7.3/src/ankerprime/session/__init__.py +1 -0
  83. anker_prime_driver-0.7.3/src/ankerprime/session/a2687.py +261 -0
  84. anker_prime_driver-0.7.3/src/ankerprime/storage/__init__.py +6 -0
  85. anker_prime_driver-0.7.3/src/ankerprime/storage/files.py +25 -0
  86. anker_prime_driver-0.7.3/src/ankerprime/storage/json_store.py +58 -0
  87. anker_prime_driver-0.7.3/src/ankerprime/transport/__init__.py +1 -0
  88. anker_prime_driver-0.7.3/src/ankerprime/transport/aiomqtt_client.py +97 -0
  89. anker_prime_driver-0.7.3/src/ankerprime/transport/ble.py +270 -0
  90. anker_prime_driver-0.7.3/src/ankerprime/transport/cloud.py +299 -0
  91. anker_prime_driver-0.7.3/src/ankerprime/utils.py +55 -0
  92. anker_prime_driver-0.7.3/tests/test_package.py +37 -0
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 didim99
4
+ Copyright (c) 2026 qzz0518 (Charker, https://github.com/qzz0518/Charker)
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
@@ -0,0 +1,113 @@
1
+ Metadata-Version: 2.4
2
+ Name: anker-prime-driver
3
+ Version: 0.7.3
4
+ Summary: Monitoring and control library for Anker Prime chargers
5
+ Author: didim99
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/didim99/anker-prime-driver
8
+ Project-URL: Issues, https://github.com/didim99/anker-prime-driver/issues
9
+ Keywords: anker,anker-prime,charger,home-assistant,mqtt,ble
10
+ Classifier: Development Status :: 2 - Pre-Alpha
11
+ Classifier: Framework :: AsyncIO
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Home Automation
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: >=3.11
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: aiohttp>=3.9
26
+ Requires-Dist: aiomqtt>=2.5
27
+ Requires-Dist: cryptography>=42
28
+ Provides-Extra: ble
29
+ Requires-Dist: bleak>=0.22; extra == "ble"
30
+ Requires-Dist: bleak-retry-connector>=3.5; extra == "ble"
31
+ Dynamic: license-file
32
+
33
+ # anker-prime-driver
34
+
35
+ Python library and command-line tool to monitor and control Anker Prime
36
+ chargers: per-port voltage, current and power, port switches, countdowns and
37
+ schedules, charging modes, display settings and energy counters.
38
+
39
+ > **Status: pre-alpha, under development.** The 250W cloud connection, energy
40
+ > counters and the command-line tool work. 160W (Bluetooth) support is
41
+ > implemented but untested on a real charger.
42
+
43
+ This is an unofficial project, not affiliated with or endorsed by Anker.
44
+
45
+ ## Supported chargers
46
+
47
+ | Model | Name | Connection | Verified on hardware |
48
+ |-------|--------------------------|-----------------------------------------|-----------------------------------|
49
+ | A2345 | Anker Prime Charger 250W | Anker cloud (account + MQTT over Wi-Fi) | everything except the UFCS switch |
50
+ | A2687 | Anker Prime 160W | Bluetooth LE (local) | display settings (by Charker) |
51
+
52
+ The 250W must be bound to an Anker account in the Anker app. Unverified
53
+ features are marked experimental: they follow the known protocol but are not
54
+ yet confirmed on that model. A local connection for the 250W may follow later
55
+ without changes for library users.
56
+
57
+ ## Installation
58
+
59
+ Not published yet. Once released:
60
+
61
+ ```bash
62
+ pip install anker-prime-driver # cloud (250W) support
63
+ pip install anker-prime-driver[ble] # plus Bluetooth (160W) support
64
+ ```
65
+
66
+ Requires Python 3.11 or later.
67
+
68
+ ## Quick start
69
+
70
+ ```bash
71
+ ankerprime login you@example.com DE # asks for the password
72
+ ankerprime devices
73
+ ankerprime charger add desk --serial A2345XXXXXXXXXX --default
74
+ ankerprime monitor # live readings until Ctrl+C
75
+ ankerprime output c1 off
76
+ ```
77
+
78
+ ## Documentation
79
+
80
+ - [Command-line tool](docs/cli.md): every command and option, the
81
+ configuration folder, charger selection, exit codes.
82
+ - [Library overview](docs/library.md): usage examples, layers, the `Charger`
83
+ interface, state model, connection behaviour, energy counters, errors.
84
+
85
+ ## Development
86
+
87
+ ```bash
88
+ python3.11 -m venv .venv
89
+ . .venv/bin/activate
90
+ pip install -e .[ble] -r requirements-dev.txt
91
+
92
+ ruff check
93
+ mypy
94
+ pytest
95
+ ```
96
+
97
+ Formatting and import order follow the project codestyle by hand; `ruff check`
98
+ verifies line length and common lint rules. Release builds use
99
+ `python -m build` and `twine`.
100
+
101
+ ## Credits
102
+
103
+ The protocol knowledge comes from [Charker](https://github.com/qzz0518/Charker)
104
+ by qzz0518 (MIT), a macOS/Windows app for the same chargers; this library is an
105
+ independent Python implementation of its charger connectivity. Charker in turn
106
+ credits [SolixBLE](https://github.com/flip-dots/SolixBLE),
107
+ [Anker_Prime_160W_WebBLE](https://github.com/Hyper-Beast/Anker_Prime_160W_WebBLE),
108
+ [Anker_Prime_BLE_hacking](https://github.com/atc1441/Anker_Prime_BLE_hacking) and
109
+ [anker-solix-api](https://github.com/thomluther/anker-solix-api).
110
+
111
+ ## License
112
+
113
+ MIT — see [LICENSE](LICENSE). Anker trademarks belong to their owner.
@@ -0,0 +1,83 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "anker-prime-driver"
7
+ version = "0.7.3"
8
+ description = "Monitoring and control library for Anker Prime chargers"
9
+ readme = "readme.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.11"
13
+ authors = [{ name = "didim99" }]
14
+ keywords = ["anker", "anker-prime", "charger", "home-assistant", "mqtt", "ble"]
15
+ classifiers = [
16
+ "Development Status :: 2 - Pre-Alpha",
17
+ "Framework :: AsyncIO",
18
+ "Intended Audience :: Developers",
19
+ "Operating System :: OS Independent",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3 :: Only",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: 3.13",
25
+ "Programming Language :: Python :: 3.14",
26
+ "Topic :: Home Automation",
27
+ "Typing :: Typed",
28
+ ]
29
+
30
+ # Lower bounds only: the library must coexist with Home Assistant's own pins.
31
+ dependencies = [
32
+ "aiohttp>=3.9",
33
+ "aiomqtt>=2.5",
34
+ "cryptography>=42",
35
+ ]
36
+
37
+ [project.optional-dependencies]
38
+ ble = [
39
+ "bleak>=0.22",
40
+ "bleak-retry-connector>=3.5",
41
+ ]
42
+
43
+ [project.scripts]
44
+ ankerprime = "ankerprime.cli.main:main"
45
+
46
+ [project.urls]
47
+ Homepage = "https://github.com/didim99/anker-prime-driver"
48
+ Issues = "https://github.com/didim99/anker-prime-driver/issues"
49
+
50
+ [tool.setuptools.packages.find]
51
+ where = ["src"]
52
+
53
+ [tool.setuptools.package-data]
54
+ ankerprime = ["py.typed"]
55
+
56
+ [tool.pytest.ini_options]
57
+ testpaths = ["tests"]
58
+ addopts = ["--strict-markers", "--strict-config"]
59
+ asyncio_mode = "auto"
60
+ asyncio_default_fixture_loop_scope = "function"
61
+
62
+ [tool.ruff]
63
+ line-length = 85
64
+ target-version = "py311"
65
+ src = ["src", "tests"]
66
+
67
+ [tool.ruff.lint]
68
+ # No "I" (isort): its fixed layout puts the closing bracket of multi-line
69
+ # imports on its own line, which the codestyle forbids.
70
+ select = [
71
+ "B", # bugbear
72
+ "E", # pycodestyle errors
73
+ "F", # pyflakes
74
+ "UP", # pyupgrade (3.11 syntax)
75
+ "W", # pycodestyle warnings
76
+ ]
77
+ # Override-me stubs with an explicit `pass` are part of the codestyle.
78
+ ignore = ["B027"]
79
+
80
+ [tool.mypy]
81
+ python_version = "3.11"
82
+ strict = true
83
+ files = ["src", "tests"]
@@ -0,0 +1,81 @@
1
+ # anker-prime-driver
2
+
3
+ Python library and command-line tool to monitor and control Anker Prime
4
+ chargers: per-port voltage, current and power, port switches, countdowns and
5
+ schedules, charging modes, display settings and energy counters.
6
+
7
+ > **Status: pre-alpha, under development.** The 250W cloud connection, energy
8
+ > counters and the command-line tool work. 160W (Bluetooth) support is
9
+ > implemented but untested on a real charger.
10
+
11
+ This is an unofficial project, not affiliated with or endorsed by Anker.
12
+
13
+ ## Supported chargers
14
+
15
+ | Model | Name | Connection | Verified on hardware |
16
+ |-------|--------------------------|-----------------------------------------|-----------------------------------|
17
+ | A2345 | Anker Prime Charger 250W | Anker cloud (account + MQTT over Wi-Fi) | everything except the UFCS switch |
18
+ | A2687 | Anker Prime 160W | Bluetooth LE (local) | display settings (by Charker) |
19
+
20
+ The 250W must be bound to an Anker account in the Anker app. Unverified
21
+ features are marked experimental: they follow the known protocol but are not
22
+ yet confirmed on that model. A local connection for the 250W may follow later
23
+ without changes for library users.
24
+
25
+ ## Installation
26
+
27
+ Not published yet. Once released:
28
+
29
+ ```bash
30
+ pip install anker-prime-driver # cloud (250W) support
31
+ pip install anker-prime-driver[ble] # plus Bluetooth (160W) support
32
+ ```
33
+
34
+ Requires Python 3.11 or later.
35
+
36
+ ## Quick start
37
+
38
+ ```bash
39
+ ankerprime login you@example.com DE # asks for the password
40
+ ankerprime devices
41
+ ankerprime charger add desk --serial A2345XXXXXXXXXX --default
42
+ ankerprime monitor # live readings until Ctrl+C
43
+ ankerprime output c1 off
44
+ ```
45
+
46
+ ## Documentation
47
+
48
+ - [Command-line tool](docs/cli.md): every command and option, the
49
+ configuration folder, charger selection, exit codes.
50
+ - [Library overview](docs/library.md): usage examples, layers, the `Charger`
51
+ interface, state model, connection behaviour, energy counters, errors.
52
+
53
+ ## Development
54
+
55
+ ```bash
56
+ python3.11 -m venv .venv
57
+ . .venv/bin/activate
58
+ pip install -e .[ble] -r requirements-dev.txt
59
+
60
+ ruff check
61
+ mypy
62
+ pytest
63
+ ```
64
+
65
+ Formatting and import order follow the project codestyle by hand; `ruff check`
66
+ verifies line length and common lint rules. Release builds use
67
+ `python -m build` and `twine`.
68
+
69
+ ## Credits
70
+
71
+ The protocol knowledge comes from [Charker](https://github.com/qzz0518/Charker)
72
+ by qzz0518 (MIT), a macOS/Windows app for the same chargers; this library is an
73
+ independent Python implementation of its charger connectivity. Charker in turn
74
+ credits [SolixBLE](https://github.com/flip-dots/SolixBLE),
75
+ [Anker_Prime_160W_WebBLE](https://github.com/Hyper-Beast/Anker_Prime_160W_WebBLE),
76
+ [Anker_Prime_BLE_hacking](https://github.com/atc1441/Anker_Prime_BLE_hacking) and
77
+ [anker-solix-api](https://github.com/thomluther/anker-solix-api).
78
+
79
+ ## License
80
+
81
+ MIT — see [LICENSE](LICENSE). Anker trademarks belong to their owner.
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,113 @@
1
+ Metadata-Version: 2.4
2
+ Name: anker-prime-driver
3
+ Version: 0.7.3
4
+ Summary: Monitoring and control library for Anker Prime chargers
5
+ Author: didim99
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/didim99/anker-prime-driver
8
+ Project-URL: Issues, https://github.com/didim99/anker-prime-driver/issues
9
+ Keywords: anker,anker-prime,charger,home-assistant,mqtt,ble
10
+ Classifier: Development Status :: 2 - Pre-Alpha
11
+ Classifier: Framework :: AsyncIO
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Home Automation
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: >=3.11
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: aiohttp>=3.9
26
+ Requires-Dist: aiomqtt>=2.5
27
+ Requires-Dist: cryptography>=42
28
+ Provides-Extra: ble
29
+ Requires-Dist: bleak>=0.22; extra == "ble"
30
+ Requires-Dist: bleak-retry-connector>=3.5; extra == "ble"
31
+ Dynamic: license-file
32
+
33
+ # anker-prime-driver
34
+
35
+ Python library and command-line tool to monitor and control Anker Prime
36
+ chargers: per-port voltage, current and power, port switches, countdowns and
37
+ schedules, charging modes, display settings and energy counters.
38
+
39
+ > **Status: pre-alpha, under development.** The 250W cloud connection, energy
40
+ > counters and the command-line tool work. 160W (Bluetooth) support is
41
+ > implemented but untested on a real charger.
42
+
43
+ This is an unofficial project, not affiliated with or endorsed by Anker.
44
+
45
+ ## Supported chargers
46
+
47
+ | Model | Name | Connection | Verified on hardware |
48
+ |-------|--------------------------|-----------------------------------------|-----------------------------------|
49
+ | A2345 | Anker Prime Charger 250W | Anker cloud (account + MQTT over Wi-Fi) | everything except the UFCS switch |
50
+ | A2687 | Anker Prime 160W | Bluetooth LE (local) | display settings (by Charker) |
51
+
52
+ The 250W must be bound to an Anker account in the Anker app. Unverified
53
+ features are marked experimental: they follow the known protocol but are not
54
+ yet confirmed on that model. A local connection for the 250W may follow later
55
+ without changes for library users.
56
+
57
+ ## Installation
58
+
59
+ Not published yet. Once released:
60
+
61
+ ```bash
62
+ pip install anker-prime-driver # cloud (250W) support
63
+ pip install anker-prime-driver[ble] # plus Bluetooth (160W) support
64
+ ```
65
+
66
+ Requires Python 3.11 or later.
67
+
68
+ ## Quick start
69
+
70
+ ```bash
71
+ ankerprime login you@example.com DE # asks for the password
72
+ ankerprime devices
73
+ ankerprime charger add desk --serial A2345XXXXXXXXXX --default
74
+ ankerprime monitor # live readings until Ctrl+C
75
+ ankerprime output c1 off
76
+ ```
77
+
78
+ ## Documentation
79
+
80
+ - [Command-line tool](docs/cli.md): every command and option, the
81
+ configuration folder, charger selection, exit codes.
82
+ - [Library overview](docs/library.md): usage examples, layers, the `Charger`
83
+ interface, state model, connection behaviour, energy counters, errors.
84
+
85
+ ## Development
86
+
87
+ ```bash
88
+ python3.11 -m venv .venv
89
+ . .venv/bin/activate
90
+ pip install -e .[ble] -r requirements-dev.txt
91
+
92
+ ruff check
93
+ mypy
94
+ pytest
95
+ ```
96
+
97
+ Formatting and import order follow the project codestyle by hand; `ruff check`
98
+ verifies line length and common lint rules. Release builds use
99
+ `python -m build` and `twine`.
100
+
101
+ ## Credits
102
+
103
+ The protocol knowledge comes from [Charker](https://github.com/qzz0518/Charker)
104
+ by qzz0518 (MIT), a macOS/Windows app for the same chargers; this library is an
105
+ independent Python implementation of its charger connectivity. Charker in turn
106
+ credits [SolixBLE](https://github.com/flip-dots/SolixBLE),
107
+ [Anker_Prime_160W_WebBLE](https://github.com/Hyper-Beast/Anker_Prime_160W_WebBLE),
108
+ [Anker_Prime_BLE_hacking](https://github.com/atc1441/Anker_Prime_BLE_hacking) and
109
+ [anker-solix-api](https://github.com/thomluther/anker-solix-api).
110
+
111
+ ## License
112
+
113
+ MIT — see [LICENSE](LICENSE). Anker trademarks belong to their owner.
@@ -0,0 +1,90 @@
1
+ LICENSE
2
+ pyproject.toml
3
+ readme.md
4
+ src/anker_prime_driver.egg-info/PKG-INFO
5
+ src/anker_prime_driver.egg-info/SOURCES.txt
6
+ src/anker_prime_driver.egg-info/dependency_links.txt
7
+ src/anker_prime_driver.egg-info/entry_points.txt
8
+ src/anker_prime_driver.egg-info/requires.txt
9
+ src/anker_prime_driver.egg-info/top_level.txt
10
+ src/ankerprime/__init__.py
11
+ src/ankerprime/__main__.py
12
+ src/ankerprime/py.typed
13
+ src/ankerprime/utils.py
14
+ src/ankerprime/api/__init__.py
15
+ src/ankerprime/api/ble.py
16
+ src/ankerprime/api/cloud.py
17
+ src/ankerprime/cli/__init__.py
18
+ src/ankerprime/cli/aliases.py
19
+ src/ankerprime/cli/base.py
20
+ src/ankerprime/cli/config.py
21
+ src/ankerprime/cli/main.py
22
+ src/ankerprime/cli/parsing.py
23
+ src/ankerprime/cli/render.py
24
+ src/ankerprime/cli/style.py
25
+ src/ankerprime/cli/terminal.py
26
+ src/ankerprime/cli/commands/__init__.py
27
+ src/ankerprime/cli/commands/account.py
28
+ src/ankerprime/cli/commands/bluetooth.py
29
+ src/ankerprime/cli/commands/chargers.py
30
+ src/ankerprime/cli/commands/control.py
31
+ src/ankerprime/cli/commands/energy.py
32
+ src/ankerprime/cli/commands/reading.py
33
+ src/ankerprime/cloud/__init__.py
34
+ src/ankerprime/cloud/auth.py
35
+ src/ankerprime/cloud/client.py
36
+ src/ankerprime/cloud/credential_files.py
37
+ src/ankerprime/cloud/crypto.py
38
+ src/ankerprime/cloud/http.py
39
+ src/ankerprime/cloud/payload.py
40
+ src/ankerprime/cloud/regions.py
41
+ src/ankerprime/device/__init__.py
42
+ src/ankerprime/device/a2345.py
43
+ src/ankerprime/device/a2687.py
44
+ src/ankerprime/device/base.py
45
+ src/ankerprime/energy/__init__.py
46
+ src/ankerprime/energy/meter.py
47
+ src/ankerprime/energy/recorder.py
48
+ src/ankerprime/energy/store.py
49
+ src/ankerprime/interfaces/__init__.py
50
+ src/ankerprime/interfaces/channel.py
51
+ src/ankerprime/interfaces/charger.py
52
+ src/ankerprime/interfaces/http.py
53
+ src/ankerprime/interfaces/mqtt.py
54
+ src/ankerprime/interfaces/storage.py
55
+ src/ankerprime/model/__init__.py
56
+ src/ankerprime/model/capabilities.py
57
+ src/ankerprime/model/enums.py
58
+ src/ankerprime/model/errors.py
59
+ src/ankerprime/model/product.py
60
+ src/ankerprime/model/serialize.py
61
+ src/ankerprime/model/state.py
62
+ src/ankerprime/protocol/__init__.py
63
+ src/ankerprime/protocol/codes.py
64
+ src/ankerprime/protocol/ff09.py
65
+ src/ankerprime/protocol/a2345/__init__.py
66
+ src/ankerprime/protocol/a2345/codes.py
67
+ src/ankerprime/protocol/a2345/commands.py
68
+ src/ankerprime/protocol/a2345/frame.py
69
+ src/ankerprime/protocol/a2345/messages.py
70
+ src/ankerprime/protocol/a2345/settings.py
71
+ src/ankerprime/protocol/a2345/tracker.py
72
+ src/ankerprime/protocol/a2687/__init__.py
73
+ src/ankerprime/protocol/a2687/codes.py
74
+ src/ankerprime/protocol/a2687/commands.py
75
+ src/ankerprime/protocol/a2687/crypto.py
76
+ src/ankerprime/protocol/a2687/frame.py
77
+ src/ankerprime/protocol/a2687/handshake.py
78
+ src/ankerprime/protocol/a2687/telemetry.py
79
+ src/ankerprime/protocol/a2687/tlv.py
80
+ src/ankerprime/protocol/a2687/tracker.py
81
+ src/ankerprime/session/__init__.py
82
+ src/ankerprime/session/a2687.py
83
+ src/ankerprime/storage/__init__.py
84
+ src/ankerprime/storage/files.py
85
+ src/ankerprime/storage/json_store.py
86
+ src/ankerprime/transport/__init__.py
87
+ src/ankerprime/transport/aiomqtt_client.py
88
+ src/ankerprime/transport/ble.py
89
+ src/ankerprime/transport/cloud.py
90
+ tests/test_package.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ ankerprime = ankerprime.cli.main:main
@@ -0,0 +1,7 @@
1
+ aiohttp>=3.9
2
+ aiomqtt>=2.5
3
+ cryptography>=42
4
+
5
+ [ble]
6
+ bleak>=0.22
7
+ bleak-retry-connector>=3.5
@@ -0,0 +1,6 @@
1
+ """Monitoring and control library for Anker Prime chargers."""
2
+
3
+ from importlib.metadata import version
4
+
5
+
6
+ __version__ = version('anker-prime-driver')
@@ -0,0 +1,8 @@
1
+ """Runs the command-line interface as ``python -m ankerprime``."""
2
+
3
+ import sys
4
+
5
+ from ankerprime.cli.main import main
6
+
7
+
8
+ sys.exit(main())
@@ -0,0 +1,7 @@
1
+ """Public high-level charger API."""
2
+
3
+ from ankerprime.api.cloud import CloudAccount
4
+ from ankerprime.interfaces.charger import Charger, ChargerListener, Unsubscribe
5
+
6
+
7
+ __all__ = ['Charger', 'ChargerListener', 'CloudAccount', 'Unsubscribe']
@@ -0,0 +1,54 @@
1
+ """Bluetooth-connected chargers (Anker Prime 160W, A2687); needs ``[ble]``."""
2
+
3
+ from bleak.backends.device import BLEDevice
4
+
5
+ from ankerprime.device.a2687 import DEFAULT_COUNTRY, A2687Device, A2687Timings
6
+ from ankerprime.interfaces.channel import Channel
7
+ from ankerprime.interfaces.charger import Charger
8
+ from ankerprime.interfaces.storage import DocumentStore
9
+ from ankerprime.model.state import DeviceInfo
10
+ from ankerprime.protocol.a2687.handshake import new_client_id
11
+ from ankerprime.session.a2687 import A2687Session
12
+ from ankerprime.transport.ble import (
13
+ BleTransport, DeviceCallback, DiscoveredCharger,
14
+ advertisement_match, discover_chargers)
15
+ from ankerprime.utils import Clock
16
+
17
+
18
+ __all__ = ['A2687Timings', 'DeviceCallback', 'DiscoveredCharger',
19
+ 'advertisement_match', 'ble_charger', 'discover_chargers',
20
+ 'new_client_id']
21
+
22
+
23
+ def ble_charger(device: BLEDevice | str, *, owner_id: str | None = None,
24
+ client_id: str | None = None,
25
+ country: str = DEFAULT_COUNTRY,
26
+ keep_connection: bool = True,
27
+ info: DeviceInfo | None = None,
28
+ energy_store: DocumentStore | None = None,
29
+ timings: A2687Timings | None = None,
30
+ clock: Clock | None = None,
31
+ ble_device_callback: DeviceCallback | None = None,
32
+ transport: Channel | None = None) -> Charger:
33
+ """Return a charger reached over Bluetooth LE.
34
+
35
+ ``device`` is a ``BLEDevice`` or an address to scan for. ``owner_id`` is
36
+ the Anker account ID the charger is bound to; firmware that checks it
37
+ ignores other identities. ``client_id`` is the fallback identity (random
38
+ when omitted; keep it stable across runs). ``country`` is the account's
39
+ two-letter country code. ``info`` gives the known identity. Energy
40
+ counters are kept in ``energy_store`` under the charger's serial.
41
+ ``ble_device_callback`` returns the newest ``BLEDevice`` before each
42
+ connection attempt (Home Assistant:
43
+ ``bluetooth.async_ble_device_from_address``), falling back to ``device``.
44
+ ``transport`` replaces the Bluetooth link (tests, custom links).
45
+ """
46
+
47
+ link = transport if transport is not None else BleTransport(
48
+ device, device_callback=ble_device_callback)
49
+ session = A2687Session(link, client_id=client_id, owner_id=owner_id,
50
+ clock=clock)
51
+ return A2687Device(session, info, keep_connection=keep_connection,
52
+ country=country, owner_id=owner_id,
53
+ energy_store=energy_store, timings=timings,
54
+ clock=clock)