ESPHome  2021.9.1
Public Member Functions | Protected Member Functions | Protected Attributes
esphome::gpio::GPIOSwitch Class Reference

#include <gpio_switch.h>

Inheritance diagram for esphome::gpio::GPIOSwitch:
esphome::switch_::Switch esphome::Component esphome::Nameable

Public Member Functions

void set_pin (GPIOPin *pin)
void set_restore_mode (GPIOSwitchRestoreMode restore_mode)
float get_setup_priority () const override
void setup () override
void dump_config () override
void set_interlock (const std::vector< Switch *> &interlock)
void set_interlock_wait_time (uint32_t interlock_wait_time)
- Public Member Functions inherited from esphome::switch_::Switch
 Switch ()
 Switch (const std::string &name)
void publish_state (bool state)
 Publish a state to the front-end from the back-end. More...
void turn_on ()
 Turn this switch on. More...
void turn_off ()
 Turn this switch off. More...
void toggle ()
 Toggle this switch. More...
void set_inverted (bool inverted)
 Set whether the state should be treated as inverted. More...
void set_icon (const std::string &icon)
 Set the icon for this switch. "" for no icon. More...
std::string get_icon ()
 Get the icon for this switch. Using icon() if not manually set. More...
void add_on_state_callback (std::function< void(bool)> &&callback)
 Set callback for state changes. More...
optional< bool > get_initial_state ()
virtual bool assumed_state ()
 Return whether this switch uses an assumed state - i.e. More...
bool is_inverted () const
- Public Member Functions inherited from esphome::Nameable
 Nameable ()
 Nameable (std::string name)
const std::string & get_name () const
void set_name (const std::string &name)
const std::string & get_object_id ()
 Get the sanitized name of this nameable as an ID. Caching it internally. More...
uint32_t get_object_id_hash ()
bool is_internal () const
void set_internal (bool internal)
bool is_disabled_by_default () const
 Check if this object is declared to be disabled by default. More...
void set_disabled_by_default (bool disabled_by_default)
- Public Member Functions inherited from esphome::Component
virtual void loop ()
 This method will be called repeatedly. More...
float get_actual_setup_priority () const
void set_setup_priority (float priority)
virtual float get_loop_priority () const
 priority of loop(). More...
void call ()
virtual void on_shutdown ()
virtual void on_safe_shutdown ()
uint32_t get_component_state () const
virtual void mark_failed ()
 Mark this component as failed. More...
bool is_failed ()
virtual bool can_proceed ()
bool status_has_warning ()
bool status_has_error ()
void status_set_warning ()
void status_set_error ()
void status_clear_warning ()
void status_clear_error ()
void status_momentary_warning (const std::string &name, uint32_t length=5000)
void status_momentary_error (const std::string &name, uint32_t length=5000)
bool has_overridden_loop () const
void set_component_source (const char *source)
 Set where this component was loaded from for some debug messages. More...
const char * get_component_source () const
 Get the integration where this component was declared as a string. More...

Protected Member Functions

void write_state (bool state) override
- Protected Member Functions inherited from esphome::switch_::Switch
virtual std::string icon ()
 Override this to set the Home Assistant icon for this switch. More...
uint32_t hash_base () override
- Protected Member Functions inherited from esphome::Nameable
void calc_object_id_ ()
- Protected Member Functions inherited from esphome::Component
virtual void call_loop ()
virtual void call_setup ()
void set_interval (const std::string &name, uint32_t interval, std::function< void()> &&f)
 Set an interval function with a unique name. More...
void set_interval (uint32_t interval, std::function< void()> &&f)
bool cancel_interval (const std::string &name)
 Cancel an interval function. More...
void set_timeout (uint32_t timeout, std::function< void()> &&f)
void set_timeout (const std::string &name, uint32_t timeout, std::function< void()> &&f)
 Set a timeout function with a unique name. More...
bool cancel_timeout (const std::string &name)
 Cancel a timeout function. More...
void defer (const std::string &name, std::function< void()> &&f)
 Defer a callback to the next loop() call. More...
void defer (std::function< void()> &&f)
 Defer a callback to the next loop() call. More...
bool cancel_defer (const std::string &name)
 Cancel a defer callback using the specified name, name must not be empty. More...

Protected Attributes

GPIOSwitchRestoreMode restore_mode_ {GPIO_SWITCH_RESTORE_DEFAULT_OFF}
std::vector< Switch * > interlock_
uint32_t interlock_wait_time_ {0}
- Protected Attributes inherited from esphome::switch_::Switch
optional< std::string > icon_ {}
 The icon shown here. Not set means use default from switch. Empty means no icon. More...
CallbackManager< void(bool)> state_callback_ {}
bool inverted_ {false}
Deduplicator< bool > publish_dedup_
ESPPreferenceObject rtc_
- Protected Attributes inherited from esphome::Nameable
std::string name_
std::string object_id_
uint32_t object_id_hash_
bool internal_ {false}
bool disabled_by_default_ {false}
- Protected Attributes inherited from esphome::Component
uint32_t component_state_ {0x0000}
 State of this component. More...
float setup_priority_override_ {NAN}
const char * component_source_ = nullptr

Additional Inherited Members

- Data Fields inherited from esphome::switch_::Switch
bool state
 The current reported state of the binary sensor. More...

Detailed Description

Definition at line 18 of file gpio_switch.h.

Member Function Documentation

◆ dump_config()

void esphome::gpio::GPIOSwitch::dump_config ( )

Reimplemented from esphome::Component.

Definition at line 47 of file gpio_switch.cpp.

◆ get_setup_priority()

float esphome::gpio::GPIOSwitch::get_setup_priority ( ) const

Reimplemented from esphome::Component.

Definition at line 9 of file gpio_switch.cpp.

◆ set_interlock()

void esphome::gpio::GPIOSwitch::set_interlock ( const std::vector< Switch *> &  interlock)

Definition at line 113 of file gpio_switch.cpp.

◆ set_interlock_wait_time()

void esphome::gpio::GPIOSwitch::set_interlock_wait_time ( uint32_t  interlock_wait_time)

Definition at line 31 of file gpio_switch.h.

◆ set_pin()

void esphome::gpio::GPIOSwitch::set_pin ( GPIOPin pin)

Definition at line 20 of file gpio_switch.h.

◆ set_restore_mode()

void esphome::gpio::GPIOSwitch::set_restore_mode ( GPIOSwitchRestoreMode  restore_mode)

Definition at line 112 of file gpio_switch.cpp.

◆ setup()

void esphome::gpio::GPIOSwitch::setup ( )

Reimplemented from esphome::Component.

Definition at line 10 of file gpio_switch.cpp.

◆ write_state()

void esphome::gpio::GPIOSwitch::write_state ( bool  state)

Implements esphome::switch_::Switch.

Definition at line 81 of file gpio_switch.cpp.

Field Documentation

◆ interlock_

std::vector<Switch *> esphome::gpio::GPIOSwitch::interlock_

Definition at line 38 of file gpio_switch.h.

◆ interlock_wait_time_

uint32_t esphome::gpio::GPIOSwitch::interlock_wait_time_ {0}

Definition at line 39 of file gpio_switch.h.

◆ pin_

GPIOPin* esphome::gpio::GPIOSwitch::pin_

Definition at line 36 of file gpio_switch.h.

◆ restore_mode_

GPIOSwitchRestoreMode esphome::gpio::GPIOSwitch::restore_mode_ {GPIO_SWITCH_RESTORE_DEFAULT_OFF}

Definition at line 37 of file gpio_switch.h.

The documentation for this class was generated from the following files: