Merge pull request #531 from iranl/clear-mqtt-topics-on-upgrade
Clear MQTT Topics on upgrade
This commit is contained in:
243
src/MqttTopics.h
243
src/MqttTopics.h
@@ -1,118 +1,149 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
|
||||
#define mqtt_topic_lock_action "/action"
|
||||
#define mqtt_topic_lock_status_updated "/statusUpdated"
|
||||
#define mqtt_topic_lock_state "/state"
|
||||
#define mqtt_topic_lock_ha_state "/hastate"
|
||||
#define mqtt_topic_lock_json "/json"
|
||||
#define mqtt_topic_lock_binary_state "/binaryState"
|
||||
#define mqtt_topic_lock_continuous_mode "/continuousMode"
|
||||
#define mqtt_topic_lock_ring "/ring"
|
||||
#define mqtt_topic_lock_binary_ring "/binaryRing"
|
||||
#define mqtt_topic_lock_trigger "/trigger"
|
||||
#define mqtt_topic_lock_last_lock_action "/lastLockAction"
|
||||
#define mqtt_topic_lock_log "/log"
|
||||
#define mqtt_topic_lock_log_latest "/shortLog"
|
||||
#define mqtt_topic_lock_log_rolling "/rollingLog"
|
||||
#define mqtt_topic_lock_log_rolling_last "/lastRollingLog"
|
||||
#define mqtt_topic_lock_auth_id "/authorizationId"
|
||||
#define mqtt_topic_lock_auth_name "/authorizationName"
|
||||
#define mqtt_topic_lock_completionStatus "/completionStatus"
|
||||
#define mqtt_topic_lock_action_command_result "/commandResult"
|
||||
#define mqtt_topic_lock_door_sensor_state "/doorSensorState"
|
||||
#define mqtt_topic_lock_rssi "/rssi"
|
||||
#define mqtt_topic_lock_address "/address"
|
||||
#define mqtt_topic_lock_retry "/retry"
|
||||
#define mqtt_topic_lock_action (char*)"/action"
|
||||
#define mqtt_topic_lock_status_updated (char*)"/statusUpdated"
|
||||
#define mqtt_topic_lock_state (char*)"/state"
|
||||
#define mqtt_topic_lock_ha_state (char*)"/hastate"
|
||||
#define mqtt_topic_lock_json (char*)"/json"
|
||||
#define mqtt_topic_lock_binary_state (char*)"/binaryState"
|
||||
#define mqtt_topic_lock_continuous_mode (char*)"/continuousMode"
|
||||
#define mqtt_topic_lock_ring (char*)"/ring"
|
||||
#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_log (char*)"/log"
|
||||
#define mqtt_topic_lock_log_latest (char*)"/shortLog"
|
||||
#define mqtt_topic_lock_log_rolling (char*)"/rollingLog"
|
||||
#define mqtt_topic_lock_log_rolling_last (char*)"/lastRollingLog"
|
||||
#define mqtt_topic_lock_auth_id (char*)"/authorizationId"
|
||||
#define mqtt_topic_lock_auth_name (char*)"/authorizationName"
|
||||
#define mqtt_topic_lock_completionStatus (char*)"/completionStatus"
|
||||
#define mqtt_topic_lock_action_command_result (char*)"/commandResult"
|
||||
#define mqtt_topic_lock_door_sensor_state (char*)"/doorSensorState"
|
||||
#define mqtt_topic_lock_rssi (char*)"/rssi"
|
||||
#define mqtt_topic_lock_address (char*)"/address"
|
||||
#define mqtt_topic_lock_retry (char*)"/retry"
|
||||
|
||||
#define mqtt_topic_official_lock_action "/lockAction"
|
||||
//#define mqtt_topic_official_mode "/mode"
|
||||
#define mqtt_topic_official_state "/state"
|
||||
#define mqtt_topic_official_batteryCritical "/batteryCritical"
|
||||
#define mqtt_topic_official_batteryChargeState "/batteryChargeState"
|
||||
#define mqtt_topic_official_batteryCharging "/batteryCharging"
|
||||
#define mqtt_topic_official_keypadBatteryCritical "/keypadBatteryCritical"
|
||||
#define mqtt_topic_official_doorsensorState "/doorsensorState"
|
||||
#define mqtt_topic_official_doorsensorBatteryCritical "/doorsensorBatteryCritical"
|
||||
#define mqtt_topic_official_connected "/connected"
|
||||
#define mqtt_topic_official_commandResponse "/commandResponse"
|
||||
#define mqtt_topic_official_lockActionEvent "/lockActionEvent"
|
||||
#define mqtt_topic_official_lock_action (char*)"/lockAction"
|
||||
//#define mqtt_topic_official_mode (char*)"/mode"
|
||||
#define mqtt_topic_official_state (char*)"/state"
|
||||
#define mqtt_topic_official_batteryCritical (char*)"/batteryCritical"
|
||||
#define mqtt_topic_official_batteryChargeState (char*)"/batteryChargeState"
|
||||
#define mqtt_topic_official_batteryCharging (char*)"/batteryCharging"
|
||||
#define mqtt_topic_official_keypadBatteryCritical (char*)"/keypadBatteryCritical"
|
||||
#define mqtt_topic_official_doorsensorState (char*)"/doorsensorState"
|
||||
#define mqtt_topic_official_doorsensorBatteryCritical (char*)"/doorsensorBatteryCritical"
|
||||
#define mqtt_topic_official_connected (char*)"/connected"
|
||||
#define mqtt_topic_official_commandResponse (char*)"/commandResponse"
|
||||
#define mqtt_topic_official_lockActionEvent (char*)"/lockActionEvent"
|
||||
|
||||
#define mqtt_topic_config_action "/configuration/action"
|
||||
#define mqtt_topic_config_action_command_result "/configuration/commandResult"
|
||||
#define mqtt_topic_config_basic_json "/configuration/basicJson"
|
||||
#define mqtt_topic_config_advanced_json "/configuration/advancedJson"
|
||||
#define mqtt_topic_config_button_enabled "/configuration/buttonEnabled"
|
||||
#define mqtt_topic_config_led_enabled "/configuration/ledEnabled"
|
||||
#define mqtt_topic_config_led_brightness "/configuration/ledBrightness"
|
||||
#define mqtt_topic_config_auto_unlock "/configuration/autoUnlock"
|
||||
#define mqtt_topic_config_auto_lock "/configuration/autoLock"
|
||||
#define mqtt_topic_config_single_lock "/configuration/singleLock"
|
||||
#define mqtt_topic_config_sound_level "/configuration/soundLevel"
|
||||
#define mqtt_topic_config_action (char*)"/configuration/action"
|
||||
#define mqtt_topic_config_action_command_result (char*)"/configuration/commandResult"
|
||||
#define mqtt_topic_config_basic_json (char*)"/configuration/basicJson"
|
||||
#define mqtt_topic_config_advanced_json (char*)"/configuration/advancedJson"
|
||||
#define mqtt_topic_config_button_enabled (char*)"/configuration/buttonEnabled"
|
||||
#define mqtt_topic_config_led_enabled (char*)"/configuration/ledEnabled"
|
||||
#define mqtt_topic_config_led_brightness (char*)"/configuration/ledBrightness"
|
||||
#define mqtt_topic_config_auto_unlock (char*)"/configuration/autoUnlock"
|
||||
#define mqtt_topic_config_auto_lock (char*)"/configuration/autoLock"
|
||||
#define mqtt_topic_config_single_lock (char*)"/configuration/singleLock"
|
||||
#define mqtt_topic_config_sound_level (char*)"/configuration/soundLevel"
|
||||
|
||||
#define mqtt_topic_query_config "/query/config"
|
||||
#define mqtt_topic_query_lockstate "/query/lockstate"
|
||||
#define mqtt_topic_query_keypad "/query/keypad"
|
||||
#define mqtt_topic_query_battery "/query/battery"
|
||||
#define mqtt_topic_query_lockstate_command_result "/query/lockstateCommandResult"
|
||||
#define mqtt_topic_query_config (char*)"/query/config"
|
||||
#define mqtt_topic_query_lockstate (char*)"/query/lockstate"
|
||||
#define mqtt_topic_query_keypad (char*)"/query/keypad"
|
||||
#define mqtt_topic_query_battery (char*)"/query/battery"
|
||||
#define mqtt_topic_query_lockstate_command_result (char*)"/query/lockstateCommandResult"
|
||||
|
||||
#define mqtt_topic_battery_level "/battery/level"
|
||||
#define mqtt_topic_battery_critical "/battery/critical"
|
||||
#define mqtt_topic_battery_charging "/battery/charging"
|
||||
#define mqtt_topic_battery_voltage "/battery/voltage"
|
||||
#define mqtt_topic_battery_drain "/battery/drain"
|
||||
#define mqtt_topic_battery_max_turn_current "/battery/maxTurnCurrent"
|
||||
#define mqtt_topic_battery_lock_distance "/battery/lockDistance"
|
||||
#define mqtt_topic_battery_keypad_critical "/battery/keypadCritical"
|
||||
#define mqtt_topic_battery_doorsensor_critical "/battery/doorSensorCritical"
|
||||
#define mqtt_topic_battery_basic_json "/battery/basicJson"
|
||||
#define mqtt_topic_battery_advanced_json "/battery/advancedJson"
|
||||
#define mqtt_topic_battery_level (char*)"/battery/level"
|
||||
#define mqtt_topic_battery_critical (char*)"/battery/critical"
|
||||
#define mqtt_topic_battery_charging (char*)"/battery/charging"
|
||||
#define mqtt_topic_battery_voltage (char*)"/battery/voltage"
|
||||
#define mqtt_topic_battery_drain (char*)"/battery/drain"
|
||||
#define mqtt_topic_battery_max_turn_current (char*)"/battery/maxTurnCurrent"
|
||||
#define mqtt_topic_battery_lock_distance (char*)"/battery/lockDistance"
|
||||
#define mqtt_topic_battery_keypad_critical (char*)"/battery/keypadCritical"
|
||||
#define mqtt_topic_battery_doorsensor_critical (char*)"/battery/doorSensorCritical"
|
||||
#define mqtt_topic_battery_basic_json (char*)"/battery/basicJson"
|
||||
#define mqtt_topic_battery_advanced_json (char*)"/battery/advancedJson"
|
||||
|
||||
#define mqtt_topic_keypad "/keypad"
|
||||
#define mqtt_topic_keypad_codes "/keypad/codes"
|
||||
#define mqtt_topic_keypad_command_action "/keypad/command/action"
|
||||
#define mqtt_topic_keypad_command_id "/keypad/command/id"
|
||||
#define mqtt_topic_keypad_command_name "/keypad/command/name"
|
||||
#define mqtt_topic_keypad_command_code "/keypad/command/code"
|
||||
#define mqtt_topic_keypad_command_enabled "/keypad/command/enabled"
|
||||
#define mqtt_topic_keypad_command_result "/keypad/command/commandResult"
|
||||
#define mqtt_topic_keypad_json "/keypad/json"
|
||||
#define mqtt_topic_keypad_json_action "/keypad/actionJson"
|
||||
#define mqtt_topic_keypad_json_command_result "/keypad/commandResultJson"
|
||||
#define mqtt_topic_keypad (char*)"/keypad"
|
||||
#define mqtt_topic_keypad_codes (char*)"/keypad/codes"
|
||||
#define mqtt_topic_keypad_command_action (char*)"/keypad/command/action"
|
||||
#define mqtt_topic_keypad_command_id (char*)"/keypad/command/id"
|
||||
#define mqtt_topic_keypad_command_name (char*)"/keypad/command/name"
|
||||
#define mqtt_topic_keypad_command_code (char*)"/keypad/command/code"
|
||||
#define mqtt_topic_keypad_command_enabled (char*)"/keypad/command/enabled"
|
||||
#define mqtt_topic_keypad_command_result (char*)"/keypad/command/commandResult"
|
||||
#define mqtt_topic_keypad_json (char*)"/keypad/json"
|
||||
#define mqtt_topic_keypad_json_action (char*)"/keypad/actionJson"
|
||||
#define mqtt_topic_keypad_json_command_result (char*)"/keypad/commandResultJson"
|
||||
|
||||
#define mqtt_topic_timecontrol "/timecontrol"
|
||||
#define mqtt_topic_timecontrol_entries "/timecontrol/entries"
|
||||
#define mqtt_topic_timecontrol_json "/timecontrol/json"
|
||||
#define mqtt_topic_timecontrol_action "/timecontrol/action"
|
||||
#define mqtt_topic_timecontrol_command_result "/timecontrol/commandResult"
|
||||
#define mqtt_topic_timecontrol (char*)"/timecontrol"
|
||||
#define mqtt_topic_timecontrol_entries (char*)"/timecontrol/entries"
|
||||
#define mqtt_topic_timecontrol_json (char*)"/timecontrol/json"
|
||||
#define mqtt_topic_timecontrol_action (char*)"/timecontrol/action"
|
||||
#define mqtt_topic_timecontrol_command_result (char*)"/timecontrol/commandResult"
|
||||
|
||||
#define mqtt_topic_auth "/authorization"
|
||||
#define mqtt_topic_auth_entries "/authorization/entries"
|
||||
#define mqtt_topic_auth_json "/authorization/json"
|
||||
#define mqtt_topic_auth_action "/authorization/action"
|
||||
#define mqtt_topic_auth_command_result "/authorization/commandResult"
|
||||
#define mqtt_topic_auth (char*)"/authorization"
|
||||
#define mqtt_topic_auth_entries (char*)"/authorization/entries"
|
||||
#define mqtt_topic_auth_json (char*)"/authorization/json"
|
||||
#define mqtt_topic_auth_action (char*)"/authorization/action"
|
||||
#define mqtt_topic_auth_command_result (char*)"/authorization/commandResult"
|
||||
|
||||
#define mqtt_topic_info_hardware_version "/info/hardwareVersion"
|
||||
#define mqtt_topic_info_firmware_version "/info/firmwareVersion"
|
||||
#define mqtt_topic_info_nuki_hub_version "/info/nukiHubVersion"
|
||||
#define mqtt_topic_info_nuki_hub_build "/info/nukiHubBuild"
|
||||
#define mqtt_topic_info_nuki_hub_latest "/info/nukiHubLatest"
|
||||
#define mqtt_topic_info_nuki_hub_ip "/info/nukiHubIp"
|
||||
#define mqtt_topic_info_hardware_version (char*)"/info/hardwareVersion"
|
||||
#define mqtt_topic_info_firmware_version (char*)"/info/firmwareVersion"
|
||||
#define mqtt_topic_info_nuki_hub_version (char*)"/info/nukiHubVersion"
|
||||
#define mqtt_topic_info_nuki_hub_build (char*)"/info/nukiHubBuild"
|
||||
#define mqtt_topic_info_nuki_hub_latest (char*)"/info/nukiHubLatest"
|
||||
#define mqtt_topic_info_nuki_hub_ip (char*)"/info/nukiHubIp"
|
||||
|
||||
#define mqtt_topic_reset "/maintenance/reset"
|
||||
#define mqtt_topic_update "/maintenance/update"
|
||||
#define mqtt_topic_webserver_state "/maintenance/webserver/state"
|
||||
#define mqtt_topic_webserver_action "/maintenance/webserver/enable"
|
||||
#define mqtt_topic_uptime "/maintenance/uptime"
|
||||
#define mqtt_topic_wifi_rssi "/maintenance/wifiRssi"
|
||||
#define mqtt_topic_log "/maintenance/log"
|
||||
#define mqtt_topic_freeheap "/maintenance/freeHeap"
|
||||
#define mqtt_topic_restart_reason_fw "/maintenance/restartReasonNukiHub"
|
||||
#define mqtt_topic_restart_reason_esp "/maintenance/restartReasonNukiEsp"
|
||||
#define mqtt_topic_mqtt_connection_state "/maintenance/mqttConnectionState"
|
||||
#define mqtt_topic_network_device "/maintenance/networkDevice"
|
||||
#define mqtt_topic_hybrid_state "/hybridConnected"
|
||||
#define mqtt_topic_reset (char*)"/maintenance/reset"
|
||||
#define mqtt_topic_update (char*)(char*)"/maintenance/update"
|
||||
#define mqtt_topic_webserver_state (char*)"/maintenance/webserver/state"
|
||||
#define mqtt_topic_webserver_action (char*)"/maintenance/webserver/enable"
|
||||
#define mqtt_topic_uptime (char*)"/maintenance/uptime"
|
||||
#define mqtt_topic_wifi_rssi (char*)"/maintenance/wifiRssi"
|
||||
#define mqtt_topic_log (char*)"/maintenance/log"
|
||||
#define mqtt_topic_freeheap (char*)"/maintenance/freeHeap"
|
||||
#define mqtt_topic_restart_reason_fw (char*)"/maintenance/restartReasonNukiHub"
|
||||
#define mqtt_topic_restart_reason_esp (char*)"/maintenance/restartReasonNukiEsp"
|
||||
#define mqtt_topic_mqtt_connection_state (char*)"/maintenance/mqttConnectionState"
|
||||
#define mqtt_topic_network_device (char*)"/maintenance/networkDevice"
|
||||
#define mqtt_topic_hybrid_state (char*)"/hybridConnected"
|
||||
|
||||
#define mqtt_topic_gpio_prefix "/gpio"
|
||||
#define mqtt_topic_gpio_pin "/pin_"
|
||||
#define mqtt_topic_gpio_role "/role"
|
||||
#define mqtt_topic_gpio_state "/state"
|
||||
#define mqtt_topic_gpio_prefix (char*)"/gpio"
|
||||
#define mqtt_topic_gpio_pin (char*)"/pin_"
|
||||
#define mqtt_topic_gpio_role (char*)"/role"
|
||||
#define mqtt_topic_gpio_state (char*)"/state"
|
||||
|
||||
class MqttTopics
|
||||
{
|
||||
private:
|
||||
std::vector<char*> _keys =
|
||||
{
|
||||
mqtt_topic_lock_action, mqtt_topic_lock_status_updated, mqtt_topic_lock_state, mqtt_topic_lock_ha_state, mqtt_topic_lock_json, mqtt_topic_lock_binary_state,
|
||||
mqtt_topic_lock_continuous_mode, mqtt_topic_lock_ring, mqtt_topic_lock_binary_ring, mqtt_topic_lock_trigger, mqtt_topic_lock_last_lock_action, mqtt_topic_lock_log,
|
||||
mqtt_topic_lock_log_latest, mqtt_topic_lock_log_rolling, mqtt_topic_lock_log_rolling_last, mqtt_topic_lock_auth_id, mqtt_topic_lock_auth_name, mqtt_topic_lock_completionStatus,
|
||||
mqtt_topic_lock_action_command_result, mqtt_topic_lock_door_sensor_state, mqtt_topic_lock_rssi, mqtt_topic_lock_address, mqtt_topic_lock_retry, mqtt_topic_config_action,
|
||||
mqtt_topic_config_action_command_result, mqtt_topic_config_basic_json, mqtt_topic_config_advanced_json, mqtt_topic_config_button_enabled, mqtt_topic_config_led_enabled,
|
||||
mqtt_topic_config_led_brightness, mqtt_topic_config_auto_unlock, mqtt_topic_config_auto_lock, mqtt_topic_config_single_lock, mqtt_topic_config_sound_level,
|
||||
mqtt_topic_query_config, mqtt_topic_query_lockstate, mqtt_topic_query_keypad, mqtt_topic_query_battery, mqtt_topic_query_lockstate_command_result,
|
||||
mqtt_topic_battery_level, mqtt_topic_battery_critical, mqtt_topic_battery_charging, mqtt_topic_battery_voltage, mqtt_topic_battery_drain,
|
||||
mqtt_topic_battery_max_turn_current, mqtt_topic_battery_lock_distance, mqtt_topic_battery_keypad_critical, mqtt_topic_battery_doorsensor_critical,
|
||||
mqtt_topic_battery_basic_json,mqtt_topic_battery_advanced_json, mqtt_topic_keypad, mqtt_topic_keypad_codes, mqtt_topic_keypad_command_action,
|
||||
mqtt_topic_keypad_command_id, mqtt_topic_keypad_command_name, mqtt_topic_keypad_command_code, mqtt_topic_keypad_command_enabled, mqtt_topic_keypad_command_result,
|
||||
mqtt_topic_keypad_json, mqtt_topic_keypad_json_action, mqtt_topic_keypad_json_command_result, mqtt_topic_timecontrol, mqtt_topic_timecontrol_entries,
|
||||
mqtt_topic_timecontrol_json, mqtt_topic_timecontrol_action, mqtt_topic_timecontrol_command_result, mqtt_topic_auth, mqtt_topic_auth_entries,
|
||||
mqtt_topic_auth_json, mqtt_topic_auth_action, mqtt_topic_auth_command_result, mqtt_topic_info_hardware_version, mqtt_topic_info_firmware_version,
|
||||
mqtt_topic_info_nuki_hub_version, mqtt_topic_info_nuki_hub_build, mqtt_topic_info_nuki_hub_latest, mqtt_topic_info_nuki_hub_ip, mqtt_topic_reset,
|
||||
mqtt_topic_update, mqtt_topic_webserver_state, mqtt_topic_webserver_action, mqtt_topic_uptime, mqtt_topic_wifi_rssi, mqtt_topic_log, mqtt_topic_freeheap,
|
||||
mqtt_topic_restart_reason_fw, mqtt_topic_restart_reason_esp, mqtt_topic_mqtt_connection_state, mqtt_topic_network_device, mqtt_topic_hybrid_state
|
||||
};
|
||||
public:
|
||||
const std::vector<char*> getMqttTopics()
|
||||
{
|
||||
return _keys;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -141,10 +141,10 @@ void NukiNetwork::setupDevice()
|
||||
{
|
||||
onMqttDisconnect(reason);
|
||||
});
|
||||
|
||||
|
||||
_hadiscovery = new HomeAssistantDiscovery(_device, _preferences, _buffer, _bufferSize);
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
void NukiNetwork::reconfigureDevice()
|
||||
@@ -658,32 +658,90 @@ bool NukiNetwork::reconnect()
|
||||
delay(100);
|
||||
_device->mqttOnMessage(onMqttDataReceivedCallback);
|
||||
|
||||
initTopic(_maintenancePathPrefix, mqtt_topic_reset, "0");
|
||||
subscribe(_maintenancePathPrefix, mqtt_topic_reset);
|
||||
|
||||
if(_preferences->getBool(preference_update_from_mqtt, false))
|
||||
{
|
||||
initTopic(_maintenancePathPrefix, mqtt_topic_update, "0");
|
||||
subscribe(_maintenancePathPrefix, mqtt_topic_update);
|
||||
}
|
||||
|
||||
initTopic(_maintenancePathPrefix, mqtt_topic_webserver_action, "--");
|
||||
subscribe(_maintenancePathPrefix, mqtt_topic_webserver_action);
|
||||
initTopic(_maintenancePathPrefix, mqtt_topic_webserver_state, (_preferences->getBool(preference_webserver_enabled, true) || forceEnableWebServer ? "1" : "0"));
|
||||
|
||||
if(_firstConnect)
|
||||
{
|
||||
_firstConnect = false;
|
||||
|
||||
if(_preferences->getBool(preference_reset_mqtt_topics, false))
|
||||
{
|
||||
char mqttLockPath[181] = {0};
|
||||
char mqttOpenerPath[181] = {0};
|
||||
char mqttOldOpenerPath[181] = {0};
|
||||
char mqttOldOpenerPath2[181] = {0};
|
||||
String mqttPath = _preferences->getString(preference_mqtt_lock_path, "");
|
||||
mqttPath.concat("/lock");
|
||||
|
||||
size_t len = mqttPath.length();
|
||||
for(int i=0; i < len; i++)
|
||||
{
|
||||
mqttLockPath[i] = mqttPath.charAt(i);
|
||||
}
|
||||
|
||||
mqttPath = _preferences->getString(preference_mqtt_lock_path, "");
|
||||
mqttPath.concat("/opener");
|
||||
|
||||
len = mqttPath.length();
|
||||
for(int i=0; i < len; i++)
|
||||
{
|
||||
mqttOpenerPath[i] = mqttPath.charAt(i);
|
||||
}
|
||||
|
||||
mqttPath = _preferences->getString(preference_mqtt_opener_path, "");
|
||||
|
||||
len = mqttPath.length();
|
||||
for(int i=0; i < len; i++)
|
||||
{
|
||||
mqttOldOpenerPath[i] = mqttPath.charAt(i);
|
||||
}
|
||||
|
||||
mqttPath = _preferences->getString(preference_mqtt_opener_path, "");
|
||||
mqttPath.concat("/lock");
|
||||
|
||||
len = mqttPath.length();
|
||||
for(int i=0; i < len; i++)
|
||||
{
|
||||
mqttOldOpenerPath2[i] = mqttPath.charAt(i);
|
||||
}
|
||||
|
||||
MqttTopics mqttTopics;
|
||||
|
||||
const std::vector<char*> mqttTopicsKeys = mqttTopics.getMqttTopics();
|
||||
|
||||
for(const auto& topic : mqttTopicsKeys)
|
||||
{
|
||||
removeTopic(_maintenancePathPrefix, topic);
|
||||
removeTopic(mqttLockPath, topic);
|
||||
removeTopic(mqttOpenerPath, topic);
|
||||
removeTopic(mqttOldOpenerPath, topic);
|
||||
removeTopic(mqttOldOpenerPath2, topic);
|
||||
}
|
||||
|
||||
_preferences->putBool(preference_reset_mqtt_topics, false);
|
||||
}
|
||||
|
||||
publishString(_maintenancePathPrefix, mqtt_topic_network_device, _device->deviceName().c_str(), true);
|
||||
for(const auto& it : _initTopics)
|
||||
{
|
||||
publish(it.first.c_str(), it.second.c_str(), true);
|
||||
}
|
||||
|
||||
|
||||
if(_preferences->getBool(preference_mqtt_hass_enabled, false))
|
||||
{
|
||||
setupHASS(0, 0, {0}, {0}, {0}, false, false);
|
||||
}
|
||||
|
||||
initTopic(_maintenancePathPrefix, mqtt_topic_reset, "0");
|
||||
subscribe(_maintenancePathPrefix, mqtt_topic_reset);
|
||||
|
||||
if(_preferences->getBool(preference_update_from_mqtt, false))
|
||||
{
|
||||
initTopic(_maintenancePathPrefix, mqtt_topic_update, "0");
|
||||
subscribe(_maintenancePathPrefix, mqtt_topic_update);
|
||||
}
|
||||
|
||||
initTopic(_maintenancePathPrefix, mqtt_topic_webserver_action, "--");
|
||||
subscribe(_maintenancePathPrefix, mqtt_topic_webserver_action);
|
||||
initTopic(_maintenancePathPrefix, mqtt_topic_webserver_state, (_preferences->getBool(preference_webserver_enabled, true) || forceEnableWebServer ? "1" : "0"));
|
||||
}
|
||||
|
||||
for(const String& topic : _subscribedTopics)
|
||||
|
||||
@@ -125,6 +125,7 @@
|
||||
#define preference_opener_max_timecontrol_entry_count (char*)"opmaxtc"
|
||||
#define preference_latest_version (char*)"latest"
|
||||
#define preference_wifi_converted (char*)"wifiConv"
|
||||
#define preference_reset_mqtt_topics (char*)"rstMqtt"
|
||||
|
||||
//OBSOLETE
|
||||
#define preference_access_level (char*)"accLvl"
|
||||
@@ -132,6 +133,7 @@
|
||||
#define preference_network_hardware_gpio (char*)"nwhwdt"
|
||||
#define preference_presence_detection_timeout (char*)"prdtimeout"
|
||||
#define preference_network_wifi_fallback_disabled (char*)"nwwififb"
|
||||
#define preference_mqtt_opener_path (char*)"mqttoppath"
|
||||
|
||||
inline void initPreferences(Preferences* preferences)
|
||||
{
|
||||
@@ -203,7 +205,7 @@ inline void initPreferences(Preferences* preferences)
|
||||
#ifndef CONFIG_IDF_TARGET_ESP32H2
|
||||
WiFi.begin();
|
||||
WiFi.disconnect(true, true);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -315,6 +317,7 @@ inline void initPreferences(Preferences* preferences)
|
||||
}
|
||||
}
|
||||
|
||||
preferences->putBool(preference_reset_mqtt_topics, true);
|
||||
preferences->putInt(preference_config_version, atof(NUKI_HUB_VERSION) * 100);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user