aioccl 2024.12.2__py3-none-any.whl → 2024.12.5__py3-none-any.whl
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.
- aioccl/sensor.py +4 -3
- aioccl/server.py +8 -12
- {aioccl-2024.12.2.dist-info → aioccl-2024.12.5.dist-info}/METADATA +1 -1
- aioccl-2024.12.5.dist-info/RECORD +9 -0
- aioccl-2024.12.2.dist-info/RECORD +0 -9
- {aioccl-2024.12.2.dist-info → aioccl-2024.12.5.dist-info}/LICENSE +0 -0
- {aioccl-2024.12.2.dist-info → aioccl-2024.12.5.dist-info}/WHEEL +0 -0
- {aioccl-2024.12.2.dist-info → aioccl-2024.12.5.dist-info}/top_level.txt +0 -0
aioccl/sensor.py
CHANGED
@@ -13,7 +13,7 @@ class CCLSensor:
|
|
13
13
|
"""Initialize a CCL sensor."""
|
14
14
|
self._value: None | str | int | float = None
|
15
15
|
|
16
|
-
if key in CCL_SENSORS
|
16
|
+
if key in CCL_SENSORS:
|
17
17
|
self._key = key
|
18
18
|
|
19
19
|
@property
|
@@ -34,7 +34,7 @@ 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:
|
38
38
|
return CCL_SENSORS[self._key].compartment.value
|
39
39
|
|
40
40
|
@property
|
@@ -49,7 +49,8 @@ class CCLSensor:
|
|
49
49
|
return CCL_SENSOR_VALUES[self.sensor_type.name].get(self._value)
|
50
50
|
elif self.sensor_type == CCLSensorTypes.BATTERY_BINARY:
|
51
51
|
try:
|
52
|
-
|
52
|
+
x = int(self._value) - 1
|
53
|
+
return x
|
53
54
|
except ValueError:
|
54
55
|
pass
|
55
56
|
else:
|
aioccl/server.py
CHANGED
@@ -24,15 +24,10 @@ class CCLServer:
|
|
24
24
|
def register(device: CCLDevice) -> None:
|
25
25
|
"""Register a device with a passkey."""
|
26
26
|
CCLServer.devices.setdefault(device.passkey, device)
|
27
|
-
_LOGGER.debug("Device registered: %s",
|
28
|
-
|
29
|
-
@staticmethod
|
30
|
-
def get_handler() -> Callable[[web.BaseRequest], web.Response]:
|
31
|
-
"""Get the handler."""
|
32
|
-
return CCLServer._handler
|
27
|
+
_LOGGER.debug("Device registered: %s", device)
|
33
28
|
|
34
29
|
@staticmethod
|
35
|
-
async def
|
30
|
+
async def handler(request: web.BaseRequest | web.Request) -> web.Response:
|
36
31
|
"""Handle POST requests for data updating."""
|
37
32
|
_body: dict[str, None | str | int | float] = {}
|
38
33
|
_device: CCLDevice = None
|
@@ -43,11 +38,12 @@ class CCLServer:
|
|
43
38
|
_text: None | str = None
|
44
39
|
|
45
40
|
try:
|
46
|
-
|
47
|
-
|
48
|
-
|
41
|
+
_passkey = request.path[-8:]
|
42
|
+
for passkey in CCLServer.devices:
|
43
|
+
if passkey == _passkey:
|
44
|
+
_device = CCLServer.devices[_passkey]
|
49
45
|
break
|
50
|
-
assert _device, 404
|
46
|
+
assert isinstance(_device, CCLDevice), 404
|
51
47
|
|
52
48
|
assert request.content_type == "application/json", 400
|
53
49
|
assert 0 < request.content_length <= 5000, 400
|
@@ -81,7 +77,7 @@ class CCLServer:
|
|
81
77
|
return web.Response(status=_status, text=_text)
|
82
78
|
|
83
79
|
app = web.Application()
|
84
|
-
app.add_routes([web.get('/{passkey}',
|
80
|
+
app.add_routes([web.get('/{passkey}', handler)])
|
85
81
|
runner = web.AppRunner(app)
|
86
82
|
|
87
83
|
@staticmethod
|
@@ -0,0 +1,9 @@
|
|
1
|
+
aioccl/__init__.py,sha256=XnegKtbvHvUTwVuuWNLb4LB9ZuGGar0xrZYOqk7scyg,133
|
2
|
+
aioccl/device.py,sha256=4TYkr3O4XI2l3XdTlGs62qXxsa0pA0_ig0d87nXwaSY,5278
|
3
|
+
aioccl/sensor.py,sha256=6F4iJytKjP6GkOtjxBVb31roIop_C1qnHt_wBP88dHE,16908
|
4
|
+
aioccl/server.py,sha256=9-rn-kQKKYguqOALTHE2kLzgZBa43SvrbrPN7O8U9jw,3237
|
5
|
+
aioccl-2024.12.5.dist-info/LICENSE,sha256=PBRsTHchx7o0TQ2R2ktEAfFmn1iNHTxcOP_xaeuSAuo,11349
|
6
|
+
aioccl-2024.12.5.dist-info/METADATA,sha256=6_9VudA-dBm5hqwYandmLBfQeaqb427m0naX7sTQZtk,768
|
7
|
+
aioccl-2024.12.5.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
8
|
+
aioccl-2024.12.5.dist-info/top_level.txt,sha256=-xIJfyfXTaW_EH7XCIHyxjSSSwjLmawa2qhsrHZH1vA,7
|
9
|
+
aioccl-2024.12.5.dist-info/RECORD,,
|
@@ -1,9 +0,0 @@
|
|
1
|
-
aioccl/__init__.py,sha256=XnegKtbvHvUTwVuuWNLb4LB9ZuGGar0xrZYOqk7scyg,133
|
2
|
-
aioccl/device.py,sha256=4TYkr3O4XI2l3XdTlGs62qXxsa0pA0_ig0d87nXwaSY,5278
|
3
|
-
aioccl/sensor.py,sha256=tMv_ypqsDIxWdghHQv91PUTOt2kUJGygZmFnJtzOx0k,16905
|
4
|
-
aioccl/server.py,sha256=k1YgFeNImxYILxalPIV23UDB3hvjaOH4pVWeB7cJkmM,3343
|
5
|
-
aioccl-2024.12.2.dist-info/LICENSE,sha256=PBRsTHchx7o0TQ2R2ktEAfFmn1iNHTxcOP_xaeuSAuo,11349
|
6
|
-
aioccl-2024.12.2.dist-info/METADATA,sha256=gYgnLScvW9u0xS60IzPWhLc0OqwKJrUQzMEDufl3w0E,768
|
7
|
-
aioccl-2024.12.2.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
8
|
-
aioccl-2024.12.2.dist-info/top_level.txt,sha256=-xIJfyfXTaW_EH7XCIHyxjSSSwjLmawa2qhsrHZH1vA,7
|
9
|
-
aioccl-2024.12.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|