Skip to content

Commit

Permalink
Update driver.h
Browse files Browse the repository at this point in the history
Added get_0C09 for Hydrocal M4
  • Loading branch information
wonsky007 authored Dec 20, 2023
1 parent 09ad02d commit 346628f
Showing 1 changed file with 21 additions and 0 deletions.
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

0 comments on commit 346628f

Please sign in to comment.