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

Fix: SBS battery: use Batteries::Stats setCurrent #1644

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions include/battery/sbs/Stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ friend class Provider;
public:
void getLiveViewData(JsonVariant& root) const final;
void mqttPublish() const final;
float getChargeCurrent() const { return _current; } ;
float getChargeCurrentLimitation() const { return _chargeCurrentLimitation; } ;

private:
Expand All @@ -20,7 +19,6 @@ friend class Provider;
float _chargeVoltage;
float _chargeCurrentLimitation;
uint16_t _stateOfHealth;
float _current;
float _temperature;

bool _alarmUnderTemperature;
Expand Down
6 changes: 3 additions & 3 deletions src/battery/sbs/Provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ void Provider::onMessage(twai_message_t rx_message)
switch (rx_message.identifier) {
case 0x610: {
_stats->setVoltage(this->readUnsignedInt16(rx_message.data)* 0.001, millis());
_stats->_current =(this->readSignedInt16(rx_message.data + 3)) * 0.001;
_stats->setCurrent(this->readSignedInt16(rx_message.data + 3) * 0.001, 2/*precision*/, millis());
_stats->setSoC(static_cast<float>(this->readUnsignedInt16(rx_message.data + 6)), 1, millis());

if (_verboseLogging) {
MessageOutput.printf("[SBS Unipower] 1552 SoC: %f Voltage: %f Current: %f\r\n", _stats->getSoC(), _stats->getVoltage(), _stats->_current);
MessageOutput.printf("[SBS Unipower] 1552 SoC: %f Voltage: %f Current: %f\r\n", _stats->getSoC(), _stats->getVoltage(), _stats->getChargeCurrent());
}
break;
}
Expand Down Expand Up @@ -152,7 +152,7 @@ void Provider::dummyData()
_stats->setDischargeCurrentLimit(dummyFloat(12), millis());
_stats->_stateOfHealth = 99;
_stats->setVoltage(48.67, millis());
_stats->_current = dummyFloat(-1);
_stats->setCurrent(dummyFloat(-1), 2/*precision*/, millis());
_stats->_temperature = dummyFloat(20);

_stats->_chargeEnabled = true;
Expand Down
2 changes: 0 additions & 2 deletions src/battery/sbs/Stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ void Stats::getLiveViewData(JsonVariant& root) const
addLiveViewValue(root, "chargeVoltage", _chargeVoltage, "V", 1);
addLiveViewValue(root, "chargeCurrentLimitation", _chargeCurrentLimitation, "A", 1);
addLiveViewValue(root, "stateOfHealth", _stateOfHealth, "%", 0);
addLiveViewValue(root, "current", _current, "A", 1);
addLiveViewValue(root, "temperature", _temperature, "°C", 1);
addLiveViewTextValue(root, "chargeEnabled", (_chargeEnabled?"yes":"no"));
addLiveViewTextValue(root, "dischargeEnabled", (_dischargeEnabled?"yes":"no"));
Expand All @@ -34,7 +33,6 @@ void Stats::mqttPublish() const
MqttSettings.publish("battery/settings/chargeVoltage", String(_chargeVoltage));
MqttSettings.publish("battery/settings/chargeCurrentLimitation", String(_chargeCurrentLimitation));
MqttSettings.publish("battery/stateOfHealth", String(_stateOfHealth));
MqttSettings.publish("battery/current", String(_current));
MqttSettings.publish("battery/temperature", String(_temperature));
MqttSettings.publish("battery/alarm/underVoltage", String(_alarmUnderVoltage));
MqttSettings.publish("battery/alarm/overVoltage", String(_alarmOverVoltage));
Expand Down