Skip to content

Commit

Permalink
Update driver_flowiq2200.h
Browse files Browse the repository at this point in the history
  • Loading branch information
anhorbc authored Aug 24, 2024
1 parent cfd7a9f commit 235a011
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions driver_flowiq2200.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,28 @@ struct Flowiq2200: Driver
esphome::optional<double> ret_val{};
uint8_t l_field = telegram[0];
uint8_t tpl_ci_field = telegram[19];
uint16_t signature = ((uint16_t)telegram[20] << 8) | telegram[21];
uint16_t signature;
if ((tpl_ci_field == 0x79) && (l_field > 49)) {
signature = ((uint16_t)telegram[20] << 8) | telegram[21];
ESP_LOGVV(TAG, "Signature of message is: '%X'", signature);
}
else
{
signature = 0;
}
if (tpl_ci_field == 0x78) {
ret_val = this->get_0413(telegram);
}
else if ((tpl_ci_field == 0x79) && (l_field > 49)) {
ESP_LOGD(TAG, "Signature of message is: '%X'", signature);
uint32_t usage{0};
uint8_t i = 28;
usage = (((uint32_t)telegram[i+3] << 24) | ((uint32_t)telegram[i+2] << 16) |
((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0]));
ret_val = usage / 1000.0;
ESP_LOGVV(TAG, "Found total_water with '%d'->'%f'", usage, ret_val.value());
if (signature == 0xF3A9) {
ESP_LOGD(TAG, "Signature of message is: '%X'", signature);
uint32_t usage{0};
uint8_t i = 28;
usage = (((uint32_t)telegram[i+3] << 24) | ((uint32_t)telegram[i+2] << 16) |
((uint32_t)telegram[i+1] << 8) | ((uint32_t)telegram[i+0]));
ret_val = usage / 1000.0;
ESP_LOGVV(TAG, "Found total_water with '%d'->'%f'", usage, ret_val.value());
}
}
return ret_val;
};
Expand Down

0 comments on commit 235a011

Please sign in to comment.