pydiagral 1.5.1b1__py3-none-any.whl → 1.6.0b1__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.
pydiagral/api.py CHANGED
@@ -63,7 +63,7 @@ class DiagralAPI:
63
63
  serial_id: str,
64
64
  apikey: str | None = None,
65
65
  secret_key: str | None = None,
66
- pincode: int | None = None,
66
+ pincode: str | None = None,
67
67
  ) -> None:
68
68
  """Initialize the DiagralAPI instance.
69
69
 
@@ -73,7 +73,7 @@ class DiagralAPI:
73
73
  serial_id (str): The serial ID of the Diagral system.
74
74
  apikey (str | None, optional): The API key for additional authentication. Defaults to None.
75
75
  secret_key (str | None, optional): The secret key for additional authentication. Defaults to None.
76
- pincode (int | None, optional): The PIN code for the Diagral system. Defaults to None.
76
+ pincode (str | None, optional): The PIN code for the Diagral system. Defaults to None.
77
77
 
78
78
  Raises:
79
79
  ConfigurationError: If any required field is empty or invalid.
@@ -104,9 +104,11 @@ class DiagralAPI:
104
104
 
105
105
  # Validate pincode
106
106
  if pincode is not None:
107
- if not isinstance(pincode, int):
108
- raise ConfigurationError("pincode must be an integer")
109
- self.__pincode: int | None = pincode
107
+ if not isinstance(pincode, str) or (
108
+ isinstance(pincode, str) and not pincode.isdigit()
109
+ ):
110
+ raise ConfigurationError("pincode must be an string of digits")
111
+ self.__pincode: str | None = pincode
110
112
 
111
113
  # Initialize session and access_token
112
114
  self.session: aiohttp.ClientSession | None = None
@@ -597,7 +599,7 @@ class DiagralAPI:
597
599
  )
598
600
 
599
601
  _HEADERS: dict[str, str] = {
600
- "X-PIN-CODE": str(self.__pincode),
602
+ "X-PIN-CODE": self.__pincode,
601
603
  "X-HMAC": _HMAC,
602
604
  "X-TIMESTAMP": _TIMESTAMP,
603
605
  "X-APIKEY": self.__apikey,
@@ -640,7 +642,7 @@ class DiagralAPI:
640
642
  )
641
643
 
642
644
  _HEADERS: dict[str, str] = {
643
- "X-PIN-CODE": str(self.__pincode),
645
+ "X-PIN-CODE": self.__pincode,
644
646
  "X-HMAC": _HMAC,
645
647
  "X-TIMESTAMP": _TIMESTAMP,
646
648
  "X-APIKEY": self.__apikey,
@@ -694,7 +696,7 @@ class DiagralAPI:
694
696
  )
695
697
 
696
698
  _HEADERS: dict[str, str] = {
697
- "X-PIN-CODE": str(self.__pincode),
699
+ "X-PIN-CODE": self.__pincode,
698
700
  "X-HMAC": _HMAC,
699
701
  "X-TIMESTAMP": _TIMESTAMP,
700
702
  "X-APIKEY": self.__apikey,
@@ -829,7 +831,7 @@ class DiagralAPI:
829
831
  )
830
832
 
831
833
  _HEADERS: dict[str, str] = {
832
- "X-PIN-CODE": str(self.__pincode),
834
+ "X-PIN-CODE": self.__pincode,
833
835
  "X-HMAC": _HMAC,
834
836
  "X-TIMESTAMP": _TIMESTAMP,
835
837
  "X-APIKEY": self.__apikey,
@@ -936,7 +938,7 @@ class DiagralAPI:
936
938
  )
937
939
 
938
940
  _HEADERS: dict[str, str] = {
939
- "X-PIN-CODE": str(self.__pincode),
941
+ "X-PIN-CODE": self.__pincode,
940
942
  "X-HMAC": _HMAC,
941
943
  "X-TIMESTAMP": _TIMESTAMP,
942
944
  "X-APIKEY": self.__apikey,
pydiagral/models.py CHANGED
@@ -13,7 +13,7 @@ from datetime import datetime, timezone
13
13
  import logging
14
14
  import re
15
15
  import types
16
- from typing import TypeVar, Union, get_args, get_origin, get_type_hints
16
+ from typing import Self, Union, get_args, get_origin, get_type_hints
17
17
 
18
18
  logger: logging.Logger = logging.getLogger(__name__)
19
19
 
@@ -54,9 +54,6 @@ class CamelCaseModel:
54
54
 
55
55
  """
