Skip to content

Commit

Permalink
Merge pull request #4 from wonsky007/master
Browse files Browse the repository at this point in the history
Update driver_hydrocalm3.h
  • Loading branch information
SzczepanLeon authored Dec 20, 2023
2 parents 2c0b1d9 + 346628f commit 1c31d53
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
21 changes: 21 additions & 0 deletions driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,27 @@ struct Driver
return ret_val;
};


esphome::optional<double> get_0C09(std::vector<unsigned char> &telegram) {
esphome::optional<double> ret_val{};
uint32_t usage = 0;
size_t i = 11;
uint32_t total_register = 0x0C09;
while (i < telegram.size()) {
uint32_t c = (((uint32_t)telegram[i+0] << 8) | ((uint32_t)telegram[i+1]));
if (c == total_register) {
i += 2;
usage = bcd_2_int(telegram, i, 4);
// in kWh
ret_val = usage / 3.6;
ESP_LOGVV(TAG, "Found register '0C09' with '%d'->'%f'", usage, ret_val.value());
break;
}
i++;
}
return ret_val;
};

esphome::optional<double> get_0C0D(std::vector<unsigned char> &telegram) {
esphome::optional<double> ret_val{};
uint32_t usage = 0;
Expand Down
3 changes: 2 additions & 1 deletion driver_hydrocalm3.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ struct Hydrocalm3: Driver
add_to_map(ret_val, "total_heating_kwh", this->get_0C0E(telegram));
add_to_map(ret_val, "total_heating_kwh", this->get_0C03(telegram));
add_to_map(ret_val, "total_heating_kwh", this->get_0C0A(telegram));
add_to_map(ret_val, "total_heating_kwh", this->get_0C09(telegram)); /* Hydrocal M4 kWh metering map value */
add_to_map(ret_val, "total_water_m3", this->get_0C13(telegram));

if (ret_val.size() > 0) {
Expand All @@ -30,4 +31,4 @@ struct Hydrocalm3: Driver
};

private:
};
};

0 comments on commit 1c31d53

Please sign in to comment.