ESPHome  2022.6.3
pipsolar_output.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "../pipsolar.h"
6 
7 namespace esphome {
8 namespace pipsolar {
9 
10 class Pipsolar;
11 
13  public:
15  void set_parent(Pipsolar *parent) { this->parent_ = parent; }
16  void set_set_command(const std::string &command) { this->set_command_ = command; };
17  void set_possible_values(std::vector<float> possible_values) { this->possible_values_ = std::move(possible_values); }
18  void set_value(float value) { this->write_state(value); };
19 
20  protected:
21  void write_state(float state) override;
22  std::string set_command_;
24  std::vector<float> possible_values_;
25 };
26 
27 template<typename... Ts> class SetOutputAction : public Action<Ts...> {
28  public:
29  SetOutputAction(PipsolarOutput *output) : output_(output) {}
30 
31  TEMPLATABLE_VALUE(float, level)
32 
33  void play(Ts... x) override { this->output_->set_value(this->level_.value(x...)); }
34 
35  protected:
37 };
38 
39 } // namespace pipsolar
40 } // namespace esphome
Base class for all output components that can output a variable level, like PWM.
Definition: float_output.h:31
std::vector< float > possible_values_
void write_state(float state) override
void set_possible_values(std::vector< float > possible_values)
TEMPLATABLE_VALUE(float, level) void play(Ts... x) override
SetOutputAction(PipsolarOutput *output)
void set_parent(Pipsolar *parent)
Definition: a4988.cpp:4
void set_set_command(const std::string &command)
bool state
Definition: fan.h:34