-
Notifications
You must be signed in to change notification settings - Fork 67
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
Restructure solarcharger classes #1457
base: development
Are you sure you want to change the base?
Restructure solarcharger classes #1457
Conversation
d4d9737
to
d11be3b
Compare
e23be05
to
983abde
Compare
d11be3b
to
a3d0408
Compare
08e5b9a
to
635a450
Compare
5723f4e
to
b630fb9
Compare
|
||
void MqttHandleVedirectHassClass::init(Scheduler& scheduler) | ||
void HassIntegration::publishSensors() const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@schlimmchen because we need details about the individual charge controller it might make sense to move this into Stats
instead of having this separated. what do you think?
I did set this up separately, following your battery restructure, but for the batteries you don't need any data from the battery itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure that I can follow all the way... This is what I can say:
- As this class is specific to Victron charge controllers, I don't feel too bad having to ask for a Victron charge controller data structure here. So, I guess the method is fine here.
- Passing a
std::optional<VeDirectMpptController::data_t>
around, even as a reference, to only use the serial number from it (if I see it correctly), is not a good idea. You might be able to de-couple thepublishSensor()
method into the base class if you instead pass a serial number as a string. - This whole setup is... questionable. What I mean is conditionally publishing the info for HA auto-discovery. What if this method is only executed before the first data is received from the charge controller? It is not executed periodically, for sure, but only once after reboot and when reconnecting to the MQTT broker (right?). So, this method would not even need a
std::optional<VeDirectMpptController::data_t>
but only the serial number if we published all sensors unconditionally. My hope is that HA is fine with published sensors that don't have a value at the respective MQTT topic. ChatGPT says the sensor is still created and visible and so one, but its value will "forever" read "unknown". Meh... So we have to deal with this and publish the sensors conditionally, which means we should also revisit this method regularly?
8f5e560
to
d5775dc
Compare
// TODO(andreasboehm): _data and _lastUpdate in two different structures is not ideal and needs to change | ||
mutable std::map<String, std::optional<VeDirectMpptController::data_t>> _data; | ||
mutable std::map<String, uint32_t> _lastUpdate; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@schlimmchen any ideas without duplicating all data found in data_t
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep using a copy. This is a direct copy of _tmpFrame
of VeDirectFrameHandler
, isn't it? It is good that we keep at leas one immutable copy of the data around. VeDirectFrameHandler
is messing with it's _tmpFrame
in-situ...
BTW: In the long run I see DataPoints being used instead.
4811e65
to
9e73fcc
Compare
9ce82e7
to
bf3d3f8
Compare
did not touch 'MqttHandleVedirect'. will be done in a stats realted branch/PR fix includes
bf3d3f8
to
585d262
Compare
Based on the structure that @schlimmchen introduced here: #1451
I did not touch 'MqttHandleVedirect'. will be done in a stats related branch/PR.