aioccl 2024.12.5__tar.gz → 2024.12.7__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.1
2
2
  Name: aioccl
3
- Version: 2024.12.5
3
+ Version: 2024.12.7
4
4
  Summary: A Python library for CCL API server
5
5
  Home-page: https://github.com/fkiscd/aioccl
6
6
  Download-URL: https://github.com/fkiscd/aioccl
@@ -16,21 +16,21 @@ CCL_DEVICE_INFO_TYPES = ("serial_no", "mac_address", "model", "fw_ver")
16
16
  class CCLDevice:
17
17
  """Mapping for a CCL device."""
18
18
  _binary_sensors: dict[str, CCLSensor] | None = {}
19
- _fw_ver: str | None
20
- _last_updated_time: float | None
21
- _mac_address: str | None
22
- _model: str | None
19
+ _device_id: str | None = None
20
+ _fw_ver: str | None = None
21
+ _last_updated_time: float | None = None
22
+ _mac_address: str | None = None
23
+ _model: str | None = None
23
24
  _new_binary_sensor_callbacks = set()
24
25
  _new_sensors: list[CCLSensor] | None = []
25
26
  _new_sensor_callbacks = set()
27
+ _passkey = ''
26
28
  _sensors: dict[str, CCLSensor] | None = {}
27
- _serial_no: str | None
28
- _update_callbacks = set()
29
-
29
+ _serial_no: str | None = None
30
+ _update_callbacks = set()
30
31
 
31
32
  def __init__(self, passkey: str):
32
33
  """Initialize a CCL device."""
33
- _LOGGER.debug("Initializing CCL Device: %s", self)
34
34
  self._passkey = passkey
35
35
 
36
36
  @property
@@ -41,12 +41,18 @@ class CCLDevice:
41
41
  @property
42
42
  def device_id(self) -> str | None:
43
43
  """Return the device ID."""
44
- return self._mac_address.replace(":", "").lower()[-6:]
44
+ try:
45
+ self._device_id = self._mac_address.replace(":", "").lower()[-6:]
46
+ except Exception: # pylint: disable=broad-exception-caught
47
+ return None
48
+ return self._device_id
45
49
 
46
50
  @property
47
51
  def name(self) -> str | None:
48
52
  """Return the display name."""
49
- return self._model + " - " + self.device_id
53
+ if self._device_id is not None:
54
+ return self._model + " - " + self._device_id
55
+ return self._model
50
56
 
51
57
  @property
52
58
  def mac_address(self) -> str | None:
@@ -133,7 +139,6 @@ class CCLDevice:
133
139
  """Schedule call all registered callbacks."""
134
140
  for sensor in self._new_sensors[:]:
135
141
  try:
136
- _LOGGER.debug("Publishing new sensor: %s", sensor)
137
142
  if sensor.binary:
138
143
  for callback in self._new_binary_sensor_callbacks:
139
144
  callback(sensor)
@@ -34,8 +34,9 @@ class CCLSensor:
34
34
  @property
35
35
  def compartment(self) -> None | str:
36
36
  """Decide which compartment it belongs to."""
37
- if CCL_SENSORS[self._key].compartment:
37
+ if CCL_SENSORS[self._key].compartment in CCLDeviceCompartment:
38
38
  return CCL_SENSORS[self._key].compartment.value
39
+ return None
39
40
 
40
41
  @property
41
42
  def binary(self) -> bool:
@@ -47,14 +48,12 @@ class CCLSensor:
47
48
  """Return the intrinsic sensor value."""
48
49
  if self.sensor_type.name in CCL_SENSOR_VALUES:
49
50
  return CCL_SENSOR_VALUES[self.sensor_type.name].get(self._value)
50
- elif self.sensor_type == CCLSensorTypes.BATTERY_BINARY:
51
+ if self.sensor_type == CCLSensorTypes.BATTERY_BINARY:
51
52
  try:
52
- x = int(self._value) - 1
53
- return x
53
+ return int(self._value) - 1
54
54
  except ValueError:
55
55
  pass
56
- else:
57
- return self._value
56
+ return self._value
58
57
 
59
58
  @value.setter
60
59
  def value(self, new_value):
@@ -67,7 +66,7 @@ class CCLSensorPreset:
67
66
 
68
67
  name: str
69
68
  sensor_type: str
70
- compartment: None | CCLDeviceCompartment = None
69
+ compartment: CCLDeviceCompartment | None = None
71
70
  binary: bool = False
72
71
 
73
72
 
@@ -3,7 +3,6 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import logging
6
- from typing import Callable
7
6
 
8
7
  from aiohttp import web
9
8
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aioccl
3
- Version: 2024.12.5
3
+ Version: 2024.12.7
4
4
  Summary: A Python library for CCL API server
5
5
  Home-page: https://github.com/fkiscd/aioccl
6
6
  Download-URL: https://github.com/fkiscd/aioccl
@@ -3,7 +3,7 @@
3
3
  from pathlib import Path
4
4
  from setuptools import find_packages, setup
5
5
 
6
- VERSION = "2024.12.5"
6
+ VERSION = "2024.12.7"
7
7
 
8
8
  ROOT_DIR = Path(__file__).parent.resolve()
9
9
 
File without changes
File without changes
File without changes