plugwise 0.36.2__py3-none-any.whl → 0.37.0__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/util.py CHANGED
@@ -3,16 +3,27 @@ from __future__ import annotations
3
3
 
4
4
  import re
5
5
 
6
- from .constants import (
6
+ from plugwise.constants import (
7
+ ATTR_UNIT_OF_MEASUREMENT,
7
8
  ELECTRIC_POTENTIAL_VOLT,
8
9
  ENERGY_KILO_WATT_HOUR,
9
10
  HW_MODELS,
10
11
  PERCENTAGE,
12
+ POWER_WATT,
11
13
  SPECIAL_FORMAT,
12
14
  TEMP_CELSIUS,
15
+ DeviceData,
13
16
  )
14
17
 
15
18
 
19
+ def check_model(name: str | None, vendor_name: str | None) -> str | None:
20
+ """Model checking before using version_to_model."""
21
+ if vendor_name == "Plugwise" and ((model := version_to_model(name)) != "Unknown"):
22
+ return model
23
+
24
+ return name
25
+
26
+
16
27
  def escape_illegal_xml_characters(xmldata: str) -> str:
17
28
  """Replace illegal &-characters."""
18
29
  return re.sub(r"&([^a-zA-Z#])", r"&\1", xmldata)
@@ -47,6 +58,19 @@ def format_measure(measure: str, unit: str) -> float | int:
47
58
  return result
48
59
 
49
60
 
61
+ def power_data_local_format(
62
+ attrs: dict[str, str], key_string: str, val: str
63
+ ) -> float | int:
64
+ """Format power data."""
65
+ # Special formatting of P1_MEASUREMENT POWER_WATT values, do not move to util-format_measure() function!
66
+ if all(item in key_string for item in ("electricity", "cumulative")):
67
+ return format_measure(val, ENERGY_KILO_WATT_HOUR)
68
+ if (attrs_uom := getattr(attrs, ATTR_UNIT_OF_MEASUREMENT)) == POWER_WATT:
69
+ return int(round(float(val)))
70
+
71
+ return format_measure(val, attrs_uom)
72
+
73
+
50
74
  # NOTE: this function version_to_model is shared between Smile and USB
51
75
  def version_to_model(version: str | None) -> str | None:
52
76
  """Translate hardware_version to device type."""
@@ -62,3 +86,13 @@ def version_to_model(version: str | None) -> str | None:
62
86
  model = HW_MODELS.get(version[-2:] + version[-4:-2] + version[-6:-4])
63
87
 
64
88
  return model if model is not None else "Unknown"
89
+
90
+
91
+ def remove_empty_platform_dicts(data: DeviceData) -> None:
92
+ """Helper-function for removing any empty platform dicts."""
93
+ if not data["binary_sensors"]:
94
+ data.pop("binary_sensors")
95
+ if not data["sensors"]:
96
+ data.pop("sensors")
97
+ if not data["switches"]:
98
+ data.pop("switches")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: plugwise
3
- Version: 0.36.2
3
+ Version: 0.37.0
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
@@ -48,7 +48,7 @@ Requires-Dist: defusedxml
48
48
  Requires-Dist: munch
49
49
  Requires-Dist: pyserial
50
50
  Requires-Dist: python-dateutil
51
- Requires-Dist: semver (>=3.0.0)
51
+ Requires-Dist: semver >=3.0.0
52
52
 
53
53
  # Plugwise python module
54
54
 
@@ -0,0 +1,16 @@
1
+ plugwise/__init__.py,sha256=TMpDJgS-Nz7zwiuM8CTZk9wMenrxzFanRDxmloUAM08,15257
2
+ plugwise/constants.py,sha256=_IO-MQQu_gFZ71VTNlmNY5Lqr6u0t5rWaQTQJqe_xRc,16467
3
+ plugwise/data.py,sha256=6yJ7G-0ujwuGFwgHiHIxmomATohVmgwFmiEKwinr3EM,9535
4
+ plugwise/exceptions.py,sha256=rymGtWnXosdFkzSehc_41HVl2jXJEg_9Hq9APDEUwrk,1223
5
+ plugwise/helper.py,sha256=Iud_UPXqmXXq_U_EA7L4IRhXgg187dfynZ9tVEfFJIM,56508
6
+ plugwise/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ plugwise/smile.py,sha256=7p5KAdl_vorthsRWYHpWkXLqbe27yS3o_OmbpL4H9Yc,16709
8
+ plugwise/util.py,sha256=es3NZ8AlT9_CNkod4IXEJ-MgH_Al4vqD4XNcnLv315Y,3117
9
+ plugwise/legacy/data.py,sha256=_Ijoq4XaUlSbmpelx5wRR2cl5dwfSZIRDD0UBygd0uE,4252
10
+ plugwise/legacy/helper.py,sha256=vVk1fk-h3pCnvjrHcT5vBJq_eHm9K-HDftqA-C3Sl-Y,30991
11
+ plugwise/legacy/smile.py,sha256=EegTdPb_baIOCGpPXtQ5c9SFPYrhkC4ARGk4_Pc8jK0,10336
12
+ plugwise-0.37.0.dist-info/LICENSE,sha256=mL22BjmXtg_wnoDnnaqps5_Bg_VGj_yHueX5lsKwbCc,1144
13
+ plugwise-0.37.0.dist-info/METADATA,sha256=KZ1fI7O1i0wRcywhDBolxksc93nV3t2iYORw7NVU2h0,9095
14
+ plugwise-0.37.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
15
+ plugwise-0.37.0.dist-info/top_level.txt,sha256=MYOmktMFf8ZmX6_OE1y9MoCZFfY-L8DA0F2tA2IvE4s,9
16
+ plugwise-0.37.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.40.0)
2
+ Generator: bdist_wheel (0.42.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,11 +0,0 @@
1
- plugwise/__init__.py,sha256=MeHRSYO6XfOPsBGNNcnA7ipYPfYu5t1ALtjCsAtYbV0,36705
2
- plugwise/constants.py,sha256=_IO-MQQu_gFZ71VTNlmNY5Lqr6u0t5rWaQTQJqe_xRc,16467
3
- plugwise/exceptions.py,sha256=rymGtWnXosdFkzSehc_41HVl2jXJEg_9Hq9APDEUwrk,1223
4
- plugwise/helper.py,sha256=H3LxEMrakIZmNG80FoObOevRx90Y34sIO-LTwDtXbb4,65502
5
- plugwise/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- plugwise/util.py,sha256=rK7LUmfM_1tXUrmmUovWiz7rw44dz9hpomOZEcky16E,1949
7
- plugwise-0.36.2.dist-info/LICENSE,sha256=mL22BjmXtg_wnoDnnaqps5_Bg_VGj_yHueX5lsKwbCc,1144
8
- plugwise-0.36.2.dist-info/METADATA,sha256=en-5Yyk9bPWHdDUGtmDMj1D8Sap35ovGfB9Khi7pBLs,9097
9
- plugwise-0.36.2.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
10
- plugwise-0.36.2.dist-info/top_level.txt,sha256=MYOmktMFf8ZmX6_OE1y9MoCZFfY-L8DA0F2tA2IvE4s,9
11
- plugwise-0.36.2.dist-info/RECORD,,