set lock action node to ack or unknown_action after receiving command

This commit is contained in:
technyon
2022-05-13 22:04:15 +02:00
parent f502909e9c
commit 23e4f5e5d4
6 changed files with 13 additions and 10 deletions

View File

@@ -222,11 +222,12 @@ void Network::onMqttDataReceived(char *&topic, byte *&payload, unsigned int &len
Serial.print(F("Lock action received: ")); Serial.print(F("Lock action received: "));
Serial.println(value); Serial.println(value);
bool success = false;
if(_lockActionReceivedCallback != NULL) if(_lockActionReceivedCallback != NULL)
{ {
_lockActionReceivedCallback(value); success = _lockActionReceivedCallback(value);
} }
publishString(mqtt_topic_lock_action, ""); publishString(mqtt_topic_lock_action, success ? "ack" : "unknown_action");
} }
for(auto configTopic : _configTopics) for(auto configTopic : _configTopics)
@@ -323,7 +324,7 @@ void Network::publishPresenceDetection(char *csv)
_presenceCsv = csv; _presenceCsv = csv;
} }
void Network::setLockActionReceivedCallback(void (*lockActionReceivedCallback)(const char *)) void Network::setLockActionReceivedCallback(bool (*lockActionReceivedCallback)(const char *))
{ {
_lockActionReceivedCallback = lockActionReceivedCallback; _lockActionReceivedCallback = lockActionReceivedCallback;
} }

View File

@@ -36,7 +36,7 @@ public:
void publishAdvancedConfig(const Nuki::AdvancedConfig& config); void publishAdvancedConfig(const Nuki::AdvancedConfig& config);
void publishPresenceDetection(char* csv); void publishPresenceDetection(char* csv);
void setLockActionReceivedCallback(void (*lockActionReceivedCallback)(const char* value)); void setLockActionReceivedCallback(bool (*lockActionReceivedCallback)(const char* value));
void setConfigUpdateReceivedCallback(void (*configUpdateReceivedCallback)(const char* path, const char* value)); void setConfigUpdateReceivedCallback(void (*configUpdateReceivedCallback)(const char* path, const char* value));
void restartAndConfigureWifi(); void restartAndConfigureWifi();
@@ -78,6 +78,6 @@ private:
long _lastMaintain = 0; long _lastMaintain = 0;
void (*_lockActionReceivedCallback)(const char* value) = nullptr; bool (*_lockActionReceivedCallback)(const char* value) = nullptr;
void (*_configUpdateReceivedCallback)(const char* path, const char* value) = nullptr; void (*_configUpdateReceivedCallback)(const char* path, const char* value) = nullptr;
}; };

View File

@@ -242,9 +242,11 @@ Nuki::LockAction NukiWrapper::lockActionToEnum(const char *str)
return (Nuki::LockAction)0xff; return (Nuki::LockAction)0xff;
} }
void NukiWrapper::onLockActionReceivedCallback(const char *value) bool NukiWrapper::onLockActionReceivedCallback(const char *value)
{ {
nukiInst->_nextLockAction = nukiInst->lockActionToEnum(value); Nuki::LockAction action = nukiInst->lockActionToEnum(value);
nukiInst->_nextLockAction = action;
return (int)action != 0xff;
} }
void NukiWrapper::onConfigUpdateReceivedCallback(const char *topic, const char *value) void NukiWrapper::onConfigUpdateReceivedCallback(const char *topic, const char *value)

View File

@@ -25,7 +25,7 @@ public:
void notify(Nuki::EventType eventType) override; void notify(Nuki::EventType eventType) override;
private: private:
static void onLockActionReceivedCallback(const char* value); static bool onLockActionReceivedCallback(const char* value);
static void onConfigUpdateReceivedCallback(const char* topic, const char* value); static void onConfigUpdateReceivedCallback(const char* topic, const char* value);
void onConfigUpdateReceived(const char* topic, const char* value); void onConfigUpdateReceived(const char* topic, const char* value);

View File

@@ -26,7 +26,7 @@ Just enable pairing mode on the NUKI lock and power on the ESP32. Pairing should
## MQTT Interface ## MQTT Interface
- lock/action: Allows to execute lock actions. After executing the action, the value is reset to an empty string. Possible actions: unlock, lock, unlatch, lockNgo, lockNgoUnlatch, fullLock, fobAction1, fobAction2, fobAction3 - lock/action: Allows to execute lock actions. After receiving the action, the value is set to "ack". Possible actions: unlock, lock, unlatch, lockNgo, lockNgoUnlatch, fullLock, fobAction1, fobAction2, fobAction3
- lock/state: Reports the current lock state as a string. Possible values are: uncalibrated, locked, unlocked, unlatched, unlockedLnga, unlatching, bootRun, motorBlocked - lock/state: Reports the current lock state as a string. Possible values are: uncalibrated, locked, unlocked, unlatched, unlockedLnga, unlatching, bootRun, motorBlocked
- lock/trigger: The trigger of the last action: autoLock, automatic, button, manual, system - lock/trigger: The trigger of the last action: autoLock, automatic, button, manual, system
- lock/completionStatus: Status of the last action as reported by NUKI lock (needs bluetooth connection): success, motorBlocked, canceled, tooRecent, busy, lowMotorVoltage, clutchFailure, motorPowerFailure, incompleteFailure, invalidCode, otherError, unknown - lock/completionStatus: Status of the last action as reported by NUKI lock (needs bluetooth connection): success, motorBlocked, canceled, tooRecent, busy, lowMotorVoltage, clutchFailure, motorPowerFailure, incompleteFailure, invalidCode, otherError, unknown

View File

@@ -1,3 +1,3 @@
#pragma once #pragma once
#define nuki_hub_version "2.1" #define nuki_hub_version "2.2"