Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize VE.Direct to SolarCharger #1442

Draft
wants to merge 13 commits into
base: development
Choose a base branch
from

Conversation

schlimmchen
Copy link
Member

This is @AndreasBoehm's work to start generalizing the VE.Direct implementation into an abstract solar charger, which allows to later add a different provider/implementation (MQTT) retrieving info related to the solar charger in a system.

Copy link
Member Author

@schlimmchen schlimmchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a solid start 💪

LOL, I can't check "request changes" as I created the PR myself. Well...

include/SolarChargerProvider.h Outdated Show resolved Hide resolved
Comment on lines 24 to 23
uint32_t getDataAgeMillis() const;
uint32_t getDataAgeMillis(size_t idx) const;
uint32_t getDataAgeMillis() final;
uint32_t getDataAgeMillis(size_t idx) final;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You removed the const from all these functions. I guess that is an oversight? final does not imply const. Please make all functions const in the interface that were const before. This diff should only add the "final" keyword.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops.. fixed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The respective functions should be const in SolarChargerClass as well.

include/VictronMppt.h Show resolved Hide resolved
include/VictronMppt.h Show resolved Hide resolved
include/defaults.h Outdated Show resolved Hide resolved
src/main.cpp Outdated Show resolved Hide resolved
src/main.cpp Outdated Show resolved Hide resolved
webapp/src/locales/de.json Outdated Show resolved Hide resolved
webapp/src/locales/en.json Outdated Show resolved Hide resolved
Comment on lines 15 to 38
// TODO(andreasboehm): below methods are taken from VictronMppt to start abstracting
// solar chargers without breaking everything.
size_t controllerAmount();
uint32_t getDataAgeMillis();
uint32_t getDataAgeMillis(size_t idx);

// total output of all MPPT charge controllers in Watts
int32_t getPowerOutputWatts();

// total panel input power of all MPPT charge controllers in Watts
int32_t getPanelPowerWatts();

// sum of total yield of all MPPT charge controllers in kWh
float getYieldTotal();

// sum of today's yield of all MPPT charge controllers in kWh
float getYieldDay();

// minimum of all MPPT charge controllers' output voltages in V
float getOutputVoltage();

std::optional<VeDirectMpptController::data_t> getData(size_t idx = 0);

bool isDataValid();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess, for starters, we should only have these in the interface, and hand out a (const?) reference to the current provider. Once we know the functions that will actually be available in SolarChargerClass, we'll make them available here directly. Example: Yield values will not be implemented by the MQTT provider (in my opinion), so the respective getters will not be available. But getPanelPowerWatts() and getPowerOutputWatts() will be, but one std::optional<>, I guess? We'll have to figure it out later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am currently working on figuring out which values will be general values (e.g. panelPowerWatts) and which are implementation specific (e.g. yieldTotal).

I planned to hand out a ref to the current provider to allow the vedirect mqtt handling to keep working as it its right now and provide 'stats' like we do for the batteries for all other use-cases.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where will we be doing MQTT publishing and HASS auto-discovery? in the battery context, that's done by the stats, isn't it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is true. The issue that i see is that the MQTT topics are tied to 'vedirect' because they also include that name. But we could deprecate them and provide replacements.

@AndreasBoehm AndreasBoehm force-pushed the rename-vedirect-to-solarcharger branch 3 times, most recently from dcd578e to cad70b1 Compare December 7, 2024 17:26
@AndreasBoehm AndreasBoehm force-pushed the rename-vedirect-to-solarcharger branch from cad70b1 to 8c0ecbc Compare December 7, 2024 19:58
src/VictronMppt.cpp Outdated Show resolved Hide resolved
src/VictronMppt.cpp Outdated Show resolved Hide resolved
@AndreasBoehm AndreasBoehm force-pushed the rename-vedirect-to-solarcharger branch from 8c0ecbc to afcbc95 Compare December 7, 2024 21:36
@AndreasBoehm AndreasBoehm force-pushed the rename-vedirect-to-solarcharger branch from f61f456 to f43b7a5 Compare December 7, 2024 22:03
@AndreasBoehm AndreasBoehm marked this pull request as draft December 13, 2024 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants