Sml.ListEntry (SmlEx v0.1.0)

Copy Markdown View Source

One entry of the value list in a Sml.Messages.GetListResponse (SML_ListEntry), e.g. the meter reading for 1-0:1.8.0*255.

value is the raw value as sent by the meter. Use scaled_value/1 to get the value with the scaler applied, and Sml.Units to interpret unit.

Summary

Functions

Returns value * 10^scaler.

Returns the unit name (e.g. :wh) of the entry, see Sml.Units.name/1.

Types

t()

@type t() :: %Sml.ListEntry{
  obis: Sml.Obis.t() | binary(),
  scaler: integer() | nil,
  status: non_neg_integer() | nil,
  unit: Sml.Units.code() | nil,
  val_time: Sml.Time.t(),
  value: integer() | binary() | boolean() | list() | nil,
  value_signature: binary() | nil
}

Functions

scaled_value(list_entry)

@spec scaled_value(t()) :: number() | binary() | boolean() | list() | nil

Returns value * 10^scaler.

The result is an integer if the scaler is missing or not negative, and a float otherwise. Non-numeric values are returned unchanged.

iex> Sml.ListEntry.scaled_value(%Sml.ListEntry{value: 123_456, scaler: -1})
12345.6

iex> Sml.ListEntry.scaled_value(%Sml.ListEntry{value: 42, scaler: 2})
4200

iex> Sml.ListEntry.scaled_value(%Sml.ListEntry{value: "EMH", scaler: nil})
"EMH"

unit_name(list_entry)

@spec unit_name(t()) :: atom() | nil

Returns the unit name (e.g. :wh) of the entry, see Sml.Units.name/1.