3 #include "../EventLimiter.h"
4 #include "../SinricProStrings.h"
6 #include "../SinricProNamespace.h"
7 namespace SINRICPRO_NAMESPACE {
9 FSTR(CONTACT, setContactState);
11 FSTR(CONTACT, closed);
22 bool sendContactEvent(
bool detected, String cause = FSTR_SINRICPRO_PHYSICAL_INTERACTION);
24 EventLimiter event_limiter;
29 : event_limiter(EVENT_LIMIT_SENSOR_STATE) {}
41 if (event_limiter)
return false;
42 T* device =
static_cast<T*
>(
this);
44 JsonDocument eventMessage = device->prepareEvent(FSTR_CONTACT_setContactState, cause.c_str());
45 JsonObject event_value = eventMessage[FSTR_SINRICPRO_payload][FSTR_SINRICPRO_value];
46 event_value[FSTR_CONTACT_state] = detected ? FSTR_CONTACT_closed : FSTR_CONTACT_open;
47 return device->sendEvent(eventMessage);
53 using ContactSensor = SINRICPRO_NAMESPACE::ContactSensor<T>;