diff --git a/include/solarcharger/Controller.h b/include/solarcharger/Controller.h index 7453203b5..dc3f37e9a 100644 --- a/include/solarcharger/Controller.h +++ b/include/solarcharger/Controller.h @@ -6,7 +6,6 @@ #include #include #include -#include namespace SolarChargers { diff --git a/include/solarcharger/HassIntegration.h b/include/solarcharger/HassIntegration.h index fc712b775..7f1a3014c 100644 --- a/include/solarcharger/HassIntegration.h +++ b/include/solarcharger/HassIntegration.h @@ -2,7 +2,6 @@ #pragma once #include -#include namespace SolarChargers { diff --git a/include/solarcharger/Provider.h b/include/solarcharger/Provider.h index 3fcd3de16..8428b7d95 100644 --- a/include/solarcharger/Provider.h +++ b/include/solarcharger/Provider.h @@ -1,8 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later #pragma once -#include - namespace SolarChargers { class Stats; diff --git a/include/solarcharger/victron/Provider.h b/include/solarcharger/victron/Provider.h index 8d3fc8e93..6d4c507c8 100644 --- a/include/solarcharger/victron/Provider.h +++ b/include/solarcharger/victron/Provider.h @@ -4,10 +4,7 @@ #include #include #include - -#include #include -#include #include #include diff --git a/include/solarcharger/victron/Stats.h b/include/solarcharger/victron/Stats.h index e52cd876d..cb4750c6e 100644 --- a/include/solarcharger/victron/Stats.h +++ b/include/solarcharger/victron/Stats.h @@ -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 diff --git a/src/PowerLimiter.cpp b/src/PowerLimiter.cpp index 35e9d6558..1fd6f8932 100644 --- a/src/PowerLimiter.cpp +++ b/src/PowerLimiter.cpp @@ -377,7 +377,6 @@ float PowerLimiterClass::getBatteryVoltage(bool log) { float chargeControllerVoltage = -1; auto chargerOutputVoltage = SolarCharger.getStats()->getOutputVoltage(); - if (chargerOutputVoltage) { res = chargeControllerVoltage = *chargerOutputVoltage; } diff --git a/src/solarcharger/victron/HassIntegration.cpp b/src/solarcharger/victron/HassIntegration.cpp index 7af0f127c..55e2dedaa 100644 --- a/src/solarcharger/victron/HassIntegration.cpp +++ b/src/solarcharger/victron/HassIntegration.cpp @@ -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 #include namespace SolarChargers::Victron { @@ -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 diff --git a/src/solarcharger/victron/Stats.cpp b/src/solarcharger/victron/Stats.cpp index 9990a6db2..c50f9805f 100644 --- a/src/solarcharger/victron/Stats.cpp +++ b/src/solarcharger/victron/Stats.cpp @@ -34,14 +34,16 @@ uint32_t Stats::getAgeMillis() const std::optional 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; } @@ -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; @@ -288,7 +290,7 @@ void Stats::mqttPublish() const } } -void Stats::publish_mppt_data(const VeDirectMpptController::data_t ¤tData, const VeDirectMpptController::data_t &previousData) const { +void Stats::publishMpptData(const VeDirectMpptController::data_t ¤tData, const VeDirectMpptController::data_t &previousData) const { String value; String topic = "victron/"; topic.concat(currentData.serialNr_SER);