15#define LOG_COVER(prefix, type, obj) \
16 if ((obj) != nullptr) { \
17 ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, LOG_STR_LITERAL(type), (obj)->get_name().c_str()); \
18 auto traits_ = (obj)->get_traits(); \
19 if (traits_.get_is_assumed_state()) { \
20 ESP_LOGCONFIG(TAG, "%s Assumed State: YES", prefix); \
22 if (!(obj)->get_device_class().empty()) { \
23 ESP_LOGCONFIG(TAG, "%s Device Class: '%s'", prefix, (obj)->get_device_class().c_str()); \
132 ESPDEPRECATED(
"open() is deprecated, use make_call().set_command_open().perform() instead.",
"2021.9")
138 ESPDEPRECATED("close() is deprecated, use
make_call().set_command_close().perform() instead.", "2021.9")
145 ESPDEPRECATED("stop() is deprecated, use
make_call().set_command_stop().perform() instead.", "2021.9")
const optional< float > & get_tilt() const
CoverCall & set_command_toggle()
Set the command to toggle the cover.
const optional< bool > & get_toggle() const
CoverCall & set_command_open()
Set the command to open the cover.
CoverCall & set_command_close()
Set the command to close the cover.
CoverCall & set_command(const char *command)
Set the command as a string, "STOP", "OPEN", "CLOSE", "TOGGLE".
void perform()
Perform the cover call.
CoverCall & set_position(float position)
Set the call to a certain target position.
CoverCall & set_command_stop()
Set the command to stop the cover.
optional< float > position_
const optional< float > & get_position() const
CoverCall & set_tilt(float tilt)
Set the call to a certain target tilt.
CoverCall & set_stop(bool stop)
Set whether this cover call should stop the cover.
Base class for all cover devices.
CoverOperation current_operation
The current operation of the cover (idle, opening, closing).
ESPDEPRECATED("open() is deprecated, use make_call().set_command_open().perform() instead.", "2021.9") void open()
Open the cover.
optional< CoverRestoreState > restore_state_()
void publish_state(bool save=true)
Publish the current state of the cover.
void add_on_state_callback(std::function< void()> &&f)
CoverCall make_call()
Construct a new cover call used to control the cover.
float tilt
The current tilt value of the cover from 0.0 to 1.0.
float position
The position of the cover from 0.0 (fully closed) to 1.0 (fully open).
bool is_fully_closed() const
Helper method to check if the cover is fully closed. Equivalent to comparing .position against 0....
CallbackManager< void()> state_callback_
virtual CoverTraits get_traits()=0
bool is_fully_open() const
Helper method to check if the cover is fully open. Equivalent to comparing .position against 1....
virtual void control(const CoverCall &call)=0
enum esphome::cover::CoverOperation __attribute__
const char * cover_operation_to_str(CoverOperation op)
CoverOperation
Enum encoding the current operation of a cover.
@ COVER_OPERATION_OPENING
The cover is currently opening.
@ COVER_OPERATION_CLOSING
The cover is currently closing.
@ COVER_OPERATION_IDLE
The cover is currently idle (not moving)
Providing packet encoding functions for exchanging data with a remote host.
Struct used to store the restored state of a cover.
void apply(Cover *cover)
Apply these settings to the cover.
CoverCall to_call(Cover *cover)
Convert this struct to a cover call that can be performed.