11 #include "SinricProDevice.h"
24 String getProductType() {
return SinricProDevice::getProductType() + String(
"SMARTLOCK"); }
49 void onPowerState() =
delete;
51 bool sendPowerStateEvent() =
delete;
54 bool handleRequest(
const DeviceId &deviceId,
const char* action, JsonObject &request_value, JsonObject &response_value)
override;
59 SinricProLock::SinricProLock(
const DeviceId &deviceId) :
SinricProDevice(deviceId),
60 lockStateCallback(nullptr) {}
62 bool SinricProLock::handleRequest(
const DeviceId &deviceId,
const char* action, JsonObject &request_value, JsonObject &response_value) {
63 if (deviceId != this->deviceId)
return false;
65 String actionString = String(action);
67 if (actionString ==
"setLockState" && lockStateCallback) {
68 bool lockState = request_value[
"state"]==
"lock"?
true:
false;
69 success = lockStateCallback(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);