PyPlumIO 0.5.41__py3-none-any.whl → 0.5.42__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.
pyplumio/_version.py CHANGED
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '0.5.41'
21
- __version_tuple__ = version_tuple = (0, 5, 41)
20
+ __version__ = version = '0.5.42'
21
+ __version_tuple__ = version_tuple = (0, 5, 42)
@@ -13,6 +13,7 @@ from typing_extensions import TypeAlias
13
13
 
14
14
  from pyplumio.const import BYTE_UNDEFINED, STATE_OFF, STATE_ON, State, UnitOfMeasurement
15
15
  from pyplumio.frames import Request
16
+ from pyplumio.utils import is_divisible
16
17
 
17
18
  if TYPE_CHECKING:
18
19
  from pyplumio.devices import Device
@@ -286,6 +287,8 @@ class Parameter(ABC):
286
287
  class NumberDescription(ParameterDescription):
287
288
  """Represents a parameter description."""
288
289
 
290
+ step: float = 1.0
291
+ precision: int = 6
289
292
  unit_of_measurement: UnitOfMeasurement | Literal["%"] | None = None
290
293
 
291
294
 
@@ -298,18 +301,24 @@ class Number(Parameter):
298
301
 
299
302
  def _pack_value(self, value: NumericType) -> int:
300
303
  """Pack the parameter value."""
301
- return int(value)
304
+ return int(round(value / self.description.step))
302
305
 
303
306
  def _unpack_value(self, value: int) -> NumericType:
304
307
  """Unpack the parameter value."""
305
- return value
308
+ return round(value * self.description.step, self.description.precision)
306
309
 
307
310
  def validate(self, value: Any) -> bool:
308
311
  """Validate a parameter value."""
309
312
  if value < self.min_value or value > self.max_value:
310
313
  raise ValueError(
311
- f"Invalid number value: {value}. Must be between "
312
- f"{self.min_value} and {self.max_value}."
314
+ f"Invalid value: {value}. The value must be between {self.min_value} "
315
+ f"and {self.max_value}."
316
+ )
317
+
318
+ if not is_divisible(value, self.description.step, self.description.precision):
319
+ raise ValueError(
320
+ f"Invalid value: {value}. The value must be adjusted in increments of "
321
+ f"{self.description.step}."
313
322
  )
314
323
 
315
324
  return True
@@ -33,7 +33,7 @@ from pyplumio.helpers.parameter import (
33
33
  )
34
34
  from pyplumio.structures import StructureDecoder
35
35
  from pyplumio.structures.thermostat_parameters import ATTR_THERMOSTAT_PROFILE
36
- from pyplumio.utils import ensure_dict, is_divisible
36
+ from pyplumio.utils import ensure_dict
37
37
 
38
38
  if TYPE_CHECKING:
39
39
  from pyplumio.devices.ecomax import EcoMAX
@@ -90,9 +90,7 @@ class EcomaxParameter(Parameter):
90
90
  class EcomaxNumberDescription(EcomaxParameterDescription, NumberDescription):
91
91
  """Represents an ecoMAX number description."""
92
92
 
93
- step: float = 1.0
94
93
  offset: int = 0
95
- precision: int = 6
96
94
 
97
95
 
98
96
  class EcomaxNumber(EcomaxParameter, Number):
@@ -102,25 +100,13 @@ class EcomaxNumber(EcomaxParameter, Number):
102
100
 
103
101
  description: EcomaxNumberDescription
104
102
 
105
- def validate(self, value: NumericType) -> bool:
106
- """Validate the parameter value."""
107
- if not is_divisible(value, self.description.step, self.description.precision):
108
- raise ValueError(
109
- f"Invalid value: {value}. The value must be adjusted in increments of "
110
- f"{self.description.step}."
111
- )
112
-
113
- return super().validate(value)
114
-
115
103
  def _pack_value(self, value: NumericType) -> int:
116
104
  """Pack the parameter value."""
117
- value += self.description.offset
118
- return round(value / self.description.step)
105
+ return super()._pack_value(value + self.description.offset)
119
106
 
120
107
  def _unpack_value(self, value: int) -> NumericType:
121
108
  """Unpack the parameter value."""
122
- value -= self.description.offset
123
- return round(value * self.description.step, self.description.precision)
109
+ return super()._unpack_value(value - self.description.offset)
124
110
 
