disable keypad control by default; add more sanity checks

This commit is contained in:
technyon
2022-08-13 08:49:46 +02:00
parent 8c53e93e9d
commit 7ccaffec7a
5 changed files with 30 additions and 13 deletions

View File

@@ -203,6 +203,7 @@ void NukiWrapper::updateConfig()
{
readConfig();
readAdvancedConfig();
_configRead = true;
_hasKeypad = _nukiConfig.hasKeypad > 0;
_network->publishConfig(_nukiConfig);
_network->publishAdvancedConfig(_nukiAdvancedConfig);
@@ -362,7 +363,15 @@ void NukiWrapper::onConfigUpdateReceived(const char *topic, const char *value)
void NukiWrapper::onKeypadCommandReceived(const char *command, const uint &id, const String &name, const String &code, const int& enabled)
{
if(!_hasKeypad || !_keypadEnabled)
if(!_hasKeypad)
{
if(_configRead)
{
_network->publishKeypadCommandResult("KeypadNotAvailable");
}
return;
}
if(!_keypadEnabled)
{
return;
}
@@ -444,6 +453,10 @@ void NukiWrapper::onKeypadCommandReceived(const char *command, const uint &id, c
Serial.print("Update keypad code: "); Serial.println((int)result);
updateKeypad();
}
else if(command == "--")
{
return;
}
else
{
_network->publishKeypadCommandResult("UnknownCommand");