Devices¶
-
class
utils.
Devices
¶ Bases:
object
Devices Collection (Iterator)
Methods Summary
as_dict
(update)Get Devices collection represented as a dictionary get
(device_id, create_if_unknown)Get (or create) a specific Device purge
(**kwargs)Purge (delete) databases of requested content stats
()Generate device related statistics to_dict
(devices)Converts list of Devices to list of dictionaries update
()Refreshed cache of known devices from database Methods Documentation
-
as_dict
(update: bool = False) → dict¶ Get Devices collection represented as a dictionary
Parameters: update – Update cache before returning. Returns: Dictionary containing three lists. All devices (all), Registered devices (registered) and Unregistered devices (unregistered) Return type: dict
-
get
(device_id: str, create_if_unknown: bool = False)¶ Get (or create) a specific Device
Parameters: device_id – The unique ID of the device. Keyword Arguments: create_if_unknown – If the device_id is not known then create a new Device. Returns: If device_id is found returns a Device. If no mathcing device found and create_if_unknown is False then returns None. However if create_if_unknown is True then return the newly created Device() Return type: Device
-
purge
(**kwargs)¶ Purge (delete) databases of requested content
Keyword Arguments: - registered (bool) – Purge registered devices.
- unregistered (bool) – Purge unregistered devices.
- registry (bool) – Purge known device registry.
- start (str) – DateTime string from when to purge data.
- end (str) – DateTime string until when to purge data.
Raises: ValueError
– If ill defined purge
-
stats
()¶ Generate device related statistics
Returns: total_readings, last_update, last_update_humanized, list of registered_devices Return type: dict
-
to_dict
(devices: list)¶ Converts list of Devices to list of dictionaries
Parameters: devices – List of Device() objects Returns: List of dictionaries, each representing a Device() Return type: list
-
update
()¶ Refreshed cache of known devices from database
-