7static const char *
const TAG =
"copy.fan";
44 if (
call.get_state().has_value())
46 if (
call.get_oscillating().has_value())
48 if (
call.get_speed().has_value())
50 if (
call.get_direction().has_value())
52 if (
call.has_preset_mode())
void control(const fan::FanCall &call) override
void dump_config() override
fan::FanTraits get_traits() override
FanCall & set_oscillating(bool oscillating)
FanCall & set_direction(FanDirection direction)
FanCall & set_speed(int speed)
FanCall & set_state(bool binary_state)
FanCall & set_preset_mode(const std::string &preset_mode)
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 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.
bool oscillating
The current oscillation state of the fan.
bool state
The current on/off state of the fan.
const char * get_preset_mode() const
Get the current preset mode (returns pointer to string stored in traits, or nullptr if not set)
int speed
The current fan speed level.
void set_direction(bool direction)
Set whether this fan supports changing direction.
void set_speed(bool speed)
Set whether this fan supports speed levels.
void set_supported_speed_count(int speed_count)
Set how many speed levels this fan has.
void set_oscillation(bool oscillation)
Set whether this fan supports oscillation.
void set_supported_preset_modes(std::initializer_list< const char * > preset_modes)
Set the preset modes supported by the fan (from initializer list).
Providing packet encoding functions for exchanging data with a remote host.