Clear MQTT topics on boot

This commit is contained in:
iranl
2025-01-05 11:48:24 +01:00
parent 00c96831cd
commit 850f7fcc8a
3 changed files with 34 additions and 8 deletions

View File

@@ -757,6 +757,9 @@ bool NukiNetwork::reconnect()
initTopic(_maintenancePathPrefix, mqtt_topic_reset, "0");
subscribe(_maintenancePathPrefix, mqtt_topic_reset);
initTopic(_maintenancePathPrefix, mqtt_topic_freeheap, "");
initTopic(_maintenancePathPrefix, mqtt_topic_log, "");
initTopic(_maintenancePathPrefix, mqtt_topic_wifi_rssi, "");
if(_preferences->getBool(preference_update_from_mqtt, false))
{

View File

@@ -51,6 +51,7 @@ void NukiNetworkLock::initialize()
_network->initTopic(_mqttPath, mqtt_topic_config_action, "--");
_network->subscribe(_mqttPath, mqtt_topic_config_action);
_network->initTopic(_mqttPath, mqtt_topic_query_keypad, "0");
_network->initTopic(_mqttPath, mqtt_topic_query_config, "0");
_network->initTopic(_mqttPath, mqtt_topic_query_lockstate, "0");
_network->initTopic(_mqttPath, mqtt_topic_query_battery, "0");
@@ -58,6 +59,21 @@ void NukiNetworkLock::initialize()
_network->subscribe(_mqttPath, mqtt_topic_query_lockstate);
_network->subscribe(_mqttPath, mqtt_topic_query_battery);
_network->initTopic(_mqttPath, mqtt_topic_auth_action, "--");
_network->initTopic(_mqttPath, mqtt_topic_timecontrol_action, "--");
_network->initTopic(_mqttPath, mqtt_topic_keypad_json_action, "--");
_network->initTopic(_mqttPath, mqtt_topic_lock_retry, "0");
_network->removeTopic(_mqttPath, mqtt_topic_hybrid_state);
_network->removeTopic(_mqttPath, mqtt_topic_config_action_command_result);
_network->removeTopic(_mqttPath, mqtt_topic_keypad_command_result);
_network->removeTopic(_mqttPath, mqtt_topic_keypad_json_command_result);
_network->removeTopic(_mqttPath, mqtt_topic_timecontrol_command_result);
_network->removeTopic(_mqttPath, mqtt_topic_auth_command_result);
_network->removeTopic(_mqttPath, mqtt_topic_query_lockstate_command_result);
_network->removeTopic(_mqttPath, mqtt_topic_lock_completionStatus);
_network->removeTopic(_mqttPath, mqtt_topic_lock_action_command_result);
if(_disableNonJSON)
{
_network->removeTopic(_mqttPath, mqtt_topic_keypad_command_action);
@@ -110,21 +126,17 @@ void NukiNetworkLock::initialize()
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_enabled);
}
_network->initTopic(_mqttPath, mqtt_topic_query_keypad, "0");
_network->initTopic(_mqttPath, mqtt_topic_keypad_json_action, "--");
_network->subscribe(_mqttPath, mqtt_topic_query_keypad);
_network->subscribe(_mqttPath, mqtt_topic_keypad_json_action);
}
if(_preferences->getBool(preference_timecontrol_control_enabled))
{
_network->initTopic(_mqttPath, mqtt_topic_timecontrol_action, "--");
_network->subscribe(_mqttPath, mqtt_topic_timecontrol_action);
}
if(_preferences->getBool(preference_auth_control_enabled))
{
_network->initTopic(_mqttPath, mqtt_topic_auth_action, "--");
_network->subscribe(_mqttPath, mqtt_topic_auth_action);
}

View File

@@ -39,6 +39,7 @@ void NukiNetworkOpener::initialize()
_network->initTopic(_mqttPath, mqtt_topic_config_action, "--");
_network->subscribe(_mqttPath, mqtt_topic_config_action);
_network->initTopic(_mqttPath, mqtt_topic_query_keypad, "0");
_network->initTopic(_mqttPath, mqtt_topic_query_config, "0");
_network->initTopic(_mqttPath, mqtt_topic_query_lockstate, "0");
_network->initTopic(_mqttPath, mqtt_topic_query_battery, "0");
@@ -47,6 +48,20 @@ void NukiNetworkOpener::initialize()
_network->subscribe(_mqttPath, mqtt_topic_query_config);
_network->subscribe(_mqttPath, mqtt_topic_query_lockstate);
_network->subscribe(_mqttPath, mqtt_topic_query_battery);
_network->initTopic(_mqttPath, mqtt_topic_keypad_json_action, "--");
_network->initTopic(_mqttPath, mqtt_topic_timecontrol_action, "--");
_network->initTopic(_mqttPath, mqtt_topic_auth_action, "--");
_network->initTopic(_mqttPath, mqtt_topic_lock_retry, "0");
_network->removeTopic(_mqttPath, mqtt_topic_config_action_command_result);
_network->removeTopic(_mqttPath, mqtt_topic_keypad_command_result);
_network->removeTopic(_mqttPath, mqtt_topic_keypad_json_command_result);
_network->removeTopic(_mqttPath, mqtt_topic_timecontrol_command_result);
_network->removeTopic(_mqttPath, mqtt_topic_auth_command_result);
_network->removeTopic(_mqttPath, mqtt_topic_query_lockstate_command_result);
_network->removeTopic(_mqttPath, mqtt_topic_lock_completionStatus);
_network->removeTopic(_mqttPath, mqtt_topic_lock_action_command_result);
if(_disableNonJSON)
{
@@ -94,21 +109,17 @@ void NukiNetworkOpener::initialize()
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_enabled);
}
_network->initTopic(_mqttPath, mqtt_topic_query_keypad, "0");
_network->initTopic(_mqttPath, mqtt_topic_keypad_json_action, "--");
_network->subscribe(_mqttPath, mqtt_topic_query_keypad);
_network->subscribe(_mqttPath, mqtt_topic_keypad_json_action);
}
if(_preferences->getBool(preference_timecontrol_control_enabled, false))
{
_network->initTopic(_mqttPath, mqtt_topic_timecontrol_action, "--");
_network->subscribe(_mqttPath, mqtt_topic_timecontrol_action);
}
if(_preferences->getBool(preference_auth_control_enabled))
{
_network->initTopic(_mqttPath, mqtt_topic_auth_action, "--");
_network->subscribe(_mqttPath, mqtt_topic_auth_action);
}