Automation

API Reference

Typedefs

using NoArg = bool
template <typename T>
class Condition

Subclassed by AndCondition< T >, binary_sensor::BinarySensorCondition< T >, LambdaCondition< T >, OrCondition< T >, sensor::SensorInRangeCondition< T >, switch_::SwitchCondition< 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 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)
void process_trigger_(T x)
void stop()

Protected Attributes

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

Public Functions

void trigger(T x)
void set_parent(Automation<T> *parent)
void stop()

Protected Attributes

Automation<T> *parent_ = {nullptr}
template <>
template<>
class Trigger<NoArg>

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

Public Functions

ESPHOMELIB_NAMESPACE_BEGIN void Trigger::trigger()
void trigger(bool arg)
void set_parent(Automation<NoArg> *parent)
void stop()

Protected Attributes

Automation<NoArg> *parent_ = {nullptr}
class StartupTrigger : public Trigger<NoArg>, public Component

Public Functions

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

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()
float get_setup_priority() const
class IntervalTrigger : public Trigger<NoArg>, public PollingComponent

Public Functions

IntervalTrigger(uint32_t update_interval)
void update()
float get_setup_priority() const
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 ScriptStopAction : public Action<T>

Public Functions

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

Protected Attributes

Script *script_
template <typename T>
class ScriptStopAction : public Action<T>

Public Functions

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

Protected Attributes

Script *script_
class Script : public Trigger<NoArg>

Public Functions

void execute()
void stop()
template <typename T>
ScriptExecuteAction<T> *make_execute_action()
template <typename T>
ScriptStopAction<T> *make_stop_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)
void stop()
bool empty() const

Protected Attributes

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

Subclassed by api::HomeAssistantServiceCallAction< T >, 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 >, ScriptStopAction< T >, stepper::ReportPositionAction< T >, stepper::SetTargetAction< T >, switch_::ToggleAction< T >, switch_::TurnOffAction< T >, switch_::TurnOnAction< T >, UpdateComponentAction< T >, WhileAction< T >

Public Functions

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

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 stop()
void play(T x)
float get_setup_priority() const

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)
void stop()

Protected Attributes

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

Public Functions

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

Protected Attributes

std::vector<Condition<T> *> conditions_
ActionList<T> then_
bool is_running_ = {false}
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 ScriptStopAction : public Action<T>

Public Functions

ScriptStopAction(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)
void stop()
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)
void process_trigger_(T x)
void stop()

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()
float get_setup_priority() const
void loop()
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_