Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasBoehm committed Jan 15, 2025
1 parent 5fe9813 commit e447c6b
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 16 deletions.
1 change: 0 additions & 1 deletion include/solarcharger/Controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <TaskSchedulerDeclarations.h>
#include <solarcharger/Provider.h>
#include <solarcharger/Stats.h>
#include <VeDirectMpptController.h>

namespace SolarChargers {

Expand Down
1 change: 0 additions & 1 deletion include/solarcharger/HassIntegration.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#pragma once

#include <Arduino.h>
#include <ArduinoJson.h>

namespace SolarChargers {

Expand Down
2 changes: 0 additions & 2 deletions include/solarcharger/Provider.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

#include <VeDirectMpptController.h>

namespace SolarChargers {

class Stats;
Expand Down
3 changes: 0 additions & 3 deletions include/solarcharger/victron/Provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
#include <mutex>
#include <memory>
#include <TaskSchedulerDeclarations.h>

#include <Configuration.h>
#include <solarcharger/Provider.h>
#include <solarcharger/victron/HassIntegration.h>
#include <solarcharger/victron/Stats.h>
#include <VeDirectMpptController.h>

Expand Down
2 changes: 1 addition & 1 deletion include/solarcharger/victron/Stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Stats : public ::SolarChargers::Stats {

void populateJsonWithInstanceStats(const JsonObject &root, const VeDirectMpptController::data_t &mpptData) const;

void publish_mppt_data(const VeDirectMpptController::data_t &mpptData, const VeDirectMpptController::data_t &frame) const;
void publishMpptData(const VeDirectMpptController::data_t &mpptData, const VeDirectMpptController::data_t &frame) const;
};

} // namespace SolarChargers::Victron
1 change: 0 additions & 1 deletion src/PowerLimiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ float PowerLimiterClass::getBatteryVoltage(bool log) {
float chargeControllerVoltage = -1;

auto chargerOutputVoltage = SolarCharger.getStats()->getOutputVoltage();

if (chargerOutputVoltage) {
res = chargeControllerVoltage = *chargerOutputVoltage;
}
Expand Down
4 changes: 1 addition & 3 deletions src/solarcharger/victron/HassIntegration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
#include "Configuration.h"
#include "MqttSettings.h"
#include "MqttHandleHass.h"
#include "NetworkSettings.h"
#include "MessageOutput.h"
#include "Utils.h"
#include "__compiled_constants.h"
#include <solarcharger/Controller.h>
#include <solarcharger/victron/HassIntegration.h>

namespace SolarChargers::Victron {
Expand Down Expand Up @@ -131,6 +128,7 @@ void HassIntegration::publishSensor(const char *caption, const char *icon, const
publish(configTopic, buffer);

}

void HassIntegration::publishBinarySensor(const char *caption, const char *icon, const char *subTopic,
const char *payload_on, const char *payload_off,
const VeDirectMpptController::data_t &mpptData) const
Expand Down
10 changes: 6 additions & 4 deletions src/solarcharger/victron/Stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ uint32_t Stats::getAgeMillis() const

std::optional<int32_t> Stats::getOutputPowerWatts() const
{
int32_t sum = -1;
int32_t sum = 0;
auto data = false;

for (auto const& entry : _data) {
if (!entry.second) { continue; }
data = true;
sum += entry.second->batteryOutputPower_W;
}

if (sum == -1) { return std::nullopt; }
if (!data) { return std::nullopt; }

return sum;
}
Expand Down Expand Up @@ -263,7 +265,7 @@ void Stats::mqttPublish() const
if (!currentData) { continue; }

auto const& previousData = _previousData[entry.first];
publish_mppt_data(*currentData, previousData);
publishMpptData(*currentData, previousData);

if (!_PublishFull) {
_previousData[entry.first] = *currentData;
Expand All @@ -288,7 +290,7 @@ void Stats::mqttPublish() const
}
}

void Stats::publish_mppt_data(const VeDirectMpptController::data_t &currentData, const VeDirectMpptController::data_t &previousData) const {
void Stats::publishMpptData(const VeDirectMpptController::data_t &currentData, const VeDirectMpptController::data_t &previousData) const {
String value;
String topic = "victron/";
topic.concat(currentData.serialNr_SER);
Expand Down

0 comments on commit e447c6b

Please sign in to comment.