SinricPro Library
ContactController.h
1 #ifndef _CONTACTCONTROLLER_H_
2 #define _CONTACTCONTROLLER_H_
3 
4 #include "./../SinricProDeviceInterface.h"
5 
11  public:
12  ContactController(SinricProDeviceInterface *device);
13  bool sendContactEvent(bool detected, String cause = "PHYSICAL_INTERACTION");
14  protected:
15  private:
16  SinricProDeviceInterface *device;
17 };
18 
19 ContactController::ContactController(SinricProDeviceInterface *device) : device(device) {}
20 
29 bool ContactController::sendContactEvent(bool state, String cause) {
30  DynamicJsonDocument eventMessage = device->prepareEvent("setContactState", cause.c_str());
31  JsonObject event_value = eventMessage["payload"]["value"];
32  event_value["state"] = state ? "closed" : "open";
33  return device->sendEvent(eventMessage);
34 }
35 
36 #endif
ContactController
ContactController.
Definition: ContactController.h:10
ContactController::sendContactEvent
bool sendContactEvent(bool detected, String cause="PHYSICAL_INTERACTION")
Send setContactState event to SinricPro Server indicating actual power state.
Definition: ContactController.h:29