Ejemplo n.º 1
0
def api_get_times_step(sensor, watt_euros, time1, time2, step, db):
    """
    Returns all the measures of sensor `sensor` between timestamps `time1`
    and `time2`, grouped by step, as a list of the number of steps element.
    Each item is null if no matching measures are found.

    * If `watts_euros` is watts, returns the mean power for each group.
    * If `watt_euros` is kwatthours, returns the total energy for each group.
    * If `watt_euros` is euros, returns the cost of each group.

    Returns measure in ASC order of timestamp.
    """
    if time1 < 0 or time2 < 0 or step <= 0:
        abort(400, "Invalid parameters")

    data = cache.do_cache_group_timestamp(sensor, watt_euros, time1, time2,
                                          step, db)

    return {"data": data, "rate": get_rate_type(db)}
Ejemplo n.º 2
0
def api_get_times_step(sensor, watt_euros, time1, time2, step, db):
    """
    Returns all the measures of sensor `sensor` between timestamps `time1`
    and `time2`, grouped by step, as a list of the number of steps element.
    Each item is null if no matching measures are found.

    * If `watts_euros` is watts, returns the mean power for each group.
    * If `watt_euros` is kwatthours, returns the total energy for each group.
    * If `watt_euros` is euros, returns the cost of each group.

    Returns measure in ASC order of timestamp.
    """
    if time1 < 0 or time2 < 0 or step <= 0:
        abort(400, "Invalid parameters")

    data = cache.do_cache_group_timestamp(sensor,
                                          watt_euros,
                                          time1,
                                          time2,
                                          step,
                                          db)

    return {"data": data, "rate": get_rate_type(db)}