aioccl 2024.7__py3-none-any.whl → 2024.7.2__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/device.py +50 -22
- aioccl/sensor.py +52 -6
- aioccl/server.py +1 -1
- {aioccl-2024.7.dist-info → aioccl-2024.7.2.dist-info}/LICENSE +1 -1
- {aioccl-2024.7.dist-info → aioccl-2024.7.2.dist-info}/METADATA +1 -1
- aioccl-2024.7.2.dist-info/RECORD +9 -0
- {aioccl-2024.7.dist-info → aioccl-2024.7.2.dist-info}/WHEEL +1 -1
- aioccl-2024.7.dist-info/RECORD +0 -9
- {aioccl-2024.7.dist-info → aioccl-2024.7.2.dist-info}/top_level.txt +0 -0
aioccl/device.py
CHANGED
@@ -5,7 +5,7 @@ import logging
|
|
5
5
|
import time
|
6
6
|
from typing import Callable
|
7
7
|
|
8
|
-
from .sensor import CCLSensor
|
8
|
+
from .sensor import CCLSensor, CCL_SENSORS
|
9
9
|
|
10
10
|
_LOGGER = logging.getLogger(__name__)
|
11
11
|
|
@@ -17,14 +17,13 @@ class CCLDevice:
|
|
17
17
|
_LOGGER.debug('Initializing CCL Device: %s', self)
|
18
18
|
self._passkey = passkey
|
19
19
|
|
20
|
-
self.
|
21
|
-
self.
|
22
|
-
self.
|
23
|
-
self.
|
24
|
-
|
25
|
-
self.
|
26
|
-
|
27
|
-
self.sensors: dict[str, CCLSensor] | None = {}
|
20
|
+
self._serial_no: str | None
|
21
|
+
self._mac_address: str | None
|
22
|
+
self._model: str | None
|
23
|
+
self._version: str | None
|
24
|
+
self._binary_sensors: dict[str, CCLSensor] | None = {}
|
25
|
+
self._sensors: dict[str, CCLSensor] | None = {}
|
26
|
+
self.last_updated_time: float | None
|
28
27
|
|
29
28
|
self._new_sensors: list[CCLSensor] | None = []
|
30
29
|
|
@@ -36,26 +35,56 @@ class CCLDevice:
|
|
36
35
|
return self._passkey
|
37
36
|
|
38
37
|
@property
|
39
|
-
def device_id(self) -> str:
|
40
|
-
return self.
|
38
|
+
def device_id(self) -> str | None:
|
39
|
+
return self._mac_address.replace(":", "").lower()[-6:]
|
40
|
+
|
41
|
+
@property
|
42
|
+
def serial_no(self) -> str | None:
|
43
|
+
return self._serial_no
|
44
|
+
|
45
|
+
@property
|
46
|
+
def mac_address(self) -> str | None:
|
47
|
+
return self._mac_address
|
48
|
+
|
49
|
+
@property
|
50
|
+
def model(self) -> str | None:
|
51
|
+
return self._model
|
52
|
+
|
53
|
+
@property
|
54
|
+
def version(self) -> str | None:
|
55
|
+
return self._version
|
56
|
+
|
57
|
+
@property
|
58
|
+
def binary_sensors(self) -> dict[str, CCLSensor] | None:
|
59
|
+
return self._binary_sensors
|
60
|
+
|
61
|
+
@property
|
62
|
+
def sensors(self) -> dict[str, CCLSensor] | None:
|
63
|
+
return self._sensors
|
41
64
|
|
42
65
|
def update_info(self, info: dict[str, None | str]) -> None:
|
43
66
|
"""Add or update device info."""
|
44
|
-
self.
|
45
|
-
self.
|
46
|
-
self.
|
47
|
-
self.
|
67
|
+
self._serial_no = info.get('serial_no')
|
68
|
+
self._mac_address = info.get('mac_address')
|
69
|
+
self._model = info.get('model')
|
70
|
+
self._version = info.get('version')
|
48
71
|
|
49
72
|
def update_sensors(self, sensors: dict[str, None | str | int | float]) -> None:
|
50
73
|
"""Add or update all sensor values."""
|
51
|
-
for
|
52
|
-
if
|
53
|
-
self.
|
54
|
-
|
55
|
-
|
74
|
+
for key, value in sensors.items():
|
75
|
+
if CCL_SENSORS[key].binary:
|
76
|
+
if not self._binary_sensors.get(key):
|
77
|
+
self._binary_sensors[key] = CCLSensor(key)
|
78
|
+
self._new_sensors.append(self._binary_sensors[key])
|
79
|
+
self._binary_sensors[key].value = value
|
80
|
+
else:
|
81
|
+
if not self._sensors.get(key):
|
82
|
+
self._sensors[key] = CCLSensor(key)
|
83
|
+
self._new_sensors.append(self.sensors[key])
|
84
|
+
self._sensors[key].value = value
|
56
85
|
self._publish_new_sensors()
|
57
86
|
self._publish_updates()
|
58
|
-
self.
|
87
|
+
self._last_updated_time = time.monotonic()
|
59
88
|
_LOGGER.debug("Sensors Updated: %s", self.last_updated_time)
|
60
89
|
|
61
90
|
def register_update_cb(self, callback: Callable[[], None]) -> None:
|
@@ -87,7 +116,6 @@ class CCLDevice:
|
|
87
116
|
try:
|
88
117
|
for sensor in self._new_sensors:
|
89
118
|
_LOGGER.debug("Publishing new sensor: %s", sensor)
|
90
|
-
_LOGGER.debug("Sensors remaining: %s", self._new_sensors)
|
91
119
|
for callback in self._new_sensor_callbacks:
|
92
120
|
callback(sensor)
|
93
121
|
self._new_sensors.clear()
|
aioccl/sensor.py
CHANGED
@@ -9,27 +9,38 @@ class CCLSensor:
|
|
9
9
|
|
10
10
|
def __init__(self, key: str):
|
11
11
|
"""Initialize a CCL sensor."""
|
12
|
-
self.
|
12
|
+
self._value: None | str | int | float
|
13
13
|
|
14
14
|
if key in CCL_SENSORS.keys():
|
15
15
|
self._key = key
|
16
16
|
|
17
17
|
@property
|
18
|
-
def key(self):
|
18
|
+
def key(self) -> str:
|
19
19
|
return self._key
|
20
20
|
|
21
21
|
@property
|
22
|
-
def name(self):
|
22
|
+
def name(self) -> str:
|
23
23
|
return CCL_SENSORS[self._key].name
|
24
24
|
|
25
25
|
@property
|
26
|
-
def sensor_type(self):
|
26
|
+
def sensor_type(self) -> CCLSensorTypes:
|
27
27
|
return CCL_SENSORS[self._key].sensor_type
|
28
|
+
|
29
|
+
@property
|
30
|
+
def binary(self) -> bool:
|
31
|
+
return CCL_SENSORS[self._key].binary
|
32
|
+
|
33
|
+
@property
|
34
|
+
def value(self):
|
35
|
+
if self.sensor_type == CCLSensorTypes.CH_SENSOR_TYPE:
|
36
|
+
return CCL_CH_SENSOR_TYPES[self.sensor_type]
|
37
|
+
return self._value
|
28
38
|
|
29
39
|
@dataclass
|
30
40
|
class CCLSensorPreset:
|
31
41
|
name: str
|
32
42
|
sensor_type: str
|
43
|
+
binary: bool = False
|
33
44
|
|
34
45
|
class CCLSensorTypes(enum.Enum):
|
35
46
|
PRESSURE = 1
|
@@ -37,6 +48,15 @@ class CCLSensorTypes(enum.Enum):
|
|
37
48
|
HUMIDITY = 3
|
38
49
|
WIND_DIRECITON = 4
|
39
50
|
WIND_SPEED = 5
|
51
|
+
RAIN_RATE = 6
|
52
|
+
RAINFALL = 7
|
53
|
+
UVI = 8
|
54
|
+
RADIATION = 9
|
55
|
+
BATTERY_BINARY = 10
|
56
|
+
CONNECTION = 11
|
57
|
+
CH_SENSOR_TYPE = 12
|
58
|
+
|
59
|
+
CCL_CH_SENSOR_TYPES: list[str] = [None, None, 'Thermo-Hygro', 'Pool', 'Soil']
|
40
60
|
|
41
61
|
CCL_SENSORS: dict[str, CCLSensorPreset] = {
|
42
62
|
'rbar': CCLSensorPreset('Air Pressure', CCLSensorTypes.PRESSURE),
|
@@ -44,6 +64,32 @@ CCL_SENSORS: dict[str, CCLSensorPreset] = {
|
|
44
64
|
'inhum': CCLSensorPreset('Indoor Humidity', CCLSensorTypes.HUMIDITY),
|
45
65
|
't1tem': CCLSensorPreset('Outdoor Temperature', CCLSensorTypes.TEMPERATURE),
|
46
66
|
't1hum': CCLSensorPreset('Outdoor Humidity', CCLSensorTypes.HUMIDITY),
|
47
|
-
't1wdir': CCLSensorPreset('
|
48
|
-
't1ws': CCLSensorPreset('
|
67
|
+
't1wdir': CCLSensorPreset('Wind Direction', CCLSensorTypes.WIND_DIRECITON),
|
68
|
+
't1ws': CCLSensorPreset('Wind Speed', CCLSensorTypes.WIND_SPEED),
|
69
|
+
't1ws10mav': CCLSensorPreset('Wind Speed (10 mins avg.)', CCLSensorTypes.WIND_SPEED),
|
70
|
+
't1wgust': CCLSensorPreset('Wind Gust', CCLSensorTypes.WIND_SPEED),
|
71
|
+
't1rainra': CCLSensorPreset('Rain Rate', CCLSensorTypes.RAIN_RATE),
|
72
|
+
't1rainhr': CCLSensorPreset('Hourly Rainfall', CCLSensorTypes.RAINFALL),
|
73
|
+
't1raindy': CCLSensorPreset('Daily Rainfall', CCLSensorTypes.RAINFALL),
|
74
|
+
't1rainwy': CCLSensorPreset('Weekly Rainfall', CCLSensorTypes.RAINFALL),
|
75
|
+
't1rainmth': CCLSensorPreset('Monthly Rainfall', CCLSensorTypes.RAINFALL),
|
76
|
+
't1uvi': CCLSensorPreset('UV Index', CCLSensorTypes.UVI),
|
77
|
+
't1solrad': CCLSensorPreset('Light Intensity', CCLSensorTypes.RADIATION),
|
78
|
+
't1bat': CCLSensorPreset('CH0 Battery', CCLSensorTypes.BATTERY_BINARY, True),
|
79
|
+
't1cn': CCLSensorPreset('CH0 Connection', CCLSensorTypes.CONNECTION),
|
80
|
+
't1feels': CCLSensorPreset('Feels Like', CCLSensorTypes.TEMPERATURE),
|
81
|
+
't1chill': CCLSensorPreset('Wind Chill', CCLSensorTypes.TEMPERATURE),
|
82
|
+
't1heat': CCLSensorPreset('Heat Index', CCLSensorTypes.TEMPERATURE),
|
83
|
+
't1dew': CCLSensorPreset('Dew Point', CCLSensorTypes.TEMPERATURE),
|
84
|
+
't1wbgt': CCLSensorPreset('WBGT Index', CCLSensorTypes.TEMPERATURE),
|
85
|
+
't234c1tem': CCLSensorPreset('CH1 Temperature', CCLSensorTypes.TEMPERATURE),
|
86
|
+
't234c1hum': CCLSensorPreset('CH1 Humidity', CCLSensorTypes.HUMIDITY),
|
87
|
+
't234c1bat': CCLSensorPreset('CH1 Battery', CCLSensorTypes.BATTERY_BINARY, True),
|
88
|
+
't234c1cn': CCLSensorPreset('CH1 Connection', CCLSensorTypes.CONNECTION, True),
|
89
|
+
't234c1tp': CCLSensorPreset('CH1 Sensor Type', CCLSensorTypes.CH_SENSOR_TYPE),
|
90
|
+
't234c2tem': CCLSensorPreset('CH2 Temperature', CCLSensorTypes.TEMPERATURE),
|
91
|
+
't234c2hum': CCLSensorPreset('CH2 Humidity', CCLSensorTypes.HUMIDITY),
|
92
|
+
't234c2bat': CCLSensorPreset('CH2 Battery', CCLSensorTypes.BATTERY_BINARY, True),
|
93
|
+
't234c2cn': CCLSensorPreset('CH2 Connection', CCLSensorTypes.CONNECTION, True),
|
94
|
+
't234c2tp': CCLSensorPreset('CH2 Sensor Type', CCLSensorTypes.CH_SENSOR_TYPE),
|
49
95
|
}
|
aioccl/server.py
CHANGED
@@ -186,7 +186,7 @@
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
187
187
|
identification within third-party archives.
|
188
188
|
|
189
|
-
Copyright 2024
|
189
|
+
Copyright 2024 CCL Electronics Ltd
|
190
190
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
192
192
|
you may not use this file except in compliance with the License.
|
@@ -0,0 +1,9 @@
|
|
1
|
+
aioccl/__init__.py,sha256=iL1OC2F_rf3qkswi-bO8Y_uj2-lf284LCnyxwqdLUU8,137
|
2
|
+
aioccl/device.py,sha256=RzneGYQujYdQGRa7G382hIea1Q95V-LJ_gi5x7pmeSk,4380
|
3
|
+
aioccl/sensor.py,sha256=jonbAEgs1QG6akjNBv_2Rd1DGscd3rV5yVs1zFjR5GY,3991
|
4
|
+
aioccl/server.py,sha256=JPwhjp7pzQnm7J2RcHh3GiaqBc-jkRH2mQA4KHJzm28,3669
|
5
|
+
aioccl-2024.7.2.dist-info/LICENSE,sha256=PBRsTHchx7o0TQ2R2ktEAfFmn1iNHTxcOP_xaeuSAuo,11349
|
6
|
+
aioccl-2024.7.2.dist-info/METADATA,sha256=o3zif4UU7Bu7JCu_74WkfVPrhZGGPIzh_xJOToBYXbc,769
|
7
|
+
aioccl-2024.7.2.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
8
|
+
aioccl-2024.7.2.dist-info/top_level.txt,sha256=-xIJfyfXTaW_EH7XCIHyxjSSSwjLmawa2qhsrHZH1vA,7
|
9
|
+
aioccl-2024.7.2.dist-info/RECORD,,
|
aioccl-2024.7.dist-info/RECORD
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
aioccl/__init__.py,sha256=iL1OC2F_rf3qkswi-bO8Y_uj2-lf284LCnyxwqdLUU8,137
|
2
|
-
aioccl/device.py,sha256=Wat8WNJQ3MNDXiW5gfs_GHSeamNgqAdZ-g1xmVYCHdc,3510
|
3
|
-
aioccl/sensor.py,sha256=A6Puccd49P7h_o3J-v4R9eyvpIl4t342Y_rAMWTwtGs,1435
|
4
|
-
aioccl/server.py,sha256=yu1LUwR3yslL92SYaTqey-itkFIPQjUeNYvZQ27kl5E,3673
|
5
|
-
aioccl-2024.7.dist-info/LICENSE,sha256=zEe43d4DW7O2Oe1-zDY0peOCPTBDNpWJkDa8kxrpVn8,11346
|
6
|
-
aioccl-2024.7.dist-info/METADATA,sha256=stAM0j5FVF7_RphsSlNz8BtrE0WgqUxudLSsu19LRj8,767
|
7
|
-
aioccl-2024.7.dist-info/WHEEL,sha256=rWxmBtp7hEUqVLOnTaDOPpR-cZpCDkzhhcBce-Zyd5k,91
|
8
|
-
aioccl-2024.7.dist-info/top_level.txt,sha256=-xIJfyfXTaW_EH7XCIHyxjSSSwjLmawa2qhsrHZH1vA,7
|
9
|
-
aioccl-2024.7.dist-info/RECORD,,
|
File without changes
|