ESPHome 2025.11.0-dev
Loading...
Searching...
No Matches
dyson_protocol.h
Go to the documentation of this file.
1#pragma once
2
3#include "remote_base.h"
4
5#include <cinttypes>
6
7namespace esphome {
8namespace remote_base {
9
10static constexpr uint8_t IGNORE_INDEX = 0xFF;
11
12struct DysonData {
13 uint16_t code; // the button, e.g. power, swing, fan++, ...
14 uint8_t index; // the rolling index counter
15 bool operator==(const DysonData &rhs) const {
16 if (IGNORE_INDEX == index || IGNORE_INDEX == rhs.index) {
17 return code == rhs.code;
18 }
19 return code == rhs.code && index == rhs.index;
20 }
21};
22
23class DysonProtocol : public RemoteProtocol<DysonData> {
24 public:
25 void encode(RemoteTransmitData *dst, const DysonData &data) override;
27 void dump(const DysonData &data) override;
28};
29
30DECLARE_REMOTE_PROTOCOL(Dyson)
31
32template<typename... Ts> class DysonAction : public RemoteTransmitterActionBase<Ts...> {
33 public:
34 TEMPLATABLE_VALUE(uint16_t, code)
35 TEMPLATABLE_VALUE(uint8_t, index)
36
37 void encode(RemoteTransmitData *dst, Ts... x) override {
38 DysonData data{};
39 data.code = this->code_.value(x...);
40 data.index = this->index_.value(x...);
41 DysonProtocol().encode(dst, data);
42 }
43};
44
45} // namespace remote_base
46} // namespace esphome
optional< DysonData > decode(RemoteReceiveData src) override
void encode(RemoteTransmitData *dst, const DysonData &data) override
void dump(const DysonData &data) override
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
bool operator==(const DysonData &rhs) const
uint16_t x
Definition tt21100.cpp:5