pymiele 0.5.0__py3-none-any.whl → 0.5.2__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.
pymiele/code_enum.py CHANGED
@@ -1,4 +1,4 @@
1
- """Classes for code enums."""
1
+ """Enum class for Miele intergration."""
2
2
 
3
3
  from enum import IntEnum
4
4
  import logging
@@ -11,10 +11,20 @@ completed_warnings: set[str] = set()
11
11
  class MieleEnum(IntEnum):
12
12
  """Miele Enum for codes with int values."""
13
13
 
14
+ # Modify the behaviour of the class when detecting a missing value:
15
+ # Add a member missing2none in order to:
16
+ # - Log a warning that the code is missing
17
+ # - Return None as key name
18
+ #
19
+ # Add a member unknown_code in order to:
20
+ # - Log a warning that the code is missing
21
+ # - Return 'unknown_value' as key name
22
+
14
23
  @property
15
- def name(self) -> str:
24
+ def name(self) -> str | None:
16
25
  """Force to lower case."""
17
- return super().name.lower()
26
+ _name = super().name.lower()
27
+ return _name if _name != "missing2none" else None
18
28
 
19
29
  @classmethod
20
30
  def _missing_(cls, value: object) -> Any | None:
@@ -25,7 +35,14 @@ class MieleEnum(IntEnum):
25
35
  if warning not in completed_warnings:
26
36
  completed_warnings.add(warning)
27
37
  _LOGGER.warning(warning)
28
- return cls.unknown_code
38
+ return cls.unknown_code # pylint: disable=no-member
39
+ if hasattr(cls, "missing2none"):
40
+ warning = f"Missing {cls.__name__} code: {value} - defaulting to Unknown"
41
+ if warning not in completed_warnings:
42
+ completed_warnings.add(warning)
43
+ _LOGGER.warning(warning)
44
+ return cls.missing2none # pylint: disable=no-member
45
+
29
46
  return None
30
47
 
31
48
  def __new__(cls, value: int, *values: list[int]) -> Any:
@@ -39,12 +56,12 @@ class MieleEnum(IntEnum):
39
56
  @classmethod
40
57
  def as_dict(cls) -> dict[str, int]:
41
58
  """Return a dict of enum names and values."""
42
- return {i.name: i.value for i in cls if i.name != "unknown_code"}
59
+ return {i.name: i.value for i in cls if i.name is not None}
43
60
 
44
61
  @classmethod
45
62
  def as_enum_dict(cls) -> dict[int, Any]:
46
63
  """Return a dict of enum values and enum names."""
47
- return {i.value: i for i in cls if i.name != "unknown_code"}
64
+ return {i.value: i for i in cls if i.name is not None}
48
65
 
49
66
  @classmethod
50
67
  def values(cls) -> list[int]:
pymiele/const.py CHANGED
@@ -1,6 +1,6 @@
1
1
  """Constants for pymiele."""
2
2
 
3
- VERSION = "0.5.0"
3
+ VERSION = "0.5.2"
4
4
 
5
5
  MIELE_API = "https://api.mcs3.miele.com/v1"
6
6
  OAUTH2_AUTHORIZE = "https://api.mcs3.miele.com/thirdparty/login"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pymiele
3
- Version: 0.5.0
3
+ Version: 0.5.2
4
4
  Summary: Python library for Miele integration with Home Assistant
5
5
  Author-email: Ake Strandberg <ake@strandberg.eu>
6
6
  License: MIT
@@ -0,0 +1,11 @@
1
+ pymiele/__init__.py,sha256=yaR_pvVA5HfAxQ9oHCk8CsoHfEkskdZLmxbY1QgrMBE,260
2
+ pymiele/code_enum.py,sha256=fagb4d114ZgMKcVZuITZNpwrJOUReYpkf3qLEmabqLQ,2603
3
+ pymiele/const.py,sha256=8zzTh8sdNUoWzuKJsmpXnkzRFNR7HmnbG0mWDBQm-rM,237
4
+ pymiele/model.py,sha256=oMf8CVnCrbrzvs66mVXNjilDolkRQV4UedtEVoOrD8A,21726
5
+ pymiele/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ pymiele/pymiele.py,sha256=yGL4rekRPGzwXziZ5ydVrsEN-XPN110dmuWygbXF148,9405
7
+ pymiele-0.5.2.dist-info/licenses/LICENSE,sha256=scGm4_U2pd-rsGa6Edf6zsXFebrMT4RoyQz7-904_Wg,1072
8
+ pymiele-0.5.2.dist-info/METADATA,sha256=8QVtr2txJTjFWjAk5-_0qGbL8Sr6R5BgQ9-iHrudu7s,747
9
+ pymiele-0.5.2.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
10
+ pymiele-0.5.2.dist-info/top_level.txt,sha256=BwkHrSO2w_Bfxh6s8Ikcao5enEuQOpQhJ3SwUXBqY10,8
11
+ pymiele-0.5.2.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- pymiele/__init__.py,sha256=yaR_pvVA5HfAxQ9oHCk8CsoHfEkskdZLmxbY1QgrMBE,260
2
- pymiele/code_enum.py,sha256=q8EfNM06JtNSq2Viv5E2p3MHPEqr3-AjyfMvHzwpcm0,1839
3
- pymiele/const.py,sha256=JtfE0YP3ID7hGIEiQ87OwWf8SP-a0f8MAaP7ufwAKec,237
4
- pymiele/model.py,sha256=oMf8CVnCrbrzvs66mVXNjilDolkRQV4UedtEVoOrD8A,21726
5
- pymiele/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- pymiele/pymiele.py,sha256=yGL4rekRPGzwXziZ5ydVrsEN-XPN110dmuWygbXF148,9405
7
- pymiele-0.5.0.dist-info/licenses/LICENSE,sha256=scGm4_U2pd-rsGa6Edf6zsXFebrMT4RoyQz7-904_Wg,1072
8
- pymiele-0.5.0.dist-info/METADATA,sha256=NbjjhacKJz9QI5kkZEn4NsQQZ1lNLJpvByv-bACBg1Y,747
9
- pymiele-0.5.0.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
10
- pymiele-0.5.0.dist-info/top_level.txt,sha256=BwkHrSO2w_Bfxh6s8Ikcao5enEuQOpQhJ3SwUXBqY10,8
11
- pymiele-0.5.0.dist-info/RECORD,,