mirror of
https://github.com/esphome/esphome.git
synced 2025-09-30 17:12:20 +01:00
Nexa 433MHz RF protocol (#2037)
Co-authored-by: Stefan Grufman <stefan.grufman@gmail.com> Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
52
esphome/components/remote_base/nexa_protocol.h
Normal file
52
esphome/components/remote_base/nexa_protocol.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
#include "remote_base.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace remote_base {
|
||||
|
||||
struct NexaData {
|
||||
uint32_t device;
|
||||
uint8_t group;
|
||||
uint8_t state;
|
||||
uint8_t channel;
|
||||
uint8_t level;
|
||||
bool operator==(const NexaData &rhs) const {
|
||||
return device == rhs.device && group == rhs.group && state == rhs.state && channel == rhs.channel &&
|
||||
level == rhs.level;
|
||||
}
|
||||
};
|
||||
|
||||
class NexaProtocol : public RemoteProtocol<NexaData> {
|
||||
public:
|
||||
void one(RemoteTransmitData *dst) const;
|
||||
void zero(RemoteTransmitData *dst) const;
|
||||
void sync(RemoteTransmitData *dst) const;
|
||||
|
||||
void encode(RemoteTransmitData *dst, const NexaData &data) override;
|
||||
optional<NexaData> decode(RemoteReceiveData src) override;
|
||||
void dump(const NexaData &data) override;
|
||||
};
|
||||
|
||||
DECLARE_REMOTE_PROTOCOL(Nexa)
|
||||
|
||||
template<typename... Ts> class NexaAction : public RemoteTransmitterActionBase<Ts...> {
|
||||
public:
|
||||
TEMPLATABLE_VALUE(uint32_t, device)
|
||||
TEMPLATABLE_VALUE(uint8_t, group)
|
||||
TEMPLATABLE_VALUE(uint8_t, state)
|
||||
TEMPLATABLE_VALUE(uint8_t, channel)
|
||||
TEMPLATABLE_VALUE(uint8_t, level)
|
||||
void encode(RemoteTransmitData *dst, Ts... x) override {
|
||||
NexaData data{};
|
||||
data.device = this->device_.value(x...);
|
||||
data.group = this->group_.value(x...);
|
||||
data.state = this->state_.value(x...);
|
||||
data.channel = this->channel_.value(x...);
|
||||
data.level = this->level_.value(x...);
|
||||
NexaProtocol().encode(dst, data);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace remote_base
|
||||
} // namespace esphome
|
Reference in New Issue
Block a user