mirror of
https://github.com/esphome/esphome.git
synced 2026-08-22 22:26:21 +00:00
[valve] Inline the trivial Valve and ValveCall accessors
This commit is contained in:
@@ -120,10 +120,6 @@ ValveCall &ValveCall::set_stop(bool stop) {
|
||||
this->stop_ = stop;
|
||||
return *this;
|
||||
}
|
||||
bool ValveCall::get_stop() const { return this->stop_; }
|
||||
|
||||
ValveCall Valve::make_call() { return {this}; }
|
||||
|
||||
void Valve::publish_state(bool save) {
|
||||
this->position = clamp(this->position, 0.0f, 1.0f);
|
||||
|
||||
@@ -162,9 +158,6 @@ optional<ValveRestoreState> Valve::restore_state_() {
|
||||
return recovered;
|
||||
}
|
||||
|
||||
bool Valve::is_fully_open() const { return this->position == VALVE_OPEN; }
|
||||
bool Valve::is_fully_closed() const { return this->position == VALVE_CLOSED; }
|
||||
|
||||
ValveCall ValveRestoreState::to_call(Valve *valve) {
|
||||
auto call = valve->make_call();
|
||||
call.set_position(this->position);
|
||||
|
||||
@@ -47,7 +47,7 @@ class ValveCall {
|
||||
void perform();
|
||||
|
||||
const optional<float> &get_position() const;
|
||||
bool get_stop() const;
|
||||
bool get_stop() const { return this->stop_; }
|
||||
const optional<bool> &get_toggle() const;
|
||||
|
||||
protected:
|
||||
@@ -114,7 +114,7 @@ class Valve : public EntityBase {
|
||||
float position;
|
||||
|
||||
/// Construct a new valve call used to control the valve.
|
||||
ValveCall make_call();
|
||||
ValveCall make_call() { return {this}; }
|
||||
|
||||
template<typename F> void add_on_state_callback(F &&f) { this->state_callback_.add(std::forward<F>(f)); }
|
||||
|
||||
@@ -130,9 +130,9 @@ class Valve : public EntityBase {
|
||||
virtual ValveTraits get_traits() = 0;
|
||||
|
||||
/// Helper method to check if the valve is fully open. Equivalent to comparing .position against 1.0
|
||||
bool is_fully_open() const;
|
||||
bool is_fully_open() const { return this->position == VALVE_OPEN; }
|
||||
/// Helper method to check if the valve is fully closed. Equivalent to comparing .position against 0.0
|
||||
bool is_fully_closed() const;
|
||||
bool is_fully_closed() const { return this->position == VALVE_CLOSED; }
|
||||
|
||||
protected:
|
||||
friend ValveCall;
|
||||
|
||||
Reference in New Issue
Block a user