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