Cover

Supported Covers

Example Usage

See Application::register_cover().

API Reference

Cover

class Cover : public Nameable

Subclassed by cover::TemplateCover

Public Functions

Cover(const std::string &name)
virtual void open() = 0
virtual void close() = 0
virtual void stop() = 0
void add_on_publish_state_callback(std::function<void(CoverState)> &&f)
void publish_state(CoverState state)
template <typename T>
OpenAction<T> *make_open_action()
template <typename T>
CloseAction<T> *make_close_action()
template <typename T>
StopAction<T> *make_stop_action()
bool optimistic()

Return whether this cover is optimistic - i.e.

if both the OPEN/CLOSE actions should be displayed in Home Assistant because the real state is unknown.

Defaults to false.

Public Members

CoverState state = {COVER_MAX}

Protected Attributes

CallbackManager<void(CoverState)> state_callback_ = {}
enum cover::CoverState

Values:

COVER_OPEN = 0
COVER_CLOSED
COVER_MAX
template <typename T>
class OpenAction : public Action<T>

Public Functions

OpenAction(Cover *cover)
void play(T x)

Protected Attributes

Cover *cover_
template <typename T>
class CloseAction : public Action<T>

Public Functions

CloseAction(Cover *cover)
void play(T x)

Protected Attributes

Cover *cover_
template <typename T>
class StopAction : public Action<T>

Public Functions

StopAction(Cover *cover)
void play(T x)

Protected Attributes

Cover *cover_

MQTTCoverComponent

class MQTTCoverComponent : public mqtt::MQTTComponent

Public Functions

MQTTCoverComponent(Cover *cover)
void setup()

Where the component’s initialization should happen.

Analogous to Arduino’s setup(). This method is guaranteed to only be called once. Defaults to doing noting.

void send_discovery(JsonBuffer &buffer, JsonObject &root, mqtt::SendDiscoveryConfig &config)

Send discovery info the Home Assistant, override this.

void send_initial_state()
bool is_internal()
void publish_state(cover::CoverState state)

Protected Functions

std::string component_type() const

Override this method to return the component type (e.g. “light”, “sensor”, …)

std::string friendly_name() const

Get the friendly name of this MQTT component.

Protected Attributes

Cover *cover_