7static const char *
const TAG =
"template.switch";
12 if (!this->
f_.has_value())
14 auto s = (*this->
f_)();
46 ESP_LOGD(TAG,
" Restored state %s", ONOFF(initial_state.
value()));
48 if (initial_state.
value()) {
56 LOG_SWITCH(
"",
"Template Switch",
this);
57 ESP_LOGCONFIG(TAG,
" Optimistic: %s", YESNO(this->
optimistic_));
void stop_action()
Stop any action connected to this trigger.
void trigger(Ts... x)
Inform the parent automation that the event has triggered.
value_type const & value() const
void turn_on()
Turn this switch on.
void turn_off()
Turn this switch off.
void publish_state(bool state)
Publish a state to the front-end from the back-end.
optional< bool > get_initial_state_with_restore_mode()
Returns the initial state of the switch, after applying restore mode rules.
float get_setup_priority() const override
void write_state(bool state) override
void set_assumed_state(bool assumed_state)
Trigger * turn_on_trigger_
bool assumed_state() override
Trigger * get_turn_off_trigger() const
optional< std::function< optional< bool >()> > f_
Trigger * turn_off_trigger_
void set_state_lambda(std::function< optional< bool >()> &&f)
Trigger * get_turn_on_trigger() const
void dump_config() override
void set_optimistic(bool optimistic)
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Providing packet encoding functions for exchanging data with a remote host.