View Source Statux.Transitions (Statux v0.2.0)

Handles evaluation and execution of a Transition from one to another or the same status.

Link to this section Summary

Functions

Pass in an entity state, a list of options and the name of the status

Link to this section Functions

Link to this function

transition(entity_state, status_name, no_valid_options, pubsub)

View Source

Pass in an entity state, a list of options and the name of the status

iex> maybe_transition(entity_state, :battery_voltage, [:low])
updated_entity_state

to check constraints for the given status_name and options and, if the constraints are fulfilled, alter the entity_state to the new status.

As a side effect, this function may

  1. broadcast PubSub messages, if PubSub is configured, and/or
  2. trigger the callback functions provided in the rule set for :enter, :stay, :exit (to be implemented)

You may use these side effects to react to updates in your application.