SolixBLE 4.0.0b3__tar.gz → 4.0.0b4__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.
- {solixble-4.0.0b3 → solixble-4.0.0b4}/PKG-INFO +2 -1
- {solixble-4.0.0b3 → solixble-4.0.0b4}/README.md +1 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/__init__.py +2 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/devices/__init__.py +6 -4
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/devices/f2000.py +154 -2
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/devices/f2600.py +15 -150
- solixble-4.0.0b4/SolixBLE/devices/prime_charge_base_150w.py +209 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/devices/solarbank2.py +15 -3
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/states.py +97 -2
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE.egg-info/PKG-INFO +2 -1
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE.egg-info/SOURCES.txt +1 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/pyproject.toml +1 -1
- {solixble-4.0.0b3 → solixble-4.0.0b4}/tests/test_commands.py +8 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/tests/test_devices.py +29 -6
- {solixble-4.0.0b3 → solixble-4.0.0b4}/LICENSE.txt +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/advertisement.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/const.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/constructs.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/device.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/devices/c1000.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/devices/c1000g2.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/devices/c300.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/devices/c300dc.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/devices/c800.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/devices/f3800.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/devices/generic.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/devices/maggo_3in1.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/devices/prime_charger_160w.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/devices/prime_charger_250w.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/devices/prime_power_bank_20k.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/devices/solarbank3.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/factory.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/prime_device.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/protocols/__init__.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/protocols/base.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/protocols/ecdh.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/protocols/outer.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/protocols/session.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/transport.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE/utilities.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE.egg-info/dependency_links.txt +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE.egg-info/requires.txt +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/SolixBLE.egg-info/top_level.txt +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/setup.cfg +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/tests/test_advertisement.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/tests/test_connection.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/tests/test_constructs.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/tests/test_dynamic_negotiation.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/tests/test_factory.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/tests/test_prime.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/tests/test_protocols.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/tests/test_routing.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/tests/test_transport.py +0 -0
- {solixble-4.0.0b3 → solixble-4.0.0b4}/tests/test_utilities.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: SolixBLE
|
|
3
|
-
Version: 4.0.
|
|
3
|
+
Version: 4.0.0b4
|
|
4
4
|
Summary: Python module for monitoring & controlling Bluetooth Anker Solix devices
|
|
5
5
|
Author-email: Harvey Lelliott <harveylelliott@duck.com>
|
|
6
6
|
License: MIT License
|
|
@@ -105,6 +105,7 @@ See the [support table](https://solixble.readthedocs.io/en/latest) in the docume
|
|
|
105
105
|
- F3800
|
|
106
106
|
- Solarbank 2
|
|
107
107
|
- Solarbank 3
|
|
108
|
+
- Prime Charge Base 150w
|
|
108
109
|
- Prime Charger 160w
|
|
109
110
|
- Prime Charger 250w
|
|
110
111
|
- Prime MagGo 3in1 (A25X7)
|
|
@@ -17,6 +17,7 @@ from .devices import (
|
|
|
17
17
|
F3800,
|
|
18
18
|
Generic,
|
|
19
19
|
MagGo3in1,
|
|
20
|
+
PrimeChargeBase150w,
|
|
20
21
|
PrimeCharger160w,
|
|
21
22
|
PrimeCharger250w,
|
|
22
23
|
PrimePowerBank20k,
|
|
@@ -53,6 +54,7 @@ __all__ = [
|
|
|
53
54
|
"MagGo3in1",
|
|
54
55
|
"PortOverload",
|
|
55
56
|
"PortStatus",
|
|
57
|
+
"PrimeChargeBase150w",
|
|
56
58
|
"PrimeCharger160w",
|
|
57
59
|
"PrimeCharger250w",
|
|
58
60
|
"PrimeDevice",
|
|
@@ -14,6 +14,7 @@ from .f2600 import F2600
|
|
|
14
14
|
from .f3800 import F3800
|
|
15
15
|
from .generic import Generic
|
|
16
16
|
from .maggo_3in1 import MagGo3in1
|
|
17
|
+
from .prime_charge_base_150w import PrimeChargeBase150w
|
|
17
18
|
from .prime_charger_160w import PrimeCharger160w
|
|
18
19
|
from .prime_charger_250w import PrimeCharger250w
|
|
19
20
|
from .prime_power_bank_20k import PrimePowerBank20k
|
|
@@ -29,11 +30,12 @@ __all__ = [
|
|
|
29
30
|
"F2000",
|
|
30
31
|
"F2600",
|
|
31
32
|
"F3800",
|
|
32
|
-
"
|
|
33
|
-
"
|
|
33
|
+
"Generic",
|
|
34
|
+
"MagGo3in1",
|
|
35
|
+
"PrimeChargeBase150w",
|
|
34
36
|
"PrimeCharger160w",
|
|
35
37
|
"PrimeCharger250w",
|
|
36
38
|
"PrimePowerBank20k",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
+
"Solarbank2",
|
|
40
|
+
"Solarbank3",
|
|
39
41
|
]
|
|
@@ -4,14 +4,63 @@
|
|
|
4
4
|
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
+
import logging
|
|
7
8
|
from datetime import datetime, timedelta
|
|
8
9
|
|
|
10
|
+
from SolixBLE.constructs import ParameterDict, Parameters
|
|
11
|
+
|
|
9
12
|
from ..const import (
|
|
10
13
|
DEFAULT_METADATA_FLOAT,
|
|
11
14
|
DEFAULT_METADATA_INT,
|
|
12
15
|
DEFAULT_METADATA_STRING,
|
|
16
|
+
TELEMETRY_PATTERN_A,
|
|
13
17
|
)
|
|
14
18
|
from ..device import SolixBLEDevice
|
|
19
|
+
from ..states import LightStatus
|
|
20
|
+
|
|
21
|
+
CMD_DISPLAY_ON_OFF = "4052"
|
|
22
|
+
CMD_AC_OUTPUT = "404a"
|
|
23
|
+
CMD_DC_OUTPUT = "404b"
|
|
24
|
+
CMD_POWER_SAVING_MODE = "404e"
|
|
25
|
+
CMD_LIGHT_MODE = "404f"
|
|
26
|
+
CMD_GET_STATUS = "4040"
|
|
27
|
+
|
|
28
|
+
CMD_RESPONSE_GET_STATUS = "c840"
|
|
29
|
+
|
|
30
|
+
PARAMETERS_ON = {
|
|
31
|
+
"a1": {
|
|
32
|
+
"value": "21",
|
|
33
|
+
}, "a2": {
|
|
34
|
+
"type": 1,
|
|
35
|
+
"value": 1,
|
|
36
|
+
},
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
PARAMETERS_OFF = {
|
|
40
|
+
"a1": {
|
|
41
|
+
"value": "21",
|
|
42
|
+
}, "a2": {
|
|
43
|
+
"type": 1,
|
|
44
|
+
"value": 0,
|
|
45
|
+
},
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
PARAMETERS_LIGHT_MODE = {
|
|
49
|
+
"a1": {
|
|
50
|
+
"value": "21",
|
|
51
|
+
}, "a2": {
|
|
52
|
+
"type": 1,
|
|
53
|
+
"value": lambda mode: mode.value,
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
PARAMETERS_GET_STATUS = {
|
|
58
|
+
"a1": {
|
|
59
|
+
"value": "21",
|
|
60
|
+
},
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
_LOGGER = logging.getLogger(__name__)
|
|
15
64
|
|
|
16
65
|
|
|
17
66
|
class F2000(SolixBLEDevice):
|
|
@@ -22,8 +71,9 @@ class F2000(SolixBLEDevice):
|
|
|
22
71
|
This model is also known as the A1780 or the 767 PowerHouse.
|
|
23
72
|
|
|
24
73
|
.. note::
|
|
25
|
-
This model was added using data from anker-solix-api.
|
|
26
|
-
|
|
74
|
+
This model was added using data from anker-solix-api. The commands
|
|
75
|
+
below have been confirmed on real units (see issue #29), but not all
|
|
76
|
+
of the telemetry has been tested.
|
|
27
77
|
|
|
28
78
|
.. note::
|
|
29
79
|
It should be possible to add more sensors. I think devices with lots of
|
|
@@ -282,3 +332,105 @@ class F2000(SolixBLEDevice):
|
|
|
282
332
|
:returns: Device serial number or default str value.
|
|
283
333
|
"""
|
|
284
334
|
return self._parse_string("d0", begin=1)
|
|
335
|
+
|
|
336
|
+
async def turn_ac_on(self) -> None:
|
|
337
|
+
"""Turn the AC output on.
|
|
338
|
+
|
|
339
|
+
:raises ConnectionError: If not connected to device.
|
|
340
|
+
:raises BleakError: If command transmission fails.
|
|
341
|
+
"""
|
|
342
|
+
await self._send_command(cmd=CMD_AC_OUTPUT, parameters=PARAMETERS_ON)
|
|
343
|
+
|
|
344
|
+
async def turn_ac_off(self) -> None:
|
|
345
|
+
"""Turn the AC output off.
|
|
346
|
+
|
|
347
|
+
:raises ConnectionError: If not connected to device.
|
|
348
|
+
:raises BleakError: If command transmission fails.
|
|
349
|
+
"""
|
|
350
|
+
await self._send_command(cmd=CMD_AC_OUTPUT, parameters=PARAMETERS_OFF)
|
|
351
|
+
|
|
352
|
+
async def turn_dc_on(self) -> None:
|
|
353
|
+
"""Turn the DC output on.
|
|
354
|
+
|
|
355
|
+
:raises ConnectionError: If not connected to device.
|
|
356
|
+
:raises BleakError: If command transmission fails.
|
|
357
|
+
"""
|
|
358
|
+
await self._send_command(cmd=CMD_DC_OUTPUT, parameters=PARAMETERS_ON)
|
|
359
|
+
|
|
360
|
+
async def turn_dc_off(self) -> None:
|
|
361
|
+
"""Turn the DC output off.
|
|
362
|
+
|
|
363
|
+
:raises ConnectionError: If not connected to device.
|
|
364
|
+
:raises BleakError: If command transmission fails.
|
|
365
|
+
"""
|
|
366
|
+
await self._send_command(cmd=CMD_DC_OUTPUT, parameters=PARAMETERS_OFF)
|
|
367
|
+
|
|
368
|
+
async def set_light_mode(self, mode: LightStatus) -> None:
|
|
369
|
+
"""Set the light mode of the LED bar.
|
|
370
|
+
|
|
371
|
+
:param mode: Mode to set light bar to.
|
|
372
|
+
:raises ValueError: If requested mode is invalid.
|
|
373
|
+
:raises ConnectionError: If not connected to device.
|
|
374
|
+
:raises BleakError: If command transmission fails.
|
|
375
|
+
"""
|
|
376
|
+
if mode is LightStatus.UNKNOWN:
|
|
377
|
+
raise ValueError("You cannot set the light status to unknown")
|
|
378
|
+
await self._send_command(
|
|
379
|
+
cmd=CMD_LIGHT_MODE,
|
|
380
|
+
parameters=PARAMETERS_LIGHT_MODE,
|
|
381
|
+
mode=mode,
|
|
382
|
+
)
|
|
383
|
+
|
|
384
|
+
async def turn_display_on(self) -> None:
|
|
385
|
+
"""Turn the display on.
|
|
386
|
+
|
|
387
|
+
:raises ConnectionError: If not connected to device.
|
|
388
|
+
:raises BleakError: If command transmission fails.
|
|
389
|
+
"""
|
|
390
|
+
await self._send_command(cmd=CMD_DISPLAY_ON_OFF, parameters=PARAMETERS_ON)
|
|
391
|
+
|
|
392
|
+
async def turn_display_off(self) -> None:
|
|
393
|
+
"""Turn the display off.
|
|
394
|
+
|
|
395
|
+
:raises ConnectionError: If not connected to device.
|
|
396
|
+
:raises BleakError: If command transmission fails.
|
|
397
|
+
"""
|
|
398
|
+
await self._send_command(cmd=CMD_DISPLAY_ON_OFF, parameters=PARAMETERS_OFF)
|
|
399
|
+
|
|
400
|
+
async def turn_power_saving_mode_on(self) -> None:
|
|
401
|
+
"""Turn the power saving mode on.
|
|
402
|
+
|
|
403
|
+
:raises ConnectionError: If not connected to device.
|
|
404
|
+
:raises BleakError: If command transmission fails.
|
|
405
|
+
"""
|
|
406
|
+
await self._send_command(cmd=CMD_POWER_SAVING_MODE, parameters=PARAMETERS_ON)
|
|
407
|
+
|
|
408
|
+
async def turn_power_saving_mode_off(self) -> None:
|
|
409
|
+
"""Turn the power saving mode off.
|
|
410
|
+
|
|
411
|
+
:raises ConnectionError: If not connected to device.
|
|
412
|
+
:raises BleakError: If command transmission fails.
|
|
413
|
+
"""
|
|
414
|
+
await self._send_command(cmd=CMD_POWER_SAVING_MODE, parameters=PARAMETERS_OFF)
|
|
415
|
+
|
|
416
|
+
async def get_status_update(self) -> ParameterDict:
|
|
417
|
+
"""Request and retrieve a status update from the device.
|
|
418
|
+
|
|
419
|
+
:raises ConnectionError: If not connected to device.
|
|
420
|
+
:raises TimeoutError: If no response from device.
|
|
421
|
+
:raises BleakError: If command transmission fails.
|
|
422
|
+
:returns: Dictionary containing telemetry parameters.
|
|
423
|
+
"""
|
|
424
|
+
await self._send_command(cmd=CMD_GET_STATUS, parameters=PARAMETERS_GET_STATUS)
|
|
425
|
+
payload = await self._listen_for_packet(
|
|
426
|
+
bytes.fromhex(TELEMETRY_PATTERN_A), bytes.fromhex(CMD_RESPONSE_GET_STATUS),
|
|
427
|
+
)
|
|
428
|
+
if not payload:
|
|
429
|
+
raise TimeoutError("Timed out waiting for payload!")
|
|
430
|
+
|
|
431
|
+
parameters = Parameters.parse(payload)
|
|
432
|
+
_LOGGER.debug(f"Parameters: {parameters}")
|
|
433
|
+
await self._process_telemetry(
|
|
434
|
+
parameters,
|
|
435
|
+
) # update the internal parameters as well
|
|
436
|
+
return parameters
|
|
@@ -5,59 +5,35 @@
|
|
|
5
5
|
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
-
import logging
|
|
9
8
|
from datetime import datetime, timedelta
|
|
10
9
|
|
|
11
|
-
from SolixBLE.constructs import ParameterDict, Parameters
|
|
12
|
-
|
|
13
10
|
from ..const import (
|
|
14
11
|
DEFAULT_METADATA_BOOL,
|
|
15
12
|
DEFAULT_METADATA_INT,
|
|
16
|
-
TELEMETRY_PATTERN_A,
|
|
17
13
|
)
|
|
18
14
|
from ..states import ChargingStatus, DisplayTimeout, LightStatus, PortStatus
|
|
19
15
|
from . import F2000
|
|
20
16
|
|
|
17
|
+
# The commands the F2000 shares now live there. They stay importable from here.
|
|
18
|
+
from .f2000 import (
|
|
19
|
+
CMD_AC_OUTPUT as CMD_AC_OUTPUT,
|
|
20
|
+
CMD_DC_OUTPUT as CMD_DC_OUTPUT,
|
|
21
|
+
CMD_DISPLAY_ON_OFF as CMD_DISPLAY_ON_OFF,
|
|
22
|
+
CMD_GET_STATUS as CMD_GET_STATUS,
|
|
23
|
+
CMD_LIGHT_MODE as CMD_LIGHT_MODE,
|
|
24
|
+
CMD_POWER_SAVING_MODE as CMD_POWER_SAVING_MODE,
|
|
25
|
+
CMD_RESPONSE_GET_STATUS as CMD_RESPONSE_GET_STATUS,
|
|
26
|
+
PARAMETERS_GET_STATUS as PARAMETERS_GET_STATUS,
|
|
27
|
+
PARAMETERS_LIGHT_MODE,
|
|
28
|
+
PARAMETERS_OFF as PARAMETERS_OFF,
|
|
29
|
+
PARAMETERS_ON as PARAMETERS_ON,
|
|
30
|
+
)
|
|
31
|
+
|
|
21
32
|
CMD_AC_TIMER = "4042"
|
|
22
33
|
CMD_DC_TIMER = "4043"
|
|
23
34
|
CMD_AC_CHARGING_POWER = "4044"
|
|
24
35
|
CMD_DISPLAY_TIMEOUT = "4046"
|
|
25
|
-
CMD_DISPLAY_ON_OFF = "4052"
|
|
26
|
-
CMD_AC_OUTPUT = "404a"
|
|
27
|
-
CMD_DC_OUTPUT = "404b"
|
|
28
36
|
CMD_DISPLAY_MODE = "404c"
|
|
29
|
-
CMD_POWER_SAVING_MODE = "404e"
|
|
30
|
-
CMD_LIGHT_MODE = "404f"
|
|
31
|
-
CMD_GET_STATUS = "4040"
|
|
32
|
-
|
|
33
|
-
CMD_RESPONSE_GET_STATUS = "c840"
|
|
34
|
-
|
|
35
|
-
PARAMETERS_ON = {
|
|
36
|
-
"a1": {
|
|
37
|
-
"value": "21",
|
|
38
|
-
}, "a2": {
|
|
39
|
-
"type": 1,
|
|
40
|
-
"value": 1,
|
|
41
|
-
},
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
PARAMETERS_OFF = {
|
|
45
|
-
"a1": {
|
|
46
|
-
"value": "21",
|
|
47
|
-
}, "a2": {
|
|
48
|
-
"type": 1,
|
|
49
|
-
"value": 0,
|
|
50
|
-
},
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
PARAMETERS_LIGHT_MODE = {
|
|
54
|
-
"a1": {
|
|
55
|
-
"value": "21",
|
|
56
|
-
}, "a2": {
|
|
57
|
-
"type": 1,
|
|
58
|
-
"value": lambda mode: mode.value,
|
|
59
|
-
},
|
|
60
|
-
}
|
|
61
37
|
|
|
62
38
|
PARAMETERS_TIMEOUT_TIME = {
|
|
63
39
|
"a1": {
|
|
@@ -98,15 +74,6 @@ PARAMETERS_TIMER = {
|
|
|
98
74
|
},
|
|
99
75
|
}
|
|
100
76
|
|
|
101
|
-
PARAMETERS_GET_STATUS = {
|
|
102
|
-
"a1": {
|
|
103
|
-
"value": "21",
|
|
104
|
-
},
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
_LOGGER = logging.getLogger(__name__)
|
|
108
|
-
|
|
109
|
-
|
|
110
77
|
class F2600(F2000):
|
|
111
78
|
"""
|
|
112
79
|
F2600 Power Station.
|
|
@@ -359,38 +326,6 @@ class F2600(F2000):
|
|
|
359
326
|
return LightStatus.UNKNOWN
|
|
360
327
|
return LightStatus(self._parse_int("d9", begin=1))
|
|
361
328
|
|
|
362
|
-
async def turn_ac_on(self) -> None:
|
|
363
|
-
"""Turn the AC output on.
|
|
364
|
-
|
|
365
|
-
:raises ConnectionError: If not connected to device.
|
|
366
|
-
:raises BleakError: If command transmission fails.
|
|
367
|
-
"""
|
|
368
|
-
await self._send_command(cmd=CMD_AC_OUTPUT, parameters=PARAMETERS_ON)
|
|
369
|
-
|
|
370
|
-
async def turn_ac_off(self) -> None:
|
|
371
|
-
"""Turn the AC output off.
|
|
372
|
-
|
|
373
|
-
:raises ConnectionError: If not connected to device.
|
|
374
|
-
:raises BleakError: If command transmission fails.
|
|
375
|
-
"""
|
|
376
|
-
await self._send_command(cmd=CMD_AC_OUTPUT, parameters=PARAMETERS_OFF)
|
|
377
|
-
|
|
378
|
-
async def turn_dc_on(self) -> None:
|
|
379
|
-
"""Turn the DC output on.
|
|
380
|
-
|
|
381
|
-
:raises ConnectionError: If not connected to device.
|
|
382
|
-
:raises BleakError: If command transmission fails.
|
|
383
|
-
"""
|
|
384
|
-
await self._send_command(cmd=CMD_DC_OUTPUT, parameters=PARAMETERS_ON)
|
|
385
|
-
|
|
386
|
-
async def turn_dc_off(self) -> None:
|
|
387
|
-
"""Turn the DC output off.
|
|
388
|
-
|
|
389
|
-
:raises ConnectionError: If not connected to device.
|
|
390
|
-
:raises BleakError: If command transmission fails.
|
|
391
|
-
"""
|
|
392
|
-
await self._send_command(cmd=CMD_DC_OUTPUT, parameters=PARAMETERS_OFF)
|
|
393
|
-
|
|
394
329
|
async def set_ac_timer(self, seconds: int) -> None:
|
|
395
330
|
"""Set the AC auto-off timer.
|
|
396
331
|
|
|
@@ -417,22 +352,6 @@ class F2600(F2000):
|
|
|
417
352
|
seconds=seconds,
|
|
418
353
|
)
|
|
419
354
|
|
|
420
|
-
async def set_light_mode(self, mode: LightStatus) -> None:
|
|
421
|
-
"""Set the light mode of the LED bar.
|
|
422
|
-
|
|
423
|
-
:param mode: Mode to set light bar to.
|
|
424
|
-
:raises ValueError: If requested mode is invalid.
|
|
425
|
-
:raises ConnectionError: If not connected to device.
|
|
426
|
-
:raises BleakError: If command transmission fails.
|
|
427
|
-
"""
|
|
428
|
-
if mode is LightStatus.UNKNOWN:
|
|
429
|
-
raise ValueError("You cannot set the light status to unknown")
|
|
430
|
-
await self._send_command(
|
|
431
|
-
cmd=CMD_LIGHT_MODE,
|
|
432
|
-
parameters=PARAMETERS_LIGHT_MODE,
|
|
433
|
-
mode=mode,
|
|
434
|
-
)
|
|
435
|
-
|
|
436
355
|
async def set_display_mode(self, mode: LightStatus) -> None:
|
|
437
356
|
"""Set the status/mode of the LCD display.
|
|
438
357
|
|
|
@@ -468,38 +387,6 @@ class F2600(F2000):
|
|
|
468
387
|
time=timeout,
|
|
469
388
|
)
|
|
470
389
|
|
|
471
|
-
async def turn_display_on(self) -> None:
|
|
472
|
-
"""Turn the display on.
|
|
473
|
-
|
|
474
|
-
:raises ConnectionError: If not connected to device.
|
|
475
|
-
:raises BleakError: If command transmission fails.
|
|
476
|
-
"""
|
|
477
|
-
await self._send_command(cmd=CMD_DISPLAY_ON_OFF, parameters=PARAMETERS_ON)
|
|
478
|
-
|
|
479
|
-
async def turn_display_off(self) -> None:
|
|
480
|
-
"""Turn the display off.
|
|
481
|
-
|
|
482
|
-
:raises ConnectionError: If not connected to device.
|
|
483
|
-
:raises BleakError: If command transmission fails.
|
|
484
|
-
"""
|
|
485
|
-
await self._send_command(cmd=CMD_DISPLAY_ON_OFF, parameters=PARAMETERS_OFF)
|
|
486
|
-
|
|
487
|
-
async def turn_power_saving_mode_on(self) -> None:
|
|
488
|
-
"""Turn the power saving mode on.
|
|
489
|
-
|
|
490
|
-
:raises ConnectionError: If not connected to device.
|
|
491
|
-
:raises BleakError: If command transmission fails.
|
|
492
|
-
"""
|
|
493
|
-
await self._send_command(cmd=CMD_POWER_SAVING_MODE, parameters=PARAMETERS_ON)
|
|
494
|
-
|
|
495
|
-
async def turn_power_saving_mode_off(self) -> None:
|
|
496
|
-
"""Turn the power saving mode off.
|
|
497
|
-
|
|
498
|
-
:raises ConnectionError: If not connected to device.
|
|
499
|
-
:raises BleakError: If command transmission fails.
|
|
500
|
-
"""
|
|
501
|
-
await self._send_command(cmd=CMD_POWER_SAVING_MODE, parameters=PARAMETERS_OFF)
|
|
502
|
-
|
|
503
390
|
async def set_ac_charging_power(self, watts: int) -> None:
|
|
504
391
|
"""Set the AC charging power limit in watts.
|
|
505
392
|
|
|
@@ -518,25 +405,3 @@ class F2600(F2000):
|
|
|
518
405
|
parameters=PARAMETERS_CHARGE_POWER,
|
|
519
406
|
watts=watts,
|
|
520
407
|
)
|
|
521
|
-
|
|
522
|
-
async def get_status_update(self) -> ParameterDict:
|
|
523
|
-
"""Request and retrieve a status update from the device.
|
|
524
|
-
|
|
525
|
-
:raises ConnectionError: If not connected to device.
|
|
526
|
-
:raises TimeoutError: If no response from device.
|
|
527
|
-
:raises BleakError: If command transmission fails.
|
|
528
|
-
:returns: Dictionary containing telemetry parameters.
|
|
529
|
-
"""
|
|
530
|
-
await self._send_command(cmd=CMD_GET_STATUS, parameters=PARAMETERS_GET_STATUS)
|
|
531
|
-
payload = await self._listen_for_packet(
|
|
532
|
-
bytes.fromhex(TELEMETRY_PATTERN_A), bytes.fromhex(CMD_RESPONSE_GET_STATUS),
|
|
533
|
-
)
|
|
534
|
-
if not payload:
|
|
535
|
-
raise TimeoutError("Timed out waiting for payload!")
|
|
536
|
-
|
|
537
|
-
parameters = Parameters.parse(payload)
|
|
538
|
-
_LOGGER.debug(f"Parameters: {parameters}")
|
|
539
|
-
await self._process_telemetry(
|
|
540
|
-
parameters,
|
|
541
|
-
) # update the internal parameters as well
|
|
542
|
-
return parameters
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"""Anker Prime Charging Base (150w) model.
|
|
2
|
+
|
|
3
|
+
.. moduleauthor:: Harvey Lelliott (flip-dots) <harveylelliott@duck.com>
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from ..const import DEFAULT_METADATA_FLOAT
|
|
8
|
+
from ..prime_device import PrimeDevice
|
|
9
|
+
from ..states import PortStatus
|
|
10
|
+
|
|
11
|
+
#: Command sent after connecting to start the telemetry stream. This must
|
|
12
|
+
#: be sent every ~10 seconds or no telemetry will be sent by the device.
|
|
13
|
+
CMD_SUB_AND_KEEP_ALIVE = "420b"
|
|
14
|
+
PARAMETERS_KEEP_ALIVE = {
|
|
15
|
+
"a1": {
|
|
16
|
+
"value": "21",
|
|
17
|
+
},
|
|
18
|
+
}
|
|
19
|
+
KEEP_ALIVE_INTERNAL = 10
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class PrimeChargeBase150w(PrimeDevice):
|
|
23
|
+
"""
|
|
24
|
+
Anker Prime Charge Base (150w) model.
|
|
25
|
+
|
|
26
|
+
Use this class to connect and monitor the 150w charge base.
|
|
27
|
+
This model is also known as the A1903.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
_TELEMETRY_COMMANDS = ("4303",)
|
|
31
|
+
|
|
32
|
+
async def _keep_alive(self) -> int | None:
|
|
33
|
+
await self._send_command(
|
|
34
|
+
cmd=CMD_SUB_AND_KEEP_ALIVE,
|
|
35
|
+
parameters=PARAMETERS_KEEP_ALIVE,
|
|
36
|
+
)
|
|
37
|
+
return KEEP_ALIVE_INTERNAL
|
|
38
|
+
|
|
39
|
+
@property
|
|
40
|
+
def usb_port_c1(self) -> PortStatus:
|
|
41
|
+
"""USB C1 Port Status.
|
|
42
|
+
|
|
43
|
+
:returns: Status of the USB C1 port.
|
|
44
|
+
"""
|
|
45
|
+
return PortStatus(self._parse_int("a2", begin=1, end=2))
|
|
46
|
+
|
|
47
|
+
@property
|
|
48
|
+
def usb_c1_voltage(self) -> float:
|
|
49
|
+
"""USB C1 Port voltage (V).
|
|
50
|
+
|
|
51
|
+
:returns: Voltage of the USB C1 port or default float value.
|
|
52
|
+
"""
|
|
53
|
+
if self._data is None:
|
|
54
|
+
return DEFAULT_METADATA_FLOAT
|
|
55
|
+
|
|
56
|
+
return self._parse_int("a2", begin=2, end=4) / 10.0
|
|
57
|
+
|
|
58
|
+
@property
|
|
59
|
+
def usb_c1_current(self) -> float:
|
|
60
|
+
"""USB C1 Port current (A).
|
|
61
|
+
|
|
62
|
+
:returns: Current of the USB C1 port or default float value.
|
|
63
|
+
"""
|
|
64
|
+
if self._data is None:
|
|
65
|
+
return DEFAULT_METADATA_FLOAT
|
|
66
|
+
|
|
67
|
+
return self._parse_int("a2", begin=4, end=6) / 10.0
|
|
68
|
+
|
|
69
|
+
@property
|
|
70
|
+
def usb_c1_power(self) -> float:
|
|
71
|
+
"""USB C1 Port power (W).
|
|
72
|
+
|
|
73
|
+
:returns: Power of the USB C1 port or default float value.
|
|
74
|
+
"""
|
|
75
|
+
if self._data is None:
|
|
76
|
+
return DEFAULT_METADATA_FLOAT
|
|
77
|
+
|
|
78
|
+
return self._parse_int("a2", begin=6, end=8) / 10.0
|
|
79
|
+
|
|
80
|
+
@property
|
|
81
|
+
def usb_port_c2(self) -> PortStatus:
|
|
82
|
+
"""USB C2 Port Status.
|
|
83
|
+
|
|
84
|
+
:returns: Status of the USB C2 port.
|
|
85
|
+
"""
|
|
86
|
+
return PortStatus(self._parse_int("a3", begin=1, end=2))
|
|
87
|
+
|
|
88
|
+
@property
|
|
89
|
+
def usb_c2_voltage(self) -> float:
|
|
90
|
+
"""USB C2 Port voltage (V).
|
|
91
|
+
|
|
92
|
+
:returns: Voltage of the USB C2 port or default float value.
|
|
93
|
+
"""
|
|
94
|
+
if self._data is None:
|
|
95
|
+
return DEFAULT_METADATA_FLOAT
|
|
96
|
+
|
|
97
|
+
return self._parse_int("a3", begin=2, end=4) / 10.0
|
|
98
|
+
|
|
99
|
+
@property
|
|
100
|
+
def usb_c2_current(self) -> float:
|
|
101
|
+
"""USB C2 Port current (A).
|
|
102
|
+
|
|
103
|
+
:returns: Current of the USB C2 port or default float value.
|
|
104
|
+
"""
|
|
105
|
+
if self._data is None:
|
|
106
|
+
return DEFAULT_METADATA_FLOAT
|
|
107
|
+
|
|
108
|
+
return self._parse_int("a3", begin=4, end=6) / 10.0
|
|
109
|
+
|
|
110
|
+
@property
|
|
111
|
+
def usb_c2_power(self) -> float:
|
|
112
|
+
"""USB C2 Port power (W).
|
|
113
|
+
|
|
114
|
+
:returns: Power of the USB C2 port or default float value.
|
|
115
|
+
"""
|
|
116
|
+
if self._data is None:
|
|
117
|
+
return DEFAULT_METADATA_FLOAT
|
|
118
|
+
|
|
119
|
+
return self._parse_int("a3", begin=6, end=8) / 10.0
|
|
120
|
+
|
|
121
|
+
@property
|
|
122
|
+
def usb_port_a1(self) -> PortStatus:
|
|
123
|
+
"""USB A1 Port Status.
|
|
124
|
+
|
|
125
|
+
:returns: Status of the USB A1 port.
|
|
126
|
+
"""
|
|
127
|
+
return PortStatus(self._parse_int("a4", begin=1, end=2))
|
|
128
|
+
|
|
129
|
+
@property
|
|
130
|
+
def usb_a1_voltage(self) -> float:
|
|
131
|
+
"""USB A1 Port voltage (V).
|
|
132
|
+
|
|
133
|
+
:returns: Voltage of the USB A1 port or default float value.
|
|
134
|
+
"""
|
|
135
|
+
if self._data is None:
|
|
136
|
+
return DEFAULT_METADATA_FLOAT
|
|
137
|
+
|
|
138
|
+
return self._parse_int("a4", begin=2, end=4) / 10.0
|
|
139
|
+
|
|
140
|
+
@property
|
|
141
|
+
def usb_a1_current(self) -> float:
|
|
142
|
+
"""USB A1 Port current (A).
|
|
143
|
+
|
|
144
|
+
:returns: Current of the USB A1 port or default float value.
|
|
145
|
+
"""
|
|
146
|
+
if self._data is None:
|
|
147
|
+
return DEFAULT_METADATA_FLOAT
|
|
148
|
+
|
|
149
|
+
return self._parse_int("a4", begin=4, end=6) / 10.0
|
|
150
|
+
|
|
151
|
+
@property
|
|
152
|
+
def usb_a1_power(self) -> float:
|
|
153
|
+
"""USB A1 Port power (W).
|
|
154
|
+
|
|
155
|
+
:returns: Power of the USB A1 port or default float value.
|
|
156
|
+
"""
|
|
157
|
+
if self._data is None:
|
|
158
|
+
return DEFAULT_METADATA_FLOAT
|
|
159
|
+
|
|
160
|
+
return self._parse_int("a4", begin=6, end=8) / 10.0
|
|
161
|
+
|
|
162
|
+
@property
|
|
163
|
+
def dock_status(self) -> PortStatus:
|
|
164
|
+
"""Power Bank Dock Port Status.
|
|
165
|
+
|
|
166
|
+
:returns: Status of the power bank charging port.
|
|
167
|
+
"""
|
|
168
|
+
return PortStatus(self._parse_int("a5", begin=1, end=2))
|
|
169
|
+
|
|
170
|
+
@property
|
|
171
|
+
def dock_voltage(self) -> float:
|
|
172
|
+
"""Power Bank Dock Port voltage (V).
|
|
173
|
+
|
|
174
|
+
:returns: Voltage of the power bank charging port or default float value.
|
|
175
|
+
"""
|
|
176
|
+
if self._data is None:
|
|
177
|
+
return DEFAULT_METADATA_FLOAT
|
|
178
|
+
|
|
179
|
+
return self._parse_int("a5", begin=2, end=4) / 10.0
|
|
180
|
+
|
|
181
|
+
@property
|
|
182
|
+
def dock_current(self) -> float:
|
|
183
|
+
"""Power Bank Dock Port Current (A).
|
|
184
|
+
|
|
185
|
+
:returns: Current of the power bank charging port or default float value.
|
|
186
|
+
"""
|
|
187
|
+
if self._data is None:
|
|
188
|
+
return DEFAULT_METADATA_FLOAT
|
|
189
|
+
|
|
190
|
+
return self._parse_int("a5", begin=4, end=6) / 10.0
|
|
191
|
+
|
|
192
|
+
@property
|
|
193
|
+
def dock_power(self) -> float:
|
|
194
|
+
"""Power Bank Dock Port Power (W).
|
|
195
|
+
|
|
196
|
+
:returns: Power of the power bank charging port or default float value.
|
|
197
|
+
"""
|
|
198
|
+
if self._data is None:
|
|
199
|
+
return DEFAULT_METADATA_FLOAT
|
|
200
|
+
|
|
201
|
+
return self._parse_int("a5", begin=6, end=8) / 10.0
|
|
202
|
+
|
|
203
|
+
@property
|
|
204
|
+
def power_out(self) -> float:
|
|
205
|
+
"""Total Power Out.
|
|
206
|
+
|
|
207
|
+
:returns: Total power out or default float value.
|
|
208
|
+
"""
|
|
209
|
+
return self._parse_int("a6", begin=1, end=3) / 10.0
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import logging
|
|
7
10
|
from enum import Enum
|
|
8
11
|
|
|
9
12
|
from ..const import (
|
|
@@ -14,11 +17,13 @@ from ..const import (
|
|
|
14
17
|
from ..device import SolixBLEDevice
|
|
15
18
|
from ..states import GridStatus, LightMode, SBPowerCutoff, SBUsageMode, TemperatureUnit
|
|
16
19
|
|
|
20
|
+
_LOGGER = logging.getLogger(__name__)
|
|
21
|
+
|
|
17
22
|
|
|
18
23
|
class MaxLoadSB2(Enum):
|
|
19
24
|
"""
|
|
20
25
|
Maximum output power of the Solarbank 2 in watts.
|
|
21
|
-
|
|
26
|
+
|
|
22
27
|
Only specific values are allowed.
|
|
23
28
|
"""
|
|
24
29
|
|
|
@@ -37,6 +42,14 @@ class MaxLoadSB2(Enum):
|
|
|
37
42
|
#: 1000 watts.
|
|
38
43
|
W1000 = 1000
|
|
39
44
|
|
|
45
|
+
@classmethod
|
|
46
|
+
def _missing_(cls, value: object) -> MaxLoadSB2:
|
|
47
|
+
"""Return the unknown value if the value is not recognized."""
|
|
48
|
+
_LOGGER.warning(
|
|
49
|
+
f"Unexpected max load '{value}'. Returning MaxLoadSB2.UNKNOWN",
|
|
50
|
+
)
|
|
51
|
+
return cls.UNKNOWN
|
|
52
|
+
|
|
40
53
|
|
|
41
54
|
class Solarbank2(SolixBLEDevice):
|
|
42
55
|
"""
|
|
@@ -381,7 +394,7 @@ class Solarbank2(SolixBLEDevice):
|
|
|
381
394
|
def max_load(self) -> MaxLoadSB2:
|
|
382
395
|
"""
|
|
383
396
|
Maximum output power in watts.
|
|
384
|
-
|
|
397
|
+
|
|
385
398
|
Maximum legal value depends on country of operation.
|
|
386
399
|
|
|
387
400
|
:returns: Maximum load as a MaxLoadSB2 enum value.
|
|
@@ -444,4 +457,3 @@ class Solarbank2(SolixBLEDevice):
|
|
|
444
457
|
if self._data is not None
|
|
445
458
|
else DEFAULT_METADATA_BOOL
|
|
446
459
|
)
|
|
447
|
-
|
|
@@ -4,8 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import logging
|
|
7
10
|
from enum import Enum
|
|
8
11
|
|
|
12
|
+
_LOGGER = logging.getLogger(__name__)
|
|
13
|
+
|
|
9
14
|
|
|
10
15
|
class PortStatus(Enum):
|
|
11
16
|
"""The status of a port on the device."""
|
|
@@ -23,8 +28,8 @@ class PortStatus(Enum):
|
|
|
23
28
|
INPUT = 2
|
|
24
29
|
|
|
25
30
|
@classmethod
|
|
26
|
-
def from_input_only(cls, value: int):
|
|
27
|
-
"""
|
|
31
|
+
def from_input_only(cls, value: int) -> PortStatus:
|
|
32
|
+
"""PortStatus factory for input only port."""
|
|
28
33
|
|
|
29
34
|
# If it would be an output (i.e 1) set it to input (i.e 2).
|
|
30
35
|
if value == PortStatus.OUTPUT.value:
|
|
@@ -32,6 +37,14 @@ class PortStatus(Enum):
|
|
|
32
37
|
|
|
33
38
|
return cls(value)
|
|
34
39
|
|
|
40
|
+
@classmethod
|
|
41
|
+
def _missing_(cls, value: object) -> PortStatus:
|
|
42
|
+
"""Return the unknown value if the value is not recognized."""
|
|
43
|
+
_LOGGER.warning(
|
|
44
|
+
f"Unexpected port status '{value}'. Returning PortStatus.UNKNOWN",
|
|
45
|
+
)
|
|
46
|
+
return cls.UNKNOWN
|
|
47
|
+
|
|
35
48
|
|
|
36
49
|
class ChargingStatus(Enum):
|
|
37
50
|
"""The status of charging/discharging on a device."""
|
|
@@ -48,6 +61,14 @@ class ChargingStatus(Enum):
|
|
|
48
61
|
#: The device is charging.
|
|
49
62
|
CHARGING = 2
|
|
50
63
|
|
|
64
|
+
@classmethod
|
|
65
|
+
def _missing_(cls, value: object) -> ChargingStatus:
|
|
66
|
+
"""Return the unknown value if the value is not recognized."""
|
|
67
|
+
_LOGGER.warning(
|
|
68
|
+
f"Unexpected charging status '{value}'. Returning ChargingStatus.UNKNOWN",
|
|
69
|
+
)
|
|
70
|
+
return cls.UNKNOWN
|
|
71
|
+
|
|
51
72
|
|
|
52
73
|
class ChargingStatusF3800(Enum):
|
|
53
74
|
"""The charging type of an F3800."""
|
|
@@ -67,6 +88,14 @@ class ChargingStatusF3800(Enum):
|
|
|
67
88
|
#: The device is charging via solar and AC.
|
|
68
89
|
BOTH = 3
|
|
69
90
|
|
|
91
|
+
@classmethod
|
|
92
|
+
def _missing_(cls, value: object) -> ChargingStatusF3800:
|
|
93
|
+
"""Return the unknown value if the value is not recognized."""
|
|
94
|
+
_LOGGER.warning(
|
|
95
|
+
f"Unexpected charging status '{value}'. Returning ChargingStatusF3800.UNKNOWN", # noqa: E501
|
|
96
|
+
)
|
|
97
|
+
return cls.UNKNOWN
|
|
98
|
+
|
|
70
99
|
|
|
71
100
|
class LightStatus(Enum):
|
|
72
101
|
"""The status of the light on the device."""
|
|
@@ -89,6 +118,14 @@ class LightStatus(Enum):
|
|
|
89
118
|
#: SOS mode. Not supported by all devices.
|
|
90
119
|
SOS = 4
|
|
91
120
|
|
|
121
|
+
@classmethod
|
|
122
|
+
def _missing_(cls, value: object) -> LightStatus:
|
|
123
|
+
"""Return the unknown value if the value is not recognized."""
|
|
124
|
+
_LOGGER.warning(
|
|
125
|
+
f"Unexpected light status '{value}'. Returning LightStatus.UNKNOWN",
|
|
126
|
+
)
|
|
127
|
+
return cls.UNKNOWN
|
|
128
|
+
|
|
92
129
|
|
|
93
130
|
class LightMode(Enum):
|
|
94
131
|
"""The light mode of the device."""
|
|
@@ -102,6 +139,14 @@ class LightMode(Enum):
|
|
|
102
139
|
#: Mood light mode.
|
|
103
140
|
MOOD = 1
|
|
104
141
|
|
|
142
|
+
@classmethod
|
|
143
|
+
def _missing_(cls, value: object) -> LightMode:
|
|
144
|
+
"""Return the unknown value if the value is not recognized."""
|
|
145
|
+
_LOGGER.warning(
|
|
146
|
+
f"Unexpected light mode '{value}'. Returning LightMode.UNKNOWN",
|
|
147
|
+
)
|
|
148
|
+
return cls.UNKNOWN
|
|
149
|
+
|
|
105
150
|
|
|
106
151
|
class DisplayTimeout(Enum):
|
|
107
152
|
"""Display timeout on device in seconds. Only specific values are allowed."""
|
|
@@ -124,6 +169,15 @@ class DisplayTimeout(Enum):
|
|
|
124
169
|
#: 1800 seconds (30m).
|
|
125
170
|
S1800 = 1800
|
|
126
171
|
|
|
172
|
+
@classmethod
|
|
173
|
+
def _missing_(cls, value: object) -> DisplayTimeout:
|
|
174
|
+
"""Return the unknown value if the value is not recognized."""
|
|
175
|
+
_LOGGER.warning(
|
|
176
|
+
f"Unexpected display timeout '{value}'. Returning DisplayTimeout.UNKNOWN",
|
|
177
|
+
)
|
|
178
|
+
return cls.UNKNOWN
|
|
179
|
+
|
|
180
|
+
|
|
127
181
|
class TemperatureUnit(Enum):
|
|
128
182
|
"""The status of the temperature unit of the device."""
|
|
129
183
|
|
|
@@ -136,6 +190,15 @@ class TemperatureUnit(Enum):
|
|
|
136
190
|
#: Display unit is Fahrenheit.
|
|
137
191
|
FAHRENHEIT = 1
|
|
138
192
|
|
|
193
|
+
@classmethod
|
|
194
|
+
def _missing_(cls, value: object) -> TemperatureUnit:
|
|
195
|
+
"""Return the unknown value if the value is not recognized."""
|
|
196
|
+
_LOGGER.warning(
|
|
197
|
+
f"Unexpected temperature unit '{value}'. Returning TemperatureUnit.UNKNOWN",
|
|
198
|
+
)
|
|
199
|
+
return cls.UNKNOWN
|
|
200
|
+
|
|
201
|
+
|
|
139
202
|
class GridStatus(Enum):
|
|
140
203
|
"""The grid connection status."""
|
|
141
204
|
|
|
@@ -156,6 +219,14 @@ class GridStatus(Enum):
|
|
|
156
219
|
#: No grid connection.
|
|
157
220
|
NO_GRID = 6
|
|
158
221
|
|
|
222
|
+
@classmethod
|
|
223
|
+
def _missing_(cls, value: object) -> GridStatus:
|
|
224
|
+
"""Return the unknown value if the value is not recognized."""
|
|
225
|
+
_LOGGER.warning(
|
|
226
|
+
f"Unexpected grid status '{value}'. Returning GridStatus.UNKNOWN",
|
|
227
|
+
)
|
|
228
|
+
return cls.UNKNOWN
|
|
229
|
+
|
|
159
230
|
|
|
160
231
|
class SBUsageMode(Enum):
|
|
161
232
|
"""Usage mode of a Solarbank device."""
|
|
@@ -184,6 +255,14 @@ class SBUsageMode(Enum):
|
|
|
184
255
|
#: Time slot mode.
|
|
185
256
|
TIME_SLOT = 8
|
|
186
257
|
|
|
258
|
+
@classmethod
|
|
259
|
+
def _missing_(cls, value: object) -> SBUsageMode:
|
|
260
|
+
"""Return the unknown value if the value is not recognized."""
|
|
261
|
+
_LOGGER.warning(
|
|
262
|
+
f"Unexpected SB usage mode '{value}'. Returning SBUsageMode.UNKNOWN",
|
|
263
|
+
)
|
|
264
|
+
return cls.UNKNOWN
|
|
265
|
+
|
|
187
266
|
|
|
188
267
|
class SBPowerCutoff(Enum):
|
|
189
268
|
"""Power cutoff threshold of a Solarbank device in %."""
|
|
@@ -197,6 +276,14 @@ class SBPowerCutoff(Enum):
|
|
|
197
276
|
#: 10 %.
|
|
198
277
|
P10 = 10
|
|
199
278
|
|
|
279
|
+
@classmethod
|
|
280
|
+
def _missing_(cls, value: object) -> SBPowerCutoff:
|
|
281
|
+
"""Return the unknown value if the value is not recognized."""
|
|
282
|
+
_LOGGER.warning(
|
|
283
|
+
f"Unexpected SB cutoff '{value}'. Returning SBPowerCutoff.UNKNOWN",
|
|
284
|
+
)
|
|
285
|
+
return cls.UNKNOWN
|
|
286
|
+
|
|
200
287
|
|
|
201
288
|
class PortOverload(Enum):
|
|
202
289
|
"""The overload status of a port."""
|
|
@@ -215,3 +302,11 @@ class PortOverload(Enum):
|
|
|
215
302
|
|
|
216
303
|
#: USB C3 overload detected.
|
|
217
304
|
USB_C3 = 10
|
|
305
|
+
|
|
306
|
+
@classmethod
|
|
307
|
+
def _missing_(cls, value: object) -> PortOverload:
|
|
308
|
+
"""Return the unknown value if the value is not recognized."""
|
|
309
|
+
_LOGGER.warning(
|
|
310
|
+
f"Unexpected port overload '{value}'. Returning PortOverload.UNKNOWN",
|
|
311
|
+
)
|
|
312
|
+
return cls.UNKNOWN
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: SolixBLE
|
|
3
|
-
Version: 4.0.
|
|
3
|
+
Version: 4.0.0b4
|
|
4
4
|
Summary: Python module for monitoring & controlling Bluetooth Anker Solix devices
|
|
5
5
|
Author-email: Harvey Lelliott <harveylelliott@duck.com>
|
|
6
6
|
License: MIT License
|
|
@@ -105,6 +105,7 @@ See the [support table](https://solixble.readthedocs.io/en/latest) in the docume
|
|
|
105
105
|
- F3800
|
|
106
106
|
- Solarbank 2
|
|
107
107
|
- Solarbank 3
|
|
108
|
+
- Prime Charge Base 150w
|
|
108
109
|
- Prime Charger 160w
|
|
109
110
|
- Prime Charger 250w
|
|
110
111
|
- Prime MagGo 3in1 (A25X7)
|
|
@@ -27,6 +27,7 @@ SolixBLE/devices/f2600.py
|
|
|
27
27
|
SolixBLE/devices/f3800.py
|
|
28
28
|
SolixBLE/devices/generic.py
|
|
29
29
|
SolixBLE/devices/maggo_3in1.py
|
|
30
|
+
SolixBLE/devices/prime_charge_base_150w.py
|
|
30
31
|
SolixBLE/devices/prime_charger_160w.py
|
|
31
32
|
SolixBLE/devices/prime_charger_250w.py
|
|
32
33
|
SolixBLE/devices/prime_power_bank_20k.py
|
|
@@ -29,6 +29,11 @@ from tests.devices.c1000 import (
|
|
|
29
29
|
C1000_TEST_COMMANDS_RESPONSES,
|
|
30
30
|
)
|
|
31
31
|
from tests.devices.c1000g2 import C1000G2_TEST_COMMANDS, C1000G2_TEST_COMMANDS_E2E
|
|
32
|
+
from tests.devices.f2000 import (
|
|
33
|
+
F2000_TEST_COMMANDS,
|
|
34
|
+
F2000_TEST_COMMANDS_E2E,
|
|
35
|
+
F2000_TEST_COMMANDS_RESPONSES,
|
|
36
|
+
)
|
|
32
37
|
from tests.devices.f2600 import (
|
|
33
38
|
F2600_TEST_COMMANDS,
|
|
34
39
|
F2600_TEST_COMMANDS_E2E,
|
|
@@ -55,6 +60,7 @@ from tests.helpers import MockDevice
|
|
|
55
60
|
*C800_TEST_COMMANDS,
|
|
56
61
|
*C1000_TEST_COMMANDS,
|
|
57
62
|
*C1000G2_TEST_COMMANDS,
|
|
63
|
+
*F2000_TEST_COMMANDS,
|
|
58
64
|
*F2600_TEST_COMMANDS,
|
|
59
65
|
*F3800_TEST_COMMANDS,
|
|
60
66
|
*PRIME_CHARGER_160W_TEST_COMMANDS,
|
|
@@ -107,6 +113,7 @@ async def test_send_command(
|
|
|
107
113
|
*C300_TEST_COMMANDS_RESPONSES,
|
|
108
114
|
*C800_TEST_COMMANDS_RESPONSES,
|
|
109
115
|
*C1000_TEST_COMMANDS_RESPONSES,
|
|
116
|
+
*F2000_TEST_COMMANDS_RESPONSES,
|
|
110
117
|
*F2600_TEST_COMMANDS_RESPONSES,
|
|
111
118
|
],
|
|
112
119
|
)
|
|
@@ -176,6 +183,7 @@ async def test_send_command_response( # noqa: PLR0913, PLR0917
|
|
|
176
183
|
*C800_TEST_COMMANDS_E2E,
|
|
177
184
|
*C1000_TEST_COMMANDS_E2E,
|
|
178
185
|
*C1000G2_TEST_COMMANDS_E2E,
|
|
186
|
+
*F2000_TEST_COMMANDS_E2E,
|
|
179
187
|
*F2600_TEST_COMMANDS_E2E,
|
|
180
188
|
*F3800_TEST_COMMANDS_E2E,
|
|
181
189
|
*PRIME_CHARGER_160W_TEST_COMMANDS_E2E,
|
|
@@ -23,6 +23,7 @@ from SolixBLE import (
|
|
|
23
23
|
MagGo3in1,
|
|
24
24
|
PortOverload,
|
|
25
25
|
PortStatus,
|
|
26
|
+
PrimeChargeBase150w,
|
|
26
27
|
PrimeCharger160w,
|
|
27
28
|
PrimeCharger250w,
|
|
28
29
|
PrimeDevice,
|
|
@@ -1007,6 +1008,31 @@ from tests.helpers import MockDevice, install_session_keys
|
|
|
1007
1008
|
},
|
|
1008
1009
|
id="f2600_solar_discharging",
|
|
1009
1010
|
),
|
|
1011
|
+
# Anker Prime Charging Base 150w
|
|
1012
|
+
pytest.param(
|
|
1013
|
+
PrimeChargeBase150w,
|
|
1014
|
+
"a10131a20e04015d001800df000008ffffffffa30e0401320001000500ff00ffffffffa409040132000100050000a5080401d3002400f702a60302e003fe05033bfb0b6b",
|
|
1015
|
+
{
|
|
1016
|
+
"usb_port_c1": PortStatus.OUTPUT,
|
|
1017
|
+
"usb_c1_current": 2.4,
|
|
1018
|
+
"usb_c1_power": 22.3,
|
|
1019
|
+
"usb_c1_voltage": 9.3,
|
|
1020
|
+
"usb_port_c2": PortStatus.OUTPUT,
|
|
1021
|
+
"usb_c2_current": 0.1,
|
|
1022
|
+
"usb_c2_power": 0.5,
|
|
1023
|
+
"usb_c2_voltage": 5.0,
|
|
1024
|
+
"usb_port_a1": PortStatus.OUTPUT,
|
|
1025
|
+
"usb_a1_current": 0.1,
|
|
1026
|
+
"usb_a1_power": 0.5,
|
|
1027
|
+
"usb_a1_voltage": 5.0,
|
|
1028
|
+
"dock_status": PortStatus.OUTPUT,
|
|
1029
|
+
"dock_voltage": 21.1,
|
|
1030
|
+
"dock_current": 3.6,
|
|
1031
|
+
"dock_power": 75.9,
|
|
1032
|
+
"power_out": 99.2,
|
|
1033
|
+
},
|
|
1034
|
+
id="prime_charge_base_150w",
|
|
1035
|
+
),
|
|
1010
1036
|
],
|
|
1011
1037
|
)
|
|
1012
1038
|
async def test_values(
|
|
@@ -1488,10 +1514,7 @@ async def test_telemetry_packet_processing( # noqa: PLR0913, PLR0917
|
|
|
1488
1514
|
for packet in packets:
|
|
1489
1515
|
await mock_bluetooth.send_data([bytes.fromhex(packet)])
|
|
1490
1516
|
|
|
1491
|
-
device_parameters = (
|
|
1492
|
-
device._data.to_str(verbose=False)
|
|
1493
|
-
if device._data else None
|
|
1494
|
-
)
|
|
1517
|
+
device_parameters = device._data.to_str(verbose=False) if device._data else None
|
|
1495
1518
|
|
|
1496
1519
|
assert parameters == device_parameters, "Parameters do not match expected!"
|
|
1497
1520
|
|
|
@@ -1569,8 +1592,8 @@ async def test_generic_packet_processing( # noqa: PLR0913, PLR0917
|
|
|
1569
1592
|
await mock_bluetooth.send_data([bytes.fromhex(packet)])
|
|
1570
1593
|
|
|
1571
1594
|
for expected_log_entry in expected_logs:
|
|
1572
|
-
assert (
|
|
1573
|
-
|
|
1595
|
+
assert expected_log_entry in str(
|
|
1596
|
+
caplog.text
|
|
1574
1597
|
), f"Expected to find '{expected_log_entry}' in logs but it was not found!"
|
|
1575
1598
|
|
|
1576
1599
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|