SinricPro Library
Main Page
Classes
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
17
class
SinricProMotionsensor
:
public
SinricProDevice
{
18
public
:
19
SinricProMotionsensor
(
const
DeviceId &deviceId);
20
String getProductType() {
return
SinricProDevice::getProductType() + String(
"MOTION_SENSOR"
); }
21
22
// event
23
bool
sendMotionEvent
(
bool
detected, String cause =
"PHYSICAL_INTERACTION"
);
24
private
:
25
};
26
27
SinricProMotionsensor::SinricProMotionsensor(
const
DeviceId &deviceId) :
SinricProDevice
(deviceId) {}
28
38
bool
SinricProMotionsensor::sendMotionEvent
(
bool
state, String cause) {
39
DynamicJsonDocument eventMessage = prepareEvent(deviceId,
"motion"
, cause.c_str());
40
JsonObject event_value = eventMessage[
"payload"
][
"value"
];
41
event_value[
"state"
] = state?
"detected"
:
"notDetected"
;
42
return
sendEvent(eventMessage);
43
}
44
45
#endif
46
SinricProMotionsensor::sendMotionEvent
bool sendMotionEvent(bool detected, String cause="PHYSICAL_INTERACTION")
Sending motion detection state to SinricPro server.
Definition:
SinricProMotionsensor.h:38
SinricProMotionsensor
Device to report motion detection events.
Definition:
SinricProMotionsensor.h:17
SinricProDevice
Base class for all device types.
Definition:
SinricProDevice.h:24
src
SinricProMotionsensor.h
Generated by
1.8.16