python-ember-mug 1.3.2__tar.gz → 1.4.0b1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-ember-mug
3
- Version: 1.3.2
3
+ Version: 1.4.0b1
4
4
  Summary: Python Library for Ember Mugs.
5
5
  Project-URL: Changelog, https://sopelj.github.io/python-ember-mug/changelog/
6
6
  Project-URL: Documentation, https://sopelj.github.io/python-ember-mug/
@@ -19,11 +19,11 @@ Classifier: Programming Language :: Python :: 3.13
19
19
  Classifier: Programming Language :: Python :: 3.14
20
20
  Requires-Python: >=3.11
21
21
  Requires-Dist: bleak-retry-connector>=4.0.2
22
- Requires-Dist: bleak<2.2.0,>=1.0.1
22
+ Requires-Dist: bleak>=1.0.1
23
23
  Provides-Extra: dev
24
24
  Requires-Dist: ipython; extra == 'dev'
25
25
  Provides-Extra: docs
26
- Requires-Dist: black; extra == 'docs'
26
+ Requires-Dist: black>=26.3.1; extra == 'docs'
27
27
  Requires-Dist: mkdocs-autorefs; extra == 'docs'
28
28
  Requires-Dist: mkdocs-gen-files; extra == 'docs'
29
29
  Requires-Dist: mkdocs-include-markdown-plugin<8.0.0,>=7.0.0; extra == 'docs'
@@ -6,4 +6,4 @@ __all__ = ("EmberMug",)
6
6
 
7
7
  __author__ = """Jesse Sopel"""
8
8
  __email__ = "jesse@sopelj.ca"
9
- __version__ = "1.3.2"
9
+ __version__ = "1.4.0b1"
@@ -10,13 +10,14 @@ import sys
10
10
  from argparse import ArgumentParser, ArgumentTypeError, FileType, Namespace
11
11
  from typing import TYPE_CHECKING, ClassVar
12
12
 
13
- from bleak import AdvertisementData, BleakError
13
+ from bleak import BleakError
14
14
 
15
15
  from ember_mug.consts import ATTR_LABELS, EMBER_BLE_SIG, EXTRA_ATTRS, IS_LINUX, TESTING_BLE_SIG, VolumeLevel
16
16
  from ember_mug.data import Colour, DeviceModel
17
17
  from ember_mug.mug import EmberMug
18
18
  from ember_mug.scanner import discover_devices, find_device
19
19
 
20
+ from .. import __version__
20
21
  from ..formatting import format_capacity
21
22
  from ..utils import get_model_info_from_advertiser_data
22
23
  from .helpers import CommandLoop, print_changes, print_info, print_table, validate_mac
@@ -24,6 +25,7 @@ from .helpers import CommandLoop, print_changes, print_info, print_table, valida
24
25
  if TYPE_CHECKING:
25
26
  from collections.abc import Awaitable, Callable
26
27
 
28
+ from bleak import AdvertisementData
27
29
  from bleak.backends.device import BLEDevice
28
30
 
29
31
  all_attrs = list(ATTR_LABELS) + list(EXTRA_ATTRS)
@@ -206,19 +208,20 @@ class EmberMugCli:
206
208
  type=validate_mac,
207
209
  help="Only look for this specific address",
208
210
  )
