ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
esphome::switch_ Namespace Reference

Data Structures

class  ApplySwitch
 Calls the codegen-generated Fn(this, state) on a state write; the hub and any publish are baked into Fn. More...
 
class  Switch
 Base class for all switches. More...
 
class  SwitchBinarySensor
 

Enumerations

enum  SwitchRestoreMode : uint8_t {
  SWITCH_ALWAYS_OFF = !RESTORE_MODE_ON_MASK , SWITCH_ALWAYS_ON = RESTORE_MODE_ON_MASK , SWITCH_RESTORE_DEFAULT_OFF = RESTORE_MODE_PERSISTENT_MASK , SWITCH_RESTORE_DEFAULT_ON = RESTORE_MODE_PERSISTENT_MASK | RESTORE_MODE_ON_MASK ,
  SWITCH_RESTORE_INVERTED_DEFAULT_OFF = RESTORE_MODE_PERSISTENT_MASK | RESTORE_MODE_INVERTED_MASK , SWITCH_RESTORE_INVERTED_DEFAULT_ON = RESTORE_MODE_PERSISTENT_MASK | RESTORE_MODE_INVERTED_MASK | RESTORE_MODE_ON_MASK , SWITCH_RESTORE_DISABLED = RESTORE_MODE_DISABLED_MASK
}
 

Functions

 ESPHOME_LOG_TAG (TAG, "switch.binary_sensor")
 
 ESPHOME_LOG_TAG (TAG, "switch")
 
void log_switch (const char *tag, const char *prefix, const char *type, Switch *obj)
 

Variables

constexpr int RESTORE_MODE_ON_MASK = 0x01
 
constexpr int RESTORE_MODE_PERSISTENT_MASK = 0x02
 
constexpr int RESTORE_MODE_INVERTED_MASK = 0x04
 
constexpr int RESTORE_MODE_DISABLED_MASK = 0x08
 
constexpr int RESTORE_MODE_STORAGE_FLASH_MASK = 0x10
 
constexpr int RESTORE_MODE_STORAGE_RTC_MASK = 0x20
 
constexpr int RESTORE_MODE_STORAGE_MASK = RESTORE_MODE_STORAGE_FLASH_MASK | RESTORE_MODE_STORAGE_RTC_MASK
 

Enumeration Type Documentation

◆ SwitchRestoreMode

Enumerator
SWITCH_ALWAYS_OFF 
SWITCH_ALWAYS_ON 
SWITCH_RESTORE_DEFAULT_OFF 
SWITCH_RESTORE_DEFAULT_ON 
SWITCH_RESTORE_INVERTED_DEFAULT_OFF 
SWITCH_RESTORE_INVERTED_DEFAULT_ON 
SWITCH_RESTORE_DISABLED 

Definition at line 28 of file switch.h.

Function Documentation

◆ ESPHOME_LOG_TAG() [1/2]

esphome::switch_::ESPHOME_LOG_TAG ( TAG ,
"switch"  )

◆ ESPHOME_LOG_TAG() [2/2]

esphome::switch_::ESPHOME_LOG_TAG ( TAG ,
"switch.binary_sensor"  )

◆ log_switch()

void esphome::switch_::log_switch ( const char * tag,
const char * prefix,
const char * type,
Switch * obj )

Definition at line 87 of file switch.cpp.

Variable Documentation

◆ RESTORE_MODE_DISABLED_MASK

int esphome::switch_::RESTORE_MODE_DISABLED_MASK = 0x08
constexpr

Definition at line 23 of file switch.h.

◆ RESTORE_MODE_INVERTED_MASK

int esphome::switch_::RESTORE_MODE_INVERTED_MASK = 0x04
constexpr

Definition at line 22 of file switch.h.

◆ RESTORE_MODE_ON_MASK

int esphome::switch_::RESTORE_MODE_ON_MASK = 0x01
constexpr

Definition at line 20 of file switch.h.

◆ RESTORE_MODE_PERSISTENT_MASK

int esphome::switch_::RESTORE_MODE_PERSISTENT_MASK = 0x02
constexpr

Definition at line 21 of file switch.h.

◆ RESTORE_MODE_STORAGE_FLASH_MASK

int esphome::switch_::RESTORE_MODE_STORAGE_FLASH_MASK = 0x10
constexpr

Definition at line 24 of file switch.h.

◆ RESTORE_MODE_STORAGE_MASK

int esphome::switch_::RESTORE_MODE_STORAGE_MASK = RESTORE_MODE_STORAGE_FLASH_MASK | RESTORE_MODE_STORAGE_RTC_MASK
constexpr

Definition at line 26 of file switch.h.

◆ RESTORE_MODE_STORAGE_RTC_MASK

int esphome::switch_::RESTORE_MODE_STORAGE_RTC_MASK = 0x20
constexpr

Definition at line 25 of file switch.h.