13#define LOG_FAN(prefix, type, obj) \
14 if ((obj) != nullptr) { \
15 ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, LOG_STR_LITERAL(type), (obj)->get_name().c_str()); \
16 (obj)->dump_traits_(TAG, prefix); \
161 const char *preset_mode_{
nullptr};
FanCall & set_oscillating(bool oscillating)
FanCall & set_direction(FanDirection direction)
optional< bool > binary_state_
optional< FanDirection > direction_
FanCall & set_direction(optional< FanDirection > direction)
optional< bool > get_state() const
const char * preset_mode_
const char * get_preset_mode() const
optional< bool > get_oscillating() const
FanCall & set_state(optional< bool > binary_state)
bool has_preset_mode() const
FanCall & set_speed(int speed)
FanCall & set_state(bool binary_state)
FanCall & set_oscillating(optional< bool > oscillating)
optional< int > get_speed() const
optional< bool > oscillating_
FanCall & set_preset_mode(const std::string &preset_mode)
optional< FanDirection > get_direction() const
virtual FanTraits get_traits()=0
bool set_preset_mode_(const char *preset_mode)
Set the preset mode (finds and stores pointer from traits). Returns true if changed.
void clear_preset_mode_()
Clear the preset mode.
void add_on_state_callback(std::function< void()> &&callback)
Register a callback that will be called each time the state changes.
FanDirection direction
The current direction of the fan.
FanRestoreMode restore_mode_
CallbackManager< void()> state_callback_
bool oscillating
The current oscillation state of the fan.
virtual void control(const FanCall &call)=0
bool state
The current on/off state of the fan.
const char * find_preset_mode_(const char *preset_mode)
Find and return the matching preset mode pointer from traits, or nullptr if not found.
void set_restore_mode(FanRestoreMode restore_mode)
Set the restore mode of this fan.
const char * get_preset_mode() const
Get the current preset mode (returns pointer to string stored in traits, or nullptr if not set)
bool has_preset_mode() const
Check if a preset mode is currently active.
int speed
The current fan speed level.
void dump_traits_(const char *tag, const char *prefix)
optional< FanRestoreState > restore_state_()
FanRestoreMode
Restore mode of a fan.
@ RESTORE_INVERTED_DEFAULT_OFF
@ RESTORE_INVERTED_DEFAULT_ON
const LogString * fan_direction_to_string(FanDirection direction)
esphome::fan::Fan __attribute__
FanDirection
Simple enum to represent the direction of a fan.
Providing packet encoding functions for exchanging data with a remote host.
void apply(Fan &fan)
Apply these settings to the fan.
FanCall to_call(Fan &fan)
Convert this struct to a fan call that can be performed.