Skip to content

Commit

Permalink
Add Govee detect_logic to older H5054 water sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
rct committed Sep 26, 2023
1 parent 403abe9 commit eddb4f3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/devices/govee.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ RevSum input for parity (first 5 bytes, and the parity extracted from the last b
static int govee_decode(r_device *decoder, bitbuffer_t *bitbuffer)
{
int model_num = GOVEE_WATER;
int wet = -1;

if (bitbuffer->num_rows < 3) {
return DECODE_ABORT_EARLY; // truncated transmission
Expand Down Expand Up @@ -201,9 +202,14 @@ static int govee_decode(r_device *decoder, bitbuffer_t *bitbuffer)
// Figure out what event was triggered
if (event == 0xafa) {
event_str = "Button Press";
// H5054 water sensor will only send a button press event when it has dried out.
// Requiring the user to press the button to clear detect_wet is a workaround
// for lack of dry/no longer wet event.
wet = 0;
}
else if (event == 0xbfb) {
event_str = "Water Leak";
wet = 1;
}
else if (event_type == 0xc) {
event_str = "Battery Report";
Expand All @@ -228,6 +234,7 @@ static int govee_decode(r_device *decoder, bitbuffer_t *bitbuffer)
"battery_ok", "Battery level", DATA_COND, battery, DATA_DOUBLE, battery_level,
"battery_mV", "Battery", DATA_COND, battery, DATA_FORMAT, "%d mV", DATA_INT, battery_mv,
"event", "", DATA_STRING, event_str,
"detect_wet", "", DATA_COND, wet >= 0, DATA_INT, wet,
"code", "Raw Code", DATA_STRING, code_str,
"mic", "Integrity", DATA_STRING, "PARITY",
NULL);
Expand All @@ -244,6 +251,7 @@ static char const *const output_fields[] = {
"battery_ok",
"battery_mV",
"event",
"detect_wet",
"code",
"mic",
NULL,
Expand Down

0 comments on commit eddb4f3

Please sign in to comment.