SinricPro Library
ContactEventSource.h
1 #ifndef _CONTACTEVENTSOURCE_H_
2 #define _CONTACTEVENTSOURCE_H_
3 
8 template <typename T>
10  public:
11  bool sendContactEvent(bool detected, String cause = "PHYSICAL_INTERACTION");
12 };
13 
22 template <typename T>
23 bool ContactEventSource<T>::sendContactEvent(bool detected, String cause) {
24  T& device = static_cast<T&>(*this);
25 
26  DynamicJsonDocument eventMessage = device.prepareEvent("setContactState", cause.c_str());
27  JsonObject event_value = eventMessage["payload"]["value"];
28  event_value["state"] = detected ? "closed" : "open";
29  return device.sendEvent(eventMessage);
30 }
31 
32 #endif
ContactEventSource.
Definition: ContactEventSource.h:9
bool sendContactEvent(bool detected, String cause="PHYSICAL_INTERACTION")
Send setContactState event to SinricPro Server indicating actual power state.
Definition: ContactEventSource.h:23