7 static const char *
const TAG =
"switch.gpio";
11 ESP_LOGCONFIG(TAG,
"Setting up GPIO Switch '%s'...", this->
name_.c_str());
13 bool initial_state =
false;
28 initial_state =
false;
50 LOG_SWITCH(
"",
"GPIO Switch",
this);
51 LOG_PIN(
" Pin: ", this->
pin_);
52 const LogString *restore_mode = LOG_STR(
"");
55 restore_mode = LOG_STR(
"Restore (Defaults to OFF)");
58 restore_mode = LOG_STR(
"Restore (Defaults to ON)");
61 restore_mode = LOG_STR(
"Restore inverted (Defaults to ON)");
64 restore_mode = LOG_STR(
"Restore inverted (Defaults to OFF)");
67 restore_mode = LOG_STR(
"Always OFF");
70 restore_mode = LOG_STR(
"Always ON");
73 ESP_LOGCONFIG(TAG,
" Restore Mode: %s", LOG_STR_ARG(restore_mode));
75 ESP_LOGCONFIG(TAG,
" Interlocks:");
79 ESP_LOGCONFIG(TAG,
" %s", lock->get_name().c_str());
virtual void digital_write(bool value)=0
bool cancel_timeout(const std::string &name)
Cancel a timeout function.
void dump_config() override
void set_timeout(const std::string &name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
uint32_t interlock_wait_time_
float get_setup_priority() const override
optional< bool > get_initial_state()
void set_restore_mode(GPIOSwitchRestoreMode restore_mode)
void turn_on()
Turn this switch on.
void set_interlock(const std::vector< Switch *> &interlock)
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
void write_state(bool state) override
GPIOSwitchRestoreMode restore_mode_
std::vector< Switch * > interlock_
void publish_state(bool state)
Publish a state to the front-end from the back-end.
bool state
The current reported state of the binary sensor.
value_type value_or(U const &v) const
void turn_off()
Turn this switch off.