mirror of
https://github.com/esphome/esphome.git
synced 2025-09-06 13:22:19 +01:00
Make some Action methods protected
Apparently play()/stop() etc. are not meant to be called directly by users of the class and if they're called directly that would not give the expected result for the classes that have an empty play(). Make all methods except play_complex, stop_comples and is_running protected. While there also make RemoteTransmitterActionBase::encode protected.
This commit is contained in:
committed by
Andrew Zaborowski
parent
da390d32f8
commit
a62b6548d2
@@ -11,9 +11,9 @@ template<typename... Ts> class TurnOnAction : public Action<Ts...> {
|
||||
public:
|
||||
explicit TurnOnAction(Switch *a_switch) : switch_(a_switch) {}
|
||||
|
||||
void play(Ts... x) override { this->switch_->turn_on(); }
|
||||
|
||||
protected:
|
||||
void play_(Ts... x) override { this->switch_->turn_on(); }
|
||||
|
||||
Switch *switch_;
|
||||
};
|
||||
|
||||
@@ -21,9 +21,9 @@ template<typename... Ts> class TurnOffAction : public Action<Ts...> {
|
||||
public:
|
||||
explicit TurnOffAction(Switch *a_switch) : switch_(a_switch) {}
|
||||
|
||||
void play(Ts... x) override { this->switch_->turn_off(); }
|
||||
|
||||
protected:
|
||||
void play_(Ts... x) override { this->switch_->turn_off(); }
|
||||
|
||||
Switch *switch_;
|
||||
};
|
||||
|
||||
@@ -31,9 +31,9 @@ template<typename... Ts> class ToggleAction : public Action<Ts...> {
|
||||
public:
|
||||
explicit ToggleAction(Switch *a_switch) : switch_(a_switch) {}
|
||||
|
||||
void play(Ts... x) override { this->switch_->toggle(); }
|
||||
|
||||
protected:
|
||||
void play_(Ts... x) override { this->switch_->toggle(); }
|
||||
|
||||
Switch *switch_;
|
||||
};
|
||||
|
||||
@@ -73,9 +73,9 @@ template<typename... Ts> class SwitchPublishAction : public Action<Ts...> {
|
||||
public:
|
||||
SwitchPublishAction(Switch *a_switch) : switch_(a_switch) {}
|
||||
TEMPLATABLE_VALUE(bool, state)
|
||||
void play(Ts... x) override { this->switch_->publish_state(this->state_.value(x...)); }
|
||||
|
||||
protected:
|
||||
void play_(Ts... x) override { this->switch_->publish_state(this->state_.value(x...)); }
|
||||
Switch *switch_;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user