aioccl 2024.7.1__tar.gz → 2024.7.2__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.
- {aioccl-2024.7.1 → aioccl-2024.7.2}/LICENSE +1 -1
- {aioccl-2024.7.1 → aioccl-2024.7.2}/PKG-INFO +1 -1
- {aioccl-2024.7.1 → aioccl-2024.7.2}/aioccl/device.py +50 -22
- aioccl-2024.7.2/aioccl/sensor.py +95 -0
- {aioccl-2024.7.1 → aioccl-2024.7.2}/aioccl.egg-info/PKG-INFO +1 -1
- {aioccl-2024.7.1 → aioccl-2024.7.2}/setup.py +1 -1
- aioccl-2024.7.1/aioccl/sensor.py +0 -49
- {aioccl-2024.7.1 → aioccl-2024.7.2}/README.md +0 -0
- {aioccl-2024.7.1 → aioccl-2024.7.2}/aioccl/__init__.py +0 -0
- {aioccl-2024.7.1 → aioccl-2024.7.2}/aioccl/server.py +0 -0
- {aioccl-2024.7.1 → aioccl-2024.7.2}/aioccl.egg-info/SOURCES.txt +0 -0
- {aioccl-2024.7.1 → aioccl-2024.7.2}/aioccl.egg-info/dependency_links.txt +0 -0
- {aioccl-2024.7.1 → aioccl-2024.7.2}/aioccl.egg-info/requires.txt +0 -0
- {aioccl-2024.7.1 → aioccl-2024.7.2}/aioccl.egg-info/top_level.txt +0 -0
- {aioccl-2024.7.1 → aioccl-2024.7.2}/setup.cfg +0 -0
@@ -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.
|
@@ -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()
|
@@ -0,0 +1,95 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
from dataclasses import dataclass
|
4
|
+
import enum
|
5
|
+
from typing import TypedDict
|
6
|
+
|
7
|
+
class CCLSensor:
|
8
|
+
"""Class that represents a CCLSensor object in the aioCCL API."""
|
9
|
+
|
10
|
+
def __init__(self, key: str):
|
11
|
+
"""Initialize a CCL sensor."""
|
12
|
+
self._value: None | str | int | float
|
13
|
+
|
14
|
+
if key in CCL_SENSORS.keys():
|
15
|
+
self._key = key
|
16
|
+
|
17
|
+
@property
|
18
|
+
def key(self) -> str:
|
19
|
+
return self._key
|
20
|
+
|
21
|
+
@property
|
22
|
+
def name(self) -> str:
|
23
|
+
return CCL_SENSORS[self._key].name
|
24
|
+
|
25
|
+
@property
|
26
|
+
def sensor_type(self) -> CCLSensorTypes:
|
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
|
38
|
+
|
39
|
+
@dataclass
|
40
|
+
class CCLSensorPreset:
|
41
|
+
name: str
|
42
|
+
sensor_type: str
|
43
|
+
binary: bool = False
|
44
|
+
|
45
|
+
class CCLSensorTypes(enum.Enum):
|
46
|
+
PRESSURE = 1
|
47
|
+
TEMPERATURE = 2
|
48
|
+
HUMIDITY = 3
|
49
|
+
WIND_DIRECITON = 4
|
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']
|
60
|
+
|
61
|
+
CCL_SENSORS: dict[str, CCLSensorPreset] = {
|
62
|
+
'rbar': CCLSensorPreset('Air Pressure', CCLSensorTypes.PRESSURE),
|
63
|
+
'intem': CCLSensorPreset('Indoor Temperature', CCLSensorTypes.TEMPERATURE),
|
64
|
+
'inhum': CCLSensorPreset('Indoor Humidity', CCLSensorTypes.HUMIDITY),
|
65
|
+
't1tem': CCLSensorPreset('Outdoor Temperature', CCLSensorTypes.TEMPERATURE),
|
66
|
+
't1hum': CCLSensorPreset('Outdoor Humidity', CCLSensorTypes.HUMIDITY),
|
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),
|
95
|
+
}
|
aioccl-2024.7.1/aioccl/sensor.py
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
from __future__ import annotations
|
2
|
-
|
3
|
-
from dataclasses import dataclass
|
4
|
-
import enum
|
5
|
-
from typing import TypedDict
|
6
|
-
|
7
|
-
class CCLSensor:
|
8
|
-
"""Class that represents a CCLSensor object in the aioCCL API."""
|
9
|
-
|
10
|
-
def __init__(self, key: str):
|
11
|
-
"""Initialize a CCL sensor."""
|
12
|
-
self.value: None | str | int | float
|
13
|
-
|
14
|
-
if key in CCL_SENSORS.keys():
|
15
|
-
self._key = key
|
16
|
-
|
17
|
-
@property
|
18
|
-
def key(self):
|
19
|
-
return self._key
|
20
|
-
|
21
|
-
@property
|
22
|
-
def name(self):
|
23
|
-
return CCL_SENSORS[self._key].name
|
24
|
-
|
25
|
-
@property
|
26
|
-
def sensor_type(self):
|
27
|
-
return CCL_SENSORS[self._key].sensor_type
|
28
|
-
|
29
|
-
@dataclass
|
30
|
-
class CCLSensorPreset:
|
31
|
-
name: str
|
32
|
-
sensor_type: str
|
33
|
-
|
34
|
-
class CCLSensorTypes(enum.Enum):
|
35
|
-
PRESSURE = 1
|
36
|
-
TEMPERATURE = 2
|
37
|
-
HUMIDITY = 3
|
38
|
-
WIND_DIRECITON = 4
|
39
|
-
WIND_SPEED = 5
|
40
|
-
|
41
|
-
CCL_SENSORS: dict[str, CCLSensorPreset] = {
|
42
|
-
'rbar': CCLSensorPreset('Air Pressure', CCLSensorTypes.PRESSURE),
|
43
|
-
'intem': CCLSensorPreset('Indoor Temperature', CCLSensorTypes.TEMPERATURE),
|
44
|
-
'inhum': CCLSensorPreset('Indoor Humidity', CCLSensorTypes.HUMIDITY),
|
45
|
-
't1tem': CCLSensorPreset('Outdoor Temperature', CCLSensorTypes.TEMPERATURE),
|
46
|
-
't1hum': CCLSensorPreset('Outdoor Humidity', CCLSensorTypes.HUMIDITY),
|
47
|
-
't1wdir': CCLSensorPreset('Outdoor Wind Direction', CCLSensorTypes.WIND_DIRECITON),
|
48
|
-
't1ws': CCLSensorPreset('Outdoor Wind Speed', CCLSensorTypes.WIND_SPEED),
|
49
|
-
}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|