Use fnv1a_hash_extend with config_hash and version for wifi preferences

Change wifi component to use fnv1a_hash_extend(config_hash, ESPHOME_VERSION)
instead of fnv1_hash(compilation_time) for the preferences hash.

This ensures wifi settings are invalidated on config or version changes,
not just on recompilation.
This commit is contained in:
David Woodhouse
2025-12-16 00:05:43 +00:00
parent 69fa5020d2
commit f231fc856b

View File

@@ -28,6 +28,7 @@
#include "esphome/core/helpers.h"
#include "esphome/core/log.h"
#include "esphome/core/util.h"
#include "esphome/core/version.h"
#ifdef USE_CAPTIVE_PORTAL
#include "esphome/components/captive_portal/captive_portal.h"
@@ -375,7 +376,7 @@ void WiFiComponent::start() {
get_mac_address_pretty_into_buffer(mac_s));
this->last_connected_ = millis();
uint32_t hash = this->has_sta() ? fnv1_hash(App.get_compilation_time_ref().c_str()) : 88491487UL;
uint32_t hash = this->has_sta() ? fnv1a_hash_extend(App.get_config_hash(), ESPHOME_VERSION) : 88491487UL;
this->pref_ = global_preferences->make_preference<wifi::SavedWifiSettings>(hash, true);
#ifdef USE_WIFI_FAST_CONNECT