-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
automation.cpp
35 lines (31 loc) · 933 Bytes
/
automation.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "esphome/core/log.h"
#include "automation.h"
namespace esphome {
namespace miot_ylai003 {
static const char *const TAG = "miot_ylai003.automation";
bool MiotYLAI003Trigger::process_object_(const miot::BLEObject &obj) {
switch (obj.id) {
case miot::MIID_BUTTON_EVENT: {
const auto button_event = obj.get_typed<miot::ButtonEvent>();
if (button_event != nullptr) {
if (button_event->button.index != 0) {
ESP_LOGW(TAG, "Unknown button index detected: %u", button_event->button.index);
}
if (this->type_ == button_event->type) {
button_event->dump(TAG);
this->trigger();
return true;
}
}
return false;
}
case miot::MIID_PAIRING_EVENT:
// skip pairing event
return false;
default:
return this->process_unhandled_(obj);
}
return false;
}
} // namespace miot_ylai003
} // namespace esphome