View Source Discovergy.Measurements (discovergy v0.6.0)

The Measurements endpoint

Summary

Functions

Return the last measurement for the specified meter.

Return load profile for the given meter.

Return the raw, unmodified load profile file as sent by the specified RLM meter on the specified date.

Return the measurements for the specified meter in the specified time interval.

Return various statistics calculated over all measurements for the specified meter in the specified time interval.

Functions

Link to this function

get_last_reading(client, meter_id, opts \\ [])

View Source
@spec get_last_reading(Discovergy.Client.t(), Meter.id(), Keyword.t()) ::
  {:ok, Discovergy.Measurement.t()} | {:error, Error.t()}

Return the last measurement for the specified meter.

Options

  • :fields - list of measurement fields to return in the result (use Discovergy.Metadata.get_field_names/2 to get all available fields)
  • :each - Return data from the virtual meter itself (false) or all its sub-meters (true). Only applies if meterId refers to a virtual meter

Examples

iex> Discovergy.Measurements.get_last_reading(client, meter_id)
{:ok, %Discovergy.Measurement{
  time: ~U[2019-07-16 22:00:00.000Z],
  values: %{
    "energy" => 441576730000,
    "energyOut" => 2154853000,
    "power" => 205980,
    "power1" => 63090,
    "power2" => 53780,
    "power3" => 89100,
    "voltage1" => 234100,
    "voltage2" => 234000,
    "voltage3" => 233800
  }
}}
Link to this function

get_load_profile(client, meter_id, from, to, opts \\ [])

View Source
@spec get_load_profile(
  Discovergy.Client.t(),
  Meter.id(),
  Date.t(),
  Date.t(),
  Keyword.t()
) ::
  {:ok, [map()]} | {:error, Error.t()}

Return load profile for the given meter.

Options

  • :resolution - reading resolution. Possible values: :raw, :one_day, :one_month, :one_year

Examples

iex> Discovergy.Measurements.get_load_profile(client, meter_id,
...>                                              ~D{2020-07-01},
...>                                              ~D{2020-07-01},
...>                                              resolution: :one_day)
{:ok, [
  %{
    "1.29" => 0.816,
    "2.29" => 833.028,
    "3.29" => 179.376,
    "4.29" => 16.128,
    "5.29" => 9.06,
    "6.29" => 170.328,
    "7.29" => 12.744,
    "8.29" => 3.384,
    "status" => 0,
    "time" => 1593640800000
  },
  %{"1.6.0" => 0.96, "time" => 1593585000000},
  %{"2.6.0" => 142.44, "time" => 1593601200000}
]}
Link to this function

get_raw_load_profile(client, meter_id, date)

View Source
@spec get_raw_load_profile(Discovergy.Client.t(), Meter.id(), Date.t()) ::
  {:ok, String.t()} | {:error, Error.t()}

Return the raw, unmodified load profile file as sent by the specified RLM meter on the specified date.

Examples

iex> {:ok, <<2, profile::binary>>} =
...>   Discovergy.Measurements.get_raw_load_profile(client, meter_id, ~D{2020-07-01})
{:ok, <<2, 80, 46, 48, 49, 40, 49, 50, 48, 48, 55, 48, 49, 48, 48, 49,
53, 48, 48, 41, 40, 48, 48, 48, 48, 48, 48, 48, 48, 41, 40, 49, 53, 41,
40, 56, 41, 40, 49, 46, 50, 57, 41, 40, 107, 87, 104, 41, ...>>}

iex> String.split(profile)
["P.01(1200701001500)(00000000)(15)(8)(1.29)(kWh)(2.29)(kWh)(3.29)(kvarh)(4.29)...",
 "(0.0001)(0.0000)(0.0000)(0.0032)(0.0000)(0.0000)(0.0026)(0.0007)",
 "(0.0000)(0.0000)(0.0000)(0.0035)(0.0000)(0.0000)(0.0029)(0.0005)",
 "(0.0000)(0.0001)(0.0000)(0.0036)(0.0000)(0.0000)(0.0030)(0.0006)",
Link to this function

get_readings(client, meter_id, from, to \\ nil, opts \\ [])

View Source
@spec get_readings(
  Discovergy.Client.t(),
  Meter.id(),
  DateTime.t(),
  DateTime.t(),
  Keyword.t()
) ::
  {:ok, [Discovergy.Measurement.t()]} | {:error, Error.t()}

Return the measurements for the specified meter in the specified time interval.

Options

  • :fields - list of measurement fields to return in the result (use Discovergy.Metadata.get_field_names/2 to get all available fields)
  • :resolution - time distance between returned readings. Possible values: :raw (default), :three_minutes, :fifteen_minutes, :one_hour, :one_day, :one_week, :one_month, :one_year
  • : disaggregation - Include load disaggregation as pseudo-measurement fields, if available. Only applies if raw resolution is selected
  • :each - Return data from the virtual meter itself (false) or all its sub-meters (true). Only applies if meterId refers to a virtual meter

Examples

iex> Discovergy.Measurements.get_readings(client, meter_id, from, to,
...>                                  resolution: :one_month)
{:ok, [
 %Discovergy.Measurement{
   time: ~U[2019-07-16 22:00:00.000Z],
   values: %{
     "energy" => 8069238602135,
     "energy1" => 0,
     "energy2" => 0,
     "energyOut" => 2033461000,
     "energyOut1" => 0,
     "energyOut2" => 0,
     "power" => 512286,
     "power1" => 189978,
     "power2" => 129660,
     "power3" => 192654,
     "voltage1" => 230469,
     "voltage2" => 231599,
     "voltage3" => 230247
   }
 },
 ...
]}
Link to this function

get_statistics(client, meter_id, from, to \\ nil, opts \\ [])

View Source
@spec get_statistics(
  Discovergy.Client.t(),
  Meter.id(),
  DateTime.t(),
  DateTime.t(),
  Keyword.t()
) ::
  {:ok, map()} | {:error, Error.t()}

Return various statistics calculated over all measurements for the specified meter in the specified time interval.

Options

Examples

iex> Discovergy.Measurements.get_statistics(client, meter_id, from)
{:ok, %{
  "energy" => %{
    "count" => 53962,
    "maximum" => 441687910000,
    "mean" => 420770138841.7405,
    "minimum" => 402102161000,
    "variance" => 1.430940674699829e20
  },
  "energyOut" => %{
    ...
  },
  "power" => %{
    ...
  },
  "power1" => %{
    ...
  },
  "power2" => %{
    ...
  },
  "power3" => %{
    ...
  },
  "voltage1" => %{
    ...
  },
  "voltage2" => %{
    ...
  },
  "voltage3" => %{
    ...
  }
}}