SinricPro Library
SinricProMotionsensor.h
1 /*
2  * Copyright (c) 2019 Sinric. All rights reserved.
3  * Licensed under Creative Commons Attribution-Share Alike (CC BY-SA)
4  *
5  * This file is part of the Sinric Pro (https://github.com/sinricpro/)
6  */
7 
8 #ifndef _SINRICMOTIONSENSOR_H_
9 #define _SINRICMOTIONSENSOR_H_
10 
11 #include "SinricProDevice.h"
12 
18  public:
19  SinricProMotionsensor(const char* deviceId, unsigned long eventWaitTime=100);
20 
21  // event
22  bool sendMotionEvent(bool detected, String cause = "PHYSICAL_INTERACTION");
23  private:
24 };
25 
26 SinricProMotionsensor::SinricProMotionsensor(const char* deviceId, unsigned long eventWaitTime) : SinricProDevice(deviceId, eventWaitTime) {}
27 
37 bool SinricProMotionsensor::sendMotionEvent(bool state, String cause) {
38  DynamicJsonDocument eventMessage = prepareEvent(deviceId, "motion", cause.c_str());
39  JsonObject event_value = eventMessage["payload"]["value"];
40  event_value["state"] = state?"detected":"notDetected";
41  return sendEvent(eventMessage);
42 }
43 
44 #endif
45 
SinricProMotionsensor::sendMotionEvent
bool sendMotionEvent(bool detected, String cause="PHYSICAL_INTERACTION")
Sending motion detection state to SinricPro server.
Definition: SinricProMotionsensor.h:37
SinricProMotionsensor
Device to report motion detection events.
Definition: SinricProMotionsensor.h:17
SinricProDevice
Base class for all device types.
Definition: SinricProDevice.h:23