ESPHome  2021.9.3
Public Member Functions | Protected Member Functions | Protected Attributes
esphome::Nameable Class Referenceabstract

Helper class that enables naming of objects so that it doesn't have to be re-implement every time. More...

#include <component.h>

Inheritance diagram for esphome::Nameable:
esphome::binary_sensor::BinarySensor esphome::climate::Climate esphome::cover::Cover esphome::esp32_camera::ESP32Camera esphome::fan::FanState esphome::light::LightState esphome::number::Number esphome::select::Select esphome::sensor::Sensor esphome::switch_::Switch esphome::text_sensor::TextSensor

Public Member Functions

 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)
 

Protected Member Functions

virtual uint32_t hash_base ()=0
 
void calc_object_id_ ()
 

Protected Attributes

std::string name_
 
std::string object_id_
 
uint32_t object_id_hash_
 
bool internal_ {false}
 
bool disabled_by_default_ {false}
 

Detailed Description

Helper class that enables naming of objects so that it doesn't have to be re-implement every time.

Definition at line 264 of file component.h.

Constructor & Destructor Documentation

◆ Nameable() [1/2]

esphome::Nameable::Nameable ( )
inline

Definition at line 266 of file component.h.

◆ Nameable() [2/2]

esphome::Nameable::Nameable ( std::string  name)
explicit

Definition at line 184 of file component.cpp.

Member Function Documentation

◆ calc_object_id_()

void esphome::Nameable::calc_object_id_ ( )
protected

Definition at line 189 of file component.cpp.

◆ get_name()

const std::string & esphome::Nameable::get_name ( ) const

Definition at line 179 of file component.cpp.

◆ get_object_id()

const std::string & esphome::Nameable::get_object_id ( )

Get the sanitized name of this nameable as an ID. Caching it internally.

Definition at line 186 of file component.cpp.

◆ get_object_id_hash()

uint32_t esphome::Nameable::get_object_id_hash ( )

Definition at line 194 of file component.cpp.

◆ hash_base()

virtual uint32_t esphome::Nameable::hash_base ( )
protectedpure virtual

◆ is_disabled_by_default()

bool esphome::Nameable::is_disabled_by_default ( ) const

Check if this object is declared to be disabled by default.

That means that when the device gets added to Home Assistant (or other clients) it should not be added to the default view by default, and a user action is necessary to manually add it.

Definition at line 196 of file component.cpp.

◆ is_internal()

bool esphome::Nameable::is_internal ( ) const

Definition at line 187 of file component.cpp.

◆ set_disabled_by_default()

void esphome::Nameable::set_disabled_by_default ( bool  disabled_by_default)

Definition at line 197 of file component.cpp.

◆ set_internal()

void esphome::Nameable::set_internal ( bool  internal)

Definition at line 188 of file component.cpp.

◆ set_name()

void esphome::Nameable::set_name ( const std::string &  name)

Definition at line 180 of file component.cpp.

Field Documentation

◆ disabled_by_default_

bool esphome::Nameable::disabled_by_default_ {false}
protected

Definition at line 294 of file component.h.

◆ internal_

bool esphome::Nameable::internal_ {false}
protected

Definition at line 293 of file component.h.

◆ name_

std::string esphome::Nameable::name_
protected

Definition at line 290 of file component.h.

◆ object_id_

std::string esphome::Nameable::object_id_
protected

Definition at line 291 of file component.h.

◆ object_id_hash_

uint32_t esphome::Nameable::object_id_hash_
protected

Definition at line 292 of file component.h.


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