pydiagral 1.5.0b5__py3-none-any.whl → 1.5.1__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
@@ -447,7 +447,8 @@ class DiagralAPI:
447
447
  try:
448
448
  await self.get_system_status()
449
449
  except DiagralAPIError:
450
- if ephemeral and not api_keys_provided:
450
+ # If connection fails, clean up keys
451
+ if not api_keys_provided:
451
452
  await self.delete_apikey(apikey=self.__apikey)
452
453
  raise
453
454
 
pydiagral/models.py CHANGED
@@ -1250,8 +1250,8 @@ class WebHookNotificationUser(CamelCaseModel):
1250
1250
  """WebHookNotificationUser represents a user who receives webhook notifications.
1251
1251
 
1252
1252
  Attributes:
1253
- username (str): The username of the user.
1254
- user_type (str): The type of the user.
1253
+ username (str | None): The username of the user.
1254
+ user_type (str | None): The type of the user.
1255
1255
 
1256
1256
  Example:
1257
1257
  >>> user = WebHookNotificationUser(username="Dark Vador", user_type="owner")
@@ -1262,8 +1262,8 @@ class WebHookNotificationUser(CamelCaseModel):
1262
1262
 
1263
1263
  """
1264
1264
 
1265
- username: str
1266
- user_type: str
1265
+ username: str | None = None
1266
+ user_type: str | None = None
1267
1267
 
1268
1268
 
1269
1269
  @dataclass
@@ -1311,7 +1311,7 @@ class WebHookNotification(CamelCaseModel):
1311
1311
  alarm_description: str
1312
1312
  group_index: str
1313
1313
  detail: WebHookNotificationDetail
1314
- user: WebHookNotificationUser
1314
+ user: WebHookNotificationUser | None
1315
1315
  date_time: datetime
1316
1316
 
1317
1317
  @classmethod
@@ -1372,6 +1372,17 @@ class WebHookNotification(CamelCaseModel):
1372
1372
  return "STATUS"
1373
1373
  return "UNKNOWN"
1374
1374
 
1375
+ # Create user object only if user data exists
1376
+ user_data = data.get("user")
1377
+ user: WebHookNotificationUser | None = (
1378
+ WebHookNotificationUser(
1379
+ username=user_data.get("username"),
1380
+ user_type=user_data.get("user_type"),
1381
+ )
1382
+ if user_data
1383
+ else None
1384
+ )
1385
+
1375
1386
  return cls(
1376
1387
  transmitter_id=data.get("transmitter_id"),
1377
1388
  alarm_type=alarm_type(data.get("alarm_code")),
@@ -1383,10 +1394,7 @@ class WebHookNotification(CamelCaseModel):
1383
1394
  device_index=data.get("detail", {}).get("device_index", None),
1384
1395
  device_label=data.get("detail", {}).get("device_label", None),
1385
1396
  ),
1386
- user=WebHookNotificationUser(
1387
- username=data.get("user", {}).get("username", None),
1388
- user_type=data.get("user", {}).get("user_type", None),
1389
- ),
1397
+ user=user,
1390
1398
  date_time=datetime.fromisoformat(data["date_time"].replace("Z", "+00:00")),
1391
1399
  )
1392
1400
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pydiagral
3
- Version: 1.5.0b5
3
+ Version: 1.5.1
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
@@ -823,7 +823,7 @@ Official Diagral API is available [here](https://appv3.tt-monitor.com/emerald/re
823
823
 
824
824
  The serial number can only be found with physical access to the box. You need to open it, and you will find a label with a QR Code.
825
825
 
826
- On this label, there is a 15-character code that represents the serial number of the box.
826
+ On this label, there is a 14-character code that represents the serial number of the box.
827
827
 
828
828
  ![How to find your Diagral Serial](https://raw.githubusercontent.com/mguyard/pydiagral/main/docs/how-to-find-diagral-serial.png)
829
829
 
@@ -0,0 +1,10 @@
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.1.dist-info/METADATA,sha256=dh2tCo5noHV47U6xTSfcXHo9NUWjk-zRqR8Dp77Q2Nk,48529
8
+ pydiagral-1.5.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
+ pydiagral-1.5.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
10
+ pydiagral-1.5.1.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- pydiagral/__init__.py,sha256=4uM-RD2GQ6JYJkxu-D6wj3XpqfY5gN2hP8NF6WvRI9k,576
2
- pydiagral/api.py,sha256=hF-Ol5KHqRXfpKcnxV8SLf-vnYwCTYugQzuQ5_ZG_bs,50094
3
- pydiagral/constants.py,sha256=2B0TdKxQHA3cpIBxojo43bMW44wN9xKYsHbBRHWsaBk,119
4
- pydiagral/exceptions.py,sha256=vMhGDQW-AhYIH9gcKHK1-4SHV3eZUXeeqXPyznUAKnU,1211
5
- pydiagral/models.py,sha256=vUjxuApjVaMtd7H6Iw5LarwABi30O4FfdObhZRbUNuc,54931
6
- pydiagral/utils.py,sha256=-VxI-lNaC4bU1K4DSmWDhvbsS2bXv5FAGULGKBf1UMU,449
7
- pydiagral-1.5.0b5.dist-info/METADATA,sha256=HhOvxestYlemcBg-V3rqY88zG0ltD5X7Az4-lUDWVw0,48531
8
- pydiagral-1.5.0b5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
- pydiagral-1.5.0b5.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
10
- pydiagral-1.5.0b5.dist-info/RECORD,,