aioccl 2024.7.1__tar.gz → 2024.7.3__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.
@@ -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 fkiscd@gmail.com
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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aioccl
3
- Version: 2024.7.1
3
+ Version: 2024.7.3
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
@@ -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.serial_no: str | None
21
- self.mac_address: str | None
22
- self.model: str | None
23
- self.version: str | None
24
-
25
- self.last_updated_time: float = -10.0 # Offset
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.mac_address.replace(":", "").lower()[-6:]
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.serial_no = info.get('serial_no')
45
- self.mac_address = info.get('mac_address')
46
- self.model = info.get('model')
47
- self.version = info.get('version')
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 sensor, value in sensors.items():
52
- if not self.sensors.get(sensor):
53
- self.sensors[sensor] = CCLSensor(sensor)
54
- self._new_sensors.append(self.sensors[sensor])
55
- self.sensors[sensor].value = value
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.last_updated_time = time.monotonic()
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,99 @@
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
+ @value.setter
40
+ def value(self, new_value):
41
+ self._value = new_value
42
+
43
+ @dataclass
44
+ class CCLSensorPreset:
45
+ name: str
46
+ sensor_type: str
47
+ binary: bool = False
48
+
49
+ class CCLSensorTypes(enum.Enum):
50
+ PRESSURE = 1
51
+ TEMPERATURE = 2
52
+ HUMIDITY = 3
53
+ WIND_DIRECITON = 4
54
+ WIND_SPEED = 5
55
+ RAIN_RATE = 6
56
+ RAINFALL = 7
57
+ UVI = 8
58
+ RADIATION = 9
59
+ BATTERY_BINARY = 10
60
+ CONNECTION = 11
61
+ CH_SENSOR_TYPE = 12
62
+
63
+ CCL_CH_SENSOR_TYPES: list[str] = [None, None, 'Thermo-Hygro', 'Pool', 'Soil']
64
+
65
+ CCL_SENSORS: dict[str, CCLSensorPreset] = {
66
+ 'rbar': CCLSensorPreset('Air Pressure', CCLSensorTypes.PRESSURE),
67
+ 'intem': CCLSensorPreset('Indoor Temperature', CCLSensorTypes.TEMPERATURE),
68
+ 'inhum': CCLSensorPreset('Indoor Humidity', CCLSensorTypes.HUMIDITY),
69
+ 't1tem': CCLSensorPreset('Outdoor Temperature', CCLSensorTypes.TEMPERATURE),
70
+ 't1hum': CCLSensorPreset('Outdoor Humidity', CCLSensorTypes.HUMIDITY),
71
+ 't1wdir': CCLSensorPreset('Wind Direction', CCLSensorTypes.WIND_DIRECITON),
72
+ 't1ws': CCLSensorPreset('Wind Speed', CCLSensorTypes.WIND_SPEED),
73
+ 't1ws10mav': CCLSensorPreset('Wind Speed (10 mins avg.)', CCLSensorTypes.WIND_SPEED),
74
+ 't1wgust': CCLSensorPreset('Wind Gust', CCLSensorTypes.WIND_SPEED),
75
+ 't1rainra': CCLSensorPreset('Rain Rate', CCLSensorTypes.RAIN_RATE),
76
+ 't1rainhr': CCLSensorPreset('Hourly Rainfall', CCLSensorTypes.RAINFALL),
77
+ 't1raindy': CCLSensorPreset('Daily Rainfall', CCLSensorTypes.RAINFALL),
78
+ 't1rainwy': CCLSensorPreset('Weekly Rainfall', CCLSensorTypes.RAINFALL),
79
+ 't1rainmth': CCLSensorPreset('Monthly Rainfall', CCLSensorTypes.RAINFALL),
80
+ 't1uvi': CCLSensorPreset('UV Index', CCLSensorTypes.UVI),
81
+ 't1solrad': CCLSensorPreset('Light Intensity', CCLSensorTypes.RADIATION),
82
+ 't1bat': CCLSensorPreset('CH0 Battery', CCLSensorTypes.BATTERY_BINARY, True),
83
+ 't1cn': CCLSensorPreset('CH0 Connection', CCLSensorTypes.CONNECTION),
84
+ 't1feels': CCLSensorPreset('Feels Like', CCLSensorTypes.TEMPERATURE),
85
+ 't1chill': CCLSensorPreset('Wind Chill', CCLSensorTypes.TEMPERATURE),
86
+ 't1heat': CCLSensorPreset('Heat Index', CCLSensorTypes.TEMPERATURE),
87
+ 't1dew': CCLSensorPreset('Dew Point', CCLSensorTypes.TEMPERATURE),
88
+ 't1wbgt': CCLSensorPreset('WBGT Index', CCLSensorTypes.TEMPERATURE),
89
+ 't234c1tem': CCLSensorPreset('CH1 Temperature', CCLSensorTypes.TEMPERATURE),
90
+ 't234c1hum': CCLSensorPreset('CH1 Humidity', CCLSensorTypes.HUMIDITY),
91
+ 't234c1bat': CCLSensorPreset('CH1 Battery', CCLSensorTypes.BATTERY_BINARY, True),
92
+ 't234c1cn': CCLSensorPreset('CH1 Connection', CCLSensorTypes.CONNECTION, True),
93
+ 't234c1tp': CCLSensorPreset('CH1 Sensor Type', CCLSensorTypes.CH_SENSOR_TYPE),
94
+ 't234c2tem': CCLSensorPreset('CH2 Temperature', CCLSensorTypes.TEMPERATURE),
95
+ 't234c2hum': CCLSensorPreset('CH2 Humidity', CCLSensorTypes.HUMIDITY),
96
+ 't234c2bat': CCLSensorPreset('CH2 Battery', CCLSensorTypes.BATTERY_BINARY, True),
97
+ 't234c2cn': CCLSensorPreset('CH2 Connection', CCLSensorTypes.CONNECTION, True),
98
+ 't234c2tp': CCLSensorPreset('CH2 Sensor Type', CCLSensorTypes.CH_SENSOR_TYPE),
99
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aioccl
3
- Version: 2024.7.1
3
+ Version: 2024.7.3
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
@@ -1,7 +1,7 @@
1
1
  from pathlib import Path
2
2
  from setuptools import find_packages, setup
3
3
 
4
- VERSION = "2024.7.1"
4
+ VERSION = "2024.7.3"
5
5
 
6
6
  ROOT_DIR = Path(__file__).parent.resolve()
7
7
 
@@ -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