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 Jan 2, 2025
1 parent 57240c2 commit 8650de4
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 13 deletions.
4 changes: 3 additions & 1 deletion include/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,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 @@ -375,7 +375,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
3 changes: 1 addition & 2 deletions src/MqttHandleVedirect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "MqttHandleVedirect.h"
#include "MqttSettings.h"
#include "MessageOutput.h"
#include "SolarChargerProvider.h"
#include "SolarCharger.h"

MqttHandleVedirectClass MqttHandleVedirect;
Expand Down Expand Up @@ -36,7 +35,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
3 changes: 1 addition & 2 deletions src/MqttHandleVedirectHass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "MqttHandleHass.h"
#include "NetworkSettings.h"
#include "MessageOutput.h"
#include "SolarChargerProvider.h"
#include "Utils.h"
#include "__compiled_constants.h"
#include "SolarCharger.h"
Expand All @@ -27,7 +26,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 8650de4

Please sign in to comment.