56
56
 
57
- # Type variable for the class itself
58
- T = TypeVar("T", bound="CamelCaseModel")
59
-
60
57
  def to_dict(self) -> dict:
61
58
  """Convert the instance attributes to a dictionary, transforming attribute names.
62
59
 
@@ -90,7 +87,7 @@ class CamelCaseModel:
90
87
  return result
91
88
 
92
89
  @classmethod
93
- def _from_dict_recursive(cls: type[T], data: dict, target_cls: type[T]) -> T:
90
+ def _from_dict_recursive(cls, data: dict, target_cls: type[Self]) -> Self:
94
91
  """Recursively converts a dictionary to an instance of the specified target class.
95
92
 
96
93
  This method handles nested dictionaries and lists, converting them to the appropriate
@@ -98,12 +95,12 @@ class CamelCaseModel:
98
95
  by handling `Union` types and removing `None` from the type hints.
99
96
 
100
97
  Args:
101
- cls (type[T]): The class that this method is a part of.
98
+ cls (type[Self]): The class that this method is a part of.
102
99
  data (dict): The dictionary to convert.
103
- target_cls (type[T]): The target class to convert the dictionary to.
100
+ target_cls (type[Self]): The target class to convert the dictionary to.
104
101
 
105
102
  Returns:
106
- T: An instance of the target class populated with the data from the dictionary.
103
+ An instance of the target class populated with the data from the dictionary.
107
104
 
108
105
  Raises:
109
106
  TypeError: If the target class cannot be instantiated with the provided data.
@@ -187,15 +184,15 @@ class CamelCaseModel:
187
184
  return target_cls(**init_values)
188
185
 
189
186
  @classmethod
