Skip to content

Commit 16155ad

Browse files
author
dingo35
committed
esp32.cpp, network.cpp: Increase accuracy of Homewizard P1 to 1 decimal
1 parent f2f8b03 commit 16155ad

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

SmartEVSE-3/src/esp32.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2829,7 +2829,7 @@ void homewizard_loop() {
28292829

28302830
const auto currents = getMainsFromHomeWizardP1();
28312831
for (int i = 0; i < currents.first; i++)
2832-
MainsMeter.Irms[i] = currents.second[i] * 10;
2832+
MainsMeter.Irms[i] = currents.second[i];
28332833
if (currents.first) {
28342834
CalcIsum();
28352835
MainsMeter.setTimeout(COMM_TIMEOUT);

SmartEVSE-3/src/network.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ String discoverHomeWizardP1() {
804804
*
805805
* @return A pair containing:
806806
* - A int flag indicating: 0: failure, 1: single phase current, 3: 3 phase current
807-
* - An array of 3 values representing the active current in amps for L1, L2, and L3
807+
* - An array of 3 values representing the active current in deci-amps for L1, L2, and L3
808808
*/
809809
std::pair<int8_t, std::array<std::int8_t, 3> > getMainsFromHomeWizardP1() {
810810

@@ -845,6 +845,9 @@ std::pair<int8_t, std::array<std::int8_t, 3> > getMainsFromHomeWizardP1() {
845845
for (const auto* key : currentKeys) filter[key] = true;
846846
for (const auto* key : powerKeys) filter[key] = true;
847847

848+
/////test homewizard connected to single phase mainsmeter
849+
//const char stream[] = "{\"wifi_ssid\":\"Imaginous\",\"wifi_strength\":86,\"smr_version\":50,\"meter_model\":\"Kaifa AIFA-METER\",\"unique_id\":\"0000000000000000000000000000000000\",\"active_tariff\":1,\"total_power_import_kwh\":7412.085,\"total_power_import_t1_kwh\":4283.482,\"total_power_import_t2_kwh\":3128.603,\"total_power_export_kwh\":6551.330,\"total_power_export_t1_kwh\":1930.678,\"total_power_export_t2_kwh\":4620.652,\"active_power_w\":-2725.000,\"active_power_l1_w\":-2725.000,\"active_voltage_l1_v\":238.400,\"active_current_a\":11.430,\"active_current_l1_a\":-11.430,\"voltage_sag_l1_count\":8.000,\"voltage_swell_l1_count\":0.000,\"any_power_fail_count\":0.000,\"long_power_fail_count\":0.000,\"total_gas_m3\":1795.627,\"gas_timestamp\":250405135009,\"gas_unique_id\":\"0000000000000000000000000000000000\",\"external\":[{\"unique_id\":\"0000000000000000000000000000000000\",\"type\":\"gas_meter\",\"timestamp\":250405135009,\"value\":1795.627,\"unit\":\"m3\"}]}";
850+
848851
// Create a filtered JSON document to hold the parsed data.
849852
DynamicJsonDocument doc(256);
850853
const DeserializationError error = deserializeJson(doc, *stream, DeserializationOption::Filter(filter));
@@ -877,9 +880,8 @@ std::pair<int8_t, std::array<std::int8_t, 3> > getMainsFromHomeWizardP1() {
877880
// Process all three phases.
878881
std::array<int8_t, 3> currents;
879882
for (size_t i = 0; i < phases; ++i) {
880-
int rawCurrent = doc[currentKeys[i]].as<int>();
881-
int8_t correction = getCorrection(powerKeys[i]);
882-
currents[i] = std::abs(rawCurrent) * correction;
883+
int rawCurrent = doc[currentKeys[i]].as<float>() * 10;
884+
currents[i] = std::abs(rawCurrent) * getCorrection(powerKeys[i]);
883885
}
884886

885887
return {phases, currents};

0 commit comments

Comments
 (0)