diff --git a/include/BatteryStats.h b/include/BatteryStats.h index a7eea2f97..b0d537619 100644 --- a/include/BatteryStats.h +++ b/include/BatteryStats.h @@ -183,6 +183,7 @@ class PytesBatteryStats : public BatteryStats { public: void getLiveViewData(JsonVariant& root) const final; void mqttPublish() const final; + bool getImmediateChargingRequest() const { return _chargeImmediately; }; float getChargeCurrentLimitation() const { return _chargeCurrentLimit; }; private: @@ -247,6 +248,8 @@ class PytesBatteryStats : public BatteryStats { bool _warningHighTemperatureCharge; bool _warningInternalFailure; bool _warningCellImbalance; + + bool _chargeImmediately; }; class JkBmsBatteryStats : public BatteryStats { diff --git a/src/BatteryStats.cpp b/src/BatteryStats.cpp index 500fb497f..84dc550b8 100644 --- a/src/BatteryStats.cpp +++ b/src/BatteryStats.cpp @@ -201,6 +201,7 @@ void PytesBatteryStats::getLiveViewData(JsonVariant& root) const if (_dischargedEnergy != -1) { addLiveViewValue(root, "dischargedEnergy", _dischargedEnergy, "kWh", 1); } + addLiveViewTextValue(root, "chargeImmediately", (_chargeImmediately?"yes":"no")); addLiveViewInSection(root, "cells", "cellMinVoltage", static_cast(_cellMinMilliVolt)/1000, "V", 3); addLiveViewInSection(root, "cells", "cellMaxVoltage", static_cast(_cellMaxMilliVolt)/1000, "V", 3); @@ -482,6 +483,8 @@ void PytesBatteryStats::mqttPublish() const MqttSettings.publish("battery/warning/highTemperatureCharge", String(_warningHighTemperatureCharge)); MqttSettings.publish("battery/warning/bmsInternal", String(_warningInternalFailure)); MqttSettings.publish("battery/warning/cellImbalance", String(_warningCellImbalance)); + + MqttSettings.publish("battery/charging/chargeImmediately", String(_chargeImmediately)); } void JkBmsBatteryStats::mqttPublish() const diff --git a/src/MqttHandleBatteryHass.cpp b/src/MqttHandleBatteryHass.cpp index 89327b110..6a54007d7 100644 --- a/src/MqttHandleBatteryHass.cpp +++ b/src/MqttHandleBatteryHass.cpp @@ -182,6 +182,8 @@ void MqttHandleBatteryHassClass::loop() publishBinarySensor("Warning Temperature high (charge)", "mdi:thermometer-high", "warning/highTemperatureCharge", "1", "0"); publishBinarySensor("Warning BMS internal", "mdi:alert-outline", "warning/bmsInternal", "1", "0"); publishBinarySensor("Warning Cell Imbalance", "mdi:alert-outline", "warning/cellImbalance", "1", "0"); + + publishBinarySensor("Charge immediately", "mdi:alert", "charging/chargeImmediately", "1", "0"); break; case 5: // SBS Unipower diff --git a/src/PytesCanReceiver.cpp b/src/PytesCanReceiver.cpp index bcdd0d274..1d6be8623 100644 --- a/src/PytesCanReceiver.cpp +++ b/src/PytesCanReceiver.cpp @@ -145,6 +145,15 @@ void PytesCanReceiver::onMessage(twai_message_t rx_message) break; } + case 0x360: { // Charging request + _stats->_chargeImmediately = rx_message.data[0]; // 0xff requests charging. + if (_verboseLogging) { + MessageOutput.printf("[Pytes] chargeImmediately: %d\r\n", + _stats->_chargeImmediately); + } + break; + } + case 0x372: { // BankInfo _stats->_moduleCountOnline = this->readUnsignedInt16(rx_message.data); _stats->_moduleCountBlockingCharge = this->readUnsignedInt16(rx_message.data + 2);