7 static 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_));
value_type const & value() const
void set_state_lambda(std::function< optional< bool >()> &&f)
Trigger * turn_off_trigger_
void set_optimistic(bool optimistic)
void write_state(bool state) override
Trigger * get_turn_off_trigger() const
void trigger(Ts... x)
Inform the parent automation that the event has triggered.
optional< std::function< optional< bool >)> > f_
Trigger * get_turn_on_trigger() const
optional< bool > get_initial_state_with_restore_mode()
Returns the initial state of the switch, after applying restore mode rules.
void turn_on()
Turn this switch on.
bool assumed_state() override
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Implementation of SPI Controller mode.
void set_assumed_state(bool assumed_state)
Trigger * turn_on_trigger_
float get_setup_priority() const override
void publish_state(bool state)
Publish a state to the front-end from the back-end.
void dump_config() override
bool state
The current reported state of the binary sensor.
void stop_action()
Stop any action connected to this trigger.
void turn_off()
Turn this switch off.