125
111
 
126
112
  @dataslots
@@ -29,7 +29,7 @@ from pyplumio.helpers.parameter import (
29
29
  unpack_parameter,
30
30
  )
31
31
  from pyplumio.structures import StructureDecoder
32
- from pyplumio.utils import ensure_dict, is_divisible
32
+ from pyplumio.utils import ensure_dict
33
33
 
34
34
  if TYPE_CHECKING:
35
35
  from pyplumio.devices.mixer import Mixer
@@ -72,9 +72,7 @@ class MixerParameter(Parameter):
72
72
  class MixerNumberDescription(MixerParameterDescription, NumberDescription):
73
73
  """Represent a mixer number description."""
74
74
 
75
- step: float = 1.0
76
75
  offset: int = 0
77
- precision: int = 6
78
76
 
79
77
 
80
78
  class MixerNumber(MixerParameter, Number):
@@ -84,25 +82,13 @@ class MixerNumber(MixerParameter, Number):
84
82
 
85
83
  description: MixerNumberDescription
86
84
 
87
- def validate(self, value: NumericType) -> bool:
88
- """Validate the parameter value."""
89
- if not is_divisible(value, self.description.step, self.description.precision):
90
- raise ValueError(
91
- f"Invalid value: {value}. The value must be adjusted in increments of "
92
- f"{self.description.step}."
93
- )
94
-
95
- return super().validate(value)
96
-
97
85
  def _pack_value(self, value: NumericType) -> int:
98
86
  """Pack the parameter value."""
99
- value += self.description.offset
100
- return round(value / self.description.step)
87
+ return super()._pack_value(value + self.description.offset)
101
88
 
102
89
  def _unpack_value(self, value: int) -> NumericType:
103
90
  """Unpack the parameter value."""
104
- value -= self.description.offset
105
- return round(value * self.description.step, self.description.precision)
91
+ return super()._unpack_value(value - self.description.offset)
106
92
 
107
93
 
108
94
  @dataslots
