ESPHome  2024.3.2
aeha_protocol.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "remote_base.h"
4 
5 #include <vector>
6 
7 namespace esphome {
8 namespace remote_base {
9 
10 struct AEHAData {
11  uint16_t address;
12  std::vector<uint8_t> data;
13 
14  bool operator==(const AEHAData &rhs) const { return address == rhs.address && data == rhs.data; }
15 };
16 
17 class AEHAProtocol : public RemoteProtocol<AEHAData> {
18  public:
19  void encode(RemoteTransmitData *dst, const AEHAData &data) override;
20  optional<AEHAData> decode(RemoteReceiveData src) override;
21  void dump(const AEHAData &data) override;
22 
23  private:
24  std::string format_data_(const std::vector<uint8_t> &data);
25 };
26 
28 
29 template<typename... Ts> class AEHAAction : public RemoteTransmitterActionBase<Ts...> {
30  public:
31  TEMPLATABLE_VALUE(uint16_t, address)
32  TEMPLATABLE_VALUE(std::vector<uint8_t>, data)
33 
34  void set_data(const std::vector<uint8_t> &data) { data_ = data; }
35  void encode(RemoteTransmitData *dst, Ts... x) override {
36  AEHAData data{};
37  data.address = this->address_.value(x...);
38  data.data = this->data_.value(x...);
39  AEHAProtocol().encode(dst, data);
40  }
41 };
42 
43 } // namespace remote_base
44 } // namespace esphome
bool operator==(const AEHAData &rhs) const
Definition: aeha_protocol.h:14
DECLARE_REMOTE_PROTOCOL(AEHA) template< typename... Ts > class AEHAAction
Definition: aeha_protocol.h:27
uint16_t x
Definition: tt21100.cpp:17
std::vector< uint8_t > data
Definition: aeha_protocol.h:12
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
void encode(RemoteTransmitData *dst, const AEHAData &data) override