Readings

class utils.Readings(readings: list, device_id: str, time_start: str, time_end: str, time_interval: int, fillmode: str, query_fields: dict)

Bases: object

Datatype for returned readings from readings query

Parameters:
  • readings – List of readings
  • device_id – Device ID
  • time_start – Readings earliest date and time
  • time_end – Readings latest date and time
  • time_interval – Readings interval in seconds
  • fillmode – Reading fill mode
  • fields_data – List of dicts each represnting a field

Methods Summary

all(**kwargs) Return all readings as a dictionary:
merge_with(other) Merge another Readings object into this one.
timestamps() Get list of timestamps in results

Methods Documentation

all(**kwargs)

Return all readings as a dictionary:

Keyword Arguments:
 format (str) – How the readings should be formatted. Options: list ot by_time

Returns: Readings as a dictionary:

{
    "device_ids": (list) List of device ids which contributed to these readings,
    "start": (str) Readings earliest date and time,
    "end": (str) Readings latest date and time,
    "count": (int) Numbner of readings,
    "fields": [
        see device.fields()
    ],
    "field_ids": (list) Field ids,
    'readings': Readings as either a list of dicts (list) or as a dict where key=time and val=dict(field->val)
}
merge_with(other)

Merge another Readings object into this one.

Parameters:other (Reading) – Readings objects to consume
timestamps()

Get list of timestamps in results

Returns:List of string date time stamps
Return type:list