Add Dish Network protocol (#2117)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
Adrián Panella
2021-08-09 20:26:42 -05:00
committed by GitHub
parent 922f7167f5
commit 06bde559da
3 changed files with 173 additions and 0 deletions
@@ -0,0 +1,38 @@
#pragma once
#include "remote_base.h"
namespace esphome {
namespace remote_base {
struct DishData {
uint8_t address;
uint8_t command;
bool operator==(const DishData &rhs) const { return address == rhs.address && command == rhs.command; }
};
class DishProtocol : public RemoteProtocol<DishData> {
public:
void encode(RemoteTransmitData *dst, const DishData &data) override;
optional<DishData> decode(RemoteReceiveData src) override;
void dump(const DishData &data) override;
};
DECLARE_REMOTE_PROTOCOL(Dish)
template<typename... Ts> class DishAction : public RemoteTransmitterActionBase<Ts...> {
public:
TEMPLATABLE_VALUE(uint8_t, address)
TEMPLATABLE_VALUE(uint8_t, command)
void encode(RemoteTransmitData *dst, Ts... x) override {
DishData data{};
data.address = this->address_.value(x...);
data.command = this->command_.value(x...);
DishProtocol().encode(dst, data);
}
};
} // namespace remote_base
} // namespace esphome