View Source Statux (Statux v0.1.2)

Link to this section Summary

Functions

Retrieve the current status for a given ID.

Pass a new value to Statux to be evaluated against the given rule_set

Forcefully sets the state of a given id and status to an option.

Link to this section Functions

See Statux.Tracker.child_spec/1.

Retrieve the current status for a given ID.

iex> Statux.get("my_device")
%{
  battery_voltage: %Statux.Models.Status{
    current: :ok,
    history: [:ok, :low],
    transition_count: 2,
    transitioned_at: DateTime%{}
  },
  other_status: %Statux.Models.Status{...},
  ...
}
Link to this function

put(id, status_name, value, rule_set \\ :default)

View Source

Pass a new value to Statux to be evaluated against the given rule_set

Feedback is provided asynchronously, either through the configured PubSub Module or by calling the callbacks given in the rule set.

Statux.put("my_device", :battery_voltage, 12.4)
Link to this function

put_for(server, id, status_name, value, rule_set \\ :default)

View Source
Link to this function

set(id, status_name, option)

View Source

Forcefully sets the state of a given id and status to an option.

This allows to create options that can not be left automatically, for example a :critical or :warning status that has to be acknowledged manually.

iex> Statux.put("my_device", :battery_voltage, :ok)
%Statux.Models.Status{
  current: :ok,
  history: [:ok, :low],
  transition_count: 2,
  transitioned_at: DateTime%{} # now
}

iex> Statux.put("my_device", :battery_voltage, :some_random_option)
{:error, :invalid_option}
Link to this function

set_for(server, id, status_name, option)

View Source