mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-05-31 10:08:27 +02:00
Add Dish Network protocol (#2117)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user