implement publish json for opener
This commit is contained in:
@@ -40,6 +40,7 @@ void NukiOpenerWrapper::initialize()
|
||||
_intervalLockstate = _preferences->getInt(preference_query_interval_lockstate);
|
||||
_intervalBattery = _preferences->getInt(preference_query_interval_battery);
|
||||
_publishAuthData = _preferences->getBool(preference_publish_authdata);
|
||||
_publishJson = _preferences->getBool(preference_publish_json);
|
||||
|
||||
if(_intervalLockstate == 0)
|
||||
{
|
||||
@@ -164,6 +165,11 @@ void NukiOpenerWrapper::updateKeyTurnerState()
|
||||
{
|
||||
updateAuthData();
|
||||
}
|
||||
|
||||
if(_publishJson)
|
||||
{
|
||||
_network->publishStateAsJson(_lastLockAction, _keyTurnerState, _lastAuthId, _lastAuthName);
|
||||
}
|
||||
}
|
||||
|
||||
void NukiOpenerWrapper::updateBatteryState()
|
||||
@@ -204,17 +210,20 @@ void NukiOpenerWrapper::updateAuthData()
|
||||
if(log.size() > 0)
|
||||
{
|
||||
const NukiOpener::LogEntry& entry = log.front();
|
||||
// log_d("Log: %d-%d-%d %d:%d:%d %s", entry.timeStampYear, entry.timeStampMonth, entry.timeStampDay,
|
||||
// entry.timeStampHour, entry.timeStampMinute, entry.timeStampSecond, entry.name);
|
||||
|
||||
if(entry.authId != _lastAuthId)
|
||||
{
|
||||
_network->publishAuthorizationInfo(entry.authId, (char *) entry.name);
|
||||
_lastAuthId = entry.authId;
|
||||
memset(_lastAuthName, 0, sizeof(_lastAuthName));
|
||||
memcpy(_lastAuthName, entry.name, sizeof(entry.name));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_network->publishAuthorizationInfo(0, "");
|
||||
_lastAuthId = 0;
|
||||
memset(_lastAuthName, 0, sizeof(_lastAuthName));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,6 +242,9 @@ NukiOpener::LockAction NukiOpenerWrapper::lockActionToEnum(const char *str)
|
||||
|
||||
bool NukiOpenerWrapper::onLockActionReceivedCallback(const char *value)
|
||||
{
|
||||
memset(&nukiOpenerInst->_lastLockAction, 0, sizeof(_lastLockAction));
|
||||
strcpy(nukiOpenerInst->_lastLockAction, value);
|
||||
|
||||
NukiOpener::LockAction action = nukiOpenerInst->lockActionToEnum(value);
|
||||
nukiOpenerInst->_nextLockAction = action;
|
||||
return (int)action != 0xff;
|
||||
|
||||
Reference in New Issue
Block a user