Skip to content

Commit

Permalink
Added new MQTT /EVTotalEnergyCharged topic to track EV energy in Home…
Browse files Browse the repository at this point in the history
… Assistant (#190)
  • Loading branch information
marcovaneck authored Aug 3, 2023
1 parent 4074545 commit 8a0c57e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion SmartEVSE-3/src/evse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ int32_t EnergyCharged = 0; // k
int32_t EnergyMeterStart = 0; // kWh meter value is stored once EV is connected to EVSE (Wh)
int32_t PowerMeasured = 0; // Measured Charge power in Watt by kWh meter
uint8_t RFIDstatus = 0;
int32_t EnergyEV = 0;
int32_t EnergyEV = 0; // Wh -> EV_import_active_energy - EV_export_active_energy
int32_t Mains_export_active_energy = 0; // Mainsmeter exported active energy, only for API purposes so you can guard the
// enery usage of your house
int32_t Mains_import_active_energy = 0; // Mainsmeter imported active energy, only for API purposes so you can guard the
Expand Down Expand Up @@ -2449,6 +2449,8 @@ void SetupMQTTClient() {
announce("EV Charge Power", "sensor");
optional_payload = jsna("device_class","energy") + jsna("unit_of_measurement","Wh");
announce("EV Energy Charged", "sensor");
optional_payload = jsna("device_class","energy") + jsna("unit_of_measurement","Wh") + jsna("state_class","total_increasing");
announce("EV Total Energy Charged", "sensor");
}

//set the parameters for and announce sensor entities without device_class or unit_of_measurement:
Expand Down Expand Up @@ -2524,6 +2526,7 @@ void mqttPublishData() {
if (EVMeter) {
MQTTclient.publish(MQTTprefix + "/EVChargePower", String(PowerMeasured), false, 0);
MQTTclient.publish(MQTTprefix + "/EVEnergyCharged", String(EnergyCharged), true, 0);
MQTTclient.publish(MQTTprefix + "/EVTotalEnergyCharged", String(EnergyEV), false, 0);
}
if (homeBatteryLastUpdate)
MQTTclient.publish(MQTTprefix + "/HomeBatteryCurrent", String(homeBatteryCurrent), false, 0);
Expand Down

0 comments on commit 8a0c57e

Please sign in to comment.