ESPHome  2023.5.5
nexa_protocol.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "remote_base.h"
4 
5 namespace esphome {
6 namespace remote_base {
7 
8 struct NexaData {
9  uint32_t device;
10  uint8_t group;
11  uint8_t state;
12  uint8_t channel;
13  uint8_t level;
14  bool operator==(const NexaData &rhs) const {
15  return device == rhs.device && group == rhs.group && state == rhs.state && channel == rhs.channel &&
16  level == rhs.level;
17  }
18 };
19 
20 class NexaProtocol : public RemoteProtocol<NexaData> {
21  public:
22  void one(RemoteTransmitData *dst) const;
23  void zero(RemoteTransmitData *dst) const;
24  void sync(RemoteTransmitData *dst) const;
25 
26  void encode(RemoteTransmitData *dst, const NexaData &data) override;
27  optional<NexaData> decode(RemoteReceiveData src) override;
28  void dump(const NexaData &data) override;
29 };
30 
32 
33 template<typename... Ts> class NexaAction : public RemoteTransmitterActionBase<Ts...> {
34  public:
35  TEMPLATABLE_VALUE(uint32_t, device)
36  TEMPLATABLE_VALUE(uint8_t, group)
37  TEMPLATABLE_VALUE(uint8_t, state)
38  TEMPLATABLE_VALUE(uint8_t, channel)
39  TEMPLATABLE_VALUE(uint8_t, level)
40  void encode(RemoteTransmitData *dst, Ts... x) override {
41  NexaData data{};
42  data.device = this->device_.value(x...);
43  data.group = this->group_.value(x...);
44  data.state = this->state_.value(x...);
45  data.channel = this->channel_.value(x...);
46  data.level = this->level_.value(x...);
47  NexaProtocol().encode(dst, data);
48  }
49 };
50 
51 } // namespace remote_base
52 } // namespace esphome
bool operator==(const NexaData &rhs) const
Definition: nexa_protocol.h:14
DECLARE_REMOTE_PROTOCOL(AEHA) template< typename... Ts > class AEHAAction
Definition: aeha_protocol.h:27
void encode(RemoteTransmitData *dst, const NexaData &data) override
Definition: a4988.cpp:4