ESPHome  2024.10.2
dooya_protocol.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "remote_base.h"
5 
6 #include <cinttypes>
7 
8 namespace esphome {
9 namespace remote_base {
10 
11 struct DooyaData {
12  uint32_t id;
13  uint8_t channel;
14  uint8_t button;
15  uint8_t check;
16 
17  bool operator==(const DooyaData &rhs) const {
18  return id == rhs.id && channel == rhs.channel && button == rhs.button && check == rhs.check;
19  }
20 };
21 
22 class DooyaProtocol : public RemoteProtocol<DooyaData> {
23  public:
24  void encode(RemoteTransmitData *dst, const DooyaData &data) override;
25  optional<DooyaData> decode(RemoteReceiveData src) override;
26  void dump(const DooyaData &data) override;
27 };
28 
30 
31 template<typename... Ts> class DooyaAction : public RemoteTransmitterActionBase<Ts...> {
32  public:
33  TEMPLATABLE_VALUE(uint32_t, id)
34  TEMPLATABLE_VALUE(uint8_t, channel)
35  TEMPLATABLE_VALUE(uint8_t, button)
36  TEMPLATABLE_VALUE(uint8_t, check)
37 
38  void encode(RemoteTransmitData *dst, Ts... x) override {
39  DooyaData data{};
40  data.id = this->id_.value(x...);
41  data.channel = this->channel_.value(x...);
42  data.button = this->button_.value(x...);
43  data.check = this->check_.value(x...);
44  DooyaProtocol().encode(dst, data);
45  }
46 };
47 
48 } // namespace remote_base
49 } // namespace esphome
DECLARE_REMOTE_PROTOCOL(AEHA) template< typename... Ts > class AEHAAction
Definition: aeha_protocol.h:27
uint16_t x
Definition: tt21100.cpp:17
void encode(RemoteTransmitData *dst, const DooyaData &data) override
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
bool operator==(const DooyaData &rhs) const