209
- shared_parser.add_argument(
211
+ self.parser.add_argument(
210
212
  "-d",
211
213
  "--debug",
212
214
  action="store_true",
213
215
  help="Print extra information for development or debugging issues",
214
216
  )
215
- shared_parser.add_argument(
217
+ self.parser.add_argument(
216
218
  "--log-file",
217
219
  type=FileType("w", encoding="utf-8"),
218
220
  nargs="?",
219
221
  default=sys.stdout,
220
222
  help="File to write logs too (Will be overwritten)",
221
223
  )
224
+ self.parser.add_argument("--version", action="version", version=__version__)
222
225
  shared_parser.add_argument("-r", "--raw", help="No formatting. One value per line.", action="store_true")
223
226
  if IS_LINUX is True:
224
227
  # Only works on Linux with BlueZ so don't add for others.
@@ -206,7 +206,7 @@ class MugMeta(AsDict):
206
206
 
207
207
 
208
208
  @dataclass
209
- class MugData(AsDict):
209
+ class MugData:
210
210
  """Class to store/display the state of the mug."""
211
211
 
212
212
  # Options
@@ -41,7 +41,7 @@ from .utils import (
41
41
  )
42
42
 
43
43
  if TYPE_CHECKING:
44
- from collections.abc import AsyncIterator, Awaitable, Callable
44
+ from collections.abc import AsyncGenerator, Awaitable, Callable
45
45
 
46
46
  from bleak.backends.characteristic import BleakGATTCharacteristic
47
47
  from bleak.backends.device import BLEDevice
@@ -266,11 +266,11 @@ class EmberMug:
266
266
 
267
267
  async def get_meta(self) -> MugMeta:
268
268
  """Fetch Meta info from the mug (Serial number and ID)."""
269
- return MugMeta.from_bytes(await self._read(MugCharacteristic.MUG_ID))
269
+ return MugMeta.from_bytes(bytes(await self._read(MugCharacteristic.MUG_ID)))
270
270
 
271
271
  async def get_battery(self) -> BatteryInfo:
272
272
  """Get Battery percent from mug gatt."""
273
- return BatteryInfo.from_bytes(await self._read(MugCharacteristic.BATTERY))
273
+ return BatteryInfo.from_bytes(bytes(await self._read(MugCharacteristic.BATTERY)))
274
274
 
275
275
  async def make_writable(self) -> bool:
276
276
  """Try to make device writable if need be."""
@@ -419,7 +419,7 @@ class EmberMug:
419
419
 
420
420
  async def get_firmware(self) -> MugFirmwareInfo:
421
421
  """Get firmware info."""
422
- return MugFirmwareInfo.from_bytes(await self._read(MugCharacteristic.FIRMWARE))
422
+ return MugFirmwareInfo.from_bytes(bytes(await self._read(MugCharacteristic.FIRMWARE)))
423
423
 
424
424
  async def update_initial(self) -> list[Change]:
425
425
  """Update attributes that don't normally change and don't need to be regularly updated."""
@@ -525,7 +525,7 @@ class EmberMug:
525
525
  self._client_kwargs = {**kwargs}
526
526
 
527
527
  @contextlib.asynccontextmanager
528
- async def connection(self, **kwargs: str) -> AsyncIterator[EmberMug]:
528
+ async def connection(self, **kwargs: str) -> AsyncGenerator[EmberMug]:
529
529
  """Establish a connection and close automatically."""
530
530
  self.set_client_options(**kwargs)
531
531
  # This will happen automatically, but calling it now will give us immediate feedback
@@ -65,7 +65,7 @@ def get_colour_from_int(colour_id: int) -> DeviceColour | None: # noqa: PLR0911
65
65
  """Extrapolate device colour from integer in advertiser data."""
66
66
  if colour_id in (-127, -63, 1, 14, 65):
67
67
  return DeviceColour.BLACK
68
- if colour_id in (-126, -62, 2):
68
+ if colour_id in (-126, -62, 2, 130):
69
69
  return DeviceColour.WHITE
70
70
  if colour_id in (-120, -117, -63, -56, -53, 8, 11):
71
71
  return DeviceColour.RED
@@ -18,7 +18,7 @@ classifiers = [
18
18
  ]
19
19
  dependencies = [
20
20
  "bleak-retry-connector>=4.0.2",
21
- "bleak>=1.0.1,<2.2.0",
21
+ "bleak>=1.0.1",
22
22
  ]
23
23
 
24
24
  [project.optional-dependencies]
@@ -32,7 +32,7 @@ docs = [
32
32
  "mkdocs-autorefs",
33
33
  "mkdocs-literate-nav",
34
34
  "mkdocs-gen-files",
35
- "black",
35
+ "black>=26.3.1",
36
36
  "termynal",
37
37
  ]
38
38
  dev = ["ipython"]
@@ -76,13 +76,14 @@ features = ["test"]
76
76
 
77
77
  [[tool.hatch.envs.test.matrix]]
78
78
  python = ["3.11", "3.12", "3.13", "3.14"]
79
+ bleak = ["1.0.1", "2.0.0", "3.0.2"]
79
80
 
80
81
  [tool.hatch.envs.test.scripts]
81
82
  cov = "pytest -vvv --asyncio-mode=auto --cov=ember_mug --cov-branch --cov-report=xml --cov-report=term-missing tests"
82
83
  no-cov = "cov --no-cov"
83
84
 
84
85
  [tool.hatch.envs.docs]
85
- python = "3.13"
86
+ python = "3.14"
86
87
  features = ["docs"]
87
88
 
88
89
  [tool.hatch.envs.docs.scripts]