Skip to content

Commit

Permalink
use 'SolarChargerProviderType' in Configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasBoehm committed Dec 7, 2024
1 parent afcbc95 commit f61f456
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 11 deletions.
4 changes: 3 additions & 1 deletion include/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions include/SolarChargerProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion include/defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/MqttHandleVedirect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void MqttHandleVedirectClass::loop()
auto const& config = Configuration.get();
if (!MqttSettings.getConnected()
|| !config.SolarCharger.Enabled
|| static_cast<SolarChargerProvider::Type>(config.SolarCharger.Provider) != SolarChargerProvider::Type::VEDIRECT) {
|| config.SolarCharger.Provider != SolarChargerProviderType::VEDIRECT) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/MqttHandleVedirectHass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void MqttHandleVedirectHassClass::loop()
{
if (!Configuration.get().Mqtt.Hass.Enabled
|| !Configuration.get().SolarCharger.Enabled
|| static_cast<SolarChargerProvider::Type>(Configuration.get().SolarCharger.Provider) != SolarChargerProvider::Type::VEDIRECT) {
|| Configuration.get().SolarCharger.Provider != SolarChargerProviderType::VEDIRECT) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/SolarCharger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ void SolarChargerClass::updateSettings()

bool verboseLogging = config.SolarCharger.VerboseLogging;

switch (static_cast<SolarChargerProvider::Type>(config.SolarCharger.Provider)) {
case SolarChargerProvider::Type::VEDIRECT:
switch (config.SolarCharger.Provider) {
case SolarChargerProviderType::VEDIRECT:
_upProvider = std::make_unique<VictronMppt>();
break;
default:
Expand Down

0 comments on commit f61f456

Please sign in to comment.