190
- def from_dict(cls: type[T], data: dict) -> T:
187
+ def from_dict(cls, data: dict) -> Self:
191
188
  """Create an instance of the class from a dictionary.
192
189
 
193
190
  Args:
194
- cls (type[T]): The class type to instantiate.
191
+ cls (type[Self]): The class type to instantiate.
195
192
  data (dict): The dictionary containing the data to populate the instance.
196
193
 
197
194
  Returns:
198
- T: An instance of the class populated with the data from the dictionary.
195
+ An instance of the class populated with the data from the dictionary.
199
196
 
200
197
  Example:
201
198
  >>> data = {"diagral_id": 123, "user_id": 456, "access_token": "abc123"}
@@ -830,11 +827,11 @@ class AlarmConfiguration(CamelCaseModel):
830
827
  reading_date (datetime | None): The date when the configuration was read, aliased as "readingDate".
831
828
  transceivers (list[TransceiverModel] | None): A list of transceiver models.
832
829
  transmitters (list[TransmitterModel] | None): A list of transmitter models.
833
- grp_marche_presence (list[int] | None): A list of group marche presence, aliased as "grpMarchePresence".
830
+ presence_group (list[int] | None): A list of group marche presence, aliased as "presenceGroup".
834
831
  installation_state (int | None): The state of the installation, aliased as "installationState".
835
832
  central_information (CentralInformation | None): Information about the central unit, aliased as "centralInformation".
836
- grp_marche_partielle1 (list[int] | None): A list of group marche partielle 1, aliased as "grpMarchePartielle1".
837
- grp_marche_partielle2 (list[int] | None): A list of group marche partielle 2, aliased as "grpMarchePartielle2".
833
+ partial_group1 (list[int] | None): A list of group marche partielle 1, aliased as "partialGroup1".
834
+ partial_group2 (list[int] | None): A list of group marche partielle 2, aliased as "partialGroup2".
838
835
 
839
836
  Example:
840
837
  >>> alarm_config = AlarmConfiguration(
@@ -847,11 +844,11 @@ class AlarmConfiguration(CamelCaseModel):
847
844
  ... reading_date=datetime(2023, 10, 1),
848
845
  ... transceivers=[TransceiverModel(uid="11223", type=5)],
849
846
  ... transmitters=[TransmitterModel(uid="44556", type=6)],
850
- ... grp_marche_presence=[1, 2, 3],
847
+ ... presence_group=[1, 2, 3],
851
848
  ... installation_state=1,
852
849
  ... central_information=CentralInformation(has_plug=True),
853
- ... grp_marche_partielle1=[4, 5, 6],
854
- ... grp_marche_partielle2=[7, 8, 9]
850
+ ... partial_group1=[4, 5, 6],
851
+ ... partial_group2=[7, 8, 9]
855
852
  ... )
856
853
  >>> print(alarm_config.alarm.name)
857
854
  Home Alarm
@@ -870,8 +867,8 @@ class AlarmConfiguration(CamelCaseModel):
870
867
  )
871
868
  transceivers: list[TransceiverModel] | None = None
872
869
  transmitters: list[TransmitterModel] | None = None
873
- grp_marche_presence: list[int] | None = field(
874
- default=None, metadata={"alias": "grpMarchePresence"}
870
+ presence_group: list[int] | None = field(
871
+ default=None, metadata={"alias": "presenceGroup"}
875
872
  )
876
873
  installation_state: int | None = field(
877
874
  default=None, metadata={"alias": "installationState"}
@@ -879,11 +876,11 @@ class AlarmConfiguration(CamelCaseModel):
879
876
  central_information: CentralInformation | None = field(
880
877
  default=None, metadata={"alias": "centralInformation"}
881
878
  )
882
- grp_marche_partielle1: list[int] | None = field(
883
- default=None, metadata={"alias": "grpMarchePartielle1"}
879
+ partial_group1: list[int] | None = field(
880
+ default=None, metadata={"alias": "partialGroup1"}
884
881
  )
885
- grp_marche_partielle2: list[int] | None = field(
886
- default=None, metadata={"alias": "grpMarchePartielle2"}
882
+ partial_group2: list[int] | None = field(
883
+ default=None, metadata={"alias": "partialGroup2"}
887
884
  )
888
885
 
889
886
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pydiagral
3
- Version: 1.5.1b1
3
+ Version: 1.6.0b1
4
4
  Summary: A Python library for interacting with Diagral systems
5
5
  Project-URL: Homepage, https://github.com/mguyard/pydiagral
6
6
  Project-URL: Documentation, https://github.com/mguyard/pydiagral
@@ -0,0 +1,10 @@
1
+ pydiagral/__init__.py,sha256=4uM-RD2GQ6JYJkxu-D6wj3XpqfY5gN2hP8NF6WvRI9k,576
2
+ pydiagral/api.py,sha256=WVefABeL7ci5glCr5wagTSfhesgj6oFmLCGyJSsqbsg,50199
3
+ pydiagral/constants.py,sha256=2B0TdKxQHA3cpIBxojo43bMW44wN9xKYsHbBRHWsaBk,119
4
+ pydiagral/exceptions.py,sha256=vMhGDQW-AhYIH9gcKHK1-4SHV3eZUXeeqXPyznUAKnU,1211
5
+ pydiagral/models.py,sha256=c9tqZUUEhnjuqRhp5md-iKnQMHk8UsuP3TmH2qFKlPc,54976
6
+ pydiagral/utils.py,sha256=-VxI-lNaC4bU1K4DSmWDhvbsS2bXv5FAGULGKBf1UMU,449
7
+ pydiagral-1.6.0b1.dist-info/METADATA,sha256=ENrZSDJHc8XQZCqrjLACQ2QkMBWlCOBpRgjrpM6-ORs,48531
8
+ pydiagral-1.6.0b1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
+ pydiagral-1.6.0b1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
10
+ pydiagral-1.6.0b1.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- pydiagral/__init__.py,sha256=4uM-RD2GQ6JYJkxu-D6wj3XpqfY5gN2hP8NF6WvRI9k,576
2
- pydiagral/api.py,sha256=nEmP1UuZWIMoSpWMxGk4dF2AbejlE7AJHMTBGUeLra8,50129
3
- pydiagral/constants.py,sha256=2B0TdKxQHA3cpIBxojo43bMW44wN9xKYsHbBRHWsaBk,119
4
- pydiagral/exceptions.py,sha256=vMhGDQW-AhYIH9gcKHK1-4SHV3eZUXeeqXPyznUAKnU,1211
5
- pydiagral/models.py,sha256=lXsVoyy3WAkBmk9V2jeFQM_CAQXcuZsyOZatlwze2kE,55161
6
- pydiagral/utils.py,sha256=-VxI-lNaC4bU1K4DSmWDhvbsS2bXv5FAGULGKBf1UMU,449
7
- pydiagral-1.5.1b1.dist-info/METADATA,sha256=q1w61g5vx15zCXuwcMJxMAQBGGNDsdsw_Jjs6ypzvPE,48531
8
- pydiagral-1.5.1b1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
- pydiagral-1.5.1b1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
10
- pydiagral-1.5.1b1.dist-info/RECORD,,