Clear HA config in next config version

This commit is contained in:
Gunnar Skjold
2023-04-01 08:02:12 +02:00
parent 799c2f19d9
commit 4947f0ec7f
2 changed files with 5 additions and 4 deletions

View File

@@ -154,7 +154,6 @@ struct DomoticzConfig {
}; // 10 }; // 10
struct HomeAssistantConfig { struct HomeAssistantConfig {
uint8_t tag; // Just to find out if we have this config already. Can be removed in v2.3
char discoveryPrefix[64]; char discoveryPrefix[64];
char discoveryHostname[64]; char discoveryHostname[64];
char discoveryNameTag[16]; char discoveryNameTag[16];
@@ -315,7 +314,7 @@ private:
bool relocateConfig96(); // 2.1.14 bool relocateConfig96(); // 2.1.14
bool relocateConfig100(); // 2.2-dev bool relocateConfig100(); // 2.2-dev
bool relocateConfig101(); // 2.2.0 through 2.2.8 bool relocateConfig101(); // 2.2.0 through 2.2.8
bool relocateConfig102(); // 2.2.9 bool relocateConfig102(); // 2.2.9 through 2.2.11
void saveToFs(); void saveToFs();
bool loadFromFs(uint8_t version); bool loadFromFs(uint8_t version);

View File

@@ -336,7 +336,6 @@ bool AmsConfiguration::getHomeAssistantConfig(HomeAssistantConfig& config) {
if(hasConfig()) { if(hasConfig()) {
EEPROM.begin(EEPROM_SIZE); EEPROM.begin(EEPROM_SIZE);
EEPROM.get(CONFIG_HA_START, config); EEPROM.get(CONFIG_HA_START, config);
if(config.tag != 0xA7) clearHomeAssistantConfig(config);
EEPROM.end(); EEPROM.end();
return true; return true;
} else { } else {
@@ -367,7 +366,6 @@ bool AmsConfiguration::setHomeAssistantConfig(HomeAssistantConfig& config) {
} }
void AmsConfiguration::clearHomeAssistantConfig(HomeAssistantConfig& config) { void AmsConfiguration::clearHomeAssistantConfig(HomeAssistantConfig& config) {
config.tag = 0xA7;
strcpy(config.discoveryPrefix, ""); strcpy(config.discoveryPrefix, "");
strcpy(config.discoveryHostname, ""); strcpy(config.discoveryHostname, "");
strcpy(config.discoveryNameTag, ""); strcpy(config.discoveryNameTag, "");
@@ -1035,6 +1033,10 @@ bool AmsConfiguration::relocateConfig102() {
gpioConfig.hanPinPullup = true; gpioConfig.hanPinPullup = true;
EEPROM.put(CONFIG_GPIO_START, gpioConfig); EEPROM.put(CONFIG_GPIO_START, gpioConfig);
HomeAssistantConfig haconf;
clearHomeAssistantConfig(haconf);
EEPROM.put(CONFIG_HA_START, haconf);
EEPROM.put(EEPROM_CONFIG_ADDRESS, 103); EEPROM.put(EEPROM_CONFIG_ADDRESS, 103);
bool ret = EEPROM.commit(); bool ret = EEPROM.commit();
EEPROM.end(); EEPROM.end();