SinricPro Library
MotionSensor.h
1 #ifndef _MOTIONSENSOR_H_
2 #define _MOTIONSENSOR_H_
3 
8 template <typename T>
9 class MotionSensor {
10  public:
11  bool sendMotionEvent(bool detected, String cause = "PHYSICAL_INTERACTION");
12 };
13 
23 template <typename T>
24 bool MotionSensor<T>::sendMotionEvent(bool detected, String cause) {
25  T& device = static_cast<T&>(*this);
26 
27  DynamicJsonDocument eventMessage = device.prepareEvent("motion", cause.c_str());
28  JsonObject event_value = eventMessage["payload"]["value"];
29  event_value["state"] = detected ? "detected" : "notDetected";
30  return device.sendEvent(eventMessage);
31 }
32 
33 #endif
MotionSensor.
Definition: MotionSensor.h:9
bool sendMotionEvent(bool detected, String cause="PHYSICAL_INTERACTION")
Sending motion detection state to SinricPro server.
Definition: MotionSensor.h:24