11 #include "SinricProDevice.h"
23 SinricProLock(
const char* deviceId,
unsigned long eventWaitTime=100);
48 void onPowerState() =
delete;
50 bool sendPowerStateEvent() =
delete;
54 bool handleRequest(
const char* deviceId,
const char* action, JsonObject &request_value, JsonObject &response_value)
override;
59 SinricProLock::SinricProLock(
const char* deviceId,
unsigned long eventWaitTime) :
SinricProDevice(deviceId, eventWaitTime),
60 lockStateCallback(nullptr) {}
62 bool SinricProLock::handleRequest(
const char* deviceId,
const char* action, JsonObject &request_value, JsonObject &response_value) {
63 if (strcmp(deviceId, this->deviceId) != 0)
return false;
65 String actionString = String(action);
67 if (actionString ==
"setLockState" && lockStateCallback) {
68 bool lockState = request_value[
"state"]==
"lock"?
true:
false;
69 success = lockStateCallback(String(deviceId), lockState);
70 response_value[
"state"] = success?lockState?
"LOCKED":
"UNLOCKED":
"JAMMED";
84 lockStateCallback = cb;
97 DynamicJsonDocument eventMessage = prepareEvent(deviceId,
"setLockState", cause.c_str());
98 JsonObject event_value = eventMessage[
"payload"][
"value"];
99 state ? event_value[
"state"] =
"LOCKED" : event_value[
"state"] =
"UNLOCKED";
100 return sendEvent(eventMessage);