Auth Name and Context
This commit is contained in:
Submodule lib/nuki_ble updated: 84865a9eed...ebcd364046
@@ -5,7 +5,7 @@
|
||||
#define NUKI_HUB_VERSION "9.07"
|
||||
#define NUKI_HUB_VERSION_INT (uint32_t)907
|
||||
#define NUKI_HUB_BUILD "unknownbuildnr"
|
||||
#define NUKI_HUB_DATE "2025-01-04"
|
||||
#define NUKI_HUB_DATE "2025-01-05"
|
||||
|
||||
#define GITHUB_LATEST_RELEASE_URL (char*)"https://github.com/technyon/nuki_hub/releases/latest"
|
||||
#define GITHUB_OTA_MANIFEST_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/manifest.json"
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#define mqtt_topic_lock_binary_ring (char*)"/binaryRing"
|
||||
#define mqtt_topic_lock_trigger (char*)"/trigger"
|
||||
#define mqtt_topic_lock_last_lock_action (char*)"/lastLockAction"
|
||||
#define mqtt_topic_lock_lock_action_context (char*)"/lockActionContext"
|
||||
#define mqtt_topic_lock_log (char*)"/log"
|
||||
#define mqtt_topic_lock_log_latest (char*)"/shortLog"
|
||||
#define mqtt_topic_lock_log_rolling (char*)"/rollingLog"
|
||||
|
||||
@@ -142,12 +142,6 @@ void NukiNetworkLock::initialize()
|
||||
{
|
||||
_network->subscribe(_mqttPath, mqtt_topic_lock_log_rolling_last);
|
||||
}
|
||||
/*
|
||||
_network->addReconnectedCallback([&]()
|
||||
{
|
||||
_reconnected = true;
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
void NukiNetworkLock::update()
|
||||
@@ -496,7 +490,7 @@ void NukiNetworkLock::publishKeyTurnerState(const NukiLock::KeyTurnerState& keyT
|
||||
}
|
||||
|
||||
json["auth_id"] = getAuthId();
|
||||
json["auth_name"] = _authName;
|
||||
json["auth_name"] = getAuthName();
|
||||
|
||||
serializeJson(json, _buffer, _bufferSize);
|
||||
_nukiPublisher->publishString(mqtt_topic_lock_json, _buffer, true);
|
||||
@@ -697,10 +691,10 @@ void NukiNetworkLock::publishAuthorizationInfo(const std::list<NukiLock::LogEntr
|
||||
_nukiPublisher->publishString(mqtt_topic_lock_log, _buffer, true);
|
||||
}
|
||||
|
||||
if(authIndex > 0)
|
||||
if(authIndex > 0 || (_nukiOfficial->getOffConnected() && _nukiOfficial->hasAuthId()))
|
||||
{
|
||||
_nukiPublisher->publishUInt(mqtt_topic_lock_auth_id, getAuthId(), true);
|
||||
_nukiPublisher->publishString(mqtt_topic_lock_auth_name, _authName, true);
|
||||
_nukiPublisher->publishString(mqtt_topic_lock_auth_name, getAuthName(), true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -911,6 +905,7 @@ void NukiNetworkLock::publishKeypad(const std::list<NukiLock::KeypadEntry>& entr
|
||||
}
|
||||
jsonEntry["enabled"] = entry.enabled;
|
||||
jsonEntry["name"] = entry.name;
|
||||
_authEntries[jsonEntry["codeId"]] = jsonEntry["name"].as<String>();
|
||||
char createdDT[20];
|
||||
sprintf(createdDT, "%04d-%02d-%02d %02d:%02d:%02d", entry.dateCreatedYear, entry.dateCreatedMonth, entry.dateCreatedDay, entry.dateCreatedHour, entry.dateCreatedMin, entry.dateCreatedSec);
|
||||
jsonEntry["dateCreated"] = createdDT;
|
||||
@@ -1276,7 +1271,7 @@ void NukiNetworkLock::publishAuth(const std::list<NukiLock::AuthorizationEntry>&
|
||||
auto jsonEntry = json.add<JsonVariant>();
|
||||
|
||||
jsonEntry["authId"] = entry.authId;
|
||||
jsonEntry["idType"] = entry.idType; //CONSIDER INT TO STRING
|
||||
jsonEntry["idType"] = entry.idType;
|
||||
jsonEntry["enabled"] = entry.enabled;
|
||||
jsonEntry["name"] = entry.name;
|
||||
_authEntries[jsonEntry["authId"]] = jsonEntry["name"].as<String>();
|
||||
@@ -1627,9 +1622,18 @@ void NukiNetworkLock::fobActionToString(const int fobact, char* str)
|
||||
|
||||
const uint32_t NukiNetworkLock::getAuthId() const
|
||||
{
|
||||
if(_nukiOfficial->hasAuthId())
|
||||
if(_nukiOfficial->getOffConnected() && _nukiOfficial->hasAuthId())
|
||||
{
|
||||
return _nukiOfficial->getAuthId();
|
||||
}
|
||||
return _authId;
|
||||
}
|
||||
|
||||
const char* NukiNetworkLock::getAuthName()
|
||||
{
|
||||
if(_nukiOfficial->getOffConnected() && _nukiOfficial->hasAuthId())
|
||||
{
|
||||
return _authEntries[getAuthId()].c_str();
|
||||
}
|
||||
return _authName;
|
||||
}
|
||||
@@ -59,6 +59,7 @@ public:
|
||||
void setupHASS(int type, uint32_t nukiId, char* nukiName, const char* firmwareVersion, const char* hardwareVersion, bool hasDoorSensor, bool hasKeypad);
|
||||
|
||||
const uint32_t getAuthId() const;
|
||||
const char* getAuthName();
|
||||
int mqttConnectionState();
|
||||
uint8_t queryCommands();
|
||||
|
||||
|
||||
@@ -116,12 +116,6 @@ void NukiNetworkOpener::initialize()
|
||||
{
|
||||
_network->subscribe(_mqttPath, mqtt_topic_lock_log_rolling_last);
|
||||
}
|
||||
/*
|
||||
_network->addReconnectedCallback([&]()
|
||||
{
|
||||
_reconnected = true;
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
void NukiNetworkOpener::update()
|
||||
@@ -886,6 +880,7 @@ void NukiNetworkOpener::publishKeypad(const std::list<NukiLock::KeypadEntry>& en
|
||||
}
|
||||
jsonEntry["enabled"] = entry.enabled;
|
||||
jsonEntry["name"] = entry.name;
|
||||
_authEntries[jsonEntry["codeId"]] = jsonEntry["name"].as<String>();
|
||||
char createdDT[20];
|
||||
sprintf(createdDT, "%04d-%02d-%02d %02d:%02d:%02d", entry.dateCreatedYear, entry.dateCreatedMonth, entry.dateCreatedDay, entry.dateCreatedHour, entry.dateCreatedMin, entry.dateCreatedSec);
|
||||
jsonEntry["dateCreated"] = createdDT;
|
||||
@@ -1218,7 +1213,7 @@ void NukiNetworkOpener::publishAuth(const std::list<NukiOpener::AuthorizationEnt
|
||||
auto jsonEntry = json.add<JsonVariant>();
|
||||
|
||||
jsonEntry["authId"] = entry.authId;
|
||||
jsonEntry["idType"] = entry.idType; //CONSIDER INT TO STRING
|
||||
jsonEntry["idType"] = entry.idType;
|
||||
jsonEntry["enabled"] = entry.enabled;
|
||||
jsonEntry["name"] = entry.name;
|
||||
_authEntries[jsonEntry["authId"]] = jsonEntry["name"].as<String>();
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
NukiOfficial::NukiOfficial(Preferences *preferences)
|
||||
{
|
||||
offEnabled = preferences->getBool(preference_official_hybrid_enabled, false);
|
||||
@@ -197,6 +196,7 @@ void NukiOfficial::onOfficialUpdateReceived(const char *topic, const char *value
|
||||
}
|
||||
else if(strcmp(topic, mqtt_topic_official_lockActionEvent) == 0)
|
||||
{
|
||||
clearAuthId();
|
||||
clearOffCommandExecutedTs();
|
||||
offLockActionEvent = (char*)value;
|
||||
String LockActionEvent = offLockActionEvent;
|
||||
@@ -210,7 +210,7 @@ void NukiOfficial::onOfficialUpdateReceived(const char *topic, const char *value
|
||||
offTrigger = atoi(LockActionEvent.substring(ind1 + 1, ind2 + 1).c_str());
|
||||
offAuthId = atoi(LockActionEvent.substring(ind2 + 1, ind3 + 1).c_str());
|
||||
offCodeId = atoi(LockActionEvent.substring(ind3 + 1, ind4 + 1).c_str());
|
||||
// offContext = atoi(LockActionEvent.substring(ind4 + 1, ind5 + 1).c_str());
|
||||
offContext = atoi(LockActionEvent.substring(ind4 + 1, ind5 + 1).c_str());
|
||||
|
||||
memset(&str, 0, sizeof(str));
|
||||
lockactionToString((NukiLock::LockAction)offLockAction, str);
|
||||
@@ -225,17 +225,69 @@ void NukiOfficial::onOfficialUpdateReceived(const char *topic, const char *value
|
||||
if(offCodeId > 0)
|
||||
{
|
||||
_authId = offCodeId;
|
||||
|
||||
switch(offContext)
|
||||
{
|
||||
case 0:
|
||||
_publisher->publishString(mqtt_topic_lock_lock_action_context, "keypadBackKey", true);
|
||||
break;
|
||||
case 1:
|
||||
_publisher->publishString(mqtt_topic_lock_lock_action_context, "keypadCode", true);
|
||||
break;
|
||||
case 2:
|
||||
_publisher->publishString(mqtt_topic_lock_lock_action_context, "keypadFingerprint", true);
|
||||
break;
|
||||
default:
|
||||
_publisher->publishString(mqtt_topic_lock_lock_action_context, "", true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_authId = offAuthId;
|
||||
|
||||
switch(offTrigger)
|
||||
{
|
||||
case 0:
|
||||
if (offContext == 1)
|
||||
{
|
||||
_publisher->publishString(mqtt_topic_lock_lock_action_context, "autoUnlock", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_publisher->publishString(mqtt_topic_lock_lock_action_context, "", true);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (offContext > 0)
|
||||
{
|
||||
_publisher->publishString(mqtt_topic_lock_lock_action_context, String("button") + String(offContext) + "press", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_publisher->publishString(mqtt_topic_lock_lock_action_context, "", true);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (offContext > 0)
|
||||
{
|
||||
_publisher->publishString(mqtt_topic_lock_lock_action_context, String("fob") + String(offContext) + "press", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_publisher->publishString(mqtt_topic_lock_lock_action_context, "", true);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
_publisher->publishString(mqtt_topic_lock_lock_action_context, "", true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
_hasAuthId = true;
|
||||
|
||||
/*
|
||||
_network->_authName = RETRIEVE FROM VECTOR AFTER AUTHORIZATION ENTRIES ARE IMPLEMENTED;
|
||||
_offContext = BASE ON CONTEXT OF TRIGGER AND PUBLISH TO MQTT;
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
_publisher->publishString(mqtt_topic_lock_lock_action_context, "", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,6 +337,7 @@ const bool NukiOfficial::hasAuthId() const
|
||||
void NukiOfficial::clearAuthId()
|
||||
{
|
||||
_hasAuthId = false;
|
||||
_authId = 0;
|
||||
}
|
||||
|
||||
const bool NukiOfficial::getOffConnected() const
|
||||
@@ -317,6 +370,11 @@ const uint8_t NukiOfficial::getOffTrigger() const
|
||||
return offTrigger;
|
||||
}
|
||||
|
||||
const uint8_t NukiOfficial::getOffContext() const
|
||||
{
|
||||
return offContext;
|
||||
}
|
||||
|
||||
const int64_t NukiOfficial::getOffCommandExecutedTs() const
|
||||
{
|
||||
return offCommandExecutedTs;
|
||||
|
||||
@@ -34,6 +34,7 @@ public:
|
||||
const uint8_t getOffState() const;
|
||||
const uint8_t getOffLockAction() const;
|
||||
const uint8_t getOffTrigger() const;
|
||||
const uint8_t getOffContext() const;
|
||||
const std::vector<char*> getOffTopics() const;
|
||||
|
||||
const int64_t getOffCommandExecutedTs() const;
|
||||
@@ -69,7 +70,7 @@ private:
|
||||
uint8_t offTrigger = 0;
|
||||
uint32_t offAuthId = 0;
|
||||
uint32_t offCodeId = 0;
|
||||
//uint8_t offContext = 0;
|
||||
uint8_t offContext = 0;
|
||||
bool offEnabled = false;
|
||||
};
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
#define preference_authlog_max_entries (char*)"authmaxentry"
|
||||
#define preference_keypad_max_entries (char*)"kpmaxentry"
|
||||
#define preference_timecontrol_max_entries (char*)"tcmaxentry"
|
||||
#define preference_register_as_app (char*)"regAsApp" // true = register as hub; false = register as app
|
||||
#define preference_register_as_app (char*)"regAsApp"
|
||||
#define preference_register_opener_as_app (char*)"regOpnAsApp"
|
||||
#define preference_acl (char*)"aclLckOpn"
|
||||
#define preference_conf_lock_basic_acl (char*)"confLckBasAcl"
|
||||
|
||||
Reference in New Issue
Block a user