diff --git a/include/Configuration.h b/include/Configuration.h index 97f0725c8..aac192836 100644 --- a/include/Configuration.h +++ b/include/Configuration.h @@ -196,10 +196,12 @@ struct BATTERY_CONFIG_T { }; using BatteryConfig = struct BATTERY_CONFIG_T; +enum SolarChargerProviderType { VEDIRECT = 0 }; + struct SOLAR_CHARGER_CONFIG_T { bool Enabled; bool VerboseLogging; - uint8_t Provider; + SolarChargerProviderType Provider; bool PublishUpdatesOnly; }; using SolarChargerConfig = struct SOLAR_CHARGER_CONFIG_T; diff --git a/include/SolarChargerProvider.h b/include/SolarChargerProvider.h index d75846321..77321412b 100644 --- a/include/SolarChargerProvider.h +++ b/include/SolarChargerProvider.h @@ -5,10 +5,6 @@ class SolarChargerProvider { public: - enum class Type : unsigned { - VEDIRECT = 0 - }; - // returns true if the provider is ready for use, false otherwise virtual bool init(bool verboseLogging) = 0; virtual void deinit() = 0; diff --git a/include/defaults.h b/include/defaults.h index bf9613552..238ae9aa0 100644 --- a/include/defaults.h +++ b/include/defaults.h @@ -117,7 +117,6 @@ // values specific to downstream project OpenDTU-OnBattery start here: #define SOLAR_CHARGER_ENABLED false #define SOLAR_CHARGER_VERBOSE_LOGGING false -#define SOLAR_CHARGER_PROVIDER 0 // Victron MPPT(s) via VE.Direct #define SOLAR_CHARGER_PUBLISH_UPDATES_ONLY true #define POWERMETER_ENABLED false diff --git a/src/Configuration.cpp b/src/Configuration.cpp index 3b1f8d565..57d6612d1 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -374,7 +374,7 @@ void ConfigurationClass::deserializeSolarChargerConfig(JsonObject const& source, { target.Enabled = source["enabled"] | SOLAR_CHARGER_ENABLED; target.VerboseLogging = source["verbose_logging"] | VERBOSE_LOGGING; - target.Provider = source["provider"] | SOLAR_CHARGER_PROVIDER; + target.Provider = source["provider"] | SolarChargerProviderType::VEDIRECT; target.PublishUpdatesOnly = source["publish_updates_only"] | SOLAR_CHARGER_PUBLISH_UPDATES_ONLY; } diff --git a/src/MqttHandleVedirect.cpp b/src/MqttHandleVedirect.cpp index 6dd52ae7b..158308f43 100644 --- a/src/MqttHandleVedirect.cpp +++ b/src/MqttHandleVedirect.cpp @@ -36,7 +36,7 @@ void MqttHandleVedirectClass::loop() auto const& config = Configuration.get(); if (!MqttSettings.getConnected() || !config.SolarCharger.Enabled - || static_cast(config.SolarCharger.Provider) != SolarChargerProvider::Type::VEDIRECT) { + || config.SolarCharger.Provider != SolarChargerProviderType::VEDIRECT) { return; } diff --git a/src/MqttHandleVedirectHass.cpp b/src/MqttHandleVedirectHass.cpp index e8d6944a8..299ab3b31 100644 --- a/src/MqttHandleVedirectHass.cpp +++ b/src/MqttHandleVedirectHass.cpp @@ -27,7 +27,7 @@ void MqttHandleVedirectHassClass::loop() { if (!Configuration.get().Mqtt.Hass.Enabled || !Configuration.get().SolarCharger.Enabled - || static_cast(Configuration.get().SolarCharger.Provider) != SolarChargerProvider::Type::VEDIRECT) { + || Configuration.get().SolarCharger.Provider != SolarChargerProviderType::VEDIRECT) { return; } diff --git a/src/SolarCharger.cpp b/src/SolarCharger.cpp index 43255d97a..ba2a56945 100644 --- a/src/SolarCharger.cpp +++ b/src/SolarCharger.cpp @@ -30,8 +30,8 @@ void SolarChargerClass::updateSettings() bool verboseLogging = config.SolarCharger.VerboseLogging; - switch (static_cast(config.SolarCharger.Provider)) { - case SolarChargerProvider::Type::VEDIRECT: + switch (config.SolarCharger.Provider) { + case SolarChargerProviderType::VEDIRECT: _upProvider = std::make_unique(); break; default: