ESPHome 2026.5.0b1
Loading...
Searching...
No Matches
keeloq_protocol.h
Go to the documentation of this file.
1#pragma once
2
4#include "remote_base.h"
5
6namespace esphome::remote_base {
7
8struct KeeloqData {
9 uint32_t encrypted; // 32 bit encrypted field
10 uint32_t address; // 28 bit serial number
11 uint8_t command; // Button Status S2-S1-S0-S3
12 bool repeat; // Repeated command bit
13 bool vlow; // Battery status bit
14
15 bool operator==(const KeeloqData &rhs) const {
16 // Treat 0x10 as a special, wildcard button press
17 // This allows us to match on just the address if wanted.
18 if (address != rhs.address) {
19 return false;
20 }
21 return (rhs.command == 0x10 || command == rhs.command);
22 }
23};
24
25class KeeloqProtocol : public RemoteProtocol<KeeloqData> {
26 public:
27 void encode(RemoteTransmitData *dst, const KeeloqData &data) override;
28 optional<KeeloqData> decode(RemoteReceiveData src) override;
29 void dump(const KeeloqData &data) override;
30};
31
32DECLARE_REMOTE_PROTOCOL(Keeloq)
33
34template<typename... Ts> class KeeloqAction : public RemoteTransmitterActionBase<Ts...> {
35 public:
36 TEMPLATABLE_VALUE(uint32_t, address)
37 TEMPLATABLE_VALUE(uint32_t, encrypted)
38 TEMPLATABLE_VALUE(uint8_t, command)
39 TEMPLATABLE_VALUE(bool, vlow)
40
41 void encode(RemoteTransmitData *dst, Ts... x) override {
42 KeeloqData data{};
43 data.address = this->address_.value(x...);
44 data.encrypted = this->encrypted_.value(x...);
45 data.command = this->command_.value(x...);
46 data.vlow = this->vlow_.value(x...);
47 KeeloqProtocol().encode(dst, data);
48 }
49};
50
51} // namespace esphome::remote_base
uint8_t address
Definition bl0906.h:4
void dump(const KeeloqData &data) override
void encode(RemoteTransmitData *dst, const KeeloqData &data) override
optional< KeeloqData > decode(RemoteReceiveData src) override
static void uint32_t
bool operator==(const KeeloqData &rhs) const
uint16_t x
Definition tt21100.cpp:5