@@ -20,7 +20,6 @@ from pyplumio.frames import Request
20
20
  from pyplumio.helpers.parameter import (
21
21
  Number,
22
22
  NumberDescription,
23
- NumericType,
24
23
  Parameter,
25
24
  ParameterDescription,
26
25
  ParameterValues,
@@ -30,7 +29,7 @@ from pyplumio.helpers.parameter import (
30
29
  )
31
30
  from pyplumio.structures import StructureDecoder
32
31
  from pyplumio.structures.thermostat_sensors import ATTR_THERMOSTATS_AVAILABLE
33
- from pyplumio.utils import ensure_dict, is_divisible
32
+ from pyplumio.utils import ensure_dict
34
33
 
35
34
  if TYPE_CHECKING:
36
35
  from pyplumio.devices.thermostat import Thermostat
@@ -93,9 +92,6 @@ class ThermostatParameter(Parameter):
93
92
  class ThermostatNumberDescription(ThermostatParameterDescription, NumberDescription):
94
93
  """Represent a thermostat number description."""
95
94
 
96
- step: float = 1.0
97
- precision: int = 6
98
-
99
95
 
100
96
  class ThermostatNumber(ThermostatParameter, Number):
101
97
  """Represents a thermostat number."""
@@ -104,24 +100,6 @@ class ThermostatNumber(ThermostatParameter, Number):
104
100
 
105
101
  description: ThermostatNumberDescription
106
102
 
107
- def validate(self, value: NumericType) -> bool:
108
- """Validate the parameter value."""
109
- if not is_divisible(value, self.description.step, self.description.precision):
110
- raise ValueError(
111
- f"Invalid value: {value}. The value must be adjusted in increments of "
112
- f"{self.description.step}."
113
- )
114
-
115
- return super().validate(value)
116
-
117
- def _pack_value(self, value: NumericType) -> int:
118
- """Pack the parameter value."""
119
- return round(value / self.description.step)
120
-
121
- def _unpack_value(self, value: int) -> NumericType:
122
- """Unpack the parameter value."""
123
- return round(value * self.description.step, self.description.precision)
124
-
125
103
 
126
104
  @dataslots
127
105
  @dataclass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyPlumIO
3
- Version: 0.5.41
3
+ Version: 0.5.42
4
4
  Summary: PyPlumIO is a native ecoNET library for Plum ecoMAX controllers.
5
5
  Author-email: Denis Paavilainen <denpa@denpa.pro>
6
6
  License: MIT License
@@ -1,6 +1,6 @@
1
1
  pyplumio/__init__.py,sha256=3ibJ43RIdfFrWp1PAsQixybAA--NPRw43B5OdLOwsU8,3319
2
2
  pyplumio/__main__.py,sha256=3IwHHSq-iay5FaeMc95klobe-xv82yydSKcBE7BFZ6M,500
3
- pyplumio/_version.py,sha256=TuHCjk-kMeHq9XPeWUeIY_Liz22Ivd6BQxf4Zhp3zGg,513
3
+ pyplumio/_version.py,sha256=a_t6VzKNKwRmdztAoxQ2F5XjG1X3ma68qioTXtwboxc,513
4
4
  pyplumio/connection.py,sha256=-dbrIK6ewoYNeBQod9ZmXT8JkxMKbcS6nosINFsg9RI,5972
5
5
  pyplumio/const.py,sha256=26s1TJF7IJa6o1pjDmHaAzPgMJ5c-fb0jeSkzDQ6Bic,5577
6
6
  pyplumio/exceptions.py,sha256=_B_0EgxDxd2XyYv3WpZM733q0cML5m6J-f55QOvYRpI,996
@@ -22,7 +22,7 @@ pyplumio/helpers/__init__.py,sha256=H2xxdkF-9uADLwEbfBUoxNTdwru3L5Z2cfJjgsuRsn0,
22
22
  pyplumio/helpers/data_types.py,sha256=nB3afOLmppgSCWkZoX1-1yWPNMMNSem77x7XQ1Mi8H8,9103
23
23
  pyplumio/helpers/event_manager.py,sha256=xQOfiP_nP1Pz5zhB6HU5gXyyJXjhisYshL8_HRxDgt8,6412
24
24
  pyplumio/helpers/factory.py,sha256=9uXUmVRvPkg9IyrfYYVbz9wsYAXltMTXkm1x82dhMyA,1126
25
- pyplumio/helpers/parameter.py,sha256=j-t2Yj8NhQzqGSRN9DFtsWVuoh49Lq7I5_8CY5dqaU8,13587
25
+ pyplumio/helpers/parameter.py,sha256=pvZPT06o7jbpmFo3C0OtHq8OAJPo-gbXFPo7yvL3DYc,14029
26
26
  pyplumio/helpers/schedule.py,sha256=Dl28p3iz8okr5AT5v78WiJv6ggYlO-f2Jk6r5t1wY0A,5266
27
27
  pyplumio/helpers/task_manager.py,sha256=HAd69yGTRL0zQsu-ywnbLu1UXiJzgHWuhYWA--vs4lQ,1181
28
28
  pyplumio/helpers/timeout.py,sha256=JAhWNtIpcXyVILIwHWVy5mYofqbbRDGKLdTUKkQuajs,772
@@ -31,13 +31,13 @@ pyplumio/structures/__init__.py,sha256=EjK-5qJZ0F7lpP2b6epvTMg9cIBl4Kn91nqNkEcLw
31
31
  pyplumio/structures/alerts.py,sha256=O4P0sbBu1g7AN_AApcViy9CcrY5Vry_LZJgidNUF7Co,3664
32
32
  pyplumio/structures/boiler_load.py,sha256=p3mOzZUU-g7A2tG_yp8podEqpI81hlsOZmHELyPNRY8,838
33
33
  pyplumio/structures/boiler_power.py,sha256=72qsvccg49FdRdXv2f2K5sGpjT7wAOLFjlIGWpO-DVg,901
34
- pyplumio/structures/ecomax_parameters.py,sha256=ysnHYa0OscL8fxrkpIn2VxqOdNXZdEDD12N2HZ39kQU,27760
34
+ pyplumio/structures/ecomax_parameters.py,sha256=_QWlwJm_IhQJ744vx6-WZb96kxjrEKleNteiE0wqLZE,27225
35
35
  pyplumio/structures/fan_power.py,sha256=Q5fv-7_2NVuLeQPIVIylvgN7M8-a9D8rRUE0QGjyS3w,871
36
36
  pyplumio/structures/frame_versions.py,sha256=hbcVuhuPNy5qd39Vk7w4WdPCW-TNx1cAYWzA2mXocyk,1548
37
37
  pyplumio/structures/fuel_consumption.py,sha256=_p2dI4H67Eopn7IF0Gj77A8c_8lNKhhDDAtmugxLd4s,976
38
38
  pyplumio/structures/fuel_level.py,sha256=mJpp1dnRD1wXi_6EyNX7TNXosjcr905rSHOnuZ5VD74,1069
39
39
  pyplumio/structures/lambda_sensor.py,sha256=JNSCiBJoM8Uk3OGbmFIigaLOntQST5U_UrmCpaQBlM0,1595
40
- pyplumio/structures/mixer_parameters.py,sha256=MZ97_g14krUdMPlyrOLqKcwEfq8PYq7f7AzJDbcM0O0,8840
40
+ pyplumio/structures/mixer_parameters.py,sha256=-ZevCkrcUemmK7RIhGtVJyVgMNc4-Kxfk5ZEUvQ1wTw,8305
41
41
  pyplumio/structures/mixer_sensors.py,sha256=-cN7U-Fr2fmAQ5McQL7bZUC8CFlb1y8TN0f_dqy3UK0,2312
42
42
  pyplumio/structures/modules.py,sha256=oXUIqrOAV1dZzBV5zUH3HDUSFvNOjpUSx0TF9nZVnbs,2569
43
43
  pyplumio/structures/network_info.py,sha256=kPxmIaDGm5SyLRKVFzcrODlUtB0u5JjiZqekoKSyDpA,4159
@@ -51,10 +51,10 @@ pyplumio/structures/regulator_data_schema.py,sha256=XM6M9ep3NyogbLPqp88mMTg8Sa9e
51
51
  pyplumio/structures/schedules.py,sha256=_D8HmxMVvAAPb0cc_xSxXFRNwR9u-RWuyTy0Z5KscUk,6717
52
52
  pyplumio/structures/statuses.py,sha256=wkoynyMRr1VREwfBC6vU48kPA8ZQ83pcXuciy2xHJrk,1166
53
53
  pyplumio/structures/temperatures.py,sha256=1CDzehNmbALz1Jyt_9gZNIk52q6Wv-xQXjijVDCVYec,2337
54
- pyplumio/structures/thermostat_parameters.py,sha256=j7uyw5eIgMgXxndaqV-XKFne6DL2_RFtU_BeJcOo9sk,8075
54
+ pyplumio/structures/thermostat_parameters.py,sha256=Hy07KU7wbUBtpX4pkPlnT7lIxiqtj6pEkGxRArfsIfc,7272
55
55
  pyplumio/structures/thermostat_sensors.py,sha256=8e1TxYIJTQKT0kIGO9gG4hGdLOBUpIhiPToQyOMyeNE,3237
56
- pyplumio-0.5.41.dist-info/licenses/LICENSE,sha256=m-UuZFjXJ22uPTGm9kSHS8bqjsf5T8k2wL9bJn1Y04o,1088
57
- pyplumio-0.5.41.dist-info/METADATA,sha256=HyZfZdbTrMXlAbh4-CTtIJxM3NZRLXKm_8AfK37RkzM,5532
58
- pyplumio-0.5.41.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
59
- pyplumio-0.5.41.dist-info/top_level.txt,sha256=kNBz9UPPkPD9teDn3U_sEy5LjzwLm9KfADCXtBlbw8A,9
60
- pyplumio-0.5.41.dist-info/RECORD,,
56
+ pyplumio-0.5.42.dist-info/licenses/LICENSE,sha256=m-UuZFjXJ22uPTGm9kSHS8bqjsf5T8k2wL9bJn1Y04o,1088
57
+ pyplumio-0.5.42.dist-info/METADATA,sha256=oj8ixR7GtUtp7-7RHf1TQ7ByQ8TVm-_vkinabJ8vkE0,5532
58
+ pyplumio-0.5.42.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
59
+ pyplumio-0.5.42.dist-info/top_level.txt,sha256=kNBz9UPPkPD9teDn3U_sEy5LjzwLm9KfADCXtBlbw8A,9
60
+ pyplumio-0.5.42.dist-info/RECORD,,