disable keypad control by default; add more sanity checks
This commit is contained in:
@@ -54,16 +54,19 @@ void NetworkLock::initialize()
|
||||
_network->subscribe(_mqttPath, mqtt_topic_reset);
|
||||
_network->initTopic(_mqttPath, mqtt_topic_reset, "0");
|
||||
|
||||
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_action);
|
||||
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_id);
|
||||
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_name);
|
||||
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_code);
|
||||
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_enabled);
|
||||
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_action, "--");
|
||||
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_id, "0");
|
||||
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_name, "--");
|
||||
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_code, "000000");
|
||||
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_enabled, "1");
|
||||
if(_preferences->getBool(preference_keypad_control_enabled))
|
||||
{
|
||||
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_action);
|
||||
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_id);
|
||||
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_name);
|
||||
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_code);
|
||||
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_enabled);
|
||||
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_action, "--");
|
||||
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_id, "0");
|
||||
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_name, "--");
|
||||
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_code, "000000");
|
||||
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_enabled, "1");
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkLock::update()
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -80,6 +80,7 @@ private:
|
||||
bool _statusUpdated = false;
|
||||
bool _hasKeypad = false;
|
||||
bool _keypadEnabled = false;
|
||||
bool _configRead = false;
|
||||
uint _maxKeypadCodeCount = 0;
|
||||
unsigned long _nextLockStateUpdateTs = 0;
|
||||
unsigned long _nextBatteryReportTs = 0;
|
||||
|
||||
@@ -118,7 +118,8 @@ NOTE: MQTT Discovery uses retained MQTT messages to store devices configurations
|
||||
## Keypad control (optional)
|
||||
|
||||
If a keypad is connected to the lock, keypad codes can be added, updated and removed.
|
||||
Information about codes is published under "keypad/code_x", x starting from 0 up the number of configured codes.
|
||||
This has to enabled first in the configuration portal. Check "Enabled keypad control via MQTT" and save the configuration.
|
||||
After enabling keypad control, information about codes is published under "keypad/code_x", x starting from 0 up the number of configured codes.
|
||||
<br>
|
||||
For security reasons, the code itself is not published. To modify keypad codes, a command
|
||||
structure is setup under keypad/command:
|
||||
|
||||
Reference in New Issue
Block a user