plugwise 1.7.3a1__py3-none-any.whl → 1.7.3a2__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.
plugwise/common.py CHANGED
@@ -76,6 +76,9 @@ class SmileCommon:
76
76
  xml_2 = return_valid(xml_2, self._domain_objects)
77
77
  self._heater_id = check_heater_central(xml_2)
78
78
 
79
+ if self._heater_id == NONE:
80
+ return Munch() # pragma: no cover
81
+
79
82
  # Info for On-Off device
80
83
  if self._on_off_device:
81
84
  appl.name = "OnOff" # pragma: no cover
plugwise/helper.py CHANGED
@@ -253,7 +253,7 @@ class SmileHelper(SmileCommon):
253
253
  appl.zigbee_mac = module_data["zigbee_mac_address"]
254
254
  return appl
255
255
  case _: # pragma: no cover
256
- return appl
256
+ return Munch()
257
257
 
258
258
  def _appl_gateway_info(self, appl: Munch, appliance: etree.Element) -> Munch:
259
259
  """Helper-function for _appliance_info_finder()."""
plugwise/util.py CHANGED
@@ -13,6 +13,7 @@ from plugwise.constants import (
13
13
  ELECTRIC_POTENTIAL_VOLT,
14
14
  ENERGY_KILO_WATT_HOUR,
15
15
  HW_MODELS,
16
+ NONE,
16
17
  OBSOLETE_MEASUREMENTS,
17
18
  PERCENTAGE,
18
19
  POWER_WATT,
@@ -93,14 +94,16 @@ def check_heater_central(xml: etree.Element) -> str:
93
94
  if heater_central.find("name").text == "Central heating boiler":
94
95
  hc_list.append({hc_id: has_actuators})
95
96
 
97
+ if not hc_list:
98
+ return NONE # pragma: no cover
99
+
96
100
  heater_central_id = list(hc_list[0].keys())[0]
97
101
  if hc_count > 1:
98
- for item in hc_list: # pragma: no cover
99
- for key, value in item.items(): # pragma: no cover
100
- if value: # pragma: no cover
101
- heater_central_id = key # pragma: no cover
102
- # Stop when a valid id is found
103
- break # pragma: no cover
102
+ for item in hc_list:
103
+ hc_id, has_actuators = next(iter(item.items()))
104
+ if has_actuators:
105
+ heater_central_id = hc_id
106
+ break
104
107
 
105
108
  return heater_central_id
106
109
 
@@ -135,7 +138,7 @@ def collect_power_values(
135
138
  if not loc.found:
136
139
  continue
137
140
 
138
- data = power_data_energy_diff(loc.measurement, loc.net_string, loc.f_val, data)
141
+ power_data_energy_diff(loc.measurement, loc.net_string, loc.f_val, data)
139
142
  key = cast(SensorType, loc.key_string)
140
143
  data["sensors"][key] = loc.f_val
141
144
 
@@ -192,8 +195,6 @@ def escape_illegal_xml_characters(xmldata: str) -> str:
192
195
 
193
196
  def format_measure(measure: str, unit: str) -> float | int:
194
197
  """Format measure to correct type."""
195
- result: float | int = 0
196
-
197
198
  float_measure = float(measure)
198
199
  if unit == PERCENTAGE and 0 < float_measure <= 1:
199
200
  return int(float_measure * 100)
@@ -202,13 +203,13 @@ def format_measure(measure: str, unit: str) -> float | int:
202
203
  float_measure = float_measure / 1000
203
204
 
204
205
  if unit in SPECIAL_FORMAT:
205
- result = float(f"{round(float_measure, 3):.3f}")
206
+ result = round(float_measure, 3)
206
207
  elif unit == ELECTRIC_POTENTIAL_VOLT:
207
- result = float(f"{round(float_measure, 1):.1f}")
208
+ result = round(float_measure, 1)
208
209
  elif abs(float_measure) < 10:
209
- result = float(f"{round(float_measure, 2):.2f}")
210
- elif abs(float_measure) >= 10:
211
- result = float(f"{round(float_measure, 1):.1f}")
210
+ result = round(float_measure, 2)
211
+ else: # abs(float_measure) >= 10
212
+ result = round(float_measure, 1)
212
213
 
213
214
  return result
214
215
 
@@ -228,31 +229,21 @@ def power_data_energy_diff(
228
229
  net_string: SensorType,
229
230
  f_val: float | int,
230
231
  data: GwEntityData,
231
- ) -> GwEntityData:
232
+ ) -> None:
232
233
  """Calculate differential energy."""
233
234
  if (
234
235
  "electricity" in measurement
235
236
  and "phase" not in measurement
236
237
  and "interval" not in net_string
237
238
  ):
238
- diff = 1
239
- if "produced" in measurement:
240
- diff = -1
241
- if net_string not in data["sensors"]:
242
- tmp_val: float | int = 0
243
- else:
244
- tmp_val = data["sensors"][net_string]
245
-
246
- if isinstance(f_val, int):
247
- tmp_val += f_val * diff
248
- else:
249
- tmp_val += float(f_val * diff)
250
- tmp_val = float(f"{round(tmp_val, 3):.3f}")
239
+ diff = 1 if "consumed" in measurement else -1
240
+ tmp_val = data["sensors"].get(net_string, 0)
241
+ tmp_val += f_val * diff
242
+ if isinstance(f_val, float):
243
+ tmp_val = round(tmp_val, 3)
251
244
 
252
245
  data["sensors"][net_string] = tmp_val
253
246
 
254
- return data
255
-
256
247
 
257
248
  def power_data_local_format(
258
249
  attrs: dict[str, str], key_string: str, val: str
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: plugwise
3
- Version: 1.7.3a1
3
+ Version: 1.7.3a2
4
4
  Summary: Plugwise Smile (Adam/Anna/P1) and Stretch module for Python 3.
5
5
  Home-page: https://github.com/plugwise/python-plugwise
6
6
  Author: Plugwise device owners
@@ -1,18 +1,18 @@
1
1
  plugwise/__init__.py,sha256=9Bc3Kaajvr-W060CVW135rPxkdQIh6wlv0jeo57zmWA,17786
2
- plugwise/common.py,sha256=I89l9Q_RvUSBUIQO163za7oIVr-uSnKNyvkA2NCU1FM,9391
2
+ plugwise/common.py,sha256=Q2P4iyLcrGLeZwNd8Z8soWhI3L5L9IWMgaIMnppsIEs,9475
3
3
  plugwise/constants.py,sha256=Vd8tvOHsRtZxtUUFXBXolZj3QiKnxRt0bnwDT9DoEqE,17073
4
4
  plugwise/data.py,sha256=SUXbyjCu-wS6l3tXnAhItEOhnYtAfd79nPiUlS5MnzY,12955
5
5
  plugwise/exceptions.py,sha256=Ce-tO9uNsMB-8FP6VAxBvsHNJ-NIM9F0onUZOdZI4Ys,1110
6
- plugwise/helper.py,sha256=2ZY2ok4kXUkNK3PNR7qwvzVnI5U-5dncmqimac4qWXw,39480
6
+ plugwise/helper.py,sha256=U1EUqX3ErmmFH4L5uXRAXNj20toeMufzyKp2-WRpIXc,39483
7
7
  plugwise/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  plugwise/smile.py,sha256=BHgOp9FaaupOghF54t53qpgnQoVdG4WfdOSUPI2dmKc,19559
9
9
  plugwise/smilecomm.py,sha256=DRQ3toRNEf3oo_mej49fPJ47m5das-jvo-8GnIrSPzw,5208
10
- plugwise/util.py,sha256=aPRA-5SURMvIHTtPrJ5f6Vj-cLktSwZXqJsxBdiJJrk,11071
10
+ plugwise/util.py,sha256=rMcqfaB4dkQEZFJY-bBJISmlYgTnb6Ns3-Doxelf92Q,10689
11
11
  plugwise/legacy/data.py,sha256=s2WYjgxwcuAGS8UOxJVf7xLSxS38Zgr8GsjxlxfD98w,3574
12
12
  plugwise/legacy/helper.py,sha256=MLEeZO4vcHTrjRUb0ZMch_5aHABXmdEiQZNpCmJdWiw,17156
13
13
  plugwise/legacy/smile.py,sha256=bbhuD0kT9xuzdRd6shl-IBRUkBlforYv-iggJXYYrU0,12850
14
- plugwise-1.7.3a1.dist-info/LICENSE,sha256=mL22BjmXtg_wnoDnnaqps5_Bg_VGj_yHueX5lsKwbCc,1144
15
- plugwise-1.7.3a1.dist-info/METADATA,sha256=1tkUvvjdH1rBMopp6RYsF3VfJyXsyh_uqZ9ly3Bh8v4,9330
16
- plugwise-1.7.3a1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
17
- plugwise-1.7.3a1.dist-info/top_level.txt,sha256=MYOmktMFf8ZmX6_OE1y9MoCZFfY-L8DA0F2tA2IvE4s,9
18
- plugwise-1.7.3a1.dist-info/RECORD,,
14
+ plugwise-1.7.3a2.dist-info/LICENSE,sha256=mL22BjmXtg_wnoDnnaqps5_Bg_VGj_yHueX5lsKwbCc,1144
15
+ plugwise-1.7.3a2.dist-info/METADATA,sha256=sF2g1_meY9DJgPi8QtlWJlU95lC77Y3hGdGj7olCdXA,9330
16
+ plugwise-1.7.3a2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
17
+ plugwise-1.7.3a2.dist-info/top_level.txt,sha256=MYOmktMFf8ZmX6_OE1y9MoCZFfY-L8DA0F2tA2IvE4s,9
18
+ plugwise-1.7.3a2.dist-info/RECORD,,