ESPHome  2022.6.3
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
esphome::fan::Fan Class Referenceabstract

#include <fan.h>

Inheritance diagram for esphome::fan::Fan:
esphome::EntityBase esphome::binary::BinaryFan esphome::copy::CopyFan esphome::demo::DemoFan esphome::hbridge::HBridgeFan esphome::speed::SpeedFan esphome::tuya::TuyaFan

Public Member Functions

 Fan ()
 
 Fan (const std::string &name)
 Construct the fan with name. More...
 
FanCall turn_on ()
 
FanCall turn_off ()
 
FanCall toggle ()
 
FanCall make_call ()
 
void add_on_state_callback (std::function< void()> &&callback)
 Register a callback that will be called each time the state changes. More...
 
void publish_state ()
 
virtual FanTraits get_traits ()=0
 
void set_restore_mode (FanRestoreMode restore_mode)
 Set the restore mode of this fan. More...
 
- Public Member Functions inherited from esphome::EntityBase
 EntityBase ()
 
 EntityBase (std::string name)
 
const std::string & get_name () const
 
void set_name (const std::string &name)
 
const std::string & get_object_id ()
 
uint32_t get_object_id_hash ()
 
bool is_internal () const
 
void set_internal (bool internal)
 
bool is_disabled_by_default () const
 
void set_disabled_by_default (bool disabled_by_default)
 
EntityCategory get_entity_category () const
 
void set_entity_category (EntityCategory entity_category)
 
const std::string & get_icon () const
 
void set_icon (const std::string &name)
 

Data Fields

bool state {false}
 The current on/off state of the fan. More...
 
bool oscillating {false}
 The current oscillation state of the fan. More...
 
int speed {0}
 The current fan speed level. More...
 
FanDirection direction {FanDirection::FORWARD}
 The current direction of the fan. More...
 

Protected Member Functions

virtual void control (const FanCall &call)=0
 
optional< FanRestoreStaterestore_state_ ()
 
void save_state_ ()
 
void dump_traits_ (const char *tag, const char *prefix)
 
- Protected Member Functions inherited from esphome::EntityBase
virtual uint32_t hash_base ()
 The hash_base() function has been deprecated. More...
 
void calc_object_id_ ()
 

Protected Attributes

friend FanCall
 
CallbackManager< void()> state_callback_ {}
 
ESPPreferenceObject rtc_
 
FanRestoreMode restore_mode_
 
- Protected Attributes inherited from esphome::EntityBase
std::string name_
 
std::string object_id_
 
std::string icon_
 
uint32_t object_id_hash_
 
bool internal_ {false}
 
bool disabled_by_default_ {false}
 
EntityCategory entity_category_ {ENTITY_CATEGORY_NONE}
 

Detailed Description

Definition at line 100 of file fan.h.

Constructor & Destructor Documentation

◆ Fan() [1/2]

esphome::fan::Fan::Fan ( )

Definition at line 79 of file fan.cpp.

◆ Fan() [2/2]

esphome::fan::Fan::Fan ( const std::string &  name)
explicit

Construct the fan with name.

Definition at line 80 of file fan.cpp.

Member Function Documentation

◆ add_on_state_callback()

void esphome::fan::Fan::add_on_state_callback ( std::function< void()> &&  callback)

Register a callback that will be called each time the state changes.

Definition at line 87 of file fan.cpp.

◆ control()

virtual void esphome::fan::Fan::control ( const FanCall call)
protectedpure virtual

◆ dump_traits_()

void esphome::fan::Fan::dump_traits_ ( const char *  tag,
const char *  prefix 
)
protected

Definition at line 145 of file fan.cpp.

◆ get_traits()

virtual FanTraits esphome::fan::Fan::get_traits ( )
pure virtual

◆ make_call()

FanCall esphome::fan::Fan::make_call ( )

Definition at line 85 of file fan.cpp.

◆ publish_state()

void esphome::fan::Fan::publish_state ( )

Definition at line 88 of file fan.cpp.

◆ restore_state_()

optional< FanRestoreState > esphome::fan::Fan::restore_state_ ( )
protected

Definition at line 106 of file fan.cpp.

◆ save_state_()

void esphome::fan::Fan::save_state_ ( )
protected

Definition at line 136 of file fan.cpp.

◆ set_restore_mode()

void esphome::fan::Fan::set_restore_mode ( FanRestoreMode  restore_mode)
inline

Set the restore mode of this fan.

Definition at line 128 of file fan.h.

◆ toggle()

FanCall esphome::fan::Fan::toggle ( )

Definition at line 84 of file fan.cpp.

◆ turn_off()

FanCall esphome::fan::Fan::turn_off ( )

Definition at line 83 of file fan.cpp.

◆ turn_on()

FanCall esphome::fan::Fan::turn_on ( )

Definition at line 82 of file fan.cpp.

Field Documentation

◆ direction

FanDirection esphome::fan::Fan::direction {FanDirection::FORWARD}

The current direction of the fan.

Definition at line 113 of file fan.h.

◆ FanCall

friend esphome::fan::Fan::FanCall
protected

Definition at line 131 of file fan.h.

◆ oscillating

bool esphome::fan::Fan::oscillating {false}

The current oscillation state of the fan.

Definition at line 109 of file fan.h.

◆ restore_mode_

FanRestoreMode esphome::fan::Fan::restore_mode_
protected

Definition at line 142 of file fan.h.

◆ rtc_

ESPPreferenceObject esphome::fan::Fan::rtc_
protected

Definition at line 141 of file fan.h.

◆ speed

int esphome::fan::Fan::speed {0}

The current fan speed level.

Definition at line 111 of file fan.h.

◆ state

bool esphome::fan::Fan::state {false}

The current on/off state of the fan.

Definition at line 107 of file fan.h.

◆ state_callback_

CallbackManager<void()> esphome::fan::Fan::state_callback_ {}
protected

Definition at line 140 of file fan.h.


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