View Source Statux (Statux v0.2.0)
The Statux library can be used to evaluate given key-value pairs to states.
Link to this section Summary
Functions
Retrieve the current status for a given ID.
Get the tracked status of a given id from a specific Statux process.
Pass a new value to Statux to be evaluated against the given rule_set
Pass a new value to a specific Statux process. Refer to put/4 for more information.
Simply evaluates the given value for the given status based on its value. This function can be used to have a simple rule evaluation without any additional constraints. Therefore, 'constraints' are ignored and only the 'value' requirements are evaluated.
Forcefully sets the state of a given id and status to an option.
Force-sets the status for the given id on a specific server. See set/3 for more information.
Link to this section Functions
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{...},
...
}
Get the tracked status of a given id from a specific Statux process.
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)
Pass a new value to a specific Statux process. Refer to put/4 for more information.
Simply evaluates the given value for the given status based on its value. This function can be used to have a simple rule evaluation without any additional constraints. Therefore, 'constraints' are ignored and only the 'value' requirements are evaluated.
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}
Force-sets the status for the given id on a specific server. See set/3 for more information.