Automation

API Reference

Typedefs

using NoArg = bool
template <typename T>
class Condition

Subclassed by AndCondition< T >, LambdaCondition< T >, OrCondition< T >

Public Functions

virtual bool check(T x) = 0
template <typename T>
class AndCondition : public Condition<T>

Public Functions

AndCondition(const std::vector<Condition<T> *> &conditions)
bool check(T x)

Protected Attributes

std::vector<Condition<T> *> conditions_
template <typename T>
class OrCondition : public Condition<T>

Public Functions

OrCondition(const std::vector<Condition<T> *> &conditions)
bool check(T x)

Protected Attributes

std::vector<Condition<T> *> conditions_
template <typename T>
class LambdaCondition : public Condition<T>

Public Functions

LambdaCondition(std::function<bool(T)> &&f)
bool check(T x)

Protected Attributes

std::function<bool(T)> f_
class RangeCondition : public Condition<float>

Public Functions

RangeCondition()
bool check(float x)
void set_min(std::function<float(float)> &&min)
void set_min(float min)
void set_max(std::function<float(float)> &&max)
void set_max(float max)

Protected Attributes

TemplatableValue<float, float> min_ = {NAN}
TemplatableValue<float, float> max_ = {NAN}
template <typename T>
class Trigger

Public Functions

void add_on_trigger_callback(std::function<void(T)> &&f)
void trigger(T x)

Protected Attributes

CallbackManager<void(T)> on_trigger_
template <>
template<>
class Trigger<NoArg>

Subclassed by binary_sensor::ClickTrigger, binary_sensor::DoubleClickTrigger, binary_sensor::MultiClickTrigger, binary_sensor::PressTrigger, binary_sensor::ReleaseTrigger, LoopTrigger, Script, StartupTrigger, time::CronTrigger

Public Functions

ESPHOMELIB_NAMESPACE_BEGIN void Trigger::add_on_trigger_callback(std::function< void(NoArg)> && f)
void trigger()

Protected Attributes

CallbackManager<void(NoArg)> on_trigger_
class StartupTrigger : public Trigger<NoArg>, public Component

Public Functions

StartupTrigger(float setup_priority = setup_priority::LATE)
void setup()

Where the component’s initialization should happen.

Analogous to Arduino’s setup(). This method is guaranteed to only be called once. Defaults to doing nothing.

float get_setup_priority() const

priority of setup().

higher -> executed earlier

Defaults to 0.

Return
The setup priority of this component

Protected Attributes

float setup_priority_
class ShutdownTrigger : public Trigger<const char *>

Public Functions

ShutdownTrigger()
class LoopTrigger : public Trigger<NoArg>, public Component

Public Functions

void loop()

This method will be called repeatedly.

Analogous to Arduino’s loop(). setup() is guaranteed to be called before this. Defaults to doing nothing.

float get_setup_priority() const

priority of setup().

higher -> executed earlier

Defaults to 0.

Return
The setup priority of this component

template <typename T>
class ScriptExecuteAction : public Action<T>

Public Functions

ScriptExecuteAction(Script *script)
void play(T x)

Protected Attributes

Script *script_
class Script : public Trigger<NoArg>

Public Functions

void execute()
template <typename T>
ScriptExecuteAction<T> *make_execute_action()
template <typename T>
class ActionList

Public Functions

Action<T> *add_action(Action<T> *action)
void add_actions(const std::vector<Action<T> *> &actions)
void play(T x)
bool empty() const

Protected Attributes

Action<T> *actions_begin_ = {nullptr}
Action<T> *actions_end_ = {nullptr}
template <typename T>
class Action

Subclassed by cover::CloseAction< T >, cover::OpenAction< T >, cover::StopAction< T >, DelayAction< T >, EnterDeepSleepAction< T >, fan::ToggleAction< T >, fan::TurnOffAction< T >, fan::TurnOnAction< T >, IfAction< T >, LambdaAction< T >, light::ToggleAction< T >, light::TurnOffAction< T >, light::TurnOnAction< T >, mqtt::MQTTPublishAction< T >, mqtt::MQTTPublishJsonAction< T >, output::SetLevelAction< T >, output::TurnOffAction< T >, output::TurnOnAction< T >, PreventDeepSleepAction< T >, ScriptExecuteAction< T >, stepper::ReportPositionAction< T >, stepper::SetTargetAction< T >, switch_::ToggleAction< T >, switch_::TurnOffAction< T >, switch_::TurnOnAction< T >, UpdateComponentAction< T >

Public Functions

virtual void play(T x) = 0
void play_next(T x)

Protected Attributes

friend Action::ActionList< T >
Action<T> *next_ = nullptr
template <typename T>
class DelayAction : public Action<T>, public Component

Public Functions

DelayAction()
void set_delay(std::function<uint32_t(T)> &&delay)
void set_delay(uint32_t delay)
void play(T x)
float get_setup_priority() const

priority of setup().

higher -> executed earlier

Defaults to 0.

Return
The setup priority of this component

Protected Attributes

TemplatableValue<uint32_t, T> delay_ = {0}
template <typename T>
class LambdaAction : public Action<T>

Public Functions

LambdaAction(std::function<void(T)> &&f)
void play(T x)

Protected Attributes

std::function<void(T)> f_
template <typename T>
class IfAction : public Action<T>

Public Functions

IfAction(std::vector<Condition<T> *> conditions)
void add_then(const std::vector<Action<T> *> &actions)
void add_else(const std::vector<Action<T> *> &actions)
void play(T x)

Protected Attributes

std::vector<Condition<T> *> conditions_
ActionList<T> then_
ActionList<T> else_
template <typename T>
class UpdateComponentAction : public Action<T>

Public Functions

UpdateComponentAction(PollingComponent *component)
void play(T x)

Protected Attributes

PollingComponent *component_
template <typename T>
class ScriptExecuteAction : public Action<T>

Public Functions

ScriptExecuteAction(Script *script)
void play(T x)

Protected Attributes

Script *script_
template <typename T>
class ActionList

Public Functions

Action<T> *add_action(Action<T> *action)
void add_actions(const std::vector<Action<T> *> &actions)
void play(T x)
bool empty() const

Protected Attributes

Action<T> *actions_begin_ = {nullptr}
Action<T> *actions_end_ = {nullptr}
template <typename T>
class Automation

Public Functions

Automation(Trigger<T> *trigger)
Condition<T> *add_condition(Condition<T> *condition)
void add_conditions(const std::vector<Condition<T> *> &conditions)
Action<T> *add_action(Action<T> *action)
void add_actions(const std::vector<Action<T> *> &actions)

Protected Functions

void process_trigger_(T x)

Protected Attributes

Trigger<T> *trigger_
std::vector<Condition<T> *> conditions_
ActionList<T> actions_
template <typename T>
class GlobalVariableComponent : public Component

Public Functions

GlobalVariableComponent()
GlobalVariableComponent(T initial_value)
T &value()
void setup()

Where the component’s initialization should happen.

Analogous to Arduino’s setup(). This method is guaranteed to only be called once. Defaults to doing nothing.

float get_setup_priority() const

priority of setup().

higher -> executed earlier

Defaults to 0.

Return
The setup priority of this component

void loop()

This method will be called repeatedly.

Analogous to Arduino’s loop(). setup() is guaranteed to be called before this. Defaults to doing nothing.

void set_restore_value(uint32_t name_hash)

Protected Attributes

T value_ = {}
T prev_value_ = {}
bool restore_value_ = {false}
uint32_t name_hash_ = {}
ESPPreferenceObject rtc_