Home Assistant Unofficial Reference 2024.12.1
helpers.py
Go to the documentation of this file.
1 """Helper functions for the Traccar Server integration."""
2 
3 from __future__ import annotations
4 
5 from pytraccar import DeviceModel, GeofenceModel
6 
7 
8 def get_device(device_id: int, devices: list[DeviceModel]) -> DeviceModel | None:
9  """Return the device."""
10  return next(
11  (dev for dev in devices if dev["id"] == device_id),
12  None,
13  )
14 
15 
17  geofences: list[GeofenceModel],
18  target: list[int],
19 ) -> GeofenceModel | None:
20  """Return the geofence."""
21  return next(
22  (geofence for geofence in geofences if geofence["id"] in target),
23  None,
24  )
GeofenceModel|None get_first_geofence(list[GeofenceModel] geofences, list[int] target)
Definition: helpers.py:19
DeviceModel|None get_device(int device_id, list[DeviceModel] devices)
Definition: helpers.py:8