mirror of
https://github.com/esphome/esphome.git
synced 2026-08-22 22:26:21 +00:00
[cover] Inline the trivial Cover and CoverCall accessors
This commit is contained in:
@@ -135,10 +135,6 @@ CoverCall &CoverCall::set_stop(bool stop) {
|
||||
this->stop_ = stop;
|
||||
return *this;
|
||||
}
|
||||
bool CoverCall::get_stop() const { return this->stop_; }
|
||||
|
||||
CoverCall Cover::make_call() { return {this}; }
|
||||
|
||||
void Cover::publish_state(bool save) {
|
||||
this->position = clamp(this->position, 0.0f, 1.0f);
|
||||
this->tilt = clamp(this->tilt, 0.0f, 1.0f);
|
||||
@@ -184,9 +180,6 @@ optional<CoverRestoreState> Cover::restore_state_() {
|
||||
return recovered;
|
||||
}
|
||||
|
||||
bool Cover::is_fully_open() const { return this->position == COVER_OPEN; }
|
||||
bool Cover::is_fully_closed() const { return this->position == COVER_CLOSED; }
|
||||
|
||||
CoverCall CoverRestoreState::to_call(Cover *cover) {
|
||||
auto call = cover->make_call();
|
||||
auto traits = cover->get_traits();
|
||||
|
||||
@@ -50,7 +50,7 @@ class CoverCall {
|
||||
void perform();
|
||||
|
||||
const optional<float> &get_position() const;
|
||||
bool get_stop() const;
|
||||
bool get_stop() const { return this->stop_; }
|
||||
const optional<float> &get_tilt() const;
|
||||
const optional<bool> &get_toggle() const;
|
||||
|
||||
@@ -123,7 +123,7 @@ class Cover : public EntityBase {
|
||||
float tilt{COVER_OPEN};
|
||||
|
||||
/// Construct a new cover call used to control the cover.
|
||||
CoverCall make_call();
|
||||
CoverCall make_call() { return {this}; }
|
||||
|
||||
template<typename F> void add_on_state_callback(F &&f) { this->state_callback_.add(std::forward<F>(f)); }
|
||||
|
||||
@@ -139,9 +139,9 @@ class Cover : public EntityBase {
|
||||
virtual CoverTraits get_traits() = 0;
|
||||
|
||||
/// Helper method to check if the cover is fully open. Equivalent to comparing .position against 1.0
|
||||
bool is_fully_open() const;
|
||||
bool is_fully_open() const { return this->position == COVER_OPEN; }
|
||||
/// Helper method to check if the cover is fully closed. Equivalent to comparing .position against 0.0
|
||||
bool is_fully_closed() const;
|
||||
bool is_fully_closed() const { return this->position == COVER_CLOSED; }
|
||||
|
||||
protected:
|
||||
friend CoverCall;
|
||||
|
||||
Reference in New Issue
Block a user