Skip to content

Commit

Permalink
system: Reschedule mqtt auto discovery when language changes
Browse files Browse the repository at this point in the history
  • Loading branch information
borg42 committed Nov 25, 2024
1 parent b47ee63 commit 2dbafb7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions software/src/modules/system/module.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ Requires = Task Scheduler
Optional = Evse Common
Users
Charge Tracker
Mqtt Auto Discovery
12 changes: 11 additions & 1 deletion software/src/modules/system/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,17 @@ void System::pre_setup()
i18n_config = ConfigRoot{Config::Object({
{"language", Config::Enum(Language::German, Language::German, Language::English)},
{"detect_browser_language", Config::Bool(true)}
})};
})
#if MODULE_MQTT_AUTO_DISCOVERY_AVAILABLE()
, [this](Config &update, ConfigSource source) -> String {
if (update.get("language")->asEnum<Language>() != i18n_config.get("language")->asEnum<Language>()) {
mqtt_auto_discovery.reschedule_announce_next_topic();
}

return "";
}
#endif
};
}

void System::setup()
Expand Down

0 comments on commit 2dbafb7

Please sign in to comment.