diff --git a/include/victron_ble.h b/include/victron_ble.h index 499ae6e..6643e02 100644 --- a/include/victron_ble.h +++ b/include/victron_ble.h @@ -9,6 +9,7 @@ struct MpptData { float pvPower; // W (1W resolution) float yieldToday; // Wh (10Wh resolution) float pvVoltage; // V (not in MPPT advert, always 0) + float externalLoad; uint8_t chargeState; // 0=off 3=bulk 4=absorption 5=float etc uint8_t errorCode; // 0 = no error bool valid; // false if decryption/parse failed diff --git a/src/main.cpp b/src/main.cpp index 85565c3..f45e8bf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -137,6 +137,14 @@ static void publishDiscovery() { "\"value_template\":\"{{ value_json.error_code | int }}\"," "\"icon\":\"mdi:alert-circle-outline\"" AVAIL DEV }, + { + "homeassistant/sensor/victron_smartsolar_garage/external_load/config", + "{\"unique_id\":\"victron_mppt_el\",\"name\":\"External Load\"," + "\"state_topic\":\"" MQTT_TOPIC_DATA "\"," + "\"value_template\":\"{{ value_json.external_load_a | float }}\"," + "\"unit_of_measurement\":\"A\",\"device_class\":\"current\"," + "\"state_class\":\"measurement\"" AVAIL DEV + }, }; for (auto& s : sensors) { @@ -164,6 +172,7 @@ static void publishData(const MpptData& d) { doc["charge_state"] = chargeStateName(d.chargeState); doc["charge_state_raw"] = d.chargeState; doc["error_code"] = d.errorCode; + doc["external_load_a"] = serialized(String(d.externalLoad, 2)); char buf[256]; serializeJson(doc, buf); diff --git a/src/victron_ble.cpp b/src/victron_ble.cpp index d6b9934..8803171 100644 --- a/src/victron_ble.cpp +++ b/src/victron_ble.cpp @@ -116,6 +116,8 @@ MpptData parseVictronMppt(const uint8_t* encKey, const uint8_t* data, size_t len int32_t batI_raw = reader.readSigned(16); uint32_t yieldToday = reader.readUnsigned(16); uint32_t solarPower = reader.readUnsigned(16); + uint32_t extLoad = reader.readUnsigned(9); // 9 bits, 0.1A/bit + result.externalLoad = (extLoad != 0x1FF) ? extLoad / 10.0f : 0.0f; result.chargeState = (uint8_t)chargeState; result.errorCode = (uint8_t)